[Bf-blender-cvs] [dc25e69c2d5] blender2.8: Fix motion paths not updating correctly for bones in some cases.

Brecht Van Lommel noreply at git.blender.org
Thu Jun 14 20:59:08 CEST 2018


Commit: dc25e69c2d5586d2635688ab18d2606be8c1ff57
Author: Brecht Van Lommel
Date:   Thu Jun 14 20:53:39 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBdc25e69c2d5586d2635688ab18d2606be8c1ff57

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.

===================================================================

M	source/blender/blenkernel/intern/anim.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list