[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31154] branches/soc-2010-aligorith-2/ source/blender/blenkernel/intern/rigidbody.c: Bullet SoC - Settings for rigid body objects are manually flushed after creating new object instances , just to be sure these get set

Joshua Leung aligorith at gmail.com
Sun Aug 8 06:04:02 CEST 2010


Revision: 31154
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31154
Author:   aligorith
Date:     2010-08-08 06:03:38 +0200 (Sun, 08 Aug 2010)

Log Message:
-----------
Bullet SoC - Settings for rigid body objects are manually flushed after creating new object instances, just to be sure these get set

While setting this up, I've added code to set the default values of the sleep thresholds when creating new Rigid Bodies, but this is disabled by default as it was what was causing unwanted glitches in many of the test scenes I've done here. If those work well for brick wall, then fine, but I really doubt it.

Modified Paths:
--------------
    branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c

Modified: branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c	2010-08-08 02:24:46 UTC (rev 31153)
+++ branches/soc-2010-aligorith-2/source/blender/blenkernel/intern/rigidbody.c	2010-08-08 04:03:38 UTC (rev 31154)
@@ -324,6 +324,15 @@
 			break;
 #endif
 	}
+	
+	/* flush every setting to the shape so that we can make sure that all 
+	 * settings have been set as intended
+	 * 	- Doing this should fix problems with changing some settings having no effect 
+	 * 	  (especially after restarting sims)
+	 */
+	if (rbo->physics_shape) {
+		rbShapeSetMargin(rbo->physics_shape, rbo->margin);
+	}
 }
 
 
@@ -366,8 +375,16 @@
 		rbDWorldAddBody(rbw->physics_world, rbo->physics_object);
 	}
 	
-	// FIXME: flush every setting to the object, just so that we can make sure that all settings have been set?
-	// Doing this should fix problems with changing some settings having no effect (esp after restarting sims)
+	/* flush every setting to the object so that we can make sure that all 
+	 * settings have been set as intended
+	 * 	- Doing this should fix problems with changing some settings having no effect 
+	 * 	  (especially after restarting sims)
+	 */
+	rbBodySetFriction(rbo->physics_object, rbo->friction);
+	rbBodySetRestitution(rbo->physics_object, rbo->bounciness);
+	
+	rbBodySetDamping(rbo->physics_object, rbo->linDamping, rbo->angDamping);
+	rbBodySetSleepThresh(rbo->physics_object, rbo->linSleepThresh, rbo->angSleepThresh);
 }	
 
 /* --------------------- */
@@ -459,8 +476,13 @@
 	rbo->friction = 0.5f; // best when non-zero. 0.5 is Bullet default
 	rbo->bounciness = 0.0f; // best when zero. 0.0 is Bullet default
 	
-	rbo->margin = 0.04; // 0.04 (in meters) is Bullet default
+	rbo->margin = 0.04f; // 0.04 (in meters) is Bullet default
 	
+#if 0 // NOTE: this results in unusable simulations for many cases (i.e. with collisions or forcefields), so disabled by default
+	rbo->linSleepThresh = 0.8f; // 0.8 is Bullet default
+	rbo->angSleepThresh = 1.0f; // 1.0 is Bullet default
+#endif
+	
 		/* convex hull offers the best performance for general cases */
 	rbo->shape = RB_SHAPE_CONVEXH;
 	





More information about the Bf-blender-cvs mailing list