[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23179] trunk/blender/source/blender: 2 Animation Fixes:
Joshua Leung
aligorith at gmail.com
Sun Sep 13 14:34:00 CEST 2009
Revision: 23179
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23179
Author: aligorith
Date: 2009-09-13 14:34:00 +0200 (Sun, 13 Sep 2009)
Log Message:
-----------
2 Animation Fixes:
* Auto-keyframing for Paste Poses and PoseLib works again. Unfortunately, it doesn't take into account whether the transforms were changed or not...
* 'Stick to View' setting for Grease Pencil has now been inverted, since the old order was confusing.
Modified Paths:
--------------
trunk/blender/source/blender/editors/armature/poselib.c
trunk/blender/source/blender/editors/armature/poseobject.c
trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c 2009-09-13 12:32:57 UTC (rev 23178)
+++ trunk/blender/source/blender/editors/armature/poselib.c 2009-09-13 12:34:00 UTC (rev 23179)
@@ -278,25 +278,8 @@
/* ************************************************************* */
/* Pointers to the builtin KeyingSets that we want to use */
-static KeyingSet *poselib_ks_locrotscale = NULL; /* the only keyingset we'll need*/
-static short poselib_ks_need_init= 1; /* have the above been obtained yet? */
+static KeyingSet *poselib_ks_locrotscale = NULL; /* the only keyingset we'll need */
-/* Make sure the builtin KeyingSets are initialised properly
- * (only gets called on first run of poselib_add_current_pose).
- */
-static void poselib_get_builtin_keyingsets (void)
-{
- /* only if we haven't got these yet */
- // FIXME: this assumes that we will always get the builtin sets...
- if (poselib_ks_need_init) {
- /* LocRotScale (quaternions or eulers depending on context) */
- poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
-
- /* clear flag requesting init */
- poselib_ks_need_init= 0;
- }
-}
-
/* ----- */
static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, void *arg)
@@ -390,9 +373,6 @@
/* validate name */
BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), 64);
- /* make sure we've got KeyingSets to use */
- poselib_get_builtin_keyingsets();
-
/* init common-key-source for use by KeyingSets */
memset(&cks, 0, sizeof(bCommonKeySrc));
cks.id= &ob->id;
@@ -406,6 +386,8 @@
cks.pchan= pchan;
/* KeyingSet to use depends on rotation mode (but that's handled by the templates code) */
+ if (poselib_ks_locrotscale == NULL)
+ poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
modify_keyframes(C, &dsources, act, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)frame);
}
}
@@ -756,13 +738,20 @@
}
/* Auto-keys/tags bones affected by the pose used from the poselib */
-static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld)
+static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData *pld)
{
bPose *pose= pld->pose;
bPoseChannel *pchan;
bAction *act= pld->act;
bActionGroup *agrp;
+ bCommonKeySrc cks;
+ ListBase dsources = {&cks, &cks};
+
+ /* init common-key-source for use by KeyingSets */
+ memset(&cks, 0, sizeof(bCommonKeySrc));
+ cks.id= &pld->ob->id;
+
/* start tagging/keying */
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
/* only for selected action channels */
@@ -770,28 +759,17 @@
pchan= get_pose_channel(pose, agrp->name);
if (pchan) {
-#if 0 // XXX old animation system
// TODO: use a standard autokeying function in future (to allow autokeying-editkeys to work)
- if (IS_AUTOKEY_MODE(NORMAL)) {
- ID *id= &pld->ob->id;
+ if (IS_AUTOKEY_MODE(scene, NORMAL)) {
+ /* Set keys on pose
+ * - KeyingSet to use depends on rotation mode
+ * (but that's handled by the templates code)
+ */
+ // TODO: for getting the KeyingSet used, we should really check which channels were affected
+ if (poselib_ks_locrotscale == NULL)
+ poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
- /* Set keys on pose */
- if (pchan->flag & POSE_ROT) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W, 0);
- }
- if (pchan->flag & POSE_SIZE) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Z, 0);
- }
- if (pchan->flag & POSE_LOC) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z, 0);
- }
+ modify_keyframes(C, &dsources, NULL, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
/* clear any unkeyed tags */
if (pchan->bone)
@@ -802,7 +780,6 @@
if (pchan->bone)
pchan->bone->flag |= BONE_UNKEYED;
}
-#endif // XXX old animation system
}
}
@@ -1345,7 +1322,7 @@
}
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
- poselib_keytag_pose(scene, pld);
+ poselib_keytag_pose(C, scene, pld);
/* change active pose setting */
act->active_marker= BLI_findindex(&act->markers, marker) + 1;
Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c 2009-09-13 12:32:57 UTC (rev 23178)
+++ trunk/blender/source/blender/editors/armature/poseobject.c 2009-09-13 12:34:00 UTC (rev 23179)
@@ -961,6 +961,11 @@
/* ---- */
+/* Pointers to the builtin KeyingSets that we want to use */
+static KeyingSet *posePaste_ks_locrotscale = NULL; /* the only keyingset we'll need */
+
+/* ---- */
+
static int pose_paste_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
@@ -969,6 +974,13 @@
char name[32];
int flip= RNA_boolean_get(op->ptr, "flipped");
+ bCommonKeySrc cks;
+ ListBase dsources = {&cks, &cks};
+
+ /* init common-key-source for use by KeyingSets */
+ memset(&cks, 0, sizeof(bCommonKeySrc));
+ cks.id= &ob->id;
+
/* sanity checks */
if ELEM(NULL, ob, ob->pose)
return OPERATOR_CANCELLED;
@@ -1045,6 +1057,13 @@
eul[1]*= -1;
eul[2]*= -1;
EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, &pchan->quat[1], &pchan->quat[0]);
+
+ // experimental method (uncomment to test):
+#if 0
+ /* experimental method: just flip the orientation of the axis on x/y axes */
+ pchan->quat[1] *= -1;
+ pchan->quat[2] *= -1;
+#endif
}
else {
float eul[3];
@@ -1056,28 +1075,16 @@
}
}
-#if 0 // XXX old animation system
- if (autokeyframe_cfra_can_key(ob)) {
- ID *id= &ob->id;
+ if (autokeyframe_cfra_can_key(scene, &ob->id)) {
+ /* Set keys on pose
+ * - KeyingSet to use depends on rotation mode
+ * (but that's handled by the templates code)
+ */
+ // TODO: for getting the KeyingSet used, we should really check which channels were affected
+ if (posePaste_ks_locrotscale == NULL)
+ posePaste_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
- /* Set keys on pose */
- // TODO: make these use keyingsets....
- if (chan->flag & POSE_ROT) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W, 0);
- }
- if (chan->flag & POSE_SIZE) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Z, 0);
- }
- if (chan->flag & POSE_LOC) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z, 0);
- }
+ modify_keyframes(C, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
/* clear any unkeyed tags */
if (chan->bone)
@@ -1088,7 +1095,6 @@
if (chan->bone)
chan->bone->flag |= BONE_UNKEYED;
}
-#endif // XXX old animation system
}
}
}
@@ -1975,6 +1981,7 @@
RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers that bone belongs to.");
}
+/* ********************************************** */
#if 0
// XXX old sys
Modified: trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_gpencil.c 2009-09-13 12:32:57 UTC (rev 23178)
+++ trunk/blender/source/blender/makesrna/intern/rna_gpencil.c 2009-09-13 12:34:00 UTC (rev 23179)
@@ -233,7 +233,7 @@
/* Flags */
prop= RNA_def_property(srna, "view_space_draw", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_VIEWALIGN);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_DATA_VIEWALIGN);
RNA_def_property_ui_text(prop, "Stick to View", "Newly drawn strokes get added in view space (i.e. sketches stick to data when view is manipulated).");
}
More information about the Bf-blender-cvs
mailing list