diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-14 21:53:39 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-14 21:58:14 +0300 |
commit | dc25e69c2d5586d2635688ab18d2606be8c1ff57 (patch) | |
tree | e054a1fa7b956a0b74f85ec74dbad7ca6a52fb3d /source | |
parent | 2e09b277d51bc03a3a38c78aacf82cb106f03ada (diff) |
Fix motion paths not updating correctly for bones in some cases.
Sometimes the evaluated pose channel pointers can change during depsgraph
evaluation, so we can't store them ahead of time. The object pointer
should be ok since evaluated ID memory is reused.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index c7730d8877b..e2cecb32a36 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -275,7 +275,6 @@ typedef struct MPathTarget { * that provide all the coordinates we want to save off) */ Object *ob_eval; /* evaluated object */ - bPoseChannel *pchan_eval; /* evaluated posechannel (if applicable) */ } MPathTarget; /* ........ */ @@ -348,9 +347,6 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) bMotionPath *mpath = mpt->mpath; bMotionPathVert *mpv; - Object *ob_eval = mpt->ob_eval; - bPoseChannel *pchan_eval = mpt->pchan_eval; - /* 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 */ @@ -361,8 +357,17 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) /* get the relevant cache vert to write to */ mpv = mpath->points + (CFRA - mpath->start_frame); + Object *ob_eval = mpt->ob_eval; + + /* Lookup evaluated pose channel, here because the depsgraph + * evaluation can change them so they are not cached in mpt. */ + bPoseChannel *pchan_eval = NULL; + if (mpt->pchan) { + pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, mpt->pchan->name); + } + /* pose-channel or object path baking? */ - if (mpt->pchan_eval) { + if (pchan_eval) { /* heads or tails */ if (mpath->flag & MOTIONPATH_FLAG_BHEAD) { copy_v3_v3(mpv->co, pchan_eval->pose_head); @@ -425,9 +430,6 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) // TODO: Create a copy of background depsgraph that only contain these entities, and only evaluates them.. for (mpt = targets->first; mpt; mpt = mpt->next) { mpt->ob_eval = DEG_get_evaluated_object(depsgraph, mpt->ob); - if (mpt->pchan) { - mpt->pchan_eval = BKE_pose_channel_find_name(mpt->ob_eval->pose, mpt->pchan->name); - } AnimData *adt = BKE_animdata_from_id(&mpt->ob_eval->id); |