[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29884] branches/soc-2010-aligorith-2/ source/blender/rigidbody/rb_bullet_api.cpp: Bullet SoC - Fixes for collision problems seen while creating latest set of videos

Joshua Leung aligorith at gmail.com
Sat Jul 3 02:43:59 CEST 2010


Revision: 29884
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29884
Author:   aligorith
Date:     2010-07-03 02:43:58 +0200 (Sat, 03 Jul 2010)

Log Message:
-----------
Bullet SoC - Fixes for collision problems seen while creating latest set of videos

* Shapes for cone, cylinder, and capsule were using the Bullet calls (default versions, as seen in old Bullet C-API were Y-Axis, while we should have used Z-Axis versions), subsequently resulting in incorrect collision detection during the demos at times. This manisfested as the shapes passing through the ground plane during demo 5.

* Capsule shape now uses the proper Bullet shapes instead of using a hack of joined multi-spheres

* All 'passive' RigidBodies are now treated as 'kinetic' for now. This means that they are treated as all being animated, which should allow interaction between animated objects and sim objects again, so I should be able to record demo 6 later today at last :). Later, I might add a separate API call to set this, but I'll leave that for now...

Modified Paths:
--------------
    branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp

Modified: branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp
===================================================================
--- branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp	2010-07-03 00:14:06 UTC (rev 29883)
+++ branches/soc-2010-aligorith-2/source/blender/rigidbody/rb_bullet_api.cpp	2010-07-03 00:43:58 UTC (rev 29884)
@@ -70,9 +70,12 @@
 	mem = btAlignedAlloc(sizeof(btCollisionDispatcher),16);
 	btDispatcher *dispatcher = new(mem) btCollisionDispatcher(collisionConfiguration);
 	
-#if 0 // Bullet C-API uses first version, but that requires extra complexity/settings to manage well...
+#if 0 // Bullet C-API uses first version, current using hardcoded world limits
+	btVector3 worldAabbMin(-1000,-1000,-1000);
+	btVector3 worldAabbMax(1000,1000,1000);
+	
 	mem = btAlignedAlloc(sizeof(btAxisSweep3),16);
-	btBroadphaseInterface *pairCache = new(mem) btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax);
+	btBroadphaseInterface *pairCache = new(mem) btAxisSweep3(worldAabbMin,worldAabbMax);
 #else // Most demos use this one instead... so assume to be fine enough for most purposes...
 	mem = btAlignedAlloc(sizeof(btDbvtBroadphase),16);
 	btBroadphaseInterface *pairCache = new(mem) btDbvtBroadphase();
@@ -183,6 +186,13 @@
 	mem = btAlignedAlloc(sizeof(btRigidBody),16);
 	btRigidBody *body = new(mem) btRigidBody(rbInfo);
 	
+	/* for animated objects (i.e. only do this when mass = 0 by default for now) */
+	// XXX: make this an extra api call which can be called on the fly...
+	if (mass == 0.0f) {
+		body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+		body->setActivationState(DISABLE_DEACTIVATION);
+	}
+	
 	return (rbRigidBody*)body;
 }
 
@@ -431,26 +441,20 @@
 
 rbCollisionShape *rbShapeNewCapsule(float radius, float height)
 {
-	/* capsule is convex hull of 2 spheres, so use btMultiSphereShape */
-	const int numSpheres = 2;
-	
-	btVector3 positions[numSpheres] = {btVector3(0,height,0),btVector3(0,-height,0)};
-	btScalar radi[numSpheres] = {radius,radius};
-	
-	void *mem = btAlignedAlloc(sizeof(btMultiSphereShape),16);
-	return (rbCollisionShape*) new(mem) btMultiSphereShape(positions,radi,numSpheres);
+	void *mem = btAlignedAlloc(sizeof(btCapsuleShapeZ),16);
+	return (rbCollisionShape*) new(mem) btCapsuleShapeZ(radius,height);
 }
 
 rbCollisionShape *rbShapeNewCone(float radius, float height)
 {
 	void *mem = btAlignedAlloc(sizeof(btConeShape),16);
-	return (rbCollisionShape*) new(mem) btConeShape(radius,height);
+	return (rbCollisionShape*) new(mem) btConeShapeZ(radius,height);
 }
 
 rbCollisionShape *rbShapeNewCylinder(float radius, float height)
 {
 	void *mem = btAlignedAlloc(sizeof(btCylinderShape),16);
-	return (rbCollisionShape*) new(mem) btCylinderShape(btVector3(radius,height,radius));
+	return (rbCollisionShape*) new(mem) btCylinderShapeZ(btVector3(radius,height,radius));
 }
 
 /* Setup (Special Shapes) ------------ */





More information about the Bf-blender-cvs mailing list