[Bf-blender-cvs] [cde74b2] temp_motionpaths: Motion Paths real time update WIP

Antony Riakiotakis noreply at git.blender.org
Mon Mar 2 18:20:41 CET 2015


Commit: cde74b2d5aa33d8813e4f1495345cb4efdad1e0f
Author: Antony Riakiotakis
Date:   Thu Feb 26 11:58:30 2015 +0100
Branches: temp_motionpaths
https://developer.blender.org/rBcde74b2d5aa33d8813e4f1495345cb4efdad1e0f

Motion Paths real time update WIP

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/anim.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/editors/transform/transform.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index d8adcf6..e2af544 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -111,12 +111,15 @@ class VIEW3D_HT_header(Header):
 
         # Pose
         if obj and mode == 'POSE':
+
             row = layout.row(align=True)
             row.operator("pose.copy", text="", icon='COPYDOWN')
             row.operator("pose.paste", text="", icon='PASTEDOWN').flipped = False
             row.operator("pose.paste", text="", icon='PASTEFLIPDOWN').flipped = True
 
-
+        if mode in {'OBJECT', 'POSE'}:
+            row.prop(toolsettings, "realtime_motion_path")
+ 
 class VIEW3D_MT_editor_menus(Menu):
     bl_space_type = 'VIEW3D_MT_editor_menus'
     bl_label = ""
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 04bddbe..410d7de 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -176,7 +176,7 @@ void BKE_object_handle_update(struct EvaluationContext *eval_ctx, struct Scene *
 void BKE_object_handle_update_ex(struct EvaluationContext *eval_ctx,
                                  struct Scene *scene, struct Object *ob,
                                  struct RigidBodyWorld *rbw,
-                                 const bool do_proxy_update);
+                                 const bool do_proxy_update, float ctime);
 void BKE_object_sculpt_modifiers_changed(struct Object *ob);
 
 int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index b878dbe..478c9f0 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -48,6 +48,7 @@
 #include "BKE_global.h"
 #include "BKE_key.h"
 #include "BKE_main.h"
+#include "BKE_library.h"
 #include "BKE_object.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
@@ -221,6 +222,7 @@ typedef struct MPathTarget {
 	bMotionPath *mpath;         /* motion path in question */
 	
 	Object *ob;                 /* source object */
+	Base *base_copy;            /* copy object, to be used for position calculations */
 	bPoseChannel *pchan;        /* source posechannel (if applicable) */
 } MPathTarget;
 
@@ -288,11 +290,19 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
 			baseNext = base->next;
 			
 			if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) {
-				BLI_remlink(&scene->base, base);
-				BLI_addhead(&scene->base, base);
-				
+				Object *ob = BKE_object_copy(mpt->ob);
+				Base *basen = MEM_mallocN(sizeof(Base), "duplibase");
+				*basen = *base;
+				basen->object = ob;
+				mpt->base_copy = basen;
+				ob->flag |= BA_TEMP_TAG;
+
+				//BLI_remlink(&scene->base, base);
+				//BLI_addhead(&scene->base, base);
+				BLI_addhead(&scene->base, basen);   /* addhead: prevent eternal loop */
+
 				mpt->ob->flag |= BA_TEMP_TAG;
-				
+
 				/* we really don't need to continue anymore once this happens, but this line might really 'break' */
 				break;
 			}
@@ -304,7 +314,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
 }
 
 /* update scene for current frame */
-static void motionpaths_calc_update_scene(Scene *scene)
+static void motionpaths_calc_update_scene(Scene *scene, float cframe)
 {
 #if 1 // 'production' optimizations always on
 	/* rigid body simulation needs complete update to work correctly for now */
@@ -332,7 +342,8 @@ static void motionpaths_calc_update_scene(Scene *scene)
 		 * is animated but not attached to/updatable from objects */
 		for (base = scene->base.first; base; base = base->next) {
 			/* update this object */
-			BKE_object_handle_update(G.main->eval_ctx, scene, base->object);
+			BKE_object_handle_update_ex(G.main->eval_ctx, scene, base->object, NULL, true, cframe);
+
 			
 			/* if this is the last one we need to update, let's stop to save some time */
 			if (base == last)
@@ -352,7 +363,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
 /* ........ */
 
 /* perform baking for the targets on the current frame */
-static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
+static void motionpaths_calc_bake_targets(ListBase *targets, int cframe)
 {
 	MPathTarget *mpt;
 	
@@ -364,11 +375,11 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
 		/* 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 ((cframe < mpath->start_frame) || (cframe >= mpath->end_frame))
 			continue;
 		
 		/* get the relevant cache vert to write to */
-		mpv = mpath->points + (CFRA - mpath->start_frame);
+		mpv = mpath->points + (cframe - mpath->start_frame);
 		
 		/* pose-channel or object path baking? */
 		if (mpt->pchan) {
@@ -385,7 +396,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
 		}
 		else {
 			/* worldspace object location */
-			copy_v3_v3(mpv->co, mpt->ob->obmat[3]);
+			copy_v3_v3(mpv->co, mpt->base_copy->object->obmat[3]);
 		}
 	}
 }
@@ -425,17 +436,16 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
 	motionpaths_calc_optimise_depsgraph(scene, targets);
 	
 	/* calculate path over requested range */
-	for (CFRA = sfra; CFRA <= efra; CFRA++) {
+	for (cfra = sfra; cfra <= efra; cfra++) {
 		/* update relevant data for new frame */
-		motionpaths_calc_update_scene(scene);
+		motionpaths_calc_update_scene(scene, cfra);
 		
 		/* perform baking for targets */
-		motionpaths_calc_bake_targets(scene, targets);
+		motionpaths_calc_bake_targets(targets, cfra);
 	}
 	
 	/* reset original environment */
-	CFRA = cfra;
-	motionpaths_calc_update_scene(scene);
+	motionpaths_calc_update_scene(scene, CFRA);
 	
 	/* clear recalc flags from targets */
 	for (mpt = targets->first; mpt; mpt = mpt->next) {
@@ -449,6 +459,15 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
 		
 		/* clear the flag requesting recalculation of targets */
 		avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
+
+		if (mpt->base_copy) {
+			DAG_id_type_tag(G.main, ID_OB);
+			DAG_relations_tag_update(G.main);
+			BKE_scene_base_unlink(scene, mpt->base_copy);
+			BKE_libblock_free_us(G.main, mpt->base_copy->object);
+			if (scene->basact == mpt->base_copy) scene->basact = NULL;
+			MEM_freeN(mpt->base_copy);
+		}
 	}
 }
 
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 0a1eda3..8850efa 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3016,7 +3016,8 @@ bool BKE_object_parent_loop_check(const Object *par, const Object *ob)
 void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
                                  Scene *scene, Object *ob,
                                  RigidBodyWorld *rbw,
-                                 const bool do_proxy_update)
+                                 const bool do_proxy_update,
+                                 float ctime)
 {
 	if (ob->recalc & OB_RECALC_ALL) {
 		/* speed optimization for animation lookups */
@@ -3057,7 +3058,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
 					copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
 			}
 			else
-				BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
+				BKE_object_where_is_calc_time_ex(scene, ob, ctime, rbw, NULL);
 		}
 		
 		if (ob->recalc & OB_RECALC_DATA) {
@@ -3065,7 +3066,6 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
 			AnimData *adt = BKE_animdata_from_id(data_id);
 			Key *key;
 			ParticleSystem *psys;
-			float ctime = BKE_scene_frame_get(scene);
 			
 			if (G.debug & G_DEBUG_DEPSGRAPH)
 				printf("recalcdata %s\n", ob->id.name + 2);
@@ -3236,7 +3236,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
  */
 void BKE_object_handle_update(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
 {
-	BKE_object_handle_update_ex(eval_ctx, scene, ob, NULL, true);
+	BKE_object_handle_update_ex(eval_ctx, scene, ob, NULL, true, BKE_scene_frame_get(scene));
 }
 
 void BKE_object_sculpt_modifiers_changed(Object *ob)
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index f94f7cd..32d568f 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1360,7 +1360,7 @@ static void scene_update_all_bases(EvaluationContext *eval_ctx, Scene *scene, Sc
 	for (base = scene->base.first; base; base = base->next) {
 		Object *object = base->object;
 
-		BKE_object_handle_update_ex(eval_ctx, scene_parent, object, scene->rigidbody_world, true);
+		BKE_object_handle_update_ex(eval_ctx, scene_parent, object, scene->rigidbody_world, true, BKE_scene_frame_get(scene_parent));
 
 		if (object->dup_group && (object->transflag & OB_DUPLIGROUP))
 			BKE_group_handle_recalc_and_update(eval_ctx, scene_parent, object, object->dup_group);
@@ -1411,7 +1411,7 @@ static void scene_update_object_func(TaskPool *pool, void *taskdata, int threadi
 		 * separately from main thread because of we've got no idea about
 		 * dependencies inside the group.
 		 */
-		BKE_object_handle_update_ex(eval_ctx, scene_parent, object, scene->rigidbody_world, false);
+		BKE_object_handle_update_ex(eval_ctx, scene_parent, object, scene->rigidbody_world, false, BKE_scene_frame_get(scene_parent));
 
 		/* Calculate statistics. */
 		if (add_to_stats) {
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index b6315a1..3ae1821 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -65,6 +65,7 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "ED_armature.h"
 #include "ED_image.h"
 #include "ED_keyframing.h"
 #include "ED_screen.h"
@@ -2356,6 +2357,20 @@ void transformApply(bContext *C, TransInfo *t)
 		viewRe

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list