[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15998] trunk/blender/source/gameengine/ Physics/Bullet/CcdPhysicsEnvironment.cpp: BGE bug #17409 fixed: BGE Near Sensor Incorrect once inside the radius.

Benoit Bolsee benoit.bolsee at online.be
Thu Aug 7 13:31:34 CEST 2008


Revision: 15998
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15998
Author:   ben2610
Date:     2008-08-07 13:31:24 +0200 (Thu, 07 Aug 2008)

Log Message:
-----------
BGE bug #17409 fixed: BGE Near Sensor Incorrect once inside the radius. The bug is located in Bullet: the manifold contact points for non-response objects (sensor, ghost) are not refreshed and stay in the cash as long as the objects overlap in the broad phase. Instead of fixing Bullet, I put a work around in the BGE. This may need review when a new Bullet library is integrated

Modified Paths:
--------------
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp	2008-08-07 11:25:45 UTC (rev 15997)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp	2008-08-07 11:31:24 UTC (rev 15998)
@@ -956,13 +956,25 @@
 	if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)))
 	{
 		//walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback
-		int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
+		btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher();
+		int numManifolds = dispatcher->getNumManifolds();
 		for (int i=0;i<numManifolds;i++)
 		{
-			btPersistentManifold* manifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
+			btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
 			int numContacts = manifold->getNumContacts();
 			if (numContacts)
 			{
+				btRigidBody* rb0 = static_cast<btRigidBody*>(manifold->getBody0());
+				btRigidBody* rb1 = static_cast<btRigidBody*>(manifold->getBody1());
+				// Bullet does not refresh the manifold contact point for object without contact response
+				// may need to remove this when a newer Bullet version is integrated
+				if (!dispatcher->needsResponse(rb0, rb1))
+				{
+					manifold->refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform());
+					numContacts = manifold->getNumContacts();
+					if (!numContacts)
+						continue;
+				}
 				if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints))
 				{
 					for (int j=0;j<numContacts;j++)
@@ -973,8 +985,8 @@
 							m_debugDrawer->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color);
 					}
 				}
-				btRigidBody* obj0 = static_cast<btRigidBody* >(manifold->getBody0());
-				btRigidBody* obj1 = static_cast<btRigidBody* >(manifold->getBody1());
+				btRigidBody* obj0 = rb0;
+				btRigidBody* obj1 = rb1;
 
 				//m_internalOwner is set in 'addPhysicsController'
 				CcdPhysicsController* ctrl0 = static_cast<CcdPhysicsController*>(obj0->getUserPointer());





More information about the Bf-blender-cvs mailing list