Browse Source

Reversed the Normals in onCollision Callback

This corrects the previous checkin.  After some research, normals in
box2D are calculated pointing from A to B.  This makes them correct from
B's point a view and inversed for A.  By inversing the normal for A, the
callbacks will also have a normal in a consistent direction.
Peter Robinson 7 years ago
parent
commit
00dd4dcdf6
1 changed files with 4 additions and 4 deletions
  1. 4 4
      engine/source/2d/scene/Scene.cc

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

@@ -511,7 +511,7 @@ void Scene::dispatchBeginContactCallbacks( void )
             dSprintf(miscInfoBufferA, sizeof(miscInfoBufferA),
                 "%d %d %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f",
                 shapeIndexA, shapeIndexB,
-                normal.x, normal.y,
+                -normal.x, -normal.y,
                 point1.x, point1.y,
                 normalImpulse1,
                 tangentImpulse1,
@@ -522,7 +522,7 @@ void Scene::dispatchBeginContactCallbacks( void )
             dSprintf(miscInfoBufferB, sizeof(miscInfoBufferB),
                "%d %d %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f",
                shapeIndexB, shapeIndexA,
-               -normal.x, -normal.y,
+               normal.x, normal.y,
                point1.x, point1.y,
                normalImpulse1,
                tangentImpulse1,
@@ -535,7 +535,7 @@ void Scene::dispatchBeginContactCallbacks( void )
             dSprintf(miscInfoBufferA, sizeof(miscInfoBufferA),
                 "%d %d %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f",
                 shapeIndexA, shapeIndexB,
-                normal.x, normal.y,
+                -normal.x, -normal.y,
                 point1.x, point1.y,
                 normalImpulse1,
                 tangentImpulse1 );
@@ -543,7 +543,7 @@ void Scene::dispatchBeginContactCallbacks( void )
             dSprintf(miscInfoBufferB, sizeof(miscInfoBufferB),
                "%d %d %0.4f %0.4f %0.4f %0.4f %0.4f %0.4f",
                shapeIndexB, shapeIndexA,
-               -normal.x, -normal.y,
+               normal.x, normal.y,
                point1.x, point1.y,
                normalImpulse1,
                tangentImpulse1);