[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25353] trunk/blender/source/blender/ editors: A few KeyingSet + Transform Tweaks:
Joshua Leung
aligorith at gmail.com
Mon Dec 14 04:20:19 CET 2009
Revision: 25353
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25353
Author: aligorith
Date: 2009-12-14 04:20:17 +0100 (Mon, 14 Dec 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/editors/animation/keyingsets.c
trunk/blender/source/blender/editors/transform/transform.c
trunk/blender/source/blender/editors/transform/transform.h
trunk/blender/source/blender/editors/transform/transform_conversions.c
trunk/blender/source/blender/editors/transform/transform_generics.c
Modified: trunk/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyingsets.c 2009-12-14 03:01:42 UTC (rev 25352)
+++ trunk/blender/source/blender/editors/animation/keyingsets.c 2009-12-14 03:20:17 UTC (rev 25353)
@@ -1318,7 +1318,7 @@
* 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,37 +1328,15 @@
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);
- }
+ /* 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);
- /* 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);
- }
-
/* set recalc-flags */
if (ksp->id) {
switch (GS(ksp->id->name)) {
@@ -1386,7 +1364,7 @@
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,33 +1439,15 @@
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);
- }
+ /* 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);
- /* 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);
- }
-
/* free the path */
MEM_freeN(path);
}
Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c 2009-12-14 03:01:42 UTC (rev 25352)
+++ trunk/blender/source/blender/editors/transform/transform.c 2009-12-14 03:20:17 UTC (rev 25353)
@@ -1146,7 +1146,7 @@
/* 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 @@
}
/* 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);
Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h 2009-12-14 03:01:42 UTC (rev 25352)
+++ trunk/blender/source/blender/editors/transform/transform.h 2009-12-14 03:20:17 UTC (rev 25353)
@@ -546,15 +546,15 @@
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 *****************************/
Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c 2009-12-14 03:01:42 UTC (rev 25352)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c 2009-12-14 03:20:17 UTC (rev 25353)
@@ -4507,7 +4507,8 @@
/* 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 @@
* 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 @@
}
}
- // 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 @@
}
-/* 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 @@
}
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 @@
/* 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 @@
posttrans_action_clean(&ac, (bAction *)ac.data);
}
}
- else if (ac.datatype == ANIMCONT_SHAPEKEY) {
-#if 0 // XXX old animation system
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list