Update tests of collision world according to changes in collision detection
This commit is contained in:
parent
4a97c2ca97
commit
c7e977250d
|
@ -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);
|
||||
|
|
|
@ -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 ---------- //
|
||||
|
|
Loading…
Reference in New Issue
Block a user