Motion Paths + Auto-Keying:

Revised the conditions under which motion paths get recalculated after transforms (when auto-keying is enabled). Now, the type of path display does not matter, but rather that the object/bone in question has any paths at all. This makes animating with these a much smoother experience.
This commit is contained in:
Joshua Leung 2010-03-11 11:15:25 +00:00
parent 69a7060678
commit 6028470a9c
5 changed files with 22 additions and 6 deletions

View File

@ -208,6 +208,9 @@ bMotionPath *animviz_verify_motionpaths(Scene *scene, Object *ob, bPoseChannel *
/* allocate a cache */
mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts");
/* tag viz settings as currently having some path(s) which use it */
avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS;
/* return it */
return mpath;
}

View File

@ -277,19 +277,26 @@ void POSE_OT_paths_calculate (wmOperatorType *ot)
void ED_pose_clear_paths(Object *ob)
{
bPoseChannel *pchan;
short skipped = 0;
if ELEM(NULL, ob, ob->pose)
return;
/* free the motionpath blocks */
/* free the motionpath blocks, but also take note of whether we skipped some... */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
if (pchan->mpath) {
if (pchan->mpath) {
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
animviz_free_motionpath(pchan->mpath);
pchan->mpath= NULL;
}
else
skipped = 1;
}
}
/* if we didn't skip any, we shouldn't have any paths left */
if (skipped == 0)
ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
}
/* operator callback for this */

View File

@ -1687,6 +1687,7 @@ void ED_objects_clear_paths(bContext *C, Scene *scene)
if (ob->mpath) {
animviz_free_motionpath(ob->mpath);
ob->mpath= NULL;
ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
}
}
CTX_DATA_END;

View File

@ -4688,9 +4688,11 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
}
/* do the bone paths
* NOTE: only do this when there is context info
* - only do this when there is context info, since we need that to resolve
* how to do the updates and so on...
* - do not calculate unless there are paths already to update...
*/
if (C && (ob->pose->avs.path_type == MOTIONPATH_TYPE_ACFRA)) {
if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
ED_pose_recalculate_paths(C, scene, ob);
}
@ -4996,7 +4998,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (!cancelled) {
autokeyframe_ob_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode);
if (ob->avs.path_type == MOTIONPATH_TYPE_ACFRA)
/* only calculate paths if there are paths to be recalculated */
if (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)
recalcObPaths= 1;
}
}

View File

@ -161,6 +161,8 @@ typedef enum eMotionPaths_BakeFlag {
MOTIONPATH_BAKE_NEEDS_RECALC = (1<<0),
/* for bones - calculate head-points for curves instead of tips */
MOTIONPATH_BAKE_HEADS = (1<<1),
/* motion paths exist for AnimVizSettings instance - set when calc for first time, and unset when clearing */
MOTIONPATH_BAKE_HAS_PATHS = (1<<2),
} eMotionPath_BakeFlag;
/* ************************************************ */