[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54799] trunk/blender/source/blender/ blenkernel/intern/anim.c: rigidbody: Fix motion paths calculation being incorrect for rigid bodies

Sergej Reich sergej.reich at googlemail.com
Sun Feb 24 00:04:10 CET 2013


Revision: 54799
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54799
Author:   sergof
Date:     2013-02-23 23:04:10 +0000 (Sat, 23 Feb 2013)
Log Message:
-----------
rigidbody: Fix motion paths calculation being incorrect for rigid bodies

For the simulation to work properly the limited update the motion paths
calculation did wasn't enough so you got different results for for
motion paths than for the actual simulation.
Now do full frame update if rigid body sim is active.

TODO investigate if we can still limit this.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/anim.c

Modified: trunk/blender/source/blender/blenkernel/intern/anim.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim.c	2013-02-23 23:04:07 UTC (rev 54798)
+++ trunk/blender/source/blender/blenkernel/intern/anim.c	2013-02-23 23:04:10 UTC (rev 54799)
@@ -69,7 +69,6 @@
 #include "BKE_depsgraph.h"
 #include "BKE_anim.h"
 #include "BKE_report.h"
-#include "BKE_rigidbody.h"
 
 
 // XXX bad level call...
@@ -327,39 +326,38 @@
 static void motionpaths_calc_update_scene(Scene *scene)
 {
 #if 1 // 'production' optimizations always on
-	Base *base, *last = NULL;
-	float ctime = BKE_scene_frame_get(scene);
-	
-	/* only stuff that moves or needs display still */
-	DAG_scene_update_flags(G.main, scene, scene->lay, TRUE);
-	
-	/* find the last object with the tag 
-	 * - all those afterwards are assumed to not be relevant for our calculations
-	 */
-	/* optimize further by moving out... */
-	for (base = scene->base.first; base; base = base->next) {
-		if (base->object->flag & BA_TEMP_TAG)
-			last = base;
+
+	/* rigid body simulation needs complete update to work correctly for now */
+	/* RB_TODO investigate if we could avoid updating everything */
+	if (BKE_scene_check_rigidbody_active(scene)) {
+		BKE_scene_update_for_newframe(G.main, scene, scene->lay);
 	}
-	
-	/* run rigidbody sim 
-	 * NOTE: keep in sync with BKE_scene_update_for_newframe() in scene.c
-	 */
-	// 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))
-		BKE_rigidbody_do_simulation(scene, ctime);
-	
-	/* perform updates for tagged objects */
-	/* XXX: this will break if rigs depend on scene or other data that
-	 * 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(scene, base->object);
+	else { /* otherwise we can optimize by restricting updates */
+		Base *base, *last = NULL;
 		
-		/* if this is the last one we need to update, let's stop to save some time */
-		if (base == last)
-			break;
+		/* only stuff that moves or needs display still */
+		DAG_scene_update_flags(G.main, scene, scene->lay, TRUE);
+		
+		/* find the last object with the tag 
+		 * - all those afterwards are assumed to not be relevant for our calculations
+		 */
+		/* optimize further by moving out... */
+		for (base = scene->base.first; base; base = base->next) {
+			if (base->object->flag & BA_TEMP_TAG)
+				last = base;
+		}
+		
+		/* perform updates for tagged objects */
+		/* XXX: this will break if rigs depend on scene or other data that
+		 * 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(scene, base->object);
+			
+			/* if this is the last one we need to update, let's stop to save some time */
+			if (base == last)
+				break;
+		}
 	}
 #else // original, 'always correct' version
 	  /* do all updates




More information about the Bf-blender-cvs mailing list