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.
This commit is contained in:
Joshua Leung
2009-09-13 12:34:00 +00:00
parent 16a7fe1314
commit ca986a6874
3 changed files with 51 additions and 67 deletions

View File

@@ -278,24 +278,7 @@ void poselib_validate_act (bAction *act)
/* ************************************************************* */
/* 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? */
/* 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 KeyingSet *poselib_ks_locrotscale = NULL; /* the only keyingset we'll need */
/* ----- */
@@ -390,9 +373,6 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
/* 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 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
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 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
}
/* 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 @@ static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld)
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 @@ static void poselib_keytag_pose (Scene *scene, tPoseLib_PreviewData *pld)
if (pchan->bone)
pchan->bone->flag |= BONE_UNKEYED;
}
#endif // XXX old animation system
}
}
@@ -1345,7 +1322,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op)
}
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;

View File

@@ -961,6 +961,11 @@ void POSE_OT_copy (wmOperatorType *ot)
/* ---- */
/* 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 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
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 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
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 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
}
}
#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 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
if (chan->bone)
chan->bone->flag |= BONE_UNKEYED;
}
#endif // XXX old animation system
}
}
}
@@ -1975,6 +1981,7 @@ void ARMATURE_OT_bone_layers (wmOperatorType *ot)
RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers that bone belongs to.");
}
/* ********************************************** */
#if 0
// XXX old sys

View File

@@ -233,7 +233,7 @@ void rna_def_gpencil_data(BlenderRNA *brna)
/* 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).");
}