From c7e977250d1eab8d64ee35d7811f346a1b7f197d Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 9 Jan 2017 21:34:31 +0100 Subject: [PATCH] Update tests of collision world according to changes in collision detection --- test/tests/collision/TestCollisionWorld.h | 51 ++++++++-------------- test/tests/collision/TestDynamicAABBTree.h | 6 +-- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/test/tests/collision/TestCollisionWorld.h b/test/tests/collision/TestCollisionWorld.h index d778bcd5..94d44a98 100644 --- a/test/tests/collision/TestCollisionWorld.h +++ b/test/tests/collision/TestCollisionWorld.h @@ -28,6 +28,7 @@ // Libraries #include "reactphysics3d.h" +#include "Test.h" /// Reactphysics3D namespace namespace reactphysics3d { @@ -70,28 +71,28 @@ class WorldCollisionCallback : public CollisionCallback } // This method will be called for contact - virtual void notifyContact(const ContactPointInfo& contactPointInfo) override { + virtual void notifyContact(const CollisionCallbackInfo& collisionCallbackInfo) override { - if (isContactBetweenBodies(boxBody, sphere1Body, contactPointInfo)) { + if (isContactBetweenBodies(boxBody, sphere1Body, collisionCallbackInfo)) { boxCollideWithSphere1 = true; } - else if (isContactBetweenBodies(boxBody, cylinderBody, contactPointInfo)) { + else if (isContactBetweenBodies(boxBody, cylinderBody, collisionCallbackInfo)) { boxCollideWithCylinder = true; } - else if (isContactBetweenBodies(sphere1Body, cylinderBody, contactPointInfo)) { + else if (isContactBetweenBodies(sphere1Body, cylinderBody, collisionCallbackInfo)) { sphere1CollideWithCylinder = true; } - else if (isContactBetweenBodies(sphere1Body, sphere2Body, contactPointInfo)) { + else if (isContactBetweenBodies(sphere1Body, sphere2Body, collisionCallbackInfo)) { sphere1CollideWithSphere2 = true; } } bool isContactBetweenBodies(const CollisionBody* body1, const CollisionBody* body2, - const ContactPointInfo& contactPointInfo) { - return (contactPointInfo.shape1->getBody()->getID() == body1->getID() && - contactPointInfo.shape2->getBody()->getID() == body2->getID()) || - (contactPointInfo.shape2->getBody()->getID() == body1->getID() && - contactPointInfo.shape1->getBody()->getID() == body2->getID()); + const CollisionCallbackInfo& collisionCallbackInfo) { + return (collisionCallbackInfo.body1->getID() == body1->getID() && + collisionCallbackInfo.body2->getID() == body2->getID()) || + (collisionCallbackInfo.body2->getID() == body1->getID() && + collisionCallbackInfo.body1->getID() == body2->getID()); } }; @@ -197,10 +198,10 @@ class TestCollisionWorld : public Test { test(!mWorld->testAABBOverlap(mSphere1Body, mCylinderBody)); test(!mWorld->testAABBOverlap(mSphere1Body, mSphere2Body)); - test(mWorld->testAABBOverlap(mBoxProxyShape, mSphere1ProxyShape)); - test(mWorld->testAABBOverlap(mBoxProxyShape, mCylinderProxyShape)); - test(!mWorld->testAABBOverlap(mSphere1ProxyShape, mCylinderProxyShape)); - test(!mWorld->testAABBOverlap(mSphere1ProxyShape, mSphere2ProxyShape)); + test(mBoxProxyShape->testAABBOverlap(mSphere1ProxyShape->getWorldAABB())); + test(mBoxProxyShape->testAABBOverlap(mCylinderProxyShape->getWorldAABB())); + test(!mSphere1ProxyShape->testAABBOverlap(mCylinderProxyShape->getWorldAABB())); + test(!mSphere1ProxyShape->testAABBOverlap(mSphere2ProxyShape->getWorldAABB())); mCollisionCallback.reset(); mWorld->testCollision(mCylinderBody, &mCollisionCallback); @@ -223,20 +224,6 @@ class TestCollisionWorld : public Test { test(!mCollisionCallback.sphere1CollideWithCylinder); test(!mCollisionCallback.sphere1CollideWithSphere2); - mCollisionCallback.reset(); - mWorld->testCollision(mCylinderProxyShape, &mCollisionCallback); - test(!mCollisionCallback.boxCollideWithSphere1); - test(mCollisionCallback.boxCollideWithCylinder); - test(!mCollisionCallback.sphere1CollideWithCylinder); - test(!mCollisionCallback.sphere1CollideWithSphere2); - - mCollisionCallback.reset(); - mWorld->testCollision(mBoxProxyShape, mCylinderProxyShape, &mCollisionCallback); - test(!mCollisionCallback.boxCollideWithSphere1); - test(mCollisionCallback.boxCollideWithCylinder); - test(!mCollisionCallback.sphere1CollideWithCylinder); - test(!mCollisionCallback.sphere1CollideWithSphere2); - // Move sphere 1 to collide with sphere 2 mSphere1Body->setTransform(Transform(Vector3(30, 15, 10), Quaternion::identity())); @@ -282,10 +269,10 @@ class TestCollisionWorld : public Test { test(!mWorld->testAABBOverlap(mSphere1Body, mCylinderBody)); test(!mWorld->testAABBOverlap(mSphere1Body, mSphere2Body)); - test(!mWorld->testAABBOverlap(mBoxProxyShape, mSphere1ProxyShape)); - test(!mWorld->testAABBOverlap(mBoxProxyShape, mCylinderProxyShape)); - test(!mWorld->testAABBOverlap(mSphere1ProxyShape, mCylinderProxyShape)); - test(!mWorld->testAABBOverlap(mSphere1ProxyShape, mSphere2ProxyShape)); + test(!mBoxProxyShape->testAABBOverlap(mSphere1ProxyShape->getWorldAABB())); + test(!mBoxProxyShape->testAABBOverlap(mCylinderProxyShape->getWorldAABB())); + test(!mSphere1ProxyShape->testAABBOverlap(mCylinderProxyShape->getWorldAABB())); + test(!mSphere1ProxyShape->testAABBOverlap(mSphere2ProxyShape->getWorldAABB())); mBoxBody->setIsActive(true); mCylinderBody->setIsActive(true); diff --git a/test/tests/collision/TestDynamicAABBTree.h b/test/tests/collision/TestDynamicAABBTree.h index cb407738..7ab3202b 100644 --- a/test/tests/collision/TestDynamicAABBTree.h +++ b/test/tests/collision/TestDynamicAABBTree.h @@ -34,7 +34,7 @@ /// Reactphysics3D namespace namespace reactphysics3d { -class OverlapCallback : public DynamicAABBTreeOverlapCallback { +class TestOverlapCallback : public DynamicAABBTreeOverlapCallback { public : @@ -86,11 +86,9 @@ class TestDynamicAABBTree : public Test { // ---------- Atributes ---------- // - OverlapCallback mOverlapCallback; + TestOverlapCallback mOverlapCallback; DynamicTreeRaycastCallback mRaycastCallback; - - public : // ---------- Methods ---------- //