Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-12-14 06:20:17 +0300
committerJoshua Leung <aligorith@gmail.com>2009-12-14 06:20:17 +0300
commit2c3eb59f0f76482cec9a65e311704b2e48936364 (patch)
treeba3acacf56a62ba6e8eddf8b1531398e8f7e5336 /source/blender/editors
parent921d4b8eb0d511e2fa2c3143142c372a178565f1 (diff)
A few KeyingSet + Transform Tweaks:
Autokeying for transform functions now gets context-info, allowing for bone paths to be recalculated. However, the main purpose of this is to allow KeyingSets to eventually have poll functions.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/keyingsets.c72
-rw-r--r--source/blender/editors/transform/transform.c4
-rw-r--r--source/blender/editors/transform/transform.h6
-rw-r--r--source/blender/editors/transform/transform_conversions.c108
-rw-r--r--source/blender/editors/transform/transform_generics.c4
5 files changed, 46 insertions, 148 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index c3606a03d1e..afd693d7981 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1318,7 +1318,7 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet
* provided by the user, and is stored, ready to use, in the KeyingSet paths.
*/
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
- int arraylen, i;
+ int i;
/* get pointer to name of group to add channels to */
if (ksp->groupmode == KSP_GROUP_NONE)
@@ -1328,36 +1328,14 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet
else
groupname= ksp->group;
- /* init arraylen and i - arraylen should be greater than i so that
- * normal non-array entries get keyframed correctly
- */
- i= ksp->array_index;
- arraylen= i;
+ /* passing -1 as the array_index results in the entire array being modified */
+ i= (ksp->flag & KSP_FLAG_WHOLE_ARRAY) ? (-1) : (ksp->array_index);
- /* get length of array if whole array option is enabled */
- if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) {
- PointerRNA id_ptr, ptr;
- PropertyRNA *prop;
-
- RNA_id_pointer_create(ksp->id, &id_ptr);
- if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop)
- arraylen= RNA_property_array_length(&ptr, prop);
- }
-
- /* we should do at least one step */
- if (arraylen == i)
- arraylen++;
-
- /* for each possible index, perform operation
- * - assume that arraylen is greater than index
- */
- for (; i < arraylen; i++) {
- /* action to take depends on mode */
- if (mode == MODIFYKEY_MODE_INSERT)
- success+= insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
- else if (mode == MODIFYKEY_MODE_DELETE)
- success+= delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
- }
+ /* action to take depends on mode */
+ if (mode == MODIFYKEY_MODE_INSERT)
+ success += insert_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
+ else if (mode == MODIFYKEY_MODE_DELETE)
+ success += delete_keyframe(ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag);
/* set recalc-flags */
if (ksp->id) {
@@ -1386,7 +1364,7 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
DynStr *pathds= BLI_dynstr_new();
char *path = NULL;
- int arraylen, i;
+ int i;
/* set initial group name */
if (cks->id == NULL) {
@@ -1461,32 +1439,14 @@ int modify_keyframes (Scene *scene, ListBase *dsources, bAction *act, KeyingSet
else if (ksp->groupmode == KSP_GROUP_NAMED)
groupname= ksp->group;
- /* init arraylen and i - arraylen should be greater than i so that
- * normal non-array entries get keyframed correctly
- */
- i= ksp->array_index;
- arraylen= i+1;
+ /* passing -1 as the array_index results in the entire array being modified */
+ i= (ksp->flag & KSP_FLAG_WHOLE_ARRAY) ? (-1) : (ksp->array_index);
- /* get length of array if whole array option is enabled */
- if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) {
- PointerRNA id_ptr, ptr;
- PropertyRNA *prop;
-
- RNA_id_pointer_create(cks->id, &id_ptr);
- if (RNA_path_resolve(&id_ptr, path, &ptr, &prop) && prop)
- arraylen= RNA_property_array_length(&ptr, prop);
- }
-
- /* for each possible index, perform operation
- * - assume that arraylen is greater than index
- */
- for (; i < arraylen; i++) {
- /* action to take depends on mode */
- if (mode == MODIFYKEY_MODE_INSERT)
- success+= insert_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
- else if (mode == MODIFYKEY_MODE_DELETE)
- success+= delete_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
- }
+ /* action to take depends on mode */
+ if (mode == MODIFYKEY_MODE_INSERT)
+ success+= insert_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
+ else if (mode == MODIFYKEY_MODE_DELETE)
+ success+= delete_keyframe(cks->id, act, groupname, path, i, cfra, kflag);
/* free the path */
MEM_freeN(path);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index d6088648eb2..312939961f5 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1146,7 +1146,7 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
/* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
- special_aftertrans_update(t);
+ special_aftertrans_update(C, t);
postTrans(C, t);
@@ -1715,7 +1715,7 @@ int transformEnd(bContext *C, TransInfo *t)
}
/* aftertrans does insert keyframes, and clears base flags, doesnt read transdata */
- special_aftertrans_update(t);
+ special_aftertrans_update(C, t);
/* free data */
postTrans(C, t);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 7d9c16ada9b..0b8fb365a56 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -546,15 +546,15 @@ float get_drawsize(struct ARegion *ar, float *co);
void createTransData(struct bContext *C, TransInfo *t);
void sort_trans_data_dist(TransInfo *t);
void add_tdi_poin(float *poin, float *old, float delta);
-void special_aftertrans_update(TransInfo *t);
+void special_aftertrans_update(struct bContext *C, TransInfo *t);
void transform_autoik_update(TransInfo *t, short mode);
int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
/* auto-keying stuff used by special_aftertrans_update */
-void autokeyframe_ob_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
-void autokeyframe_pose_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
+void autokeyframe_ob_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
+void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
/*********************** Constraints *****************************/
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 915eaca3604..c7b5c29e262 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4507,7 +4507,8 @@ static void clear_trans_object_base_flags(TransInfo *t)
/* auto-keyframing feature - for objects
* tmode: should be a transform mode
*/
-void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
+// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
+void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode)
{
ID *id= &ob->id;
FCurve *fcu;
@@ -4603,11 +4604,12 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
* tmode: should be a transform mode
* targetless_ik: has targetless ik been done on any channels?
*/
-void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
+// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
+void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
{
ID *id= &ob->id;
AnimData *adt= ob->adt;
- //bArmature *arm= ob->data;
+ bArmature *arm= ob->data;
bAction *act= (adt) ? adt->action : NULL;
bPose *pose= ob->pose;
bPoseChannel *pchan;
@@ -4714,15 +4716,13 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
}
}
- // XXX todo... figure out way to get appropriate notifiers sent
-
- /* do the bone paths */
-#if 0 // XXX TRANSFORM FIX ME
- if (arm->pathflag & ARM_PATH_ACFRA) {
+ /* do the bone paths
+ * NOTE: only do this when there is context info
+ */
+ if (C && (arm->pathflag & ARM_PATH_ACFRA)) {
//pose_clear_paths(ob); // XXX for now, don't need to clear
ED_pose_recalculate_paths(C, scene, ob);
}
-#endif
}
else {
/* tag channels that should have unkeyed data */
@@ -4736,12 +4736,12 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
}
-/* inserting keys, refresh ipo-keys, pointcache, redraw events... */
+/* inserting keys, pointcache, redraw events... */
/*
* note: sequencer freeing has its own function now because of a conflict with transform's order of freeing (campbell)
* Order changed, the sequencer stuff should go back in here
* */
-void special_aftertrans_update(TransInfo *t)
+void special_aftertrans_update(bContext *C, TransInfo *t)
{
Object *ob;
// short redrawipo=0, resetslowpar=1;
@@ -4769,24 +4769,15 @@ void special_aftertrans_update(TransInfo *t)
}
else if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
- Scene *scene;
bAnimContext ac;
- /* initialise relevant anim-context 'context' data from TransInfo data */
- /* NOTE: sync this with the code in ANIM_animdata_get_context() */
- memset(&ac, 0, sizeof(bAnimContext));
-
- scene= ac.scene= t->scene;
- ob= ac.obact= OBACT;
- ac.sa= t->sa;
- ac.ar= t->ar;
- ac.spacetype= (t->sa)? t->sa->spacetype : 0;
- ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
- if (ANIM_animdata_context_getdata(&ac) == 0)
+ /* initialise relevant anim-context 'context' data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
return;
+
+ ob = ac.obact;
- if (ac.datatype == ANIMCONT_DOPESHEET) {
+ if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
@@ -4815,12 +4806,10 @@ void special_aftertrans_update(TransInfo *t)
/* free temp memory */
BLI_freelistN(&anim_data);
}
- else if (ac.datatype == ANIMCONT_ACTION) {
+ else if (ac.datatype == ANIMCONT_ACTION) { // TODO: just integrate into the above...
/* Depending on the lock status, draw necessary views */
// fixme... some of this stuff is not good
if (ob) {
- ob->ctime= -1234567.0f;
-
if (ob->pose || ob_get_key(ob))
DAG_id_flush_update(&ob->id, OB_RECALC);
else
@@ -4834,22 +4823,6 @@ void special_aftertrans_update(TransInfo *t)
posttrans_action_clean(&ac, (bAction *)ac.data);
}
}
- else if (ac.datatype == ANIMCONT_SHAPEKEY) {
-#if 0 // XXX old animation system
- /* fix up the Ipocurves and redraw stuff */
- Key *key= (Key *)ac.data;
-
- if (key->ipo) {
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
- ((cancelled == 0) || (duplicate)) )
- {
- posttrans_ipo_clean(key->ipo);
- }
- }
-#endif // XXX old animation system
-
- DAG_id_flush_update(&OBACT->id, OB_RECALC_DATA);
- }
#if 0 // XXX future of this is still not clear
else if (ac.datatype == ANIMCONT_GPENCIL) {
/* remove duplicate frames and also make sure points are in order! */
@@ -4879,21 +4852,10 @@ void special_aftertrans_update(TransInfo *t)
}
else if (t->spacetype == SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
- Scene *scene;
bAnimContext ac;
- /* initialise relevant anim-context 'context' data from TransInfo data */
- /* NOTE: sync this with the code in ANIM_animdata_get_context() */
- memset(&ac, 0, sizeof(bAnimContext));
-
- scene= ac.scene= t->scene;
- ob= ac.obact= OBACT;
- ac.sa= t->sa;
- ac.ar= t->ar;
- ac.spacetype= (t->sa)? t->sa->spacetype : 0;
- ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
- if (ANIM_animdata_context_getdata(&ac) == 0)
+ /* initialise relevant anim-context 'context' data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
return;
if (ac.datatype)
@@ -4930,21 +4892,10 @@ void special_aftertrans_update(TransInfo *t)
ANIM_editkeyframes_refresh(&ac);
}
else if (t->spacetype == SPACE_NLA) {
- Scene *scene;
bAnimContext ac;
- /* initialise relevant anim-context 'context' data from TransInfo data */
- /* NOTE: sync this with the code in ANIM_animdata_get_context() */
- memset(&ac, 0, sizeof(bAnimContext));
-
- scene= ac.scene= t->scene;
- ob= ac.obact= OBACT;
- ac.sa= t->sa;
- ac.ar= t->ar;
- ac.spacetype= (t->sa)? t->sa->spacetype : 0;
- ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
- if (ANIM_animdata_context_getdata(&ac) == 0)
+ /* initialise relevant anim-context 'context' data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
return;
if (ac.datatype)
@@ -4974,10 +4925,6 @@ void special_aftertrans_update(TransInfo *t)
}
}
else if (t->obedit) {
- // TRANSFORM_FIX_ME
-// if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
-// allqueue(REDRAWBUTSEDIT, 0);
-
if (t->obedit->type == OB_MESH)
{
EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh;
@@ -5011,7 +4958,7 @@ void special_aftertrans_update(TransInfo *t)
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't cancelled (or TFM_DUMMY) */
if (!cancelled && (t->mode != TFM_DUMMY)) {
- autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
+ autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
}
else if (arm->flag & ARM_DELAYDEFORM) {
@@ -5022,9 +4969,6 @@ void special_aftertrans_update(TransInfo *t)
else
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- //if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
- // allqueue(REDRAWBUTSEDIT, 0);
-
}
else if(t->scene->basact && (ob = t->scene->basact->object) && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, ob)) {
;
@@ -5064,19 +5008,13 @@ void special_aftertrans_update(TransInfo *t)
/* Set autokey if necessary */
if (!cancelled)
- autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
+ autokeyframe_ob_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode);
}
}
clear_trans_object_base_flags(t);
#if 0 // TRANSFORM_FIX_ME
- if (redrawipo) {
- allqueue(REDRAWNLA, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWIPO, 0);
- }
-
if(resetslowpar)
reset_slowparents();
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 7951b002174..f2c4da0da27 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -746,7 +746,7 @@ void recalcData(TransInfo *t)
int targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
animrecord_check_state(t->scene, &ob->id, t->animtimer);
- autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
+ autokeyframe_pose_cb_func(NULL, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
}
/* old optimize trick... this enforces to bypass the depgraph */
@@ -789,7 +789,7 @@ void recalcData(TransInfo *t)
// TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
animrecord_check_state(t->scene, &ob->id, t->animtimer);
- autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
+ autokeyframe_ob_cb_func(NULL, t->scene, (View3D *)t->view, ob, t->mode);
}
/* proxy exception */