[Bf-blender-cvs] [e7eee7764a3] blender2.8: Fixes for motion path evaluation (part of T54810 work)

Joshua Leung noreply at git.blender.org
Mon May 7 16:53:03 CEST 2018


Commit: e7eee7764a30417f1200a693ead481fa4493cb17
Author: Joshua Leung
Date:   Mon May 7 16:52:42 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBe7eee7764a30417f1200a693ead481fa4493cb17

Fixes for motion path evaluation (part of T54810 work)

This commit brings back motion path calculations working on same level
as 2.7x.  Caveats:
* You cannot actually see anything, as all the drawing code for motion
  paths was removed and not reimplmented in 2.8 draw engines yet
* This doesn't actually use a separate depsgraph instance for fast
  background calculations yet. That's a separate topic, and will require
  further investigation (probably after code quest, according to original
  planning).
* The work here *does* however pave the path forwards towards fully separate
  COW evaluation though. We only need to stub in a different depsgraph instance
  here to get things working.

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

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

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

diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 1541d39938d..8edb26a0aeb 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -43,6 +43,8 @@
 #include "DNA_key_types.h"
 #include "DNA_scene_types.h"
 
+#include "BKE_anim.h"
+#include "BKE_action.h"
 #include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_global.h"
@@ -51,10 +53,10 @@
 #include "BKE_object.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
-#include "BKE_anim.h"
 #include "BKE_report.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 #include "DEG_depsgraph_build.h"
 
 // XXX bad level call...
@@ -231,8 +233,15 @@ typedef struct MPathTarget {
 	
 	bMotionPath *mpath;         /* motion path in question */
 	
+	/* Original (Source Objects) */
 	Object *ob;                 /* source object */
 	bPoseChannel *pchan;        /* source posechannel (if applicable) */
+	
+	/* "Evaluated" Copies (these come from the background COW copie
+	 * that provide all the coordinates we want to save off)
+	 */
+	Object *ob_eval;             /* evaluated object */
+	bPoseChannel *pchan_eval;    /* evaluated posechannel (if applicable) */
 } MPathTarget;
 
 /* ........ */
@@ -305,31 +314,39 @@ 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
 		 */
-		if ((CFRA < mpath->start_frame) || (CFRA >= mpath->end_frame))
+		if ((CFRA < mpath->start_frame) || (CFRA >= mpath->end_frame)) {
+			printf("skipping - out of range - %d (%d, %d)\n", CFRA, mpath->start_frame, mpath->end_frame);
 			continue;
+		}
+		else {
+			printf("doing %d\n", CFRA);
+		}
 		
 		/* get the relevant cache vert to write to */
 		mpv = mpath->points + (CFRA - mpath->start_frame);
 		
 		/* pose-channel or object path baking? */
-		if (mpt->pchan) {
+		if (mpt->pchan_eval) {
 			/* heads or tails */
 			if (mpath->flag & MOTIONPATH_FLAG_BHEAD) {
-				copy_v3_v3(mpv->co, mpt->pchan->pose_head);
+				copy_v3_v3(mpv->co, pchan_eval->pose_head);
 			}
 			else {
-				copy_v3_v3(mpv->co, mpt->pchan->pose_tail);
+				copy_v3_v3(mpv->co, pchan_eval->pose_tail);
 			}
 			
 			/* result must be in worldspace */
-			mul_m4_v3(mpt->ob->obmat, mpv->co);
+			mul_m4_v3(ob_eval->obmat, mpv->co);
 		}
 		else {
 			/* worldspace object location */
-			copy_v3_v3(mpv->co, mpt->ob->obmat[3]);
+			copy_v3_v3(mpv->co, ob_eval->obmat[3]);
 		}
 	}
 }
@@ -364,6 +381,18 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
 	}
 	if (efra <= sfra) return;
 	
+	
+	/* get copies of objects/bones to get the calculated results from
+	 * (for copy-on-write evaluation), so that we actually get some results
+	 */
+	// 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);
+		}
+	}
+	
 	/* calculate path over requested range */
 	for (CFRA = sfra; CFRA <= efra; CFRA++) {
 		/* update relevant data for new frame */
@@ -374,6 +403,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
 	}
 	
 	/* reset original environment */
+	// XXX: Soon to be obsolete
 	CFRA = cfra;
 	motionpaths_calc_update_scene(bmain, depsgraph);



More information about the Bf-blender-cvs mailing list