Browse Source

- Fix for only returning collision normal and contact points if they are available such as is the case for sensors.

MelvMay-GG 12 years ago
parent
commit
7a39345
1 changed files with 8 additions and 2 deletions
  1. 8 2
      engine/source/2d/scene/Scene.cc

+ 8 - 2
engine/source/2d/scene/Scene.cc

@@ -562,10 +562,10 @@ void Scene::dispatchBeginContactCallbacks( void )
             continue;
 
         // Fetch normal and contact points.
+        const U32& pointCount = tickContact.mPointCount;
         const b2Vec2& normal = tickContact.mWorldManifold.normal;
         const b2Vec2& point1 = tickContact.mWorldManifold.points[0];
         const b2Vec2& point2 = tickContact.mWorldManifold.points[1];
-        const U32& pointCount = tickContact.mPointCount;
         const S32 shapeIndexA = pSceneObjectA->getCollisionShapeIndex( tickContact.mpFixtureA );
         const S32 shapeIndexB = pSceneObjectB->getCollisionShapeIndex( tickContact.mpFixtureB );
 
@@ -600,7 +600,7 @@ void Scene::dispatchBeginContactCallbacks( void )
                 normalImpulse2,
                 tangentImpulse2 );
         }
-        else
+        else if ( pointCount == 1 )
         {
             dSprintf(pMiscInfoBuffer, 128,
                 "%d %d %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f",
@@ -610,6 +610,12 @@ void Scene::dispatchBeginContactCallbacks( void )
                 normalImpulse1,
                 tangentImpulse1 );
         }
+		else
+		{
+            dSprintf(pMiscInfoBuffer, 128,
+                "%d %d",
+                shapeIndexA, shapeIndexB );
+		}
 
         // Script callback.
         Con::executef( this, 4, "onCollision",