diff options
Diffstat (limited to 'source/blender/blenkernel/intern/anim.c')
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 507fc520a85..6d95df3ca84 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -154,7 +154,7 @@ void animviz_free_motionpath(bMotionPath *mpath) /* ------------------- */ -/* Setup motion paths for the given data +/* Setup motion paths for the given data * - scene: current scene (for frame ranges, etc.) * - ob: object to add paths for (must be provided) * - pchan: posechannel to add paths for (optional; if not provided, object-paths are assumed) @@ -226,8 +226,10 @@ typedef struct MPathTarget { /* ........ */ -/* get list of motion paths to be baked (assumes the list is ready to be used) */ -static void motionpaths_get_bake_targets(Object *ob, ListBase *targets) +/* get list of motion paths to be baked for the given object + * - assumes the given list is ready to be used + */ +void animviz_get_object_motionpaths(Object *ob, ListBase *targets) { MPathTarget *mpt; @@ -260,6 +262,8 @@ static void motionpaths_get_bake_targets(Object *ob, ListBase *targets) } } +/* ........ */ + /* perform baking for the targets on the current frame */ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) { @@ -270,8 +274,10 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) bMotionPath *mpath= mpt->mpath; bMotionPathVert *mpv; - /* current frame must be within the range the cache works for */ - if (IN_RANGE(CFRA, mpath->start_frame, mpath->end_frame) == 0) + /* current frame must be within the range the cache works for + * - is inclusive of the first frame, but not the last otherwise we get buffer overruns + */ + if ((CFRA < mpath->start_frame) || (CFRA >= mpath->end_frame)) continue; /* get the relevant cache vert to write to */ @@ -297,36 +303,30 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) } } -/* ........ */ - /* Perform baking of the given object's and/or its bones' transforms to motion paths * - scene: current scene * - ob: object whose flagged motionpaths should get calculated * - recalc: whether we need to */ // TODO: include reports pointer? -void animviz_calc_motionpaths(Scene *scene, Object *ob) +void animviz_calc_motionpaths(Scene *scene, ListBase *targets) { - ListBase targets = {NULL, NULL}; MPathTarget *mpt; int sfra, efra; int cfra; - /* sanity checks */ - if (ob == NULL) - return; - - /* get motion paths to affect */ - motionpaths_get_bake_targets(ob, &targets); - - if (targets.first == NULL) + /* sanity check */ + if (ELEM(NULL, targets, targets->first)) return; /* set frame values */ cfra = CFRA; sfra = efra = cfra; - for (mpt= targets.first; mpt; mpt= mpt->next) { + // TODO: this method could be improved... + // 1) max range for standard baking + // 2) minimum range for recalc baking (i.e. between keyfames, but how?) + for (mpt= targets->first; mpt; mpt= mpt->next) { /* try to increase area to do (only as much as needed) */ sfra= MIN2(sfra, mpt->mpath->start_frame); efra= MAX2(efra, mpt->mpath->end_frame); @@ -340,23 +340,29 @@ void animviz_calc_motionpaths(Scene *scene, Object *ob) * that doesn't force complete update, but for now, this is the * most accurate way! */ - scene_update_for_newframe(scene, ob->lay); // XXX is the layer flag too restrictive? + scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving /* perform baking for targets */ - motionpaths_calc_bake_targets(scene, &targets); + motionpaths_calc_bake_targets(scene, targets); } /* reset original environment */ CFRA= cfra; - scene_update_for_newframe(scene, ob->lay); // XXX is the layer flag too restrictive? - - // TODO: make an API call for this too? - ob->avs.recalc &= ~ANIMVIZ_RECALC_PATHS; - if (ob->pose) - ob->pose->avs.recalc &= ~ANIMVIZ_RECALC_PATHS; + scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving - /* free temp data */ - BLI_freelistN(&targets); + /* clear recalc flags from targets */ + for (mpt= targets->first; mpt; mpt= mpt->next) { + bAnimVizSettings *avs; + + /* get pointer to animviz settings for each target */ + if (mpt->pchan) + avs= &mpt->ob->pose->avs; + else + avs= &mpt->ob->avs; + + /* clear the flag requesting recalculation of targets */ + avs->recalc &= ~ANIMVIZ_RECALC_PATHS; + } } /* ******************************************************************** */ |