[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54991] trunk/blender/source/blender: rigidbody: Revert to running simulation on frame update

Sergej Reich sergej.reich at googlemail.com
Sun Mar 3 07:09:48 CET 2013


Revision: 54991
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54991
Author:   sergof
Date:     2013-03-03 06:09:48 +0000 (Sun, 03 Mar 2013)
Log Message:
-----------
rigidbody: Revert to running simulation on frame update

Instead of flagging the rigid body world for frame update just call
BKE_rigidbody_do_simulation() recursively for all scenes.

This avoids having to constantly check if the simulation needs to be
updated.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/rigidbody.c
    trunk/blender/source/blender/blenkernel/intern/scene.c
    trunk/blender/source/blender/makesdna/DNA_rigidbody_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/rigidbody.c	2013-03-03 06:09:45 UTC (rev 54990)
+++ trunk/blender/source/blender/blenkernel/intern/rigidbody.c	2013-03-03 06:09:48 UTC (rev 54991)
@@ -1262,8 +1262,6 @@
 	BKE_ptcache_id_time(&pid, scene, ctime, &startframe, &endframe, NULL);
 	cache = rbw->pointcache;
 
-	rbw->flag &= ~RBW_FLAG_FRAME_UPDATE;
-
 	if (ctime <= startframe) {
 		rbw->ltime = startframe;
 		return;

Modified: trunk/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/scene.c	2013-03-03 06:09:45 UTC (rev 54990)
+++ trunk/blender/source/blender/blenkernel/intern/scene.c	2013-03-03 06:09:48 UTC (rev 54991)
@@ -1081,22 +1081,22 @@
 
 }
 
-static void scene_flag_rbw_recursive(Scene *scene)
+static void scene_rebuild_rbw_recursive(Scene *scene, float ctime)
 {
 	if (scene->set)
-		scene_flag_rbw_recursive(scene->set);
+		scene_rebuild_rbw_recursive(scene->set, ctime);
 
 	if (BKE_scene_check_rigidbody_active(scene))
-		scene->rigidbody_world->flag |= RBW_FLAG_FRAME_UPDATE;
+		BKE_rigidbody_rebuild_world(scene, ctime);
 }
 
-static void scene_rebuild_rbw_recursive(Scene *scene, float ctime)
+static void scene_do_rb_simulation_recursive(Scene *scene, float ctime)
 {
 	if (scene->set)
-		scene_rebuild_rbw_recursive(scene->set, ctime);
+		scene_do_rb_simulation_recursive(scene->set, ctime);
 
 	if (BKE_scene_check_rigidbody_active(scene))
-		BKE_rigidbody_rebuild_world(scene, ctime);
+		BKE_rigidbody_do_simulation(scene, ctime);
 }
 
 static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent)
@@ -1110,22 +1110,6 @@
 	if (scene->set)
 		scene_update_tagged_recursive(bmain, scene->set, scene_parent);
 	
-	/* run rigidbody sim 
-	 * - calculate/read values from cache into RBO's, to get flushed 
-	 *   later when objects are evaluated (if they're tagged for eval)
-	 */
-	// XXX: this position may still change, objects not being updated correctly before simulation is run
-	// NOTE: current position is so that rigidbody sim affects other objects
-	if (BKE_scene_check_rigidbody_active(scene) && scene->rigidbody_world->flag & RBW_FLAG_FRAME_UPDATE) {
-		/* we use frame time of parent (this is "scene" itself for top-level of sets recursion), 
-		 * as that is the active scene controlling all timing in file at the moment
-		 */
-		float ctime = BKE_scene_frame_get(scene_parent);
-
-		/* however, "scene" contains the rigidbody world needed for eval... */
-		BKE_rigidbody_do_simulation(scene, ctime);
-	}
-	
 	/* scene objects */
 	for (base = scene->base.first; base; base = base->next) {
 		Object *ob = base->object;
@@ -1249,8 +1233,9 @@
 	tag_main_idcode(bmain, ID_MA, FALSE);
 	tag_main_idcode(bmain, ID_LA, FALSE);
 
-	/* flag rigid body worlds for update */
-	scene_flag_rbw_recursive(sce);
+	/* run rigidbody sim */
+	/* NOTE: current position is so that rigidbody sim affects other objects, might change in the future */
+	scene_do_rb_simulation_recursive(sce, ctime);
 
 	/* BKE_object_handle_update() on all objects, groups and sets */
 	scene_update_tagged_recursive(bmain, sce, sce);

Modified: trunk/blender/source/blender/makesdna/DNA_rigidbody_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_rigidbody_types.h	2013-03-03 06:09:45 UTC (rev 54990)
+++ trunk/blender/source/blender/makesdna/DNA_rigidbody_types.h	2013-03-03 06:09:48 UTC (rev 54991)
@@ -80,9 +80,7 @@
 	/* sim data needs to be rebuilt */
 	RBW_FLAG_NEEDS_REBUILD		= (1 << 1),
 	/* usse split impulse when stepping the simulation */
-	RBW_FLAG_USE_SPLIT_IMPULSE	= (1 << 2),
-	/* need to step simulation after frame update */
-	RBW_FLAG_FRAME_UPDATE		= (1 << 3)
+	RBW_FLAG_USE_SPLIT_IMPULSE	= (1 << 2)
 } eRigidBodyWorld_Flag;
 
 /* ******************************** */




More information about the Bf-blender-cvs mailing list