[DEV] add test

This commit is contained in:
Edouard DUPIN 2017-06-28 21:41:31 +02:00
parent 2436ec2ef9
commit cdd0d3e453
8 changed files with 4145 additions and 6 deletions

2
authors.txt Normal file
View File

@ -0,0 +1,2 @@
Daniel Chappuis<>
Dupin Edouard<yui.heero@gmail.com>

View File

@ -344,26 +344,26 @@ void Simplex::backupClosestPointInSimplex(vec3& v) {
// Return the closest point "v" in the convex hull of the points in the subset
// represented by the bits "subset"
vec3 Simplex::computeClosestPointForSubset(Bits subset) {
vec3 v(0.0, 0.0, 0.0); // Closet point v = sum(lambda_i * points[i])
vec3 Simplex::computeClosestPointForSubset(Bits _subset) {
vec3 v(0.0, 0.0, 0.0); // Closet point v = sum(lambda_i * points[i])
mMaxLengthSquare = 0.0;
float deltaX = 0.0; // deltaX = sum of all det[subset][i]
float deltaX = 0.0; // deltaX = sum of all det[subset][i]
int32_t i;
Bits bit;
// For each four point in the possible simplex set
for (i=0, bit=0x1; i<4; i++, bit <<= 1) {
// If the current point is in the subset
if (overlap(subset, bit)) {
if (overlap(_subset, bit)) {
// deltaX = sum of all det[subset][i]
deltaX += mDet[subset][i];
deltaX += mDet[_subset][i];
if (mMaxLengthSquare < mPointsLengthSquare[i]) {
mMaxLengthSquare = mPointsLengthSquare[i];
}
// Closest point v = sum(lambda_i * points[i])
v += mDet[subset][i] * mPoints[i];
v += mDet[_subset][i] * mPoints[i];
}
}

227
test/testAABB.cpp Normal file
View File

@ -0,0 +1,227 @@
/** @file
* @author Edouard DUPIN
* @copyright 2017, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <ephysics/ephysics.hpp>
/*
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB2(vec3(-5, 4, -30), vec3(-2, 20, 30));
ephysics::AABB m_AABB3(vec3(-25, -25, -25), vec3(25, 25, 25));
ephysics::AABB m_AABB4(vec3(-40, -40, -40), vec3(-15, -25, -12));
*/
TEST(TestAABB, methode_constructors) {
ephysics::AABB aabb1;
ephysics::AABB aabb2(vec3(-3, -5, -8), vec3(65, -1, 56));
vec3 trianglePoints[] = {
vec3(-5, 7, 23), vec3(45, -34, -73), vec3(-12, 98, 76)
};
ephysics::AABB aabb3 = ephysics::AABB::createAABBForTriangle(trianglePoints);
EXPECT_EQ(aabb1.getMin().x(), 0);
EXPECT_EQ(aabb1.getMin().y(), 0);
EXPECT_EQ(aabb1.getMin().z(), 0);
EXPECT_EQ(aabb1.getMax().x(), 0);
EXPECT_EQ(aabb1.getMax().y(), 0);
EXPECT_EQ(aabb1.getMax().z(), 0);
EXPECT_EQ(aabb2.getMin().x(), -3);
EXPECT_EQ(aabb2.getMin().y(), -5);
EXPECT_EQ(aabb2.getMin().z(), -8);
EXPECT_EQ(aabb2.getMax().x(), 65);
EXPECT_EQ(aabb2.getMax().y(), -1);
EXPECT_EQ(aabb2.getMax().z(), 56);
EXPECT_EQ(aabb3.getMin().x(), -12);
EXPECT_EQ(aabb3.getMin().y(), -34);
EXPECT_EQ(aabb3.getMin().z(), -73);
EXPECT_EQ(aabb3.getMax().x(), 45);
EXPECT_EQ(aabb3.getMax().y(), 98);
EXPECT_EQ(aabb3.getMax().z(), 76);
}
TEST(TestAABB, methode_inflate) {
ephysics::AABB aabbInflate(vec3(-3, 4, 8), vec3(-1, 6, 32));
aabbInflate.inflate(1, 2, 3);
EXPECT_FLOAT_EQ(aabbInflate.getMin().x(), -4);
EXPECT_FLOAT_EQ(aabbInflate.getMin().y(), 2);
EXPECT_FLOAT_EQ(aabbInflate.getMin().z(), 5);
EXPECT_FLOAT_EQ(aabbInflate.getMax().x(), 0);
EXPECT_FLOAT_EQ(aabbInflate.getMax().y(), 8);
EXPECT_FLOAT_EQ(aabbInflate.getMax().z(), 35);
}
TEST(TestAABB, methode_getExtent) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB2(vec3(-5, 4, -30), vec3(-2, 20, 30));
ephysics::AABB m_AABB3(vec3(-25, -25, -25), vec3(25, 25, 25));
EXPECT_FLOAT_EQ(m_AABB1.getExtent().x(), 20);
EXPECT_FLOAT_EQ(m_AABB1.getExtent().y(), 20);
EXPECT_FLOAT_EQ(m_AABB1.getExtent().z(), 20);
EXPECT_FLOAT_EQ(m_AABB2.getExtent().x(), 3);
EXPECT_FLOAT_EQ(m_AABB2.getExtent().y(), 16);
EXPECT_FLOAT_EQ(m_AABB2.getExtent().z(), 60);
EXPECT_FLOAT_EQ(m_AABB3.getExtent().x(), 50);
EXPECT_FLOAT_EQ(m_AABB3.getExtent().y(), 50);
EXPECT_FLOAT_EQ(m_AABB3.getExtent().z(), 50);
}
TEST(TestAABB, methode_getCenter) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB2(vec3(-5, 4, -30), vec3(-2, 20, 30));
EXPECT_EQ(m_AABB1.getCenter().x(), 0);
EXPECT_EQ(m_AABB1.getCenter().y(), 0);
EXPECT_EQ(m_AABB1.getCenter().z(), 0);
EXPECT_FLOAT_EQ(m_AABB2.getCenter().x(), -3.5);
EXPECT_FLOAT_EQ(m_AABB2.getCenter().y(), 12);
EXPECT_FLOAT_EQ(m_AABB2.getCenter().z(), 0);
}
TEST(TestAABB, methode_minMax) {
ephysics::AABB aabb5;
aabb5.setMin(vec3(-12, 34, 6));
aabb5.setMax(vec3(-3, 56, 20));
EXPECT_EQ(aabb5.getMin().x(), -12);
EXPECT_EQ(aabb5.getMin().y(), 34);
EXPECT_EQ(aabb5.getMin().z(), 6);
EXPECT_EQ(aabb5.getMax().x(), -3);
EXPECT_EQ(aabb5.getMax().y(), 56);
EXPECT_EQ(aabb5.getMax().z(), 20);
}
TEST(TestAABB, methode_asignement) {
ephysics::AABB aabb2(vec3(-3, -5, -8), vec3(65, -1, 56));
ephysics::AABB aabb6;
aabb6 = aabb2;
EXPECT_EQ(aabb6.getMin().x(), -3);
EXPECT_EQ(aabb6.getMin().y(), -5);
EXPECT_EQ(aabb6.getMin().z(), -8);
EXPECT_EQ(aabb6.getMax().x(), 65);
EXPECT_EQ(aabb6.getMax().y(), -1);
EXPECT_EQ(aabb6.getMax().z(), 56);
}
TEST(TestAABB, methode_getVolume) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB2(vec3(-5, 4, -30), vec3(-2, 20, 30));
EXPECT_FLOAT_EQ(m_AABB1.getVolume(), 8000);
EXPECT_FLOAT_EQ(m_AABB2.getVolume(), 2880);
}
TEST(TestAABB, merge_mergeTwoAABBs) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB4(vec3(-40, -40, -40), vec3(-15, -25, -12));
ephysics::AABB aabb1(vec3(-45, 7, -2), vec3(23, 8, 1));
ephysics::AABB aabb2(vec3(-15, 6, 23), vec3(-5, 9, 45));
ephysics::AABB aabb3;
aabb3.mergeTwoAABBs(aabb1, m_AABB1);
EXPECT_EQ(aabb3.getMin().x(), -45);
EXPECT_EQ(aabb3.getMin().y(), -10);
EXPECT_EQ(aabb3.getMin().z(), -10);
EXPECT_EQ(aabb3.getMax().x(), 23);
EXPECT_EQ(aabb3.getMax().y(), 10);
EXPECT_EQ(aabb3.getMax().z(), 10);
ephysics::AABB aabb4;
aabb4.mergeTwoAABBs(aabb1, aabb2);
EXPECT_EQ(aabb4.getMin().x(), -45);
EXPECT_EQ(aabb4.getMin().y(), 6);
EXPECT_EQ(aabb4.getMin().z(), -2);
EXPECT_EQ(aabb4.getMax().x(), 23);
EXPECT_EQ(aabb4.getMax().y(), 9);
EXPECT_EQ(aabb4.getMax().z(), 45);
}
TEST(TestAABB, merge_mergeWithAABB) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB aabb1(vec3(-45, 7, -2), vec3(23, 8, 1));
ephysics::AABB aabb2(vec3(-15, 6, 23), vec3(-5, 9, 45));
aabb1.mergeWithAABB(m_AABB1);
EXPECT_EQ(aabb1.getMin().x(), -45);
EXPECT_EQ(aabb1.getMin().y(), -10);
EXPECT_EQ(aabb1.getMin().z(), -10);
EXPECT_EQ(aabb1.getMax().x(), 23);
EXPECT_EQ(aabb1.getMax().y(), 10);
EXPECT_EQ(aabb1.getMax().z(), 10);
aabb2.mergeWithAABB(m_AABB1);
EXPECT_EQ(aabb2.getMin().x(), -15);
EXPECT_EQ(aabb2.getMin().y(), -10);
EXPECT_EQ(aabb2.getMin().z(), -10);
EXPECT_EQ(aabb2.getMax().x(), 10);
EXPECT_EQ(aabb2.getMax().y(), 10);
EXPECT_EQ(aabb2.getMax().z(), 45);
}
TEST(TestAABB, intersection_containsAABB) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB2(vec3(-5, 4, -30), vec3(-2, 20, 30));
ephysics::AABB m_AABB3(vec3(-25, -25, -25), vec3(25, 25, 25));
ephysics::AABB m_AABB4(vec3(-40, -40, -40), vec3(-15, -25, -12));
EXPECT_EQ(m_AABB1.contains(m_AABB2), false);
EXPECT_EQ(m_AABB3.contains(m_AABB1), true);
EXPECT_EQ(m_AABB1.contains(m_AABB3), false);
EXPECT_EQ(m_AABB1.contains(m_AABB4), false);
EXPECT_EQ(m_AABB4.contains(m_AABB1), false);
}
TEST(TestAABB, intersection_containsVec3) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
EXPECT_EQ(m_AABB1.contains(vec3(0, 0, 0)), true);
EXPECT_EQ(m_AABB1.contains(vec3(-5, 6, 9)), true);
EXPECT_EQ(m_AABB1.contains(vec3(-9, -4, -9)), true);
EXPECT_EQ(m_AABB1.contains(vec3(9, 4, 7)), true);
EXPECT_EQ(m_AABB1.contains(vec3(-11, -4, -9)), false);
EXPECT_EQ(m_AABB1.contains(vec3(1, 12, -9)), false);
EXPECT_EQ(m_AABB1.contains(vec3(1, 8, -13)), false);
EXPECT_EQ(m_AABB1.contains(vec3(-14, 82, -13)), false);
}
TEST(TestAABB, intersection_testCollision) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB m_AABB2(vec3(-5, 4, -30), vec3(-2, 20, 30));
ephysics::AABB m_AABB3(vec3(-25, -25, -25), vec3(25, 25, 25));
ephysics::AABB m_AABB4(vec3(-40, -40, -40), vec3(-15, -25, -12));
EXPECT_EQ(m_AABB1.testCollision(m_AABB2), true);
EXPECT_EQ(m_AABB2.testCollision(m_AABB1), true);
EXPECT_EQ(m_AABB1.testCollision(m_AABB3), true);
EXPECT_EQ(m_AABB3.testCollision(m_AABB1), true);
EXPECT_EQ(m_AABB1.testCollision(m_AABB4), false);
EXPECT_EQ(m_AABB4.testCollision(m_AABB1), false);
}
TEST(TestAABB, intersection_testCollisionTriangleAABB) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::AABB aabb(vec3(100, 100, 100), vec3(200, 200, 200));
vec3 trianglePoints[] = {
vec3(-2, 4, 6), vec3(20, -34, -73), vec3(-12, 98, 76)
};
EXPECT_EQ(m_AABB1.testCollisionTriangleAABB(trianglePoints), true);
EXPECT_EQ(aabb.testCollisionTriangleAABB(trianglePoints), false);
}
TEST(TestAABB, intersection_testRayIntersect) {
ephysics::AABB m_AABB1(vec3(-10, -10, -10), vec3(10, 10, 10));
ephysics::Ray ray1(vec3(-20, 4, -7), vec3(20, 4, -7));
ephysics::Ray ray2(vec3(-20, 11, -7), vec3(20, 11, -7));
ephysics::Ray ray3(vec3(0, 15, 0), vec3(0, -15, 0));
ephysics::Ray ray4(vec3(0, -15, 0), vec3(0, 15, 0));
ephysics::Ray ray5(vec3(-3, 4, 8), vec3(-7, 9, 4));
ephysics::Ray ray6(vec3(-4, 6, -100), vec3(-4, 6, -9));
ephysics::Ray ray7(vec3(-4, 6, -100), vec3(-4, 6, -11), 0.6);
ephysics::Ray ray8(vec3(-403, -432, -100), vec3(134, 643, 23));
EXPECT_EQ(m_AABB1.testRayIntersect(ray1), true);
EXPECT_EQ(m_AABB1.testRayIntersect(ray2), false);
EXPECT_EQ(m_AABB1.testRayIntersect(ray3), true);
EXPECT_EQ(m_AABB1.testRayIntersect(ray4), true);
EXPECT_EQ(m_AABB1.testRayIntersect(ray5), true);
EXPECT_EQ(m_AABB1.testRayIntersect(ray6), true);
EXPECT_EQ(m_AABB1.testRayIntersect(ray7), false);
EXPECT_EQ(m_AABB1.testRayIntersect(ray8), false);
}

269
test/testCollisionWorld.cpp Normal file
View File

@ -0,0 +1,269 @@
/** @file
* @author Edouard DUPIN
* @copyright 2017, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <ephysics/ephysics.hpp>
// Enumeration for categories
enum CollisionCategory {
CATEGORY_1 = 0x0001,
CATEGORY_2 = 0x0002,
CATEGORY_3 = 0x0004
};
class WorldCollisionCallback : public ephysics::CollisionCallback {
public:
bool boxCollideWithSphere1;
bool boxCollideWithCylinder;
bool sphere1CollideWithCylinder;
bool sphere1CollideWithSphere2;
ephysics::CollisionBody* boxBody;
ephysics::CollisionBody* sphere1Body;
ephysics::CollisionBody* sphere2Body;
ephysics::CollisionBody* cylinderBody;
WorldCollisionCallback() {
reset();
}
void reset() {
boxCollideWithSphere1 = false;
boxCollideWithCylinder = false;
sphere1CollideWithCylinder = false;
sphere1CollideWithSphere2 = false;
}
// This method will be called for contact
virtual void notifyContact(const ephysics::ContactPointInfo& contactPointInfo) {
if (isContactBetweenBodies(boxBody, sphere1Body, contactPointInfo)) {
boxCollideWithSphere1 = true;
} else if (isContactBetweenBodies(boxBody, cylinderBody, contactPointInfo)) {
boxCollideWithCylinder = true;
} else if (isContactBetweenBodies(sphere1Body, cylinderBody, contactPointInfo)) {
sphere1CollideWithCylinder = true;
} else if (isContactBetweenBodies(sphere1Body, sphere2Body, contactPointInfo)) {
sphere1CollideWithSphere2 = true;
}
}
bool isContactBetweenBodies(const ephysics::CollisionBody* body1,
const ephysics::CollisionBody* body2,
const ephysics::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() );
}
};
/**
* Unit test for the CollisionWorld class.
*/
class TestCollisionWorld {
public:
// Physics world
ephysics::CollisionWorld* m_world;
// Bodies
ephysics::CollisionBody* m_boxBody;
ephysics::CollisionBody* m_sphere1Body;
ephysics::CollisionBody* m_sphere2Body;
ephysics::CollisionBody* m_cylinderBody;
// Collision shapes
ephysics::BoxShape* m_boxShape;
ephysics::SphereShape* m_sphereShape;
ephysics::CylinderShape* m_cylinderShape;
// Proxy shapes
ephysics::ProxyShape* m_boxProxyShape;
ephysics::ProxyShape* m_sphere1ProxyShape;
ephysics::ProxyShape* m_sphere2ProxyShape;
ephysics::ProxyShape* m_cylinderProxyShape;
// Collision callback class
WorldCollisionCallback m_collisionCallback;
public :
TestCollisionWorld() {
// Create the world
m_world = new ephysics::CollisionWorld();
// Create the bodies
etk::Transform3D boxTransform(vec3(10, 0, 0), etk::Quaternion::identity());
m_boxBody = m_world->createCollisionBody(boxTransform);
m_boxShape = new ephysics::BoxShape(vec3(3, 3, 3));
m_boxProxyShape = m_boxBody->addCollisionShape(m_boxShape, etk::Transform3D::identity());
m_sphereShape = new ephysics::SphereShape(3.0);
etk::Transform3D sphere1Transform(vec3(10,5, 0), etk::Quaternion::identity());
m_sphere1Body = m_world->createCollisionBody(sphere1Transform);
m_sphere1ProxyShape = m_sphere1Body->addCollisionShape(m_sphereShape, etk::Transform3D::identity());
etk::Transform3D sphere2Transform(vec3(30, 10, 10), etk::Quaternion::identity());
m_sphere2Body = m_world->createCollisionBody(sphere2Transform);
m_sphere2ProxyShape = m_sphere2Body->addCollisionShape(m_sphereShape, etk::Transform3D::identity());
etk::Transform3D cylinderTransform(vec3(10, -5, 0), etk::Quaternion::identity());
m_cylinderBody = m_world->createCollisionBody(cylinderTransform);
m_cylinderShape = new ephysics::CylinderShape(2, 5);
m_cylinderProxyShape = m_cylinderBody->addCollisionShape(m_cylinderShape, etk::Transform3D::identity());
// Assign collision categories to proxy shapes
m_boxProxyShape->setCollisionCategoryBits(CATEGORY_1);
m_sphere1ProxyShape->setCollisionCategoryBits(CATEGORY_1);
m_sphere2ProxyShape->setCollisionCategoryBits(CATEGORY_2);
m_cylinderProxyShape->setCollisionCategoryBits(CATEGORY_3);
m_collisionCallback.boxBody = m_boxBody;
m_collisionCallback.sphere1Body = m_sphere1Body;
m_collisionCallback.sphere2Body = m_sphere2Body;
m_collisionCallback.cylinderBody = m_cylinderBody;
}
~TestCollisionWorld() {
delete m_boxShape;
delete m_sphereShape;
delete m_cylinderShape;
}
};
TEST(TestCollisionWorld, testCollisions_1) {
TestCollisionWorld tmp;
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(&tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, true);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxBody, tmp.m_sphere1Body), true);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxBody, tmp.m_cylinderBody), true);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1Body, tmp.m_cylinderBody), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1Body, tmp.m_sphere2Body), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxProxyShape, tmp.m_sphere1ProxyShape), true);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxProxyShape, tmp.m_cylinderProxyShape), true);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1ProxyShape, tmp.m_cylinderProxyShape), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1ProxyShape, tmp.m_sphere2ProxyShape), false);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_cylinderBody, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_boxBody, tmp.m_sphere1Body, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, true);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_boxBody, tmp.m_cylinderBody, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_cylinderProxyShape, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_boxProxyShape, tmp.m_cylinderProxyShape, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
// Move sphere 1 to collide with sphere 2
tmp.m_sphere1Body->setTransform(etk::Transform3D(vec3(30, 15, 10), etk::Quaternion::identity()));
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(&tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, true);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_boxBody, tmp.m_sphere1Body, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(tmp.m_boxBody, tmp.m_cylinderBody, &tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
// Move sphere 1 to collide with box
tmp.m_sphere1Body->setTransform(etk::Transform3D(vec3(10, 5, 0), etk::Quaternion::identity()));
// --------- Test collision with inactive bodies --------- //
tmp.m_collisionCallback.reset();
tmp.m_boxBody->setIsActive(false);
tmp.m_cylinderBody->setIsActive(false);
tmp.m_sphere1Body->setIsActive(false);
tmp.m_sphere2Body->setIsActive(false);
tmp.m_world->testCollision(&tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxBody, tmp.m_sphere1Body), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxBody, tmp.m_cylinderBody), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1Body, tmp.m_cylinderBody), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1Body, tmp.m_sphere2Body), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxProxyShape, tmp.m_sphere1ProxyShape), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_boxProxyShape, tmp.m_cylinderProxyShape), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1ProxyShape, tmp.m_cylinderProxyShape), false);
EXPECT_EQ(tmp.m_world->testAABBOverlap(tmp.m_sphere1ProxyShape, tmp.m_sphere2ProxyShape), false);
tmp.m_boxBody->setIsActive(true);
tmp.m_cylinderBody->setIsActive(true);
tmp.m_sphere1Body->setIsActive(true);
tmp.m_sphere2Body->setIsActive(true);
// --------- Test collision with collision filtering -------- //
tmp.m_boxProxyShape->setCollideWithMaskBits(CATEGORY_1 | CATEGORY_3);
tmp.m_sphere1ProxyShape->setCollideWithMaskBits(CATEGORY_1 | CATEGORY_2);
tmp.m_sphere2ProxyShape->setCollideWithMaskBits(CATEGORY_1);
tmp.m_cylinderProxyShape->setCollideWithMaskBits(CATEGORY_1);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(&tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, true);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
// Move sphere 1 to collide with sphere 2
tmp.m_sphere1Body->setTransform(etk::Transform3D(vec3(30, 15, 10), etk::Quaternion::identity()));
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(&tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, true);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, true);
tmp.m_boxProxyShape->setCollideWithMaskBits(CATEGORY_2);
tmp.m_sphere1ProxyShape->setCollideWithMaskBits(CATEGORY_2);
tmp.m_sphere2ProxyShape->setCollideWithMaskBits(CATEGORY_3);
tmp.m_cylinderProxyShape->setCollideWithMaskBits(CATEGORY_1);
tmp.m_collisionCallback.reset();
tmp.m_world->testCollision(&tmp.m_collisionCallback);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithSphere1, false);
EXPECT_EQ(tmp.m_collisionCallback.boxCollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithCylinder, false);
EXPECT_EQ(tmp.m_collisionCallback.sphere1CollideWithSphere2, false);
// Move sphere 1 to collide with box
tmp.m_sphere1Body->setTransform(etk::Transform3D(vec3(10, 5, 0), etk::Quaternion::identity()));
tmp.m_boxProxyShape->setCollideWithMaskBits(0xFFFF);
tmp.m_sphere1ProxyShape->setCollideWithMaskBits(0xFFFF);
tmp.m_sphere2ProxyShape->setCollideWithMaskBits(0xFFFF);
tmp.m_cylinderProxyShape->setCollideWithMaskBits(0xFFFF);
}

View File

@ -0,0 +1,443 @@
/** @file
* @author Edouard DUPIN
* @copyright 2017, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <ephysics/ephysics.hpp>
#include <ephysics/collision/broadphase/DynamicAABBTree.hpp>
#include <etk/Vector.hpp>
class OverlapCallback : public ephysics::DynamicAABBTreeOverlapCallback {
public :
etk::Vector<int32_t> m_overlapNodes;
// Called when a overlapping node has been found during the call to
// DynamicAABBTree:reportAllShapesOverlappingWithAABB()
virtual void notifyOverlappingNode(int32_t nodeId) {
m_overlapNodes.pushBack(nodeId);
}
void reset() {
m_overlapNodes.clear();
}
bool isOverlapping(int32_t nodeId) const {
return etk::isIn(nodeId, m_overlapNodes);
}
};
class DynamicTreeRaycastCallback : public ephysics::DynamicAABBTreeRaycastCallback {
public:
etk::Vector<int32_t> m_hitNodes;
// Called when the AABB of a leaf node is hit by a ray
virtual float raycastBroadPhaseShape(int32_t nodeId, const ephysics::Ray& ray) {
m_hitNodes.pushBack(nodeId);
return 1.0;
}
void reset() {
m_hitNodes.clear();
}
bool isHit(int32_t nodeId) const {
return etk::isIn(nodeId, m_hitNodes);
}
};
TEST(TestAABBTree, create) {
// Dynamic AABB Tree
ephysics::DynamicAABBTree tree;
int32_t object1Data = 56;
int32_t object2Data = 23;
int32_t object3Data = 13;
int32_t object4Data = 7;
// First object
ephysics::AABB aabb1 = ephysics::AABB(vec3(-6, 4, -3), vec3(4, 8, 3));
int32_t object1Id = tree.addObject(aabb1, &object1Data);
// Second object
ephysics::AABB aabb2 = ephysics::AABB(vec3(5, 2, -3), vec3(10, 7, 3));
int32_t object2Id = tree.addObject(aabb2, &object2Data);
// Third object
ephysics::AABB aabb3 = ephysics::AABB(vec3(-5, 1, -3), vec3(-2, 3, 3));
int32_t object3Id = tree.addObject(aabb3, &object3Data);
// Fourth object
ephysics::AABB aabb4 = ephysics::AABB(vec3(0, -4, -3), vec3(3, -2, 3));
int32_t object4Id = tree.addObject(aabb4, &object4Data);
// ----------- Tests ----------- //
// Test root AABB
ephysics::AABB rootAABB = tree.getRootAABB();
EXPECT_EQ(rootAABB.getMin().x(), -6);
EXPECT_EQ(rootAABB.getMin().y(), -4);
EXPECT_EQ(rootAABB.getMin().z(), -3);
EXPECT_EQ(rootAABB.getMax().x(), 10);
EXPECT_EQ(rootAABB.getMax().y(), 8);
EXPECT_EQ(rootAABB.getMax().z(), 3);
// Test data stored at the nodes of the tree
EXPECT_EQ(*(int32_t*)(tree.getNodeDataPointer(object1Id)), object1Data);
EXPECT_EQ(*(int32_t*)(tree.getNodeDataPointer(object2Id)), object2Data);
EXPECT_EQ(*(int32_t*)(tree.getNodeDataPointer(object3Id)), object3Data);
EXPECT_EQ(*(int32_t*)(tree.getNodeDataPointer(object4Id)), object4Data);
}
TEST(TestAABBTree, overlapping) {
OverlapCallback overlapCallback;
// Dynamic AABB Tree
ephysics::DynamicAABBTree tree;
int32_t object1Data = 56;
int32_t object2Data = 23;
int32_t object3Data = 13;
int32_t object4Data = 7;
// First object
ephysics::AABB aabb1 = ephysics::AABB(vec3(-6, 4, -3), vec3(4, 8, 3));
int32_t object1Id = tree.addObject(aabb1, &object1Data);
// Second object
ephysics::AABB aabb2 = ephysics::AABB(vec3(5, 2, -3), vec3(10, 7, 3));
int32_t object2Id = tree.addObject(aabb2, &object2Data);
// Third object
ephysics::AABB aabb3 = ephysics::AABB(vec3(-5, 1, -3), vec3(-2, 3, 3));
int32_t object3Id = tree.addObject(aabb3, &object3Data);
// Fourth object
ephysics::AABB aabb4 = ephysics::AABB(vec3(0, -4, -3), vec3(3, -2, 3));
int32_t object4Id = tree.addObject(aabb4, &object4Data);
// ---------- Tests ---------- //
// AABB overlapping nothing
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-10, 12, -4), vec3(10, 50, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping everything
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-15, -15, -4), vec3(15, 15, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), true);
// AABB overlapping object 1 and 3
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-4, 2, -4), vec3(-1, 7, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping object 3 and 4
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-6, -5, -2), vec3(2, 2, 0)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), true);
// AABB overlapping object 2
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(5, -10, -2), vec3(7, 10, 9)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// ---- Update the object AABBs with the initial AABBs (no reinsertion) ----- //
tree.updateObject(object1Id, aabb1, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object2Id, aabb2, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object3Id, aabb3, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object4Id, aabb4, vec3(0.0f,0.0f,0.0f));
// AABB overlapping nothing
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-10, 12, -4), vec3(10, 50, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping everything
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-15, -15, -4), vec3(15, 15, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), true);
// AABB overlapping object 1 and 3
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-4, 2, -4), vec3(-1, 7, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping object 3 and 4
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-6, -5, -2), vec3(2, 2, 0)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), true);
// AABB overlapping object 2
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(5, -10, -2), vec3(7, 10, 9)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// ---- Update the object AABBs with the initial AABBs (with reinsertion) ----- //
tree.updateObject(object1Id, aabb1, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object2Id, aabb2, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object3Id, aabb3, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object4Id, aabb4, vec3(0.0f,0.0f,0.0f));
// AABB overlapping nothing
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-10, 12, -4), vec3(10, 50, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping everything
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-15, -15, -4), vec3(15, 15, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), true);
// AABB overlapping object 1 and 3
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-4, 2, -4), vec3(-1, 7, 4)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping object 3 and 4
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-6, -5, -2), vec3(2, 2, 0)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), true);
// AABB overlapping object 2
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(5, -10, -2), vec3(7, 10, 9)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// ---- Move objects 2 and 3 ----- //
ephysics::AABB newAABB2(vec3(-7, 10, -3), vec3(1, 13, 3));
tree.updateObject(object2Id, newAABB2, vec3(0.0f,0.0f,0.0f));
ephysics::AABB newAABB3(vec3(7, -6, -3), vec3(9, 1, 3));
tree.updateObject(object3Id, newAABB3, vec3(0.0f,0.0f,0.0f));
// AABB overlapping object 3
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(6, -10, -2), vec3(8, 5, 3)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
// AABB overlapping objects 1, 2
overlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(ephysics::AABB(vec3(-8, 5, -3), vec3(-2, 11, 3)), overlapCallback);
EXPECT_EQ(overlapCallback.isOverlapping(object1Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object2Id), true);
EXPECT_EQ(overlapCallback.isOverlapping(object3Id), false);
EXPECT_EQ(overlapCallback.isOverlapping(object4Id), false);
}
TEST(TestAABBTree, raycast) {
DynamicTreeRaycastCallback raycastCallback;
ephysics::DynamicAABBTree tree;
int32_t object1Data = 56;
int32_t object2Data = 23;
int32_t object3Data = 13;
int32_t object4Data = 7;
// First object
ephysics::AABB aabb1 = ephysics::AABB(vec3(-6, 4, -3), vec3(4, 8, 3));
int32_t object1Id = tree.addObject(aabb1, &object1Data);
// Second object
ephysics::AABB aabb2 = ephysics::AABB(vec3(5, 2, -3), vec3(10, 7, 3));
int32_t object2Id = tree.addObject(aabb2, &object2Data);
// Third object
ephysics::AABB aabb3 = ephysics::AABB(vec3(-5, 1, -3), vec3(-2, 3, 3));
int32_t object3Id = tree.addObject(aabb3, &object3Data);
// Fourth object
ephysics::AABB aabb4 = ephysics::AABB(vec3(0, -4, -3), vec3(3, -2, 3));
int32_t object4Id = tree.addObject(aabb4, &object4Data);
// ---------- Tests ---------- //
// Ray with no hits
raycastCallback.reset();
ephysics::Ray ray1(vec3(4.5, -10, -5), vec3(4.5, 10, -5));
tree.raycast(ray1, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 1
raycastCallback.reset();
ephysics::Ray ray2(vec3(-1, -20, -2), vec3(-1, 20, -2));
tree.raycast(ray2, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 1 and 2
raycastCallback.reset();
ephysics::Ray ray3(vec3(-7, 6, -2), vec3(8, 6, -2));
tree.raycast(ray3, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), true);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 3
raycastCallback.reset();
ephysics::Ray ray4(vec3(-7, 2, 0), vec3(-1, 2, 0));
tree.raycast(ray4, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), true);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// ---- Update the object AABBs with the initial AABBs (no reinsertion) ----- //
tree.updateObject(object1Id, aabb1, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object2Id, aabb2, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object3Id, aabb3, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object4Id, aabb4, vec3(0.0f,0.0f,0.0f));
// Ray with no hits
raycastCallback.reset();
tree.raycast(ray1, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 1
raycastCallback.reset();
tree.raycast(ray2, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 1 and 2
raycastCallback.reset();
tree.raycast(ray3, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), true);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 3
raycastCallback.reset();
tree.raycast(ray4, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), true);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// ---- Update the object AABBs with the initial AABBs (with reinsertion) ----- //
tree.updateObject(object1Id, aabb1, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object2Id, aabb2, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object3Id, aabb3, vec3(0.0f,0.0f,0.0f));
tree.updateObject(object4Id, aabb4, vec3(0.0f,0.0f,0.0f));
// Ray with no hits
raycastCallback.reset();
tree.raycast(ray1, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 1
raycastCallback.reset();
tree.raycast(ray2, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 1 and 2
raycastCallback.reset();
tree.raycast(ray3, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), true);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 3
raycastCallback.reset();
tree.raycast(ray4, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), true);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// ---- Move objects 2 and 3 ----- //
ephysics::AABB newAABB2(vec3(-7, 10, -3), vec3(1, 13, 3));
tree.updateObject(object2Id, newAABB2, vec3(0.0f,0.0f,0.0f));
ephysics::AABB newAABB3(vec3(7, -6, -3), vec3(9, 1, 3));
tree.updateObject(object3Id, newAABB3, vec3(0.0f,0.0f,0.0f));
// Ray that hits object 1, 2
ephysics::Ray ray5(vec3(-4, -5, 0), vec3(-4, 12, 0));
raycastCallback.reset();
tree.raycast(ray5, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), true);
EXPECT_EQ(raycastCallback.isHit(object2Id), true);
EXPECT_EQ(raycastCallback.isHit(object3Id), false);
EXPECT_EQ(raycastCallback.isHit(object4Id), false);
// Ray that hits object 3 and 4
ephysics::Ray ray6(vec3(11, -3, 1), vec3(-2, -3, 1));
raycastCallback.reset();
tree.raycast(ray6, raycastCallback);
EXPECT_EQ(raycastCallback.isHit(object1Id), false);
EXPECT_EQ(raycastCallback.isHit(object2Id), false);
EXPECT_EQ(raycastCallback.isHit(object3Id), true);
EXPECT_EQ(raycastCallback.isHit(object4Id), true);
}

680
test/testPointInside.cpp Normal file
View File

@ -0,0 +1,680 @@
/** @file
* @author Edouard DUPIN
* @copyright 2017, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etest/etest.hpp>
#include <ephysics/ephysics.hpp>
#include <ephysics/collision/shapes/BoxShape.hpp>
#include <ephysics/collision/shapes/SphereShape.hpp>
#include <ephysics/collision/shapes/CapsuleShape.hpp>
#include <ephysics/collision/shapes/ConeShape.hpp>
#include <ephysics/collision/shapes/ConvexMeshShape.hpp>
#include <ephysics/collision/shapes/CylinderShape.hpp>
class TestPointInside {
public:
// Physics world
ephysics::CollisionWorld* m_world;
// Bodies
ephysics::CollisionBody* m_boxBody;
ephysics::CollisionBody* m_sphereBody;
ephysics::CollisionBody* m_capsuleBody;
ephysics::CollisionBody* m_coneBody;
ephysics::CollisionBody* m_convexMeshBody;
ephysics::CollisionBody* m_convexMeshBodyEdgesInfo;
ephysics::CollisionBody* m_cylinderBody;
ephysics::CollisionBody* m_compoundBody;
// Collision shapes
ephysics::BoxShape* m_boxShape;
ephysics::SphereShape* m_sphereShape;
ephysics::CapsuleShape* m_capsuleShape;
ephysics::ConeShape* m_coneShape;
ephysics::ConvexMeshShape* m_convexMeshShape;
ephysics::ConvexMeshShape* m_convexMeshShapeBodyEdgesInfo;
ephysics::CylinderShape* m_cylinderShape;
// etk::Transform3D
etk::Transform3D m_bodyTransform;
etk::Transform3D m_shapeTransform;
etk::Transform3D m_localShapeToWorld;
etk::Transform3D m_localShape2ToWorld;
// Proxy Shapes
ephysics::ProxyShape* m_boxProxyShape;
ephysics::ProxyShape* m_sphereProxyShape;
ephysics::ProxyShape* m_capsuleProxyShape;
ephysics::ProxyShape* m_coneProxyShape;
ephysics::ProxyShape* m_convexMeshProxyShape;
ephysics::ProxyShape* m_convexMeshProxyShapeEdgesInfo;
ephysics::ProxyShape* m_cylinderProxyShape;
public :
TestPointInside() {
// Create the world
m_world = new ephysics::CollisionWorld();
// Body transform
vec3 position(-3, 2, 7);
etk::Quaternion orientation(M_PI / 5, M_PI / 6, M_PI / 7, 1);
m_bodyTransform = etk::Transform3D(position, orientation);
// Create the bodies
m_boxBody = m_world->createCollisionBody(m_bodyTransform);
m_sphereBody = m_world->createCollisionBody(m_bodyTransform);
m_capsuleBody = m_world->createCollisionBody(m_bodyTransform);
m_coneBody = m_world->createCollisionBody(m_bodyTransform);
m_convexMeshBody = m_world->createCollisionBody(m_bodyTransform);
m_convexMeshBodyEdgesInfo = m_world->createCollisionBody(m_bodyTransform);
m_cylinderBody = m_world->createCollisionBody(m_bodyTransform);
m_compoundBody = m_world->createCollisionBody(m_bodyTransform);
// Collision shape transform
vec3 shapePosition(1, -4, -3);
etk::Quaternion shapeOrientation(3 * M_PI / 6 , -M_PI / 8, M_PI / 3, 1);
m_shapeTransform = etk::Transform3D(shapePosition, shapeOrientation);
// Compute the the transform from a local shape point to world-space
m_localShapeToWorld = m_bodyTransform * m_shapeTransform;
// Create collision shapes
m_boxShape = new ephysics::BoxShape(vec3(2, 3, 4), 0);
m_boxProxyShape = m_boxBody->addCollisionShape(m_boxShape, m_shapeTransform);
m_sphereShape = new ephysics::SphereShape(3);
m_sphereProxyShape = m_sphereBody->addCollisionShape(m_sphereShape, m_shapeTransform);
m_capsuleShape = new ephysics::CapsuleShape(2, 10);
m_capsuleProxyShape = m_capsuleBody->addCollisionShape(m_capsuleShape, m_shapeTransform);
m_coneShape = new ephysics::ConeShape(2, 6, 0);
m_coneProxyShape = m_coneBody->addCollisionShape(m_coneShape, m_shapeTransform);
m_convexMeshShape = new ephysics::ConvexMeshShape(0.0); // Box of dimension (2, 3, 4)
m_convexMeshShape->addVertex(vec3(-2, -3, -4));
m_convexMeshShape->addVertex(vec3(2, -3, -4));
m_convexMeshShape->addVertex(vec3(2, -3, 4));
m_convexMeshShape->addVertex(vec3(-2, -3, 4));
m_convexMeshShape->addVertex(vec3(-2, 3, -4));
m_convexMeshShape->addVertex(vec3(2, 3, -4));
m_convexMeshShape->addVertex(vec3(2, 3, 4));
m_convexMeshShape->addVertex(vec3(-2, 3, 4));
m_convexMeshProxyShape = m_convexMeshBody->addCollisionShape(m_convexMeshShape, m_shapeTransform);
m_convexMeshShapeBodyEdgesInfo = new ephysics::ConvexMeshShape(0.0);
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(-2, -3, -4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(2, -3, -4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(2, -3, 4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(-2, -3, 4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(-2, 3, -4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(2, 3, -4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(2, 3, 4));
m_convexMeshShapeBodyEdgesInfo->addVertex(vec3(-2, 3, 4));
m_convexMeshShapeBodyEdgesInfo->addEdge(0, 1);
m_convexMeshShapeBodyEdgesInfo->addEdge(1, 2);
m_convexMeshShapeBodyEdgesInfo->addEdge(2, 3);
m_convexMeshShapeBodyEdgesInfo->addEdge(0, 3);
m_convexMeshShapeBodyEdgesInfo->addEdge(4, 5);
m_convexMeshShapeBodyEdgesInfo->addEdge(5, 6);
m_convexMeshShapeBodyEdgesInfo->addEdge(6, 7);
m_convexMeshShapeBodyEdgesInfo->addEdge(4, 7);
m_convexMeshShapeBodyEdgesInfo->addEdge(0, 4);
m_convexMeshShapeBodyEdgesInfo->addEdge(1, 5);
m_convexMeshShapeBodyEdgesInfo->addEdge(2, 6);
m_convexMeshShapeBodyEdgesInfo->addEdge(3, 7);
m_convexMeshShapeBodyEdgesInfo->setIsEdgesInformationUsed(true);
m_convexMeshProxyShapeEdgesInfo = m_convexMeshBodyEdgesInfo->addCollisionShape(
m_convexMeshShapeBodyEdgesInfo,
m_shapeTransform);
m_cylinderShape = new ephysics::CylinderShape(3, 8, 0);
m_cylinderProxyShape = m_cylinderBody->addCollisionShape(m_cylinderShape, m_shapeTransform);
// Compound shape is a cylinder and a sphere
vec3 positionShape2(vec3(4, 2, -3));
etk::Quaternion orientationShape2(-3 *M_PI / 8, 1.5 * M_PI/ 3, M_PI / 13, 1.0f);
etk::Transform3D shapeTransform2(positionShape2, orientationShape2);
m_localShape2ToWorld = m_bodyTransform * shapeTransform2;
m_compoundBody->addCollisionShape(m_cylinderShape, m_shapeTransform);
m_compoundBody->addCollisionShape(m_sphereShape, shapeTransform2);
}
/// Destructor
~TestPointInside() {
delete m_boxShape;
delete m_sphereShape;
delete m_capsuleShape;
delete m_coneShape;
delete m_convexMeshShape;
delete m_convexMeshShapeBodyEdgesInfo;
delete m_cylinderShape;
}
};
TEST(TestPointInside, box) {
TestPointInside tmp;
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.9)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.9)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -2.9, -3.9)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 2.9, 3.9)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -2.5)));
EXPECT_EQ(true, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 3.5)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -4.1)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 4.1)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -3.1, -4.1)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 3.1, 4.1)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-10, -2, -1.5)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 4, -2.5)));
EXPECT_EQ(false, tmp.m_boxBody->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 4.5)));
// Tests with ProxyBoxShape
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.9)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.9)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -2.9, -3.9)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 2.9, 3.9)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -2.5)));
EXPECT_EQ(true, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 3.5)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -4.1)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 4.1)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -3.1, -4.1)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 3.1, 4.1)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-10, -2, -1.5)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 4, -2.5)));
EXPECT_EQ(false, tmp.m_boxProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 4.5)));
}
TEST(TestPointInside, sphere) {
TestPointInside tmp;
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -1.5)));
EXPECT_EQ(true, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 1.5)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.1)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.1)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2, -2, -2)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2, 2, -1.5)));
EXPECT_EQ(false, tmp.m_sphereBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -2, 2.5)));
// Tests with ProxySphereShape
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -1.5)));
EXPECT_EQ(true, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 1.5)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.1)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.1)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2, -2, -2)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2, 2, -1.5)));
EXPECT_EQ(false, tmp.m_sphereProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -2, 2.5)));
}
TEST(TestPointInside, capsule) {
TestPointInside tmp;
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -6.9, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 6.9, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 1.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -1.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 0, 0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 0, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, 1.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, -1.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 5, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 5, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 5, 0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 5, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, 1.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, -1.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, -5, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -5, 0)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, -5, 0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, -5, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -4, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, 0.4)));
EXPECT_EQ(true, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.3, 1, 1.5)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -7.1, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 7.1, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.1)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -2.1)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, 2.1)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, -2.1)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 5, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 5, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, 5, 1.6)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, 5, -1.7)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, 2.1)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, -2.1)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, -5, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -5, 0)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -5, 1.6)));
EXPECT_EQ(false, tmp.m_capsuleBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -5, -1.7)));
// Tests with ProxyCapsuleShape
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -6.9, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 6.9, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 1.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -1.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 0, 0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 0, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, 1.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, -1.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 5, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 5, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 5, 0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 5, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, 1.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, -1.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, -5, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -5, 0)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, -5, 0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, -5, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -4, -0.9)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, 0.4)));
EXPECT_EQ(true, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.3, 1, 1.5)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -7.1, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 7.1, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.1)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -2.1)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, 2.1)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 5, -2.1)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 5, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 5, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, 5, 1.6)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, 5, -1.7)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, 2.1)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -5, -2.1)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, -5, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -5, 0)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -5, 1.6)));
EXPECT_EQ(false, tmp.m_capsuleProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -5, -1.7)));
}
TEST(TestPointInside, Cone) {
TestPointInside tmp;
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 0, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-0.9, 0, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0.9)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -0.9)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.6, 0, -0.7)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.6, 0, 0.7)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-0.6, 0, -0.7)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-0.6, 0, 0.7)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.96, -2.9, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.96, -2.9, 0)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 1.96)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, -1.96)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.3, -2.9, -1.4)));
EXPECT_EQ(true, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.3, -2.9, 1.4)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.1, 0, 0)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.1, 0, 0)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 1.1)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -1.1)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.8, 0, -0.8)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0.8, 0, 0.8)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-0.8, 0, -0.8)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-0.8, 0, 0.8)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.97, -2.9, 0)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.97, -2.9, 0)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 1.97)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, -1.97)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -2.9, -1.5)));
EXPECT_EQ(false, tmp.m_coneBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.5, -2.9, 1.5)));
// Tests with ProxyConeShape
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.9, 0, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-0.9, 0, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0.9)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -0.9)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.6, 0, -0.7)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.6, 0, 0.7)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-0.6, 0, -0.7)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-0.6, 0, 0.7)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.96, -2.9, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.96, -2.9, 0)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 1.96)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, -1.96)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.3, -2.9, -1.4)));
EXPECT_EQ(true, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.3, -2.9, 1.4)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.1, 0, 0)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.1, 0, 0)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 1.1)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -1.1)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.8, 0, -0.8)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0.8, 0, 0.8)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-0.8, 0, -0.8)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-0.8, 0, 0.8)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.97, -2.9, 0)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.97, -2.9, 0)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 1.97)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, -1.97)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.5, -2.9, -1.5)));
EXPECT_EQ(false, tmp.m_coneProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.5, -2.9, 1.5)));
}
TEST(TestPointInside, convecMesh) {
TestPointInside tmp;
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -2.9, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 2.9, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -2.5)));
EXPECT_EQ(true, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 3.5)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -3.1, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 3.1, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-10, -2, -1.5)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 4, -2.5)));
EXPECT_EQ(false, tmp.m_convexMeshBody->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 4.5)));
// Tests with ProxyConvexMeshShape
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -2.9, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 2.9, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -2.5)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 3.5)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -3.1, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 3.1, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-10, -2, -1.5)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 4, -2.5)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 4.5)));
// ----- Tests using edges information ----- //
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -2.9, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 2.9, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -2.5)));
EXPECT_EQ(true, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 3.5)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -3.1, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 3.1, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-10, -2, -1.5)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 4, -2.5)));
EXPECT_EQ(false, tmp.m_convexMeshBodyEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 4.5)));
// Tests with ProxyConvexMeshShape
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 0, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1.9, -2.9, -3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1.9, 2.9, 3.9)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 2, -2.5)));
EXPECT_EQ(true, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 3.5)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 0, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.1, 0)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-2.1, -3.1, -4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(2.1, 3.1, 4.1)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-10, -2, -1.5)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(-1, 4, -2.5)));
EXPECT_EQ(false, tmp.m_convexMeshProxyShapeEdgesInfo->testPointInside(tmp.m_localShapeToWorld * vec3(1, -2, 4.5)));
}
TEST(TestPointInside, cylinder) {
TestPointInside tmp;
// Tests with CollisionBody
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -2.9)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 0, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 0, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 0, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 0, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 2.9)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, -2.9)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 3.9, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 3.9, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, -3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, -3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 2.9)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, -2.9)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, -3.9, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, -3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -3.9, 1.7)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 4.1, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -4.1, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.1)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.1)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 0, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 0, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, 0, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.3, 0, 2.8)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, 3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, 3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 3.1)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, -3.1)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 3.9, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, 3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, 3.9, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, -3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, -3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 3.1)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, -3.1)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, -3.9, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, -3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, -3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, -3.9, 2.2)));
// Tests with ProxyCylinderShape
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -2.9)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 0, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 0, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 0, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 0, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 2.9)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, -2.9)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 3.9, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 3.9, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, -3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, -3.9, 0)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 2.9)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, -2.9)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, -3.9, 1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, -3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -3.9, -1.7)));
EXPECT_EQ(true, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -3.9, 1.7)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 4.1, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -4.1, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, 0, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 3.1)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -3.1)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 0, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 0, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, 0, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-1.3, 0, 2.8)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, 3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, 3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 3.1)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, -3.1)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 3.9, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, 3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, 3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, 3.9, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(3.1, -3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-3.1, -3.9, 0)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 3.1)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, -3.1)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, -3.9, 2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(2.2, -3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, -3.9, -2.2)));
EXPECT_EQ(false, tmp.m_cylinderProxyShape->testPointInside(tmp.m_localShapeToWorld * vec3(-2.2, -3.9, 2.2)));
}
TEST(TestPointInside, compound) {
TestPointInside tmp;
// Points on the cylinder
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 0, -2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 0, 1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 0, -1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 0, -1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 0, 1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, 3.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, 3.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, 2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, 3.9, -2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 3.9, 1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, 3.9, -1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 3.9, -1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, 3.9, 1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(2.9, -3.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-2.9, -3.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, 2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(0, -3.9, -2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, -3.9, 1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(1.7, -3.9, -1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -3.9, -1.7)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShapeToWorld * vec3(-1.7, -3.9, 1.7)));
// Points on the sphere
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(0, 0, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(-2.9, 0, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(0, 2.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(0, -2.9, 0)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(0, 0, 2.9)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(-1, -2, -1.5)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(-1, 2, -1.5)));
EXPECT_EQ(true, tmp.m_compoundBody->testPointInside(tmp.m_localShape2ToWorld * vec3(1, -2, 1.5)));
}

2517
test/testRaycast.cpp Normal file

File diff suppressed because it is too large Load Diff

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.1.0-dev