Fix compilation issue of the unit tests

This commit is contained in:
Daniel Chappuis 2018-08-05 16:10:13 +02:00
parent 445a36ef31
commit f3be538499
18 changed files with 2684 additions and 2683 deletions

View File

@ -35,8 +35,8 @@
namespace reactphysics3d {
// Macros
#define test(condition) applyTest(condition, #condition, __FILE__, __LINE__);
#define fail(text) applyFail(text, __FILE__, __LINE__);
#define rp3d_test(condition) applyTest(condition, #condition, __FILE__, __LINE__);
#define rp3d_fail(text) applyFail(text, __FILE__, __LINE__);
// Class Test
/**

View File

@ -93,60 +93,60 @@ class TestAABB : public Test {
};
AABB aabb3 = AABB::createAABBForTriangle(trianglePoints);
test(aabb1.getMin().x == 0);
test(aabb1.getMin().y == 0);
test(aabb1.getMin().z == 0);
test(aabb1.getMax().x == 0);
test(aabb1.getMax().y == 0);
test(aabb1.getMax().z == 0);
rp3d_test(aabb1.getMin().x == 0);
rp3d_test(aabb1.getMin().y == 0);
rp3d_test(aabb1.getMin().z == 0);
rp3d_test(aabb1.getMax().x == 0);
rp3d_test(aabb1.getMax().y == 0);
rp3d_test(aabb1.getMax().z == 0);
test(aabb2.getMin().x == -3);
test(aabb2.getMin().y == -5);
test(aabb2.getMin().z == -8);
test(aabb2.getMax().x == 65);
test(aabb2.getMax().y == -1);
test(aabb2.getMax().z == 56);
rp3d_test(aabb2.getMin().x == -3);
rp3d_test(aabb2.getMin().y == -5);
rp3d_test(aabb2.getMin().z == -8);
rp3d_test(aabb2.getMax().x == 65);
rp3d_test(aabb2.getMax().y == -1);
rp3d_test(aabb2.getMax().z == 56);
test(aabb3.getMin().x == -12);
test(aabb3.getMin().y == -34);
test(aabb3.getMin().z == -73);
test(aabb3.getMax().x == 45);
test(aabb3.getMax().y == 98);
test(aabb3.getMax().z == 76);
rp3d_test(aabb3.getMin().x == -12);
rp3d_test(aabb3.getMin().y == -34);
rp3d_test(aabb3.getMin().z == -73);
rp3d_test(aabb3.getMax().x == 45);
rp3d_test(aabb3.getMax().y == 98);
rp3d_test(aabb3.getMax().z == 76);
// -------- Test inflate() -------- //
AABB aabbInflate(Vector3(-3, 4, 8), Vector3(-1, 6, 32));
aabbInflate.inflate(1, 2, 3);
test(approxEqual(aabbInflate.getMin().x, -4, 0.00001));
test(approxEqual(aabbInflate.getMin().y, 2, 0.00001));
test(approxEqual(aabbInflate.getMin().z, 5, 0.00001));
test(approxEqual(aabbInflate.getMax().x, 0, 0.00001));
test(approxEqual(aabbInflate.getMax().y, 8, 0.00001));
test(approxEqual(aabbInflate.getMax().z, 35, 0.00001));
rp3d_test(approxEqual(aabbInflate.getMin().x, -4, 0.00001));
rp3d_test(approxEqual(aabbInflate.getMin().y, 2, 0.00001));
rp3d_test(approxEqual(aabbInflate.getMin().z, 5, 0.00001));
rp3d_test(approxEqual(aabbInflate.getMax().x, 0, 0.00001));
rp3d_test(approxEqual(aabbInflate.getMax().y, 8, 0.00001));
rp3d_test(approxEqual(aabbInflate.getMax().z, 35, 0.00001));
// -------- Test getExtent() --------- //
test(approxEqual(mAABB1.getExtent().x, 20));
test(approxEqual(mAABB1.getExtent().y, 20));
test(approxEqual(mAABB1.getExtent().z, 20));
rp3d_test(approxEqual(mAABB1.getExtent().x, 20));
rp3d_test(approxEqual(mAABB1.getExtent().y, 20));
rp3d_test(approxEqual(mAABB1.getExtent().z, 20));
test(approxEqual(mAABB2.getExtent().x, 3));
test(approxEqual(mAABB2.getExtent().y, 16));
test(approxEqual(mAABB2.getExtent().z, 60));
rp3d_test(approxEqual(mAABB2.getExtent().x, 3));
rp3d_test(approxEqual(mAABB2.getExtent().y, 16));
rp3d_test(approxEqual(mAABB2.getExtent().z, 60));
test(approxEqual(mAABB3.getExtent().x, 50));
test(approxEqual(mAABB3.getExtent().y, 50));
test(approxEqual(mAABB3.getExtent().z, 50));
rp3d_test(approxEqual(mAABB3.getExtent().x, 50));
rp3d_test(approxEqual(mAABB3.getExtent().y, 50));
rp3d_test(approxEqual(mAABB3.getExtent().z, 50));
// -------- Test getCenter() -------- //
test(mAABB1.getCenter().x == 0);
test(mAABB1.getCenter().y == 0);
test(mAABB1.getCenter().z == 0);
rp3d_test(mAABB1.getCenter().x == 0);
rp3d_test(mAABB1.getCenter().y == 0);
rp3d_test(mAABB1.getCenter().z == 0);
test(approxEqual(mAABB2.getCenter().x, -3.5));
test(approxEqual(mAABB2.getCenter().y, 12));
test(approxEqual(mAABB2.getCenter().z, 0));
rp3d_test(approxEqual(mAABB2.getCenter().x, -3.5));
rp3d_test(approxEqual(mAABB2.getCenter().y, 12));
rp3d_test(approxEqual(mAABB2.getCenter().z, 0));
// -------- Test setMin(), setMax(), getMin(), getMax() -------- //
@ -154,29 +154,29 @@ class TestAABB : public Test {
aabb5.setMin(Vector3(-12, 34, 6));
aabb5.setMax(Vector3(-3, 56, 20));
test(aabb5.getMin().x == -12);
test(aabb5.getMin().y == 34);
test(aabb5.getMin().z == 6);
test(aabb5.getMax().x == -3);
test(aabb5.getMax().y == 56);
test(aabb5.getMax().z == 20);
rp3d_test(aabb5.getMin().x == -12);
rp3d_test(aabb5.getMin().y == 34);
rp3d_test(aabb5.getMin().z == 6);
rp3d_test(aabb5.getMax().x == -3);
rp3d_test(aabb5.getMax().y == 56);
rp3d_test(aabb5.getMax().z == 20);
// -------- Test assignment operator -------- //
AABB aabb6;
aabb6 = aabb2;
test(aabb6.getMin().x == -3);
test(aabb6.getMin().y == -5);
test(aabb6.getMin().z == -8);
test(aabb6.getMax().x == 65);
test(aabb6.getMax().y == -1);
test(aabb6.getMax().z == 56);
rp3d_test(aabb6.getMin().x == -3);
rp3d_test(aabb6.getMin().y == -5);
rp3d_test(aabb6.getMin().z == -8);
rp3d_test(aabb6.getMax().x == 65);
rp3d_test(aabb6.getMax().y == -1);
rp3d_test(aabb6.getMax().z == 56);
// -------- Test getVolume() -------- //
test(approxEqual(mAABB1.getVolume(), 8000));
test(approxEqual(mAABB2.getVolume(), 2880));
rp3d_test(approxEqual(mAABB1.getVolume(), 8000));
rp3d_test(approxEqual(mAABB2.getVolume(), 2880));
}
void testMergeMethods() {
@ -189,70 +189,70 @@ class TestAABB : public Test {
AABB aabb3;
aabb3.mergeTwoAABBs(aabb1, mAABB1);
test(aabb3.getMin().x == -45);
test(aabb3.getMin().y == -10);
test(aabb3.getMin().z == -10);
test(aabb3.getMax().x == 23);
test(aabb3.getMax().y == 10);
test(aabb3.getMax().z == 10);
rp3d_test(aabb3.getMin().x == -45);
rp3d_test(aabb3.getMin().y == -10);
rp3d_test(aabb3.getMin().z == -10);
rp3d_test(aabb3.getMax().x == 23);
rp3d_test(aabb3.getMax().y == 10);
rp3d_test(aabb3.getMax().z == 10);
AABB aabb4;
aabb4.mergeTwoAABBs(aabb1, aabb2);
test(aabb4.getMin().x == -45);
test(aabb4.getMin().y == 6);
test(aabb4.getMin().z == -2);
test(aabb4.getMax().x == 23);
test(aabb4.getMax().y == 9);
test(aabb4.getMax().z == 45);
rp3d_test(aabb4.getMin().x == -45);
rp3d_test(aabb4.getMin().y == 6);
rp3d_test(aabb4.getMin().z == -2);
rp3d_test(aabb4.getMax().x == 23);
rp3d_test(aabb4.getMax().y == 9);
rp3d_test(aabb4.getMax().z == 45);
// -------- Test mergeWithAABB() -------- //
aabb1.mergeWithAABB(mAABB1);
test(aabb1.getMin().x == -45);
test(aabb1.getMin().y == -10);
test(aabb1.getMin().z == -10);
test(aabb1.getMax().x == 23);
test(aabb1.getMax().y == 10);
test(aabb1.getMax().z == 10);
rp3d_test(aabb1.getMin().x == -45);
rp3d_test(aabb1.getMin().y == -10);
rp3d_test(aabb1.getMin().z == -10);
rp3d_test(aabb1.getMax().x == 23);
rp3d_test(aabb1.getMax().y == 10);
rp3d_test(aabb1.getMax().z == 10);
aabb2.mergeWithAABB(mAABB1);
test(aabb2.getMin().x == -15);
test(aabb2.getMin().y == -10);
test(aabb2.getMin().z == -10);
test(aabb2.getMax().x == 10);
test(aabb2.getMax().y == 10);
test(aabb2.getMax().z == 45);
rp3d_test(aabb2.getMin().x == -15);
rp3d_test(aabb2.getMin().y == -10);
rp3d_test(aabb2.getMin().z == -10);
rp3d_test(aabb2.getMax().x == 10);
rp3d_test(aabb2.getMax().y == 10);
rp3d_test(aabb2.getMax().z == 45);
}
void testIntersection() {
// -------- Test contains(AABB) -------- //
test(!mAABB1.contains(mAABB2));
test(mAABB3.contains(mAABB1));
test(!mAABB1.contains(mAABB3));
test(!mAABB1.contains(mAABB4));
test(!mAABB4.contains(mAABB1));
rp3d_test(!mAABB1.contains(mAABB2));
rp3d_test(mAABB3.contains(mAABB1));
rp3d_test(!mAABB1.contains(mAABB3));
rp3d_test(!mAABB1.contains(mAABB4));
rp3d_test(!mAABB4.contains(mAABB1));
// -------- Test contains(Vector3) -------- //
test(mAABB1.contains(Vector3(0, 0, 0)));
test(mAABB1.contains(Vector3(-5, 6, 9)));
test(mAABB1.contains(Vector3(-9, -4, -9)));
test(mAABB1.contains(Vector3(9, 4, 7)));
test(!mAABB1.contains(Vector3(-11, -4, -9)));
test(!mAABB1.contains(Vector3(1, 12, -9)));
test(!mAABB1.contains(Vector3(1, 8, -13)));
test(!mAABB1.contains(Vector3(-14, 82, -13)));
rp3d_test(mAABB1.contains(Vector3(0, 0, 0)));
rp3d_test(mAABB1.contains(Vector3(-5, 6, 9)));
rp3d_test(mAABB1.contains(Vector3(-9, -4, -9)));
rp3d_test(mAABB1.contains(Vector3(9, 4, 7)));
rp3d_test(!mAABB1.contains(Vector3(-11, -4, -9)));
rp3d_test(!mAABB1.contains(Vector3(1, 12, -9)));
rp3d_test(!mAABB1.contains(Vector3(1, 8, -13)));
rp3d_test(!mAABB1.contains(Vector3(-14, 82, -13)));
// -------- Test testCollision() -------- //
test(mAABB1.testCollision(mAABB2));
test(mAABB2.testCollision(mAABB1));
test(mAABB1.testCollision(mAABB3));
test(mAABB3.testCollision(mAABB1));
test(!mAABB1.testCollision(mAABB4));
test(!mAABB4.testCollision(mAABB1));
rp3d_test(mAABB1.testCollision(mAABB2));
rp3d_test(mAABB2.testCollision(mAABB1));
rp3d_test(mAABB1.testCollision(mAABB3));
rp3d_test(mAABB3.testCollision(mAABB1));
rp3d_test(!mAABB1.testCollision(mAABB4));
rp3d_test(!mAABB4.testCollision(mAABB1));
// -------- Test testCollisionTriangleAABB() -------- //
@ -260,8 +260,8 @@ class TestAABB : public Test {
Vector3 trianglePoints[] = {
Vector3(-2, 4, 6), Vector3(20, -34, -73), Vector3(-12, 98, 76)
};
test(mAABB1.testCollisionTriangleAABB(trianglePoints));
test(!aabb.testCollisionTriangleAABB(trianglePoints));
rp3d_test(mAABB1.testCollisionTriangleAABB(trianglePoints));
rp3d_test(!aabb.testCollisionTriangleAABB(trianglePoints));
// -------- Test testRayIntersect() -------- //
@ -274,14 +274,14 @@ class TestAABB : public Test {
Ray ray7(Vector3(-4, 6, -100), Vector3(-4, 6, -11), 0.6);
Ray ray8(Vector3(-403, -432, -100), Vector3(134, 643, 23));
test(mAABB1.testRayIntersect(ray1));
test(!mAABB1.testRayIntersect(ray2));
test(mAABB1.testRayIntersect(ray3));
test(mAABB1.testRayIntersect(ray4));
test(mAABB1.testRayIntersect(ray5));
test(mAABB1.testRayIntersect(ray6));
test(!mAABB1.testRayIntersect(ray7));
test(!mAABB1.testRayIntersect(ray8));
rp3d_test(mAABB1.testRayIntersect(ray1));
rp3d_test(!mAABB1.testRayIntersect(ray2));
rp3d_test(mAABB1.testRayIntersect(ray3));
rp3d_test(mAABB1.testRayIntersect(ray4));
rp3d_test(mAABB1.testRayIntersect(ray5));
rp3d_test(mAABB1.testRayIntersect(ray6));
rp3d_test(!mAABB1.testRayIntersect(ray7));
rp3d_test(!mAABB1.testRayIntersect(ray8));
}
};

File diff suppressed because it is too large Load Diff

View File

@ -147,18 +147,18 @@ class TestDynamicAABBTree : public Test {
// Test root AABB
AABB rootAABB = tree.getRootAABB();
test(rootAABB.getMin().x == -6);
test(rootAABB.getMin().y == -4);
test(rootAABB.getMin().z == -3);
test(rootAABB.getMax().x == 10);
test(rootAABB.getMax().y == 8);
test(rootAABB.getMax().z == 3);
rp3d_test(rootAABB.getMin().x == -6);
rp3d_test(rootAABB.getMin().y == -4);
rp3d_test(rootAABB.getMin().z == -3);
rp3d_test(rootAABB.getMax().x == 10);
rp3d_test(rootAABB.getMax().y == 8);
rp3d_test(rootAABB.getMax().z == 3);
// Test data stored at the nodes of the tree
test(*(int*)(tree.getNodeDataPointer(object1Id)) == object1Data);
test(*(int*)(tree.getNodeDataPointer(object2Id)) == object2Data);
test(*(int*)(tree.getNodeDataPointer(object3Id)) == object3Data);
test(*(int*)(tree.getNodeDataPointer(object4Id)) == object4Data);
rp3d_test(*(int*)(tree.getNodeDataPointer(object1Id)) == object1Data);
rp3d_test(*(int*)(tree.getNodeDataPointer(object2Id)) == object2Data);
rp3d_test(*(int*)(tree.getNodeDataPointer(object3Id)) == object3Data);
rp3d_test(*(int*)(tree.getNodeDataPointer(object4Id)) == object4Data);
#ifdef IS_PROFILING_ACTIVE
delete profiler;
@ -204,42 +204,42 @@ class TestDynamicAABBTree : public Test {
// AABB overlapping nothing
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-10, 12, -4), Vector3(10, 50, 4)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping everything
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-15, -15, -4), Vector3(15, 15, 4)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 1 and 3
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-4, 2, -4), Vector3(-1, 7, 4)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 3 and 4
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-6, -5, -2), Vector3(2, 2, 0)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 2
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(5, -10, -2), Vector3(7, 10, 9)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// ---- Update the object AABBs with the initial AABBs (no reinsertion) ----- //
@ -251,42 +251,42 @@ class TestDynamicAABBTree : public Test {
// AABB overlapping nothing
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-10, 12, -4), Vector3(10, 50, 4)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping everything
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-15, -15, -4), Vector3(15, 15, 4)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 1 and 3
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-4, 2, -4), Vector3(-1, 7, 4)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 3 and 4
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-6, -5, -2), Vector3(2, 2, 0)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 2
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(5, -10, -2), Vector3(7, 10, 9)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// ---- Update the object AABBs with the initial AABBs (with reinsertion) ----- //
@ -298,42 +298,42 @@ class TestDynamicAABBTree : public Test {
// AABB overlapping nothing
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-10, 12, -4), Vector3(10, 50, 4)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping everything
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-15, -15, -4), Vector3(15, 15, 4)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 1 and 3
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-4, 2, -4), Vector3(-1, 7, 4)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 3 and 4
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-6, -5, -2), Vector3(2, 2, 0)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping object 2
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(5, -10, -2), Vector3(7, 10, 9)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// ---- Move objects 2 and 3 ----- //
@ -346,18 +346,18 @@ class TestDynamicAABBTree : public Test {
// AABB overlapping object 3
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(6, -10, -2), Vector3(8, 5, 3)), mOverlapCallback);
test(!mOverlapCallback.isOverlapping(object1Id));
test(!mOverlapCallback.isOverlapping(object2Id));
test(mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(!mOverlapCallback.isOverlapping(object1Id));
rp3d_test(!mOverlapCallback.isOverlapping(object2Id));
rp3d_test(mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
// AABB overlapping objects 1, 2
mOverlapCallback.reset();
tree.reportAllShapesOverlappingWithAABB(AABB(Vector3(-8, 5, -3), Vector3(-2, 11, 3)), mOverlapCallback);
test(mOverlapCallback.isOverlapping(object1Id));
test(mOverlapCallback.isOverlapping(object2Id));
test(!mOverlapCallback.isOverlapping(object3Id));
test(!mOverlapCallback.isOverlapping(object4Id));
rp3d_test(mOverlapCallback.isOverlapping(object1Id));
rp3d_test(mOverlapCallback.isOverlapping(object2Id));
rp3d_test(!mOverlapCallback.isOverlapping(object3Id));
rp3d_test(!mOverlapCallback.isOverlapping(object4Id));
#ifdef IS_PROFILING_ACTIVE
delete profiler;
@ -404,37 +404,37 @@ class TestDynamicAABBTree : public Test {
mRaycastCallback.reset();
Ray ray1(Vector3(4.5, -10, -5), Vector3(4.5, 10, -5));
tree.raycast(ray1, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 1
mRaycastCallback.reset();
Ray ray2(Vector3(-1, -20, -2), Vector3(-1, 20, -2));
tree.raycast(ray2, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 1 and 2
mRaycastCallback.reset();
Ray ray3(Vector3(-7, 6, -2), Vector3(8, 6, -2));
tree.raycast(ray3, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 3
mRaycastCallback.reset();
Ray ray4(Vector3(-7, 2, 0), Vector3(-1, 2, 0));
tree.raycast(ray4, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// ---- Update the object AABBs with the initial AABBs (no reinsertion) ----- //
@ -446,34 +446,34 @@ class TestDynamicAABBTree : public Test {
// Ray with no hits
mRaycastCallback.reset();
tree.raycast(ray1, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 1
mRaycastCallback.reset();
tree.raycast(ray2, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 1 and 2
mRaycastCallback.reset();
tree.raycast(ray3, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 3
mRaycastCallback.reset();
tree.raycast(ray4, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// ---- Update the object AABBs with the initial AABBs (with reinsertion) ----- //
@ -485,34 +485,34 @@ class TestDynamicAABBTree : public Test {
// Ray with no hits
mRaycastCallback.reset();
tree.raycast(ray1, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 1
mRaycastCallback.reset();
tree.raycast(ray2, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 1 and 2
mRaycastCallback.reset();
tree.raycast(ray3, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 3
mRaycastCallback.reset();
tree.raycast(ray4, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// ---- Move objects 2 and 3 ----- //
@ -526,19 +526,19 @@ class TestDynamicAABBTree : public Test {
Ray ray5(Vector3(-4, -5, 0), Vector3(-4, 12, 0));
mRaycastCallback.reset();
tree.raycast(ray5, mRaycastCallback);
test(mRaycastCallback.isHit(object1Id));
test(mRaycastCallback.isHit(object2Id));
test(!mRaycastCallback.isHit(object3Id));
test(!mRaycastCallback.isHit(object4Id));
rp3d_test(mRaycastCallback.isHit(object1Id));
rp3d_test(mRaycastCallback.isHit(object2Id));
rp3d_test(!mRaycastCallback.isHit(object3Id));
rp3d_test(!mRaycastCallback.isHit(object4Id));
// Ray that hits object 3 and 4
Ray ray6(Vector3(11, -3, 1), Vector3(-2, -3, 1));
mRaycastCallback.reset();
tree.raycast(ray6, mRaycastCallback);
test(!mRaycastCallback.isHit(object1Id));
test(!mRaycastCallback.isHit(object2Id));
test(mRaycastCallback.isHit(object3Id));
test(mRaycastCallback.isHit(object4Id));
rp3d_test(!mRaycastCallback.isHit(object1Id));
rp3d_test(!mRaycastCallback.isHit(object2Id));
rp3d_test(mRaycastCallback.isHit(object3Id));
rp3d_test(mRaycastCallback.isHit(object4Id));
#ifdef IS_PROFILING_ACTIVE
delete profiler;

View File

@ -4,6 +4,7 @@
// Libraries
#include "reactphysics3d.h"
#include "Test.h"
#include <vector>
/// Reactphysics3D namespace
namespace reactphysics3d {
@ -94,54 +95,54 @@ class TestHalfEdgeStructure : public Test {
// --- Test that the half-edge structure of the cube is valid --- //
test(cubeStructure.getNbFaces() == 6);
test(cubeStructure.getNbVertices() == 8);
test(cubeStructure.getNbHalfEdges() == 24);
rp3d_test(cubeStructure.getNbFaces() == 6);
rp3d_test(cubeStructure.getNbVertices() == 8);
rp3d_test(cubeStructure.getNbHalfEdges() == 24);
// Test vertices
test(vertices[cubeStructure.getVertex(0).vertexPointIndex].x == -0.5);
test(vertices[cubeStructure.getVertex(0).vertexPointIndex].y == -0.5);
test(vertices[cubeStructure.getVertex(0).vertexPointIndex].z == 0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(0).edgeIndex).vertexIndex == 0);
rp3d_test(vertices[cubeStructure.getVertex(0).vertexPointIndex].x == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(0).vertexPointIndex].y == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(0).vertexPointIndex].z == 0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(0).edgeIndex).vertexIndex == 0);
test(vertices[cubeStructure.getVertex(1).vertexPointIndex].x == 0.5);
test(vertices[cubeStructure.getVertex(1).vertexPointIndex].y == -0.5);
test(vertices[cubeStructure.getVertex(1).vertexPointIndex].z == 0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(1).edgeIndex).vertexIndex == 1);
rp3d_test(vertices[cubeStructure.getVertex(1).vertexPointIndex].x == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(1).vertexPointIndex].y == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(1).vertexPointIndex].z == 0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(1).edgeIndex).vertexIndex == 1);
test(vertices[cubeStructure.getVertex(2).vertexPointIndex].x == 0.5);
test(vertices[cubeStructure.getVertex(2).vertexPointIndex].y == 0.5);
test(vertices[cubeStructure.getVertex(2).vertexPointIndex].z == 0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(2).edgeIndex).vertexIndex == 2);
rp3d_test(vertices[cubeStructure.getVertex(2).vertexPointIndex].x == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(2).vertexPointIndex].y == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(2).vertexPointIndex].z == 0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(2).edgeIndex).vertexIndex == 2);
test(vertices[cubeStructure.getVertex(3).vertexPointIndex].x == -0.5);
test(vertices[cubeStructure.getVertex(3).vertexPointIndex].y == 0.5);
test(vertices[cubeStructure.getVertex(3).vertexPointIndex].z == 0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(3).edgeIndex).vertexIndex == 3);
rp3d_test(vertices[cubeStructure.getVertex(3).vertexPointIndex].x == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(3).vertexPointIndex].y == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(3).vertexPointIndex].z == 0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(3).edgeIndex).vertexIndex == 3);
test(vertices[cubeStructure.getVertex(4).vertexPointIndex].x == -0.5);
test(vertices[cubeStructure.getVertex(4).vertexPointIndex].y == -0.5);
test(vertices[cubeStructure.getVertex(4).vertexPointIndex].z == -0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(4).edgeIndex).vertexIndex == 4);
rp3d_test(vertices[cubeStructure.getVertex(4).vertexPointIndex].x == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(4).vertexPointIndex].y == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(4).vertexPointIndex].z == -0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(4).edgeIndex).vertexIndex == 4);
test(vertices[cubeStructure.getVertex(5).vertexPointIndex].x == 0.5);
test(vertices[cubeStructure.getVertex(5).vertexPointIndex].y == -0.5);
test(vertices[cubeStructure.getVertex(5).vertexPointIndex].z == -0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(5).edgeIndex).vertexIndex == 5);
rp3d_test(vertices[cubeStructure.getVertex(5).vertexPointIndex].x == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(5).vertexPointIndex].y == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(5).vertexPointIndex].z == -0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(5).edgeIndex).vertexIndex == 5);
test(vertices[cubeStructure.getVertex(6).vertexPointIndex].x == 0.5);
test(vertices[cubeStructure.getVertex(6).vertexPointIndex].y == 0.5);
test(vertices[cubeStructure.getVertex(6).vertexPointIndex].z == -0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(6).edgeIndex).vertexIndex == 6);
rp3d_test(vertices[cubeStructure.getVertex(6).vertexPointIndex].x == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(6).vertexPointIndex].y == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(6).vertexPointIndex].z == -0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(6).edgeIndex).vertexIndex == 6);
test(vertices[cubeStructure.getVertex(7).vertexPointIndex].x == -0.5);
test(vertices[cubeStructure.getVertex(7).vertexPointIndex].y == 0.5);
test(vertices[cubeStructure.getVertex(7).vertexPointIndex].z == -0.5);
test(cubeStructure.getHalfEdge(cubeStructure.getVertex(7).edgeIndex).vertexIndex == 7);
rp3d_test(vertices[cubeStructure.getVertex(7).vertexPointIndex].x == -0.5);
rp3d_test(vertices[cubeStructure.getVertex(7).vertexPointIndex].y == 0.5);
rp3d_test(vertices[cubeStructure.getVertex(7).vertexPointIndex].z == -0.5);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getVertex(7).edgeIndex).vertexIndex == 7);
// Test faces
for (uint f=0; f<6; f++) {
test(cubeStructure.getHalfEdge(cubeStructure.getFace(f).edgeIndex).faceIndex == f);
rp3d_test(cubeStructure.getHalfEdge(cubeStructure.getFace(f).edgeIndex).faceIndex == f);
}
// Test edges
@ -156,14 +157,14 @@ class TestHalfEdgeStructure : public Test {
rp3d::HalfEdgeStructure::Edge edge = cubeStructure.getHalfEdge(edgeIndex);
test(cubeStructure.getHalfEdge(edge.twinEdgeIndex).twinEdgeIndex == edgeIndex);
test(edge.faceIndex == f);
rp3d_test(cubeStructure.getHalfEdge(edge.twinEdgeIndex).twinEdgeIndex == edgeIndex);
rp3d_test(edge.faceIndex == f);
// Go to the next edge
edgeIndex = edge.nextEdgeIndex;
}
test(firstEdgeIndex == edgeIndex);
rp3d_test(firstEdgeIndex == edgeIndex);
}
}
@ -205,34 +206,34 @@ class TestHalfEdgeStructure : public Test {
// --- Test that the half-edge structure of the tetrahedron is valid --- //
test(tetrahedron.getNbFaces() == 4);
test(tetrahedron.getNbVertices() == 4);
test(tetrahedron.getNbHalfEdges() == 12);
rp3d_test(tetrahedron.getNbFaces() == 4);
rp3d_test(tetrahedron.getNbVertices() == 4);
rp3d_test(tetrahedron.getNbHalfEdges() == 12);
// Test vertices
test(vertices[tetrahedron.getVertex(0).vertexPointIndex].x == 1);
test(vertices[tetrahedron.getVertex(0).vertexPointIndex].y == -1);
test(vertices[tetrahedron.getVertex(0).vertexPointIndex].z == -1);
test(tetrahedron.getHalfEdge(tetrahedron.getVertex(0).edgeIndex).vertexIndex == 0);
rp3d_test(vertices[tetrahedron.getVertex(0).vertexPointIndex].x == 1);
rp3d_test(vertices[tetrahedron.getVertex(0).vertexPointIndex].y == -1);
rp3d_test(vertices[tetrahedron.getVertex(0).vertexPointIndex].z == -1);
rp3d_test(tetrahedron.getHalfEdge(tetrahedron.getVertex(0).edgeIndex).vertexIndex == 0);
test(vertices[tetrahedron.getVertex(1).vertexPointIndex].x == -1);
test(vertices[tetrahedron.getVertex(1).vertexPointIndex].y == -1);
test(vertices[tetrahedron.getVertex(1).vertexPointIndex].z == -1);
test(tetrahedron.getHalfEdge(tetrahedron.getVertex(1).edgeIndex).vertexIndex == 1);
rp3d_test(vertices[tetrahedron.getVertex(1).vertexPointIndex].x == -1);
rp3d_test(vertices[tetrahedron.getVertex(1).vertexPointIndex].y == -1);
rp3d_test(vertices[tetrahedron.getVertex(1).vertexPointIndex].z == -1);
rp3d_test(tetrahedron.getHalfEdge(tetrahedron.getVertex(1).edgeIndex).vertexIndex == 1);
test(vertices[tetrahedron.getVertex(2).vertexPointIndex].x == 0);
test(vertices[tetrahedron.getVertex(2).vertexPointIndex].y == -1);
test(vertices[tetrahedron.getVertex(2).vertexPointIndex].z == 1);
test(tetrahedron.getHalfEdge(tetrahedron.getVertex(2).edgeIndex).vertexIndex == 2);
rp3d_test(vertices[tetrahedron.getVertex(2).vertexPointIndex].x == 0);
rp3d_test(vertices[tetrahedron.getVertex(2).vertexPointIndex].y == -1);
rp3d_test(vertices[tetrahedron.getVertex(2).vertexPointIndex].z == 1);
rp3d_test(tetrahedron.getHalfEdge(tetrahedron.getVertex(2).edgeIndex).vertexIndex == 2);
test(vertices[tetrahedron.getVertex(3).vertexPointIndex].x == 0);
test(vertices[tetrahedron.getVertex(3).vertexPointIndex].y == 1);
test(vertices[tetrahedron.getVertex(3).vertexPointIndex].z == 0);
test(tetrahedron.getHalfEdge(tetrahedron.getVertex(3).edgeIndex).vertexIndex == 3);
rp3d_test(vertices[tetrahedron.getVertex(3).vertexPointIndex].x == 0);
rp3d_test(vertices[tetrahedron.getVertex(3).vertexPointIndex].y == 1);
rp3d_test(vertices[tetrahedron.getVertex(3).vertexPointIndex].z == 0);
rp3d_test(tetrahedron.getHalfEdge(tetrahedron.getVertex(3).edgeIndex).vertexIndex == 3);
// Test faces
for (uint f=0; f<4; f++) {
test(tetrahedron.getHalfEdge(tetrahedron.getFace(f).edgeIndex).faceIndex == f);
rp3d_test(tetrahedron.getHalfEdge(tetrahedron.getFace(f).edgeIndex).faceIndex == f);
}
// Test edges
@ -246,14 +247,14 @@ class TestHalfEdgeStructure : public Test {
rp3d::HalfEdgeStructure::Edge edge = tetrahedron.getHalfEdge(edgeIndex);
test(tetrahedron.getHalfEdge(edge.twinEdgeIndex).twinEdgeIndex == edgeIndex);
test(edge.faceIndex == f);
rp3d_test(tetrahedron.getHalfEdge(edge.twinEdgeIndex).twinEdgeIndex == edgeIndex);
rp3d_test(edge.faceIndex == f);
// Go to the next edge
edgeIndex = edge.nextEdgeIndex;
}
test(firstEdgeIndex == edgeIndex);
rp3d_test(firstEdgeIndex == edgeIndex);
}
}
};

View File

@ -196,56 +196,56 @@ class TestPointInside : public Test {
void testBox() {
// Tests with CollisionBody
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
rp3d_test(mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
rp3d_test(!mBoxBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
// Tests with ProxyBoxShape
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
rp3d_test(mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
rp3d_test(!mBoxProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
}
/// Test the ProxySphereShape::testPointInside() and
@ -253,48 +253,48 @@ class TestPointInside : public Test {
void testSphere() {
// Tests with CollisionBody
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, 0, 0)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 0, 0)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -1.5)));
test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 1.5)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, 0, 0)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 0, 0)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -1.5)));
rp3d_test(mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 1.5)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-2, -2, -2)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-2, 2, -1.5)));
test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(1.5, -2, 2.5)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-2, -2, -2)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(-2, 2, -1.5)));
rp3d_test(!mSphereBody->testPointInside(mLocalShapeToWorld * Vector3(1.5, -2, 2.5)));
// Tests with ProxySphereShape
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.9, 0, 0)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 0, 0)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -1.5)));
test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 1.5)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.9, 0, 0)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 0, 0)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -1.5)));
rp3d_test(mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 1.5)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2, -2, -2)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2, 2, -1.5)));
test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.5, -2, 2.5)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2, -2, -2)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2, 2, -1.5)));
rp3d_test(!mSphereProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.5, -2, 2.5)));
}
/// Test the ProxyCapsuleShape::testPointInside() and
@ -302,98 +302,98 @@ class TestPointInside : public Test {
void testCapsule() {
// Tests with CollisionBody
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -6.9, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 6.9, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 1.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -1.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, 0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, -0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 1.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -1.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 5, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 5, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, 0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, -0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 1.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -1.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, -5, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -5, 0)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, 0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, -0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -4, -0.9)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, 0.4)));
test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.3, 1, 1.5)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -6.9, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 6.9, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 1.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -1.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, 0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, -0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 1.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -1.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 5, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 5, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, 0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, -0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 1.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -1.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, -5, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -5, 0)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, 0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, -0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -4, -0.9)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, 0.4)));
rp3d_test(mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(1.3, 1, 1.5)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -13.1, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 13.1, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 3.1)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -3.1)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, 5, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 5, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, 2.6)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, -2.7)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 3.1)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -3.1)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, -5, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, -5, 0)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, 2.6)));
test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, -2.7)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -13.1, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 13.1, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 3.1)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -3.1)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, 5, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 5, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, 2.6)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, -2.7)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 3.1)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -3.1)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(3.1, -5, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(-3.1, -5, 0)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, 2.6)));
rp3d_test(!mCapsuleBody->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, -2.7)));
// Tests with ProxyCapsuleShape
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -6.9, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 6.9, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 1.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -1.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, 0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, -0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 1.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -1.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 5, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 5, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, 0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, -0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 1.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -1.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, -5, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -5, 0)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, 0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, -0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -4, -0.9)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, 0.4)));
test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.3, 1, 1.5)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -6.9, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 6.9, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 1.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -1.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, 0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 0, -0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 1.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -1.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 5, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 5, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, 0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, 5, -0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 1.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -1.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, -5, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -5, 0)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, 0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0.9, -5, -0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -4, -0.9)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, 0.4)));
rp3d_test(mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.3, 1, 1.5)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -13.1, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 13.1, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 3.1)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -3.1)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, 5, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 5, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, 2.6)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, -2.7)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 3.1)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -3.1)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, -5, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, -5, 0)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, 2.6)));
test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, -2.7)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -13.1, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 13.1, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.1)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.1)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, 0, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 0, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, 3.1)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 5, -3.1)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, 5, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, 5, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, 2.6)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, 5, -2.7)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, 3.1)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -5, -3.1)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(3.1, -5, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-3.1, -5, 0)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, 2.6)));
rp3d_test(!mCapsuleProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.5, -5, -2.7)));
}
/// Test the ProxyConvexMeshShape::testPointInside() and
@ -401,101 +401,101 @@ class TestPointInside : public Test {
void testConvexMesh() {
// Tests with CollisionBody
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
rp3d_test(mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
rp3d_test(!mConvexMeshBody->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
// Tests with ProxyConvexMeshShape
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, 0, 0)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 0, 0)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -3.9)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 3.9)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1.9, -2.9, -3.9)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1.9, 2.9, 3.9)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 2, -2.5)));
rp3d_test(mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 3.5)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, 0, 0)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 0, 0)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, -3.1, 0)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 3.1, 0)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -4.1)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 4.1)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-2.1, -3.1, -4.1)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(2.1, 3.1, 4.1)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-10, -2, -1.5)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(-1, 4, -2.5)));
rp3d_test(!mConvexMeshProxyShape->testPointInside(mLocalShapeToWorld * Vector3(1, -2, 4.5)));
}
/// Test the CollisionBody::testPointInside() method
void testCompound() {
// Points on the capsule
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.9, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.9, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, 0, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 0, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -2.9)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 0, 1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 0, -1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 0, -1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 0, 1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, 3.9, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 3.9, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.9, 2.9)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.9, -2.9)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 3.9, 1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 3.9, -1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 3.9, -1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 3.9, 1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, -3.9, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, -3.9, 0)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.9, 2.9)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.9, -2.9)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, -3.9, 1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, -3.9, -1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -3.9, -1.7)));
test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -3.9, 1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, 0, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 0, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 0, -2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 0, 1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 0, -1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 0, -1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 0, 1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, 3.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, 3.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.9, 2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, 3.9, -2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 3.9, 1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, 3.9, -1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 3.9, -1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, 3.9, 1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(2.9, -3.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-2.9, -3.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.9, 2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(0, -3.9, -2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, -3.9, 1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(1.7, -3.9, -1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -3.9, -1.7)));
rp3d_test(mCompoundBody->testPointInside(mLocalShapeToWorld * Vector3(-1.7, -3.9, 1.7)));
// Points on the sphere
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 0, 0)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(2.9, 0, 0)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(-2.9, 0, 0)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 2.9, 0)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, -2.9, 0)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 0, 2.9)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 0, 2.9)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(-1, -2, -1.5)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(-1, 2, -1.5)));
test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(1, -2, 1.5)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 0, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(2.9, 0, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(-2.9, 0, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 2.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, -2.9, 0)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(0, 0, 2.9)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(-1, -2, -1.5)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(-1, 2, -1.5)));
rp3d_test(mCompoundBody->testPointInside(mLocalShape2ToWorld * Vector3(1, -2, 1.5)));
}
};

File diff suppressed because it is too large Load Diff

View File

@ -139,47 +139,47 @@ class TestTriangleVertexArray : public Test {
// ----- First triangle vertex array ----- //
test(mTriangleVertexArray1->getVertexDataType() == TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE);
test(mTriangleVertexArray1->getIndexDataType() == TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
test(mTriangleVertexArray1->getVertexNormalDataType() == TriangleVertexArray::NormalDataType::NORMAL_FLOAT_TYPE);
test(mTriangleVertexArray1->getNbTriangles() == 2);
test(mTriangleVertexArray1->getNbVertices() == 4);
test(mTriangleVertexArray1->getIndicesStart() == static_cast<const void*>(mIndices1));
test(mTriangleVertexArray1->getVerticesStart() == static_cast<const void*>(mVertices1));
test(mTriangleVertexArray1->getIndicesStride() == (3 * sizeof(uint)));
test(mTriangleVertexArray1->getVerticesStride() == (3 * sizeof(float)));
rp3d_test(mTriangleVertexArray1->getVertexDataType() == TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE);
rp3d_test(mTriangleVertexArray1->getIndexDataType() == TriangleVertexArray::IndexDataType::INDEX_INTEGER_TYPE);
rp3d_test(mTriangleVertexArray1->getVertexNormalDataType() == TriangleVertexArray::NormalDataType::NORMAL_FLOAT_TYPE);
rp3d_test(mTriangleVertexArray1->getNbTriangles() == 2);
rp3d_test(mTriangleVertexArray1->getNbVertices() == 4);
rp3d_test(mTriangleVertexArray1->getIndicesStart() == static_cast<const void*>(mIndices1));
rp3d_test(mTriangleVertexArray1->getVerticesStart() == static_cast<const void*>(mVertices1));
rp3d_test(mTriangleVertexArray1->getIndicesStride() == (3 * sizeof(uint)));
rp3d_test(mTriangleVertexArray1->getVerticesStride() == (3 * sizeof(float)));
// Get triangle indices
uint triangle0Indices[3];
mTriangleVertexArray1->getTriangleVerticesIndices(0, triangle0Indices);
test(triangle0Indices[0] == mIndices1[0]);
test(triangle0Indices[1] == mIndices1[1]);
test(triangle0Indices[2] == mIndices1[2]);
rp3d_test(triangle0Indices[0] == mIndices1[0]);
rp3d_test(triangle0Indices[1] == mIndices1[1]);
rp3d_test(triangle0Indices[2] == mIndices1[2]);
uint triangle1Indices[3];
mTriangleVertexArray1->getTriangleVerticesIndices(1, triangle1Indices);
test(triangle1Indices[0] == mIndices1[3]);
test(triangle1Indices[1] == mIndices1[4]);
test(triangle1Indices[2] == mIndices1[5]);
rp3d_test(triangle1Indices[0] == mIndices1[3]);
rp3d_test(triangle1Indices[1] == mIndices1[4]);
rp3d_test(triangle1Indices[2] == mIndices1[5]);
// Get triangle vertices
Vector3 triangle0Vertices[3];
mTriangleVertexArray1->getTriangleVertices(0, triangle0Vertices);
test(approxEqual(triangle0Vertices[0], mVertex0, decimal(0.0000001)));
test(approxEqual(triangle0Vertices[1], mVertex1, decimal(0.0000001)));
test(approxEqual(triangle0Vertices[2], mVertex2, decimal(0.0000001)));
rp3d_test(approxEqual(triangle0Vertices[0], mVertex0, decimal(0.0000001)));
rp3d_test(approxEqual(triangle0Vertices[1], mVertex1, decimal(0.0000001)));
rp3d_test(approxEqual(triangle0Vertices[2], mVertex2, decimal(0.0000001)));
Vector3 triangle1Vertices[3];
mTriangleVertexArray1->getTriangleVertices(1, triangle1Vertices);
test(approxEqual(triangle1Vertices[0], mVertex0, decimal(0.0000001)));
test(approxEqual(triangle1Vertices[1], mVertex3, decimal(0.0000001)));
test(approxEqual(triangle1Vertices[2], mVertex1, decimal(0.0000001)));
rp3d_test(approxEqual(triangle1Vertices[0], mVertex0, decimal(0.0000001)));
rp3d_test(approxEqual(triangle1Vertices[1], mVertex3, decimal(0.0000001)));
rp3d_test(approxEqual(triangle1Vertices[2], mVertex1, decimal(0.0000001)));
// Get triangle normals
@ -193,64 +193,64 @@ class TestTriangleVertexArray : public Test {
const Vector3 normal2Test(0, 1, 0);
const Vector3 normal3Test(1, 0, 0);
test(approxEqual(triangle0Normals[0], normal0Test, decimal(0.0001)));
test(approxEqual(triangle0Normals[2], normal2Test, decimal(0.0001)));
test(approxEqual(triangle1Normals[1], normal3Test, decimal(0.0001)));
rp3d_test(approxEqual(triangle0Normals[0], normal0Test, decimal(0.0001)));
rp3d_test(approxEqual(triangle0Normals[2], normal2Test, decimal(0.0001)));
rp3d_test(approxEqual(triangle1Normals[1], normal3Test, decimal(0.0001)));
// ----- Second triangle vertex array ----- //
test(mTriangleVertexArray2->getVertexDataType() == TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE);
test(mTriangleVertexArray2->getIndexDataType() == TriangleVertexArray::IndexDataType::INDEX_SHORT_TYPE);
test(mTriangleVertexArray2->getVertexNormalDataType() == TriangleVertexArray::NormalDataType::NORMAL_FLOAT_TYPE);
test(mTriangleVertexArray2->getNbTriangles() == 2);
test(mTriangleVertexArray2->getNbVertices() == 4);
test(mTriangleVertexArray2->getIndicesStart() == static_cast<const void*>(mIndices2));
test(mTriangleVertexArray2->getVerticesStart() == static_cast<const void*>(mVertices2));
test(mTriangleVertexArray2->getVerticesNormalsStart() == static_cast<const void*>(mNormals2));
test(mTriangleVertexArray2->getIndicesStride() == (3 * sizeof(short)));
test(mTriangleVertexArray2->getVerticesStride() == (3 * sizeof(double)));
test(mTriangleVertexArray2->getVerticesNormalsStride() == (3 * sizeof(float)));
rp3d_test(mTriangleVertexArray2->getVertexDataType() == TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE);
rp3d_test(mTriangleVertexArray2->getIndexDataType() == TriangleVertexArray::IndexDataType::INDEX_SHORT_TYPE);
rp3d_test(mTriangleVertexArray2->getVertexNormalDataType() == TriangleVertexArray::NormalDataType::NORMAL_FLOAT_TYPE);
rp3d_test(mTriangleVertexArray2->getNbTriangles() == 2);
rp3d_test(mTriangleVertexArray2->getNbVertices() == 4);
rp3d_test(mTriangleVertexArray2->getIndicesStart() == static_cast<const void*>(mIndices2));
rp3d_test(mTriangleVertexArray2->getVerticesStart() == static_cast<const void*>(mVertices2));
rp3d_test(mTriangleVertexArray2->getVerticesNormalsStart() == static_cast<const void*>(mNormals2));
rp3d_test(mTriangleVertexArray2->getIndicesStride() == (3 * sizeof(short)));
rp3d_test(mTriangleVertexArray2->getVerticesStride() == (3 * sizeof(double)));
rp3d_test(mTriangleVertexArray2->getVerticesNormalsStride() == (3 * sizeof(float)));
// Get triangle indices
mTriangleVertexArray2->getTriangleVerticesIndices(0, triangle0Indices);
test(triangle0Indices[0] == static_cast<uint>(mIndices2[0]));
test(triangle0Indices[1] == static_cast<uint>(mIndices2[1]));
test(triangle0Indices[2] == static_cast<uint>(mIndices2[2]));
rp3d_test(triangle0Indices[0] == static_cast<uint>(mIndices2[0]));
rp3d_test(triangle0Indices[1] == static_cast<uint>(mIndices2[1]));
rp3d_test(triangle0Indices[2] == static_cast<uint>(mIndices2[2]));
mTriangleVertexArray2->getTriangleVerticesIndices(1, triangle1Indices);
test(triangle1Indices[0] == static_cast<uint>(mIndices2[3]));
test(triangle1Indices[1] == static_cast<uint>(mIndices2[4]));
test(triangle1Indices[2] == static_cast<uint>(mIndices2[5]));
rp3d_test(triangle1Indices[0] == static_cast<uint>(mIndices2[3]));
rp3d_test(triangle1Indices[1] == static_cast<uint>(mIndices2[4]));
rp3d_test(triangle1Indices[2] == static_cast<uint>(mIndices2[5]));
// Get triangle vertices
mTriangleVertexArray2->getTriangleVertices(0, triangle0Vertices);
test(approxEqual(triangle0Vertices[0], mVertex4, decimal(0.0000001)));
test(approxEqual(triangle0Vertices[1], mVertex5, decimal(0.0000001)));
test(approxEqual(triangle0Vertices[2], mVertex6, decimal(0.0000001)));
rp3d_test(approxEqual(triangle0Vertices[0], mVertex4, decimal(0.0000001)));
rp3d_test(approxEqual(triangle0Vertices[1], mVertex5, decimal(0.0000001)));
rp3d_test(approxEqual(triangle0Vertices[2], mVertex6, decimal(0.0000001)));
mTriangleVertexArray2->getTriangleVertices(1, triangle1Vertices);
test(approxEqual(triangle1Vertices[0], mVertex4, decimal(0.0000001)));
test(approxEqual(triangle1Vertices[1], mVertex7, decimal(0.0000001)));
test(approxEqual(triangle1Vertices[2], mVertex5, decimal(0.0000001)));
rp3d_test(approxEqual(triangle1Vertices[0], mVertex4, decimal(0.0000001)));
rp3d_test(approxEqual(triangle1Vertices[1], mVertex7, decimal(0.0000001)));
rp3d_test(approxEqual(triangle1Vertices[2], mVertex5, decimal(0.0000001)));
// Get triangle normals
mTriangleVertexArray2->getTriangleVerticesNormals(0, triangle0Normals);
mTriangleVertexArray2->getTriangleVerticesNormals(1, triangle1Normals);
test(approxEqual(triangle0Normals[0], mNormal0, decimal(0.000001)));
test(approxEqual(triangle0Normals[1], mNormal1, decimal(0.000001)));
test(approxEqual(triangle0Normals[2], mNormal2, decimal(0.000001)));
rp3d_test(approxEqual(triangle0Normals[0], mNormal0, decimal(0.000001)));
rp3d_test(approxEqual(triangle0Normals[1], mNormal1, decimal(0.000001)));
rp3d_test(approxEqual(triangle0Normals[2], mNormal2, decimal(0.000001)));
test(approxEqual(triangle1Normals[0], mNormal0, decimal(0.000001)));
test(approxEqual(triangle1Normals[1], mNormal3, decimal(0.000001)));
test(approxEqual(triangle1Normals[2], mNormal1, decimal(0.000001)));
rp3d_test(approxEqual(triangle1Normals[0], mNormal0, decimal(0.000001)));
rp3d_test(approxEqual(triangle1Normals[1], mNormal3, decimal(0.000001)));
rp3d_test(approxEqual(triangle1Normals[2], mNormal1, decimal(0.000001)));
}
};

View File

@ -73,42 +73,42 @@ class TestList : public Test {
// ----- Constructors ----- //
List<int> list1(mAllocator);
test(list1.capacity() == 0);
test(list1.size() == 0);
rp3d_test(list1.capacity() == 0);
rp3d_test(list1.size() == 0);
List<int> list2(mAllocator, 100);
test(list2.capacity() == 100);
test(list2.size() == 0);
rp3d_test(list2.capacity() == 100);
rp3d_test(list2.size() == 0);
List<int> list3(mAllocator);
list3.add(1);
list3.add(2);
list3.add(3);
test(list3.capacity() == 4);
test(list3.size() == 3);
rp3d_test(list3.capacity() == 4);
rp3d_test(list3.size() == 3);
// ----- Copy Constructors ----- //
List<int> list4(list1);
test(list4.capacity() == 0);
test(list4.size() == 0);
rp3d_test(list4.capacity() == 0);
rp3d_test(list4.size() == 0);
List<int> list5(list3);
test(list5.capacity() == list3.size());
test(list5.size() == list3.size());
rp3d_test(list5.capacity() == list3.size());
rp3d_test(list5.size() == list3.size());
for (uint i=0; i<list3.size(); i++) {
test(list5[i] == list3[i]);
rp3d_test(list5[i] == list3[i]);
}
// ----- Test capacity grow ----- //
List<std::string> list6(mAllocator, 20);
test(list6.capacity() == 20);
rp3d_test(list6.capacity() == 20);
for (uint i=0; i<20; i++) {
list6.add("test");
}
test(list6.capacity() == 20);
rp3d_test(list6.capacity() == 20);
list6.add("test");
test(list6.capacity() == 40);
rp3d_test(list6.capacity() == 40);
}
void testAddRemoveClear() {
@ -117,12 +117,12 @@ class TestList : public Test {
List<int> list1(mAllocator);
list1.add(4);
test(list1.size() == 1);
test(list1[0] == 4);
rp3d_test(list1.size() == 1);
rp3d_test(list1[0] == 4);
list1.add(9);
test(list1.size() == 2);
test(list1[0] == 4);
test(list1[1] == 9);
rp3d_test(list1.size() == 2);
rp3d_test(list1[0] == 4);
rp3d_test(list1[1] == 9);
const int arraySize = 15;
int arrayTest[arraySize] = {3, 145, -182, 34, 12, 95, -1834, 4143, -111, -111, 4343, 234, 22983, -3432, 753};
@ -130,9 +130,9 @@ class TestList : public Test {
for (uint i=0; i<arraySize; i++) {
list2.add(arrayTest[i]);
}
test(list2.size() == arraySize);
rp3d_test(list2.size() == arraySize);
for (uint i=0; i<arraySize; i++) {
test(list2[i] == arrayTest[i]);
rp3d_test(list2[i] == arrayTest[i]);
}
// ----- Test remove() ----- //
@ -144,51 +144,51 @@ class TestList : public Test {
list3.add(4);
auto it = list3.removeAt(3);
test(list3.size() == 3);
test(list3.capacity() == 4);
test(it == list3.end());
test(list3[0] == 1);
test(list3[1] == 2);
test(list3[2] == 3);
rp3d_test(list3.size() == 3);
rp3d_test(list3.capacity() == 4);
rp3d_test(it == list3.end());
rp3d_test(list3[0] == 1);
rp3d_test(list3[1] == 2);
rp3d_test(list3[2] == 3);
it = list3.removeAt(1);
test(list3.size() == 2);
test(list3.capacity() == 4);
test(list3[0] == 1);
test(list3[1] == 3);
test(*it == 3);
rp3d_test(list3.size() == 2);
rp3d_test(list3.capacity() == 4);
rp3d_test(list3[0] == 1);
rp3d_test(list3[1] == 3);
rp3d_test(*it == 3);
list3.removeAt(0);
test(list3.size() == 1);
test(list3.capacity() == 4);
test(list3[0] == 3);
rp3d_test(list3.size() == 1);
rp3d_test(list3.capacity() == 4);
rp3d_test(list3[0] == 3);
it = list3.removeAt(0);
test(list3.size() == 0);
test(list3.capacity() == 4);
test(it == list3.end());
rp3d_test(list3.size() == 0);
rp3d_test(list3.capacity() == 4);
rp3d_test(it == list3.end());
list3.add(1);
list3.add(2);
list3.add(3);
it = list3.begin();
list3.remove(it);
test(list3.size() == 2);
test(list3[0] == 2);
test(list3[1] == 3);
rp3d_test(list3.size() == 2);
rp3d_test(list3[0] == 2);
rp3d_test(list3[1] == 3);
it = list3.find(3);
list3.remove(it);
test(list3.size() == 1);
test(list3[0] == 2);
rp3d_test(list3.size() == 1);
rp3d_test(list3[0] == 2);
list3.add(5);
list3.add(6);
list3.add(7);
it = list3.remove(7);
test(it == list3.end());
test(list3.size() == 3);
rp3d_test(it == list3.end());
rp3d_test(list3.size() == 3);
it = list3.remove(5);
test((*it) == 6);
rp3d_test((*it) == 6);
// ----- Test addRange() ----- //
@ -203,17 +203,17 @@ class TestList : public Test {
List<int> list6(mAllocator);
list6.addRange(list5);
test(list6.size() == list5.size());
test(list6[0] == 4);
test(list6[1] == 5);
rp3d_test(list6.size() == list5.size());
rp3d_test(list6[0] == 4);
rp3d_test(list6[1] == 5);
list4.addRange(list5);
test(list4.size() == 3 + list5.size());
test(list4[0] == 1);
test(list4[1] == 2);
test(list4[2] == 3);
test(list4[3] == 4);
test(list4[4] == 5);
rp3d_test(list4.size() == 3 + list5.size());
rp3d_test(list4[0] == 1);
rp3d_test(list4[1] == 2);
rp3d_test(list4[2] == 3);
rp3d_test(list4[3] == 4);
rp3d_test(list4[4] == 5);
// ----- Test clear() ----- //
@ -222,10 +222,10 @@ class TestList : public Test {
list7.add("test2");
list7.add("test3");
list7.clear();
test(list7.size() == 0);
rp3d_test(list7.size() == 0);
list7.add("new");
test(list7.size() == 1);
test(list7[0] == "new");
rp3d_test(list7.size() == 1);
rp3d_test(list7[0] == "new");
}
void testAssignment() {
@ -250,20 +250,20 @@ class TestList : public Test {
list5.add(3);
list3 = list2;
test(list2.size() == list3.size());
test(list2[0] == list3[0]);
test(list2[1] == list3[1]);
rp3d_test(list2.size() == list3.size());
rp3d_test(list2[0] == list3[0]);
rp3d_test(list2[1] == list3[1]);
list4 = list1;
test(list4.size() == list1.size())
test(list4[0] == list1[0]);
test(list4[1] == list1[1]);
test(list4[2] == list1[2]);
rp3d_test(list4.size() == list1.size())
rp3d_test(list4[0] == list1[0]);
rp3d_test(list4[1] == list1[1]);
rp3d_test(list4[2] == list1[2]);
list5 = list2;
test(list5.size() == list2.size());
test(list5[0] == list2[0]);
test(list5[1] == list2[1]);
rp3d_test(list5.size() == list2.size());
rp3d_test(list5[0] == list2[0]);
rp3d_test(list5[1] == list2[1]);
}
void testIndexing() {
@ -273,27 +273,27 @@ class TestList : public Test {
list1.add(2);
list1.add(3);
test(list1[0] == 1);
test(list1[1] == 2);
test(list1[2] == 3);
rp3d_test(list1[0] == 1);
rp3d_test(list1[1] == 2);
rp3d_test(list1[2] == 3);
list1[0] = 6;
list1[1] = 7;
list1[2] = 8;
test(list1[0] == 6);
test(list1[1] == 7);
test(list1[2] == 8);
rp3d_test(list1[0] == 6);
rp3d_test(list1[1] == 7);
rp3d_test(list1[2] == 8);
const int a = list1[0];
const int b = list1[1];
test(a == 6);
test(b == 7);
rp3d_test(a == 6);
rp3d_test(b == 7);
list1[0]++;
list1[1]++;
test(list1[0] == 7);
test(list1[1] == 8);
rp3d_test(list1[0] == 7);
rp3d_test(list1[1] == 8);
}
void testFind() {
@ -305,9 +305,9 @@ class TestList : public Test {
list1.add(4);
list1.add(5);
test(list1.find(1) == list1.begin());
test(*(list1.find(2)) == 2);
test(*(list1.find(5)) == 5);
rp3d_test(list1.find(1) == list1.begin());
rp3d_test(*(list1.find(2)) == 2);
rp3d_test(*(list1.find(5)) == 5);
}
void testEquality() {
@ -331,40 +331,40 @@ class TestList : public Test {
list4.add(5);
list4.add(3);
test(list1 == list1);
test(list1 != list2);
test(list1 == list3);
test(list1 != list4);
test(list2 != list4);
rp3d_test(list1 == list1);
rp3d_test(list1 != list2);
rp3d_test(list1 == list3);
rp3d_test(list1 != list4);
rp3d_test(list2 != list4);
}
void testReserve() {
List<int> list1(mAllocator);
list1.reserve(10);
test(list1.size() == 0);
test(list1.capacity() == 10);
rp3d_test(list1.size() == 0);
rp3d_test(list1.capacity() == 10);
list1.add(1);
list1.add(2);
test(list1.capacity() == 10);
test(list1.size() == 2);
test(list1[0] == 1);
test(list1[1] == 2);
rp3d_test(list1.capacity() == 10);
rp3d_test(list1.size() == 2);
rp3d_test(list1[0] == 1);
rp3d_test(list1[1] == 2);
list1.reserve(1);
test(list1.capacity() == 10);
rp3d_test(list1.capacity() == 10);
list1.reserve(100);
test(list1.capacity() == 100);
test(list1[0] == 1);
test(list1[1] == 2);
rp3d_test(list1.capacity() == 100);
rp3d_test(list1[0] == 1);
rp3d_test(list1[1] == 2);
}
void testIterators() {
List<int> list1(mAllocator);
test(list1.begin() == list1.end());
rp3d_test(list1.begin() == list1.end());
list1.add(5);
list1.add(6);
@ -375,30 +375,30 @@ class TestList : public Test {
List<int>::Iterator itEnd = list1.end();
List<int>::Iterator it = list1.begin();
test(itBegin == it);
test(*it == 5);
test(*(it++) == 5);
test(*it == 6);
test(*(it--) == 6);
test(*it == 5);
test(*(++it) == 6);
test(*it == 6);
test(*(--it) == 5);
test(*it == 5);
test(it == itBegin);
rp3d_test(itBegin == it);
rp3d_test(*it == 5);
rp3d_test(*(it++) == 5);
rp3d_test(*it == 6);
rp3d_test(*(it--) == 6);
rp3d_test(*it == 5);
rp3d_test(*(++it) == 6);
rp3d_test(*it == 6);
rp3d_test(*(--it) == 5);
rp3d_test(*it == 5);
rp3d_test(it == itBegin);
it = list1.end();
test(it == itEnd);
rp3d_test(it == itEnd);
it--;
test(*it == -1);
rp3d_test(*it == -1);
it++;
test(it == itEnd);
rp3d_test(it == itEnd);
List<int> list2(mAllocator);
for (auto it = list1.begin(); it != list1.end(); ++it) {
list2.add(*it);
}
test(list1 == list2);
rp3d_test(list1 == list2);
}
};

View File

@ -98,49 +98,49 @@ class TestMap : public Test {
// ----- Constructors ----- //
Map<int, std::string> map1(mAllocator);
test(map1.capacity() == 0);
test(map1.size() == 0);
rp3d_test(map1.capacity() == 0);
rp3d_test(map1.size() == 0);
Map<int, std::string> map2(mAllocator, 100);
test(map2.capacity() >= 100);
test(map2.size() == 0);
rp3d_test(map2.capacity() >= 100);
rp3d_test(map2.size() == 0);
// ----- Copy Constructors ----- //
Map<int, std::string> map3(map1);
test(map3.capacity() == map1.capacity());
test(map3.size() == map1.size());
rp3d_test(map3.capacity() == map1.capacity());
rp3d_test(map3.size() == map1.size());
Map<int, int> map4(mAllocator);
map4.add(Pair<int, int>(1, 10));
map4.add(Pair<int, int>(2, 20));
map4.add(Pair<int, int>(3, 30));
test(map4.capacity() >= 3);
test(map4.size() == 3);
rp3d_test(map4.capacity() >= 3);
rp3d_test(map4.size() == 3);
Map<int, int> map5(map4);
test(map5.capacity() == map4.capacity());
test(map5.size() == map4.size());
test(map5[1] == 10);
test(map5[2] == 20);
test(map5[3] == 30);
rp3d_test(map5.capacity() == map4.capacity());
rp3d_test(map5.size() == map4.size());
rp3d_test(map5[1] == 10);
rp3d_test(map5[2] == 20);
rp3d_test(map5[3] == 30);
}
void testReserve() {
Map<int, std::string> map1(mAllocator);
map1.reserve(15);
test(map1.capacity() >= 15);
rp3d_test(map1.capacity() >= 15);
map1.add(Pair<int, std::string>(1, "test1"));
map1.add(Pair<int, std::string>(2, "test2"));
test(map1.capacity() >= 15);
rp3d_test(map1.capacity() >= 15);
map1.reserve(10);
test(map1.capacity() >= 15);
rp3d_test(map1.capacity() >= 15);
map1.reserve(100);
test(map1.capacity() >= 100);
test(map1[1] == "test1");
test(map1[2] == "test2");
rp3d_test(map1.capacity() >= 100);
rp3d_test(map1[1] == "test1");
rp3d_test(map1[2] == "test2");
}
void testAddRemoveClear() {
@ -151,10 +151,10 @@ class TestMap : public Test {
map1.add(Pair<int, int>(1, 10));
map1.add(Pair<int, int>(8, 80));
map1.add(Pair<int, int>(13, 130));
test(map1[1] == 10);
test(map1[8] == 80);
test(map1[13] == 130);
test(map1.size() == 3);
rp3d_test(map1[1] == 10);
rp3d_test(map1[8] == 80);
rp3d_test(map1[13] == 130);
rp3d_test(map1.size() == 3);
Map<int, int> map2(mAllocator, 15);
for (int i = 0; i < 1000000; i++) {
@ -164,41 +164,41 @@ class TestMap : public Test {
for (int i = 0; i < 1000000; i++) {
if (map2[i] != i * 100) isValid = false;
}
test(isValid);
rp3d_test(isValid);
map1.remove(1);
map1.add(Pair<int, int>(1, 10));
test(map1.size() == 3);
test(map1[1] == 10);
rp3d_test(map1.size() == 3);
rp3d_test(map1[1] == 10);
map1.add(Pair<int, int>(56, 34));
test(map1[56] == 34);
test(map1.size() == 4);
rp3d_test(map1[56] == 34);
rp3d_test(map1.size() == 4);
map1.add(Pair<int, int>(56, 13), true);
test(map1[56] == 13);
test(map1.size() == 4);
rp3d_test(map1[56] == 13);
rp3d_test(map1.size() == 4);
// ----- Test remove() ----- //
map1.remove(1);
test(!map1.containsKey(1));
test(map1.containsKey(8));
test(map1.containsKey(13));
test(map1.size() == 3);
rp3d_test(!map1.containsKey(1));
rp3d_test(map1.containsKey(8));
rp3d_test(map1.containsKey(13));
rp3d_test(map1.size() == 3);
map1.remove(13);
test(map1.containsKey(8));
test(!map1.containsKey(13));
test(map1.size() == 2);
rp3d_test(map1.containsKey(8));
rp3d_test(!map1.containsKey(13));
rp3d_test(map1.size() == 2);
map1.remove(8);
test(!map1.containsKey(8));
test(map1.size() == 1);
rp3d_test(!map1.containsKey(8));
rp3d_test(map1.size() == 1);
auto it = map1.remove(56);
test(!map1.containsKey(56));
test(map1.size() == 0);
test(it == map1.end());
rp3d_test(!map1.containsKey(56));
rp3d_test(map1.size() == 0);
rp3d_test(it == map1.end());
isValid = true;
for (int i = 0; i < 1000000; i++) {
@ -207,8 +207,8 @@ class TestMap : public Test {
for (int i = 0; i < 1000000; i++) {
if (map2.containsKey(i)) isValid = false;
}
test(isValid);
test(map2.size() == 0);
rp3d_test(isValid);
rp3d_test(map2.size() == 0);
Map<int, int> map3(mAllocator);
for (int i=0; i < 1000000; i++) {
@ -219,19 +219,19 @@ class TestMap : public Test {
map3.add(Pair<int, int>(1, 10));
map3.add(Pair<int, int>(2, 20));
map3.add(Pair<int, int>(3, 30));
test(map3.size() == 3);
rp3d_test(map3.size() == 3);
it = map3.begin();
map3.remove(it++);
test(!map3.containsKey(1));
test(map3.size() == 2);
test(it->second == 20);
rp3d_test(!map3.containsKey(1));
rp3d_test(map3.size() == 2);
rp3d_test(it->second == 20);
map3.add(Pair<int, int>(56, 32));
map3.add(Pair<int, int>(23, 89));
for (it = map3.begin(); it != map3.end();) {
it = map3.remove(it);
}
test(map3.size() == 0);
rp3d_test(map3.size() == 0);
// ----- Test clear() ----- //
@ -240,16 +240,16 @@ class TestMap : public Test {
map4.add(Pair<int, int>(4, 40));
map4.add(Pair<int, int>(6, 60));
map4.clear();
test(map4.size() == 0);
rp3d_test(map4.size() == 0);
map4.add(Pair<int, int>(2, 20));
test(map4.size() == 1);
test(map4[2] == 20);
rp3d_test(map4.size() == 1);
rp3d_test(map4[2] == 20);
map4.clear();
test(map4.size() == 0);
rp3d_test(map4.size() == 0);
Map<int, int> map5(mAllocator);
map5.clear();
test(map5.size() == 0);
rp3d_test(map5.size() == 0);
// ----- Test map with always same hash value for keys ----- //
@ -263,37 +263,37 @@ class TestMap : public Test {
isTestValid = false;
}
}
test(isTestValid);
rp3d_test(isTestValid);
for (int i=0; i < 1000; i++) {
map6.remove(TestKey(i));
}
test(map6.size() == 0);
rp3d_test(map6.size() == 0);
}
void testContainsKey() {
Map<int, int> map1(mAllocator);
test(!map1.containsKey(2));
test(!map1.containsKey(4));
test(!map1.containsKey(6));
rp3d_test(!map1.containsKey(2));
rp3d_test(!map1.containsKey(4));
rp3d_test(!map1.containsKey(6));
map1.add(Pair<int, int>(2, 20));
map1.add(Pair<int, int>(4, 40));
map1.add(Pair<int, int>(6, 60));
test(map1.containsKey(2));
test(map1.containsKey(4));
test(map1.containsKey(6));
rp3d_test(map1.containsKey(2));
rp3d_test(map1.containsKey(4));
rp3d_test(map1.containsKey(6));
map1.remove(4);
test(!map1.containsKey(4));
test(map1.containsKey(2));
test(map1.containsKey(6));
rp3d_test(!map1.containsKey(4));
rp3d_test(map1.containsKey(2));
rp3d_test(map1.containsKey(6));
map1.clear();
test(!map1.containsKey(2));
test(!map1.containsKey(6));
rp3d_test(!map1.containsKey(2));
rp3d_test(!map1.containsKey(6));
}
void testIndexing() {
@ -302,17 +302,17 @@ class TestMap : public Test {
map1.add(Pair<int, int>(2, 20));
map1.add(Pair<int, int>(4, 40));
map1.add(Pair<int, int>(6, 60));
test(map1[2] == 20);
test(map1[4] == 40);
test(map1[6] == 60);
rp3d_test(map1[2] == 20);
rp3d_test(map1[4] == 40);
rp3d_test(map1[6] == 60);
map1[2] = 10;
map1[4] = 20;
map1[6] = 30;
test(map1[2] == 10);
test(map1[4] == 20);
test(map1[6] == 30);
rp3d_test(map1[2] == 10);
rp3d_test(map1[4] == 20);
rp3d_test(map1[6] == 30);
}
void testFind() {
@ -321,18 +321,18 @@ class TestMap : public Test {
map1.add(Pair<int, int>(2, 20));
map1.add(Pair<int, int>(4, 40));
map1.add(Pair<int, int>(6, 60));
test(map1.find(2)->second == 20);
test(map1.find(4)->second == 40);
test(map1.find(6)->second == 60);
test(map1.find(45) == map1.end());
rp3d_test(map1.find(2)->second == 20);
rp3d_test(map1.find(4)->second == 40);
rp3d_test(map1.find(6)->second == 60);
rp3d_test(map1.find(45) == map1.end());
map1[2] = 10;
map1[4] = 20;
map1[6] = 30;
test(map1.find(2)->second == 10);
test(map1.find(4)->second == 20);
test(map1.find(6)->second == 30);
rp3d_test(map1.find(2)->second == 10);
rp3d_test(map1.find(4)->second == 20);
rp3d_test(map1.find(6)->second == 30);
}
void testEquality() {
@ -340,7 +340,7 @@ class TestMap : public Test {
Map<std::string, int> map1(mAllocator, 10);
Map<std::string, int> map2(mAllocator, 2);
test(map1 == map2);
rp3d_test(map1 == map2);
map1.add(Pair<std::string, int>("a", 1));
map1.add(Pair<std::string, int>("b", 2));
@ -350,19 +350,19 @@ class TestMap : public Test {
map2.add(Pair<std::string, int>("b", 2));
map2.add(Pair<std::string, int>("c", 4));
test(map1 == map1);
test(map2 == map2);
test(map1 != map2);
rp3d_test(map1 == map1);
rp3d_test(map2 == map2);
rp3d_test(map1 != map2);
map2["c"] = 3;
test(map1 == map2);
rp3d_test(map1 == map2);
Map<std::string, int> map3(mAllocator);
map3.add(Pair<std::string, int>("a", 1));
test(map1 != map3);
test(map2 != map3);
rp3d_test(map1 != map3);
rp3d_test(map2 != map3);
}
void testAssignment() {
@ -374,40 +374,40 @@ class TestMap : public Test {
Map<int, int> map2(mAllocator);
map2 = map1;
test(map2.size() == map1.size());
test(map1 == map2);
test(map2[1] == 3);
test(map2[2] == 6);
test(map2[10] == 30);
rp3d_test(map2.size() == map1.size());
rp3d_test(map1 == map2);
rp3d_test(map2[1] == 3);
rp3d_test(map2[2] == 6);
rp3d_test(map2[10] == 30);
Map<int, int> map3(mAllocator, 100);
map3 = map1;
test(map3.size() == map1.size());
test(map3 == map1);
test(map3[1] == 3);
test(map3[2] == 6);
test(map3[10] == 30);
rp3d_test(map3.size() == map1.size());
rp3d_test(map3 == map1);
rp3d_test(map3[1] == 3);
rp3d_test(map3[2] == 6);
rp3d_test(map3[10] == 30);
Map<int, int> map4(mAllocator);
map3 = map4;
test(map3.size() == 0);
test(map3 == map4);
rp3d_test(map3.size() == 0);
rp3d_test(map3 == map4);
Map<int, int> map5(mAllocator);
map5.add(Pair<int, int>(7, 8));
map5.add(Pair<int, int>(19, 70));
map1 = map5;
test(map5.size() == map1.size());
test(map5 == map1);
test(map1[7] == 8);
test(map1[19] == 70);
rp3d_test(map5.size() == map1.size());
rp3d_test(map5 == map1);
rp3d_test(map1[7] == 8);
rp3d_test(map1[19] == 70);
}
void testIterators() {
Map<int, int> map1(mAllocator);
test(map1.begin() == map1.end());
rp3d_test(map1.begin() == map1.end());
map1.add(Pair<int, int>(1, 5));
map1.add(Pair<int, int>(2, 6));
@ -417,14 +417,14 @@ class TestMap : public Test {
Map<int, int>::Iterator itBegin = map1.begin();
Map<int, int>::Iterator it = map1.begin();
test(itBegin == it);
rp3d_test(itBegin == it);
int size = 0;
for (auto it = map1.begin(); it != map1.end(); ++it) {
test(map1.containsKey(it->first));
rp3d_test(map1.containsKey(it->first));
size++;
}
test(map1.size() == size);
rp3d_test(map1.size() == size);
}
};

View File

@ -97,51 +97,51 @@ class TestSet : public Test {
// ----- Constructors ----- //
Set<std::string> set1(mAllocator);
test(set1.capacity() == 0);
test(set1.size() == 0);
rp3d_test(set1.capacity() == 0);
rp3d_test(set1.size() == 0);
Set<std::string> set2(mAllocator, 100);
test(set2.capacity() >= 100);
test(set2.size() == 0);
rp3d_test(set2.capacity() >= 100);
rp3d_test(set2.size() == 0);
// ----- Copy Constructors ----- //
Set<std::string> set3(set1);
test(set3.capacity() == set1.capacity());
test(set3.size() == set1.size());
rp3d_test(set3.capacity() == set1.capacity());
rp3d_test(set3.size() == set1.size());
Set<int> set4(mAllocator);
set4.add(10);
set4.add(20);
set4.add(30);
test(set4.capacity() >= 3);
test(set4.size() == 3);
rp3d_test(set4.capacity() >= 3);
rp3d_test(set4.size() == 3);
set4.add(30);
test(set4.size() == 3);
rp3d_test(set4.size() == 3);
Set<int> set5(set4);
test(set5.capacity() == set4.capacity());
test(set5.size() == set4.size());
test(set5.contains(10));
test(set5.contains(20));
test(set5.contains(30));
rp3d_test(set5.capacity() == set4.capacity());
rp3d_test(set5.size() == set4.size());
rp3d_test(set5.contains(10));
rp3d_test(set5.contains(20));
rp3d_test(set5.contains(30));
}
void testReserve() {
Set<std::string> set1(mAllocator);
set1.reserve(15);
test(set1.capacity() >= 15);
rp3d_test(set1.capacity() >= 15);
set1.add("test1");
set1.add("test2");
test(set1.capacity() >= 15);
rp3d_test(set1.capacity() >= 15);
set1.reserve(10);
test(set1.capacity() >= 15);
rp3d_test(set1.capacity() >= 15);
set1.reserve(100);
test(set1.capacity() >= 100);
test(set1.contains("test1"));
test(set1.contains("test2"));
rp3d_test(set1.capacity() >= 100);
rp3d_test(set1.contains("test1"));
rp3d_test(set1.contains("test2"));
}
void testAddRemoveClear() {
@ -152,10 +152,10 @@ class TestSet : public Test {
set1.add(10);
set1.add(80);
set1.add(130);
test(set1.contains(10));
test(set1.contains(80));
test(set1.contains(130));
test(set1.size() == 3);
rp3d_test(set1.contains(10));
rp3d_test(set1.contains(80));
rp3d_test(set1.contains(130));
rp3d_test(set1.size() == 3);
Set<int> set2(mAllocator, 15);
for (int i = 0; i < 1000000; i++) {
@ -165,40 +165,40 @@ class TestSet : public Test {
for (int i = 0; i < 1000000; i++) {
if (!set2.contains(i)) isValid = false;
}
test(isValid);
rp3d_test(isValid);
set1.remove(10);
set1.add(10);
test(set1.size() == 3);
test(set1.contains(10));
rp3d_test(set1.size() == 3);
rp3d_test(set1.contains(10));
set1.add(34);
test(set1.contains(34));
test(set1.size() == 4);
rp3d_test(set1.contains(34));
rp3d_test(set1.size() == 4);
// ----- Test remove() ----- //
set1.remove(10);
test(!set1.contains(10));
test(set1.contains(80));
test(set1.contains(130));
test(set1.contains(34));
test(set1.size() == 3);
rp3d_test(!set1.contains(10));
rp3d_test(set1.contains(80));
rp3d_test(set1.contains(130));
rp3d_test(set1.contains(34));
rp3d_test(set1.size() == 3);
set1.remove(80);
test(!set1.contains(80));
test(set1.contains(130));
test(set1.contains(34));
test(set1.size() == 2);
rp3d_test(!set1.contains(80));
rp3d_test(set1.contains(130));
rp3d_test(set1.contains(34));
rp3d_test(set1.size() == 2);
set1.remove(130);
test(!set1.contains(130));
test(set1.contains(34));
test(set1.size() == 1);
rp3d_test(!set1.contains(130));
rp3d_test(set1.contains(34));
rp3d_test(set1.size() == 1);
set1.remove(34);
test(!set1.contains(34));
test(set1.size() == 0);
rp3d_test(!set1.contains(34));
rp3d_test(set1.size() == 0);
isValid = true;
for (int i = 0; i < 1000000; i++) {
@ -207,8 +207,8 @@ class TestSet : public Test {
for (int i = 0; i < 1000000; i++) {
if (set2.contains(i)) isValid = false;
}
test(isValid);
test(set2.size() == 0);
rp3d_test(isValid);
rp3d_test(set2.size() == 0);
Set<int> set3(mAllocator);
for (int i=0; i < 1000000; i++) {
@ -219,12 +219,12 @@ class TestSet : public Test {
set3.add(1);
set3.add(2);
set3.add(3);
test(set3.size() == 3);
rp3d_test(set3.size() == 3);
auto it = set3.begin();
set3.remove(it++);
test(!set3.contains(1));
test(set3.size() == 2);
test(*it == 2);
rp3d_test(!set3.contains(1));
rp3d_test(set3.size() == 2);
rp3d_test(*it == 2);
set3.add(6);
set3.add(7);
@ -232,7 +232,7 @@ class TestSet : public Test {
for (it = set3.begin(); it != set3.end();) {
it = set3.remove(it);
}
test(set3.size() == 0);
rp3d_test(set3.size() == 0);
// ----- Test clear() ----- //
@ -241,16 +241,16 @@ class TestSet : public Test {
set4.add(4);
set4.add(6);
set4.clear();
test(set4.size() == 0);
rp3d_test(set4.size() == 0);
set4.add(2);
test(set4.size() == 1);
test(set4.contains(2));
rp3d_test(set4.size() == 1);
rp3d_test(set4.contains(2));
set4.clear();
test(set4.size() == 0);
rp3d_test(set4.size() == 0);
Set<int> set5(mAllocator);
set5.clear();
test(set5.size() == 0);
rp3d_test(set5.size() == 0);
// ----- Test map with always same hash value for keys ----- //
@ -264,37 +264,37 @@ class TestSet : public Test {
isTestValid = false;
}
}
test(isTestValid);
rp3d_test(isTestValid);
for (int i=0; i < 1000; i++) {
set6.remove(TestValueSet(i));
}
test(set6.size() == 0);
rp3d_test(set6.size() == 0);
}
void testContains() {
Set<int> set1(mAllocator);
test(!set1.contains(2));
test(!set1.contains(4));
test(!set1.contains(6));
rp3d_test(!set1.contains(2));
rp3d_test(!set1.contains(4));
rp3d_test(!set1.contains(6));
set1.add(2);
set1.add(4);
set1.add(6);
test(set1.contains(2));
test(set1.contains(4));
test(set1.contains(6));
rp3d_test(set1.contains(2));
rp3d_test(set1.contains(4));
rp3d_test(set1.contains(6));
set1.remove(4);
test(!set1.contains(4));
test(set1.contains(2));
test(set1.contains(6));
rp3d_test(!set1.contains(4));
rp3d_test(set1.contains(2));
rp3d_test(set1.contains(6));
set1.clear();
test(!set1.contains(2));
test(!set1.contains(6));
rp3d_test(!set1.contains(2));
rp3d_test(!set1.contains(6));
}
void testFind() {
@ -303,14 +303,14 @@ class TestSet : public Test {
set1.add(2);
set1.add(4);
set1.add(6);
test(set1.find(2) != set1.end());
test(set1.find(4) != set1.end());
test(set1.find(6) != set1.end());
test(set1.find(45) == set1.end());
rp3d_test(set1.find(2) != set1.end());
rp3d_test(set1.find(4) != set1.end());
rp3d_test(set1.find(6) != set1.end());
rp3d_test(set1.find(45) == set1.end());
set1.remove(2);
test(set1.find(2) == set1.end());
rp3d_test(set1.find(2) == set1.end());
}
void testEquality() {
@ -318,7 +318,7 @@ class TestSet : public Test {
Set<std::string> set1(mAllocator, 10);
Set<std::string> set2(mAllocator, 2);
test(set1 == set2);
rp3d_test(set1 == set2);
set1.add("a");
set1.add("b");
@ -328,25 +328,25 @@ class TestSet : public Test {
set2.add("b");
set2.add("h");
test(set1 == set1);
test(set2 == set2);
test(set1 != set2);
test(set2 != set1);
rp3d_test(set1 == set1);
rp3d_test(set2 == set2);
rp3d_test(set1 != set2);
rp3d_test(set2 != set1);
set1.add("a");
set2.remove("h");
set2.add("c");
test(set1 == set2);
test(set2 == set1);
rp3d_test(set1 == set2);
rp3d_test(set2 == set1);
Set<std::string> set3(mAllocator);
set3.add("a");
test(set1 != set3);
test(set2 != set3);
test(set3 != set1);
test(set3 != set2);
rp3d_test(set1 != set3);
rp3d_test(set2 != set3);
rp3d_test(set3 != set1);
rp3d_test(set3 != set2);
}
void testAssignment() {
@ -358,40 +358,40 @@ class TestSet : public Test {
Set<int> set2(mAllocator);
set2 = set1;
test(set2.size() == set1.size());
test(set2.contains(1));
test(set2.contains(2));
test(set2.contains(10));
test(set1 == set2);
rp3d_test(set2.size() == set1.size());
rp3d_test(set2.contains(1));
rp3d_test(set2.contains(2));
rp3d_test(set2.contains(10));
rp3d_test(set1 == set2);
Set<int> set3(mAllocator, 100);
set3 = set1;
test(set3.size() == set1.size());
test(set3 == set1);
test(set3.contains(1));
test(set3.contains(2));
test(set3.contains(10));
rp3d_test(set3.size() == set1.size());
rp3d_test(set3 == set1);
rp3d_test(set3.contains(1));
rp3d_test(set3.contains(2));
rp3d_test(set3.contains(10));
Set<int> set4(mAllocator);
set3 = set4;
test(set3.size() == 0);
test(set3 == set4);
rp3d_test(set3.size() == 0);
rp3d_test(set3 == set4);
Set<int> set5(mAllocator);
set5.add(7);
set5.add(19);
set1 = set5;
test(set5.size() == set1.size());
test(set1 == set5);
test(set1.contains(7));
test(set1.contains(19));
rp3d_test(set5.size() == set1.size());
rp3d_test(set1 == set5);
rp3d_test(set1.contains(7));
rp3d_test(set1.contains(19));
}
void testIterators() {
Set<int> set1(mAllocator);
test(set1.begin() == set1.end());
rp3d_test(set1.begin() == set1.end());
set1.add(1);
set1.add(2);
@ -401,14 +401,14 @@ class TestSet : public Test {
Set<int>::Iterator itBegin = set1.begin();
Set<int>::Iterator it = set1.begin();
test(itBegin == it);
rp3d_test(itBegin == it);
int size = 0;
for (auto it = set1.begin(); it != set1.end(); ++it) {
test(set1.contains(*it));
rp3d_test(set1.contains(*it));
size++;
}
test(set1.size() == size);
rp3d_test(set1.size() == size);
}
};

View File

@ -56,52 +56,52 @@ class TestMathematicsFunctions : public Test {
void run() {
// Test approxEqual()
test(approxEqual(2, 7, 5.2));
test(approxEqual(7, 2, 5.2));
test(approxEqual(6, 6));
test(!approxEqual(1, 5));
test(!approxEqual(1, 5, 3));
test(approxEqual(-2, -2));
test(approxEqual(-2, -7, 6));
test(!approxEqual(-2, 7, 2));
test(approxEqual(-3, 8, 12));
test(!approxEqual(-3, 8, 6));
rp3d_test(approxEqual(2, 7, 5.2));
rp3d_test(approxEqual(7, 2, 5.2));
rp3d_test(approxEqual(6, 6));
rp3d_test(!approxEqual(1, 5));
rp3d_test(!approxEqual(1, 5, 3));
rp3d_test(approxEqual(-2, -2));
rp3d_test(approxEqual(-2, -7, 6));
rp3d_test(!approxEqual(-2, 7, 2));
rp3d_test(approxEqual(-3, 8, 12));
rp3d_test(!approxEqual(-3, 8, 6));
// Test clamp()
test(clamp(4, -3, 5) == 4);
test(clamp(-3, 1, 8) == 1);
test(clamp(45, -6, 7) == 7);
test(clamp(-5, -2, -1) == -2);
test(clamp(-5, -9, -1) == -5);
test(clamp(6, 6, 9) == 6);
test(clamp(9, 6, 9) == 9);
test(clamp(decimal(4), decimal(-3), decimal(5)) == decimal(4));
test(clamp(decimal(-3), decimal(1), decimal(8)) == decimal(1));
test(clamp(decimal(45), decimal(-6), decimal(7)) == decimal(7));
test(clamp(decimal(-5), decimal(-2), decimal(-1)) == decimal(-2));
test(clamp(decimal(-5), decimal(-9), decimal(-1)) == decimal(-5));
test(clamp(decimal(6), decimal(6), decimal(9)) == decimal(6));
test(clamp(decimal(9), decimal(6), decimal(9)) == decimal(9));
rp3d_test(clamp(4, -3, 5) == 4);
rp3d_test(clamp(-3, 1, 8) == 1);
rp3d_test(clamp(45, -6, 7) == 7);
rp3d_test(clamp(-5, -2, -1) == -2);
rp3d_test(clamp(-5, -9, -1) == -5);
rp3d_test(clamp(6, 6, 9) == 6);
rp3d_test(clamp(9, 6, 9) == 9);
rp3d_test(clamp(decimal(4), decimal(-3), decimal(5)) == decimal(4));
rp3d_test(clamp(decimal(-3), decimal(1), decimal(8)) == decimal(1));
rp3d_test(clamp(decimal(45), decimal(-6), decimal(7)) == decimal(7));
rp3d_test(clamp(decimal(-5), decimal(-2), decimal(-1)) == decimal(-2));
rp3d_test(clamp(decimal(-5), decimal(-9), decimal(-1)) == decimal(-5));
rp3d_test(clamp(decimal(6), decimal(6), decimal(9)) == decimal(6));
rp3d_test(clamp(decimal(9), decimal(6), decimal(9)) == decimal(9));
// Test min3()
test(min3(1, 5, 7) == 1);
test(min3(-4, 2, 4) == -4);
test(min3(-1, -5, -7) == -7);
test(min3(13, 5, 47) == 5);
test(min3(4, 4, 4) == 4);
rp3d_test(min3(1, 5, 7) == 1);
rp3d_test(min3(-4, 2, 4) == -4);
rp3d_test(min3(-1, -5, -7) == -7);
rp3d_test(min3(13, 5, 47) == 5);
rp3d_test(min3(4, 4, 4) == 4);
// Test max3()
test(max3(1, 5, 7) == 7);
test(max3(-4, 2, 4) == 4);
test(max3(-1, -5, -7) == -1);
test(max3(13, 5, 47) == 47);
test(max3(4, 4, 4) == 4);
rp3d_test(max3(1, 5, 7) == 7);
rp3d_test(max3(-4, 2, 4) == 4);
rp3d_test(max3(-1, -5, -7) == -1);
rp3d_test(max3(13, 5, 47) == 47);
rp3d_test(max3(4, 4, 4) == 4);
// Test sameSign()
test(sameSign(4, 53));
test(sameSign(-4, -8));
test(!sameSign(4, -7));
test(!sameSign(-4, 53));
rp3d_test(sameSign(4, 53));
rp3d_test(sameSign(-4, -8));
rp3d_test(!sameSign(4, -7));
rp3d_test(!sameSign(-4, 53));
// Test computePointToPlaneDistance()
Vector3 p(8, 4, 0);
@ -109,9 +109,9 @@ class TestMathematicsFunctions : public Test {
Vector3 n2(-1, 0, 0);
Vector3 q1(1, 54, 0);
Vector3 q2(8, 17, 0);
test(approxEqual(computePointToPlaneDistance(q1, n1, p), decimal(-7)));
test(approxEqual(computePointToPlaneDistance(q1, n2, p), decimal(7)));
test(approxEqual(computePointToPlaneDistance(q2, n2, p), decimal(0.0)));
rp3d_test(approxEqual(computePointToPlaneDistance(q1, n1, p), decimal(-7)));
rp3d_test(approxEqual(computePointToPlaneDistance(q1, n2, p), decimal(7)));
rp3d_test(approxEqual(computePointToPlaneDistance(q2, n2, p), decimal(0.0)));
// Test computeBarycentricCoordinatesInTriangle()
Vector3 a(0, 0, 0);
@ -120,66 +120,66 @@ class TestMathematicsFunctions : public Test {
Vector3 testPoint(4, 0, 1);
decimal u,v,w;
computeBarycentricCoordinatesInTriangle(a, b, c, a, u, v, w);
test(approxEqual(u, 1.0, 0.000001));
test(approxEqual(v, 0.0, 0.000001));
test(approxEqual(w, 0.0, 0.000001));
rp3d_test(approxEqual(u, 1.0, 0.000001));
rp3d_test(approxEqual(v, 0.0, 0.000001));
rp3d_test(approxEqual(w, 0.0, 0.000001));
computeBarycentricCoordinatesInTriangle(a, b, c, b, u, v, w);
test(approxEqual(u, 0.0, 0.000001));
test(approxEqual(v, 1.0, 0.000001));
test(approxEqual(w, 0.0, 0.000001));
rp3d_test(approxEqual(u, 0.0, 0.000001));
rp3d_test(approxEqual(v, 1.0, 0.000001));
rp3d_test(approxEqual(w, 0.0, 0.000001));
computeBarycentricCoordinatesInTriangle(a, b, c, c, u, v, w);
test(approxEqual(u, 0.0, 0.000001));
test(approxEqual(v, 0.0, 0.000001));
test(approxEqual(w, 1.0, 0.000001));
rp3d_test(approxEqual(u, 0.0, 0.000001));
rp3d_test(approxEqual(v, 0.0, 0.000001));
rp3d_test(approxEqual(w, 1.0, 0.000001));
computeBarycentricCoordinatesInTriangle(a, b, c, testPoint, u, v, w);
test(approxEqual(u + v + w, 1.0, 0.000001));
rp3d_test(approxEqual(u + v + w, 1.0, 0.000001));
// Test computeClosestPointBetweenTwoSegments()
Vector3 closestSeg1, closestSeg2;
computeClosestPointBetweenTwoSegments(Vector3(4, 0, 0), Vector3(6, 0, 0), Vector3(8, 0, 0), Vector3(8, 6, 0), closestSeg1, closestSeg2);
test(approxEqual(closestSeg1.x, 6.0, 0.000001));
test(approxEqual(closestSeg1.y, 0.0, 0.000001));
test(approxEqual(closestSeg1.z, 0.0, 0.000001));
test(approxEqual(closestSeg2.x, 8.0, 0.000001));
test(approxEqual(closestSeg2.y, 0.0, 0.000001));
test(approxEqual(closestSeg2.z, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.x, 6.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.y, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.z, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.x, 8.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.y, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.z, 0.0, 0.000001));
computeClosestPointBetweenTwoSegments(Vector3(4, 6, 5), Vector3(4, 6, 5), Vector3(8, 3, -9), Vector3(8, 3, -9), closestSeg1, closestSeg2);
test(approxEqual(closestSeg1.x, 4.0, 0.000001));
test(approxEqual(closestSeg1.y, 6.0, 0.000001));
test(approxEqual(closestSeg1.z, 5.0, 0.000001));
test(approxEqual(closestSeg2.x, 8.0, 0.000001));
test(approxEqual(closestSeg2.y, 3.0, 0.000001));
test(approxEqual(closestSeg2.z, -9.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.x, 4.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.y, 6.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.z, 5.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.x, 8.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.y, 3.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.z, -9.0, 0.000001));
computeClosestPointBetweenTwoSegments(Vector3(0, -5, 0), Vector3(0, 8, 0), Vector3(6, 3, 0), Vector3(10, -3, 0), closestSeg1, closestSeg2);
test(approxEqual(closestSeg1.x, 0.0, 0.000001));
test(approxEqual(closestSeg1.y, 3.0, 0.000001));
test(approxEqual(closestSeg1.z, 0.0, 0.000001));
test(approxEqual(closestSeg2.x, 6.0, 0.000001));
test(approxEqual(closestSeg2.y, 3.0, 0.000001));
test(approxEqual(closestSeg2.z, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.x, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.y, 3.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.z, 0.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.x, 6.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.y, 3.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.z, 0.0, 0.000001));
computeClosestPointBetweenTwoSegments(Vector3(1, -4, -5), Vector3(1, 4, -5), Vector3(-6, 5, -5), Vector3(6, 5, -5), closestSeg1, closestSeg2);
test(approxEqual(closestSeg1.x, 1.0, 0.000001));
test(approxEqual(closestSeg1.y, 4.0, 0.000001));
test(approxEqual(closestSeg1.z, -5.0, 0.000001));
test(approxEqual(closestSeg2.x, 1.0, 0.000001));
test(approxEqual(closestSeg2.y, 5.0, 0.000001));
test(approxEqual(closestSeg2.z, -5.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.x, 1.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.y, 4.0, 0.000001));
rp3d_test(approxEqual(closestSeg1.z, -5.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.x, 1.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.y, 5.0, 0.000001));
rp3d_test(approxEqual(closestSeg2.z, -5.0, 0.000001));
// Test computePlaneSegmentIntersection();
test(approxEqual(computePlaneSegmentIntersection(Vector3(-6, 3, 0), Vector3(6, 3, 0), 0.0, Vector3(-1, 0, 0)), 0.5, 0.000001));
test(approxEqual(computePlaneSegmentIntersection(Vector3(-6, 3, 0), Vector3(6, 3, 0), 0.0, Vector3(1, 0, 0)), 0.5, 0.000001));
test(approxEqual(computePlaneSegmentIntersection(Vector3(5, 12, 0), Vector3(5, 4, 0), 6, Vector3(0, 1, 0)), 0.75, 0.000001));
test(approxEqual(computePlaneSegmentIntersection(Vector3(5, 4, 8), Vector3(9, 14, 8), 4, Vector3(0, 1, 0)), 0.0, 0.000001));
rp3d_test(approxEqual(computePlaneSegmentIntersection(Vector3(-6, 3, 0), Vector3(6, 3, 0), 0.0, Vector3(-1, 0, 0)), 0.5, 0.000001));
rp3d_test(approxEqual(computePlaneSegmentIntersection(Vector3(-6, 3, 0), Vector3(6, 3, 0), 0.0, Vector3(1, 0, 0)), 0.5, 0.000001));
rp3d_test(approxEqual(computePlaneSegmentIntersection(Vector3(5, 12, 0), Vector3(5, 4, 0), 6, Vector3(0, 1, 0)), 0.75, 0.000001));
rp3d_test(approxEqual(computePlaneSegmentIntersection(Vector3(5, 4, 8), Vector3(9, 14, 8), 4, Vector3(0, 1, 0)), 0.0, 0.000001));
decimal tIntersect = computePlaneSegmentIntersection(Vector3(5, 4, 0), Vector3(9, 4, 0), 4, Vector3(0, 1, 0));
test(tIntersect < 0.0 || tIntersect > 1.0);
rp3d_test(tIntersect < 0.0 || tIntersect > 1.0);
// Test computePointToLineDistance()
test(approxEqual(computePointToLineDistance(Vector3(6, 0, 0), Vector3(14, 0, 0), Vector3(5, 3, 0)), 3.0, 0.000001));
test(approxEqual(computePointToLineDistance(Vector3(6, -5, 0), Vector3(10, -5, 0), Vector3(4, 3, 0)), 8.0, 0.000001));
test(approxEqual(computePointToLineDistance(Vector3(6, -5, 0), Vector3(10, -5, 0), Vector3(-43, 254, 0)), 259.0, 0.000001));
test(approxEqual(computePointToLineDistance(Vector3(6, -5, 8), Vector3(10, -5, -5), Vector3(6, -5, 8)), 0.0, 0.000001));
test(approxEqual(computePointToLineDistance(Vector3(6, -5, 8), Vector3(10, -5, -5), Vector3(10, -5, -5)), 0.0, 0.000001));
rp3d_test(approxEqual(computePointToLineDistance(Vector3(6, 0, 0), Vector3(14, 0, 0), Vector3(5, 3, 0)), 3.0, 0.000001));
rp3d_test(approxEqual(computePointToLineDistance(Vector3(6, -5, 0), Vector3(10, -5, 0), Vector3(4, 3, 0)), 8.0, 0.000001));
rp3d_test(approxEqual(computePointToLineDistance(Vector3(6, -5, 0), Vector3(10, -5, 0), Vector3(-43, 254, 0)), 259.0, 0.000001));
rp3d_test(approxEqual(computePointToLineDistance(Vector3(6, -5, 8), Vector3(10, -5, -5), Vector3(6, -5, 8)), 0.0, 0.000001));
rp3d_test(approxEqual(computePointToLineDistance(Vector3(6, -5, 8), Vector3(10, -5, -5), Vector3(10, -5, -5)), 0.0, 0.000001));
// Test clipSegmentWithPlanes()
std::vector<Vector3> segmentVertices;
@ -193,46 +193,46 @@ class TestMathematicsFunctions : public Test {
List<Vector3> clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1],
planesPoints, planesNormals, mAllocator);
test(clipSegmentVertices.size() == 2);
test(approxEqual(clipSegmentVertices[0].x, -6, 0.000001));
test(approxEqual(clipSegmentVertices[0].y, 3, 0.000001));
test(approxEqual(clipSegmentVertices[0].z, 0, 0.000001));
test(approxEqual(clipSegmentVertices[1].x, 4, 0.000001));
test(approxEqual(clipSegmentVertices[1].y, 3, 0.000001));
test(approxEqual(clipSegmentVertices[1].z, 0, 0.000001));
rp3d_test(clipSegmentVertices.size() == 2);
rp3d_test(approxEqual(clipSegmentVertices[0].x, -6, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[0].y, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[0].z, 0, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].x, 4, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].y, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].z, 0, 0.000001));
segmentVertices.clear();
segmentVertices.push_back(Vector3(8, 3, 0));
segmentVertices.push_back(Vector3(-6, 3, 0));
clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1], planesPoints, planesNormals, mAllocator);
test(clipSegmentVertices.size() == 2);
test(approxEqual(clipSegmentVertices[0].x, 4, 0.000001));
test(approxEqual(clipSegmentVertices[0].y, 3, 0.000001));
test(approxEqual(clipSegmentVertices[0].z, 0, 0.000001));
test(approxEqual(clipSegmentVertices[1].x, -6, 0.000001));
test(approxEqual(clipSegmentVertices[1].y, 3, 0.000001));
test(approxEqual(clipSegmentVertices[1].z, 0, 0.000001));
rp3d_test(clipSegmentVertices.size() == 2);
rp3d_test(approxEqual(clipSegmentVertices[0].x, 4, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[0].y, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[0].z, 0, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].x, -6, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].y, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].z, 0, 0.000001));
segmentVertices.clear();
segmentVertices.push_back(Vector3(-6, 3, 0));
segmentVertices.push_back(Vector3(3, 3, 0));
clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1], planesPoints, planesNormals, mAllocator);
test(clipSegmentVertices.size() == 2);
test(approxEqual(clipSegmentVertices[0].x, -6, 0.000001));
test(approxEqual(clipSegmentVertices[0].y, 3, 0.000001));
test(approxEqual(clipSegmentVertices[0].z, 0, 0.000001));
test(approxEqual(clipSegmentVertices[1].x, 3, 0.000001));
test(approxEqual(clipSegmentVertices[1].y, 3, 0.000001));
test(approxEqual(clipSegmentVertices[1].z, 0, 0.000001));
rp3d_test(clipSegmentVertices.size() == 2);
rp3d_test(approxEqual(clipSegmentVertices[0].x, -6, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[0].y, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[0].z, 0, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].x, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].y, 3, 0.000001));
rp3d_test(approxEqual(clipSegmentVertices[1].z, 0, 0.000001));
segmentVertices.clear();
segmentVertices.push_back(Vector3(5, 3, 0));
segmentVertices.push_back(Vector3(8, 3, 0));
clipSegmentVertices = clipSegmentWithPlanes(segmentVertices[0], segmentVertices[1], planesPoints, planesNormals, mAllocator);
test(clipSegmentVertices.size() == 0);
rp3d_test(clipSegmentVertices.size() == 0);
// Test clipPolygonWithPlanes()
List<Vector3> polygonVertices(mAllocator);
@ -253,19 +253,19 @@ class TestMathematicsFunctions : public Test {
polygonPlanesPoints.add(Vector3(10, 5, 0));
List<Vector3> clipPolygonVertices = clipPolygonWithPlanes(polygonVertices, polygonPlanesPoints, polygonPlanesNormals, mAllocator);
test(clipPolygonVertices.size() == 4);
test(approxEqual(clipPolygonVertices[0].x, 0, 0.000001));
test(approxEqual(clipPolygonVertices[0].y, 2, 0.000001));
test(approxEqual(clipPolygonVertices[0].z, 0, 0.000001));
test(approxEqual(clipPolygonVertices[1].x, 7, 0.000001));
test(approxEqual(clipPolygonVertices[1].y, 2, 0.000001));
test(approxEqual(clipPolygonVertices[1].z, 0, 0.000001));
test(approxEqual(clipPolygonVertices[2].x, 7, 0.000001));
test(approxEqual(clipPolygonVertices[2].y, 4, 0.000001));
test(approxEqual(clipPolygonVertices[2].z, 0, 0.000001));
test(approxEqual(clipPolygonVertices[3].x, 0, 0.000001));
test(approxEqual(clipPolygonVertices[3].y, 4, 0.000001));
test(approxEqual(clipPolygonVertices[3].z, 0, 0.000001));
rp3d_test(clipPolygonVertices.size() == 4);
rp3d_test(approxEqual(clipPolygonVertices[0].x, 0, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[0].y, 2, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[0].z, 0, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[1].x, 7, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[1].y, 2, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[1].z, 0, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[2].x, 7, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[2].y, 4, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[2].z, 0, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[3].x, 0, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[3].y, 4, 0.000001));
rp3d_test(approxEqual(clipPolygonVertices[3].z, 0, 0.000001));
}

View File

@ -76,17 +76,17 @@ class TestMatrix2x2 : public Test {
Matrix2x2 test2(2, 3, 4, 5);
Matrix2x2 test3(mMatrix1);
test(test1[0][0] == 5);
test(test1[0][1] == 5);
test(test1[1][0] == 5);
test(test1[1][1] == 5);
rp3d_test(test1[0][0] == 5);
rp3d_test(test1[0][1] == 5);
rp3d_test(test1[1][0] == 5);
rp3d_test(test1[1][1] == 5);
test(test2[0][0] == 2);
test(test2[0][1] == 3);
test(test2[1][0] == 4);
test(test2[1][1] == 5);
rp3d_test(test2[0][0] == 2);
rp3d_test(test2[0][1] == 3);
rp3d_test(test2[1][0] == 4);
rp3d_test(test2[1][1] == 5);
test(test3 == mMatrix1);
rp3d_test(test3 == mMatrix1);
}
/// Test the getter and setter methods
@ -95,23 +95,23 @@ class TestMatrix2x2 : public Test {
// Test method to set all the values
Matrix2x2 test2;
test2.setAllValues(2, 24, -4, 5);
test(test2 == mMatrix1);
rp3d_test(test2 == mMatrix1);
// Test method to set to zero
test2.setToZero();
test(test2 == Matrix2x2(0, 0, 0, 0));
rp3d_test(test2 == Matrix2x2(0, 0, 0, 0));
// Test method that returns a column
Vector2 column1 = mMatrix1.getColumn(0);
Vector2 column2 = mMatrix1.getColumn(1);
test(column1 == Vector2(2, -4));
test(column2 == Vector2(24, 5));
rp3d_test(column1 == Vector2(2, -4));
rp3d_test(column2 == Vector2(24, 5));
// Test method that returns a row
Vector2 row1 = mMatrix1.getRow(0);
Vector2 row2 = mMatrix1.getRow(1);
test(row1 == Vector2(2, 24));
test(row2 == Vector2(-4, 5));
rp3d_test(row1 == Vector2(2, 24));
rp3d_test(row2 == Vector2(-4, 5));
}
/// Test the identity methods
@ -121,12 +121,12 @@ class TestMatrix2x2 : public Test {
Matrix2x2 test1;
test1.setToIdentity();
test(identity[0][0] == 1);
test(identity[0][1] == 0);
test(identity[1][0] == 0);
test(identity[1][1] == 1);
rp3d_test(identity[0][0] == 1);
rp3d_test(identity[0][1] == 0);
rp3d_test(identity[1][0] == 0);
rp3d_test(identity[1][1] == 1);
test(test1 == Matrix2x2::identity());
rp3d_test(test1 == Matrix2x2::identity());
}
/// Test the zero method
@ -134,10 +134,10 @@ class TestMatrix2x2 : public Test {
Matrix2x2 zero = Matrix2x2::zero();
test(zero[0][0] == 0);
test(zero[0][1] == 0);
test(zero[1][0] == 0);
test(zero[1][1] == 0);
rp3d_test(zero[0][0] == 0);
rp3d_test(zero[0][1] == 0);
rp3d_test(zero[1][0] == 0);
rp3d_test(zero[1][1] == 0);
}
/// Test others methods
@ -145,36 +145,36 @@ class TestMatrix2x2 : public Test {
// Test transpose
Matrix2x2 transpose = mMatrix1.getTranspose();
test(transpose == Matrix2x2(2, -4, 24, 5));
rp3d_test(transpose == Matrix2x2(2, -4, 24, 5));
// Test trace
test(mMatrix1.getTrace() ==7);
test(Matrix2x2::identity().getTrace() == 2);
rp3d_test(mMatrix1.getTrace() ==7);
rp3d_test(Matrix2x2::identity().getTrace() == 2);
// Test determinant
Matrix2x2 matrix(-24, 64, 253, -35);
test(mMatrix1.getDeterminant() == 106);
test(matrix.getDeterminant() == -15352);
test(mIdentity.getDeterminant() == 1);
rp3d_test(mMatrix1.getDeterminant() == 106);
rp3d_test(matrix.getDeterminant() == -15352);
rp3d_test(mIdentity.getDeterminant() == 1);
// Test inverse
Matrix2x2 matrix2(1, 2, 3, 4);
Matrix2x2 inverseMatrix = matrix2.getInverse();
test(approxEqual(inverseMatrix[0][0], decimal(-2), decimal(10e-6)));
test(approxEqual(inverseMatrix[0][1], decimal(1), decimal(10e-6)));
test(approxEqual(inverseMatrix[1][0], decimal(1.5), decimal(10e-6)));
test(approxEqual(inverseMatrix[1][1], decimal(-0.5), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[0][0], decimal(-2), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[0][1], decimal(1), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[1][0], decimal(1.5), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[1][1], decimal(-0.5), decimal(10e-6)));
Matrix2x2 inverseMatrix1 = mMatrix1.getInverse();
test(approxEqual(inverseMatrix1[0][0], decimal(0.047169811), decimal(10e-6)));
test(approxEqual(inverseMatrix1[0][1], decimal(-0.226415094), decimal(10e-6)));
test(approxEqual(inverseMatrix1[1][0], decimal(0.037735849), decimal(10e-6)));
test(approxEqual(inverseMatrix1[1][1], decimal(0.018867925), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[0][0], decimal(0.047169811), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[0][1], decimal(-0.226415094), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[1][0], decimal(0.037735849), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[1][1], decimal(0.018867925), decimal(10e-6)));
// Test absolute matrix
Matrix2x2 matrix3(-2, -3, -4, -5);
test(matrix.getAbsoluteMatrix() == Matrix2x2(24, 64, 253, 35));
rp3d_test(matrix.getAbsoluteMatrix() == Matrix2x2(24, 64, 253, 35));
Matrix2x2 absoluteMatrix = matrix3.getAbsoluteMatrix();
test(absoluteMatrix == Matrix2x2(2, 3, 4, 5));
rp3d_test(absoluteMatrix == Matrix2x2(2, 3, 4, 5));
}
/// Test the operators
@ -186,54 +186,54 @@ class TestMatrix2x2 : public Test {
Matrix2x2 addition1 = matrix1 + matrix2;
Matrix2x2 addition2(matrix1);
addition2 += matrix2;
test(addition1 == Matrix2x2(0, 6, -1, 15));
test(addition2 == Matrix2x2(0, 6, -1, 15));
rp3d_test(addition1 == Matrix2x2(0, 6, -1, 15));
rp3d_test(addition2 == Matrix2x2(0, 6, -1, 15));
// Test substraction
Matrix2x2 substraction1 = matrix1 - matrix2;
Matrix2x2 substraction2(matrix1);
substraction2 -= matrix2;
test(substraction1 == Matrix2x2(4, 0, 9, -5));
test(substraction2 == Matrix2x2(4, 0, 9, -5));
rp3d_test(substraction1 == Matrix2x2(4, 0, 9, -5));
rp3d_test(substraction2 == Matrix2x2(4, 0, 9, -5));
// Test negative operator
Matrix2x2 negative = -matrix1;
test(negative == Matrix2x2(-2, -3, -4, -5));
rp3d_test(negative == Matrix2x2(-2, -3, -4, -5));
// Test multiplication with a number
Matrix2x2 multiplication1 = 3 * matrix1;
Matrix2x2 multiplication2 = matrix1 * 3;
Matrix2x2 multiplication3(matrix1);
multiplication3 *= 3;
test(multiplication1 == Matrix2x2(6, 9, 12, 15));
test(multiplication2 == Matrix2x2(6, 9, 12, 15));
test(multiplication3 == Matrix2x2(6, 9, 12, 15));
rp3d_test(multiplication1 == Matrix2x2(6, 9, 12, 15));
rp3d_test(multiplication2 == Matrix2x2(6, 9, 12, 15));
rp3d_test(multiplication3 == Matrix2x2(6, 9, 12, 15));
// Test multiplication with a matrix
Matrix2x2 multiplication4 = matrix1 * matrix2;
Matrix2x2 multiplication5 = matrix2 * matrix1;
test(multiplication4 == Matrix2x2(-19, 36, -33, 62));
test(multiplication5 == Matrix2x2(8, 9, 30, 35));
rp3d_test(multiplication4 == Matrix2x2(-19, 36, -33, 62));
rp3d_test(multiplication5 == Matrix2x2(8, 9, 30, 35));
// Test multiplication with a vector
Vector2 vector1(3, -32);
Vector2 vector2(-31, -422);
Vector2 test1 = matrix1 * vector1;
Vector2 test2 = matrix2 * vector2;
test(test1 == Vector2(-90, -148));
test(test2 == Vector2(-1204, -4065));
rp3d_test(test1 == Vector2(-90, -148));
rp3d_test(test2 == Vector2(-1204, -4065));
// Test equality operators
test(Matrix2x2(34, 38, 43, 64) ==
rp3d_test(Matrix2x2(34, 38, 43, 64) ==
Matrix2x2(34, 38, 43, 64));
test(Matrix2x2(34, 64, 43, 7) !=
rp3d_test(Matrix2x2(34, 64, 43, 7) !=
Matrix2x2(34, 38, 43, 64));
// Test operator to read a value
test(mMatrix1[0][0] == 2);
test(mMatrix1[0][1] == 24);
test(mMatrix1[1][0] == -4);
test(mMatrix1[1][1] == 5);
rp3d_test(mMatrix1[0][0] == 2);
rp3d_test(mMatrix1[0][1] == 24);
rp3d_test(mMatrix1[1][0] == -4);
rp3d_test(mMatrix1[1][1] == 5);
// Test operator to set a value
Matrix2x2 test3;
@ -241,7 +241,7 @@ class TestMatrix2x2 : public Test {
test3[0][1] = 24;
test3[1][0] = -4;
test3[1][1] = 5;
test(test3 == mMatrix1);
rp3d_test(test3 == mMatrix1);
}
};

View File

@ -77,27 +77,27 @@ class TestMatrix3x3 : public Test {
Matrix3x3 test1(5.0);
Matrix3x3 test2(2, 3, 4, 5, 6, 7, 8, 9, 10);
Matrix3x3 test3(mMatrix1);
test(test1[0][0] == 5);
test(test1[0][1] == 5);
test(test1[0][2] == 5);
test(test1[1][0] == 5);
test(test1[1][1] == 5);
test(test1[1][2] == 5);
test(test1[2][0] == 5);
test(test1[2][1] == 5);
test(test1[2][2] == 5);
rp3d_test(test1[0][0] == 5);
rp3d_test(test1[0][1] == 5);
rp3d_test(test1[0][2] == 5);
rp3d_test(test1[1][0] == 5);
rp3d_test(test1[1][1] == 5);
rp3d_test(test1[1][2] == 5);
rp3d_test(test1[2][0] == 5);
rp3d_test(test1[2][1] == 5);
rp3d_test(test1[2][2] == 5);
test(test2[0][0] == 2);
test(test2[0][1] == 3);
test(test2[0][2] == 4);
test(test2[1][0] == 5);
test(test2[1][1] == 6);
test(test2[1][2] == 7);
test(test2[2][0] == 8);
test(test2[2][1] == 9);
test(test2[2][2] == 10);
rp3d_test(test2[0][0] == 2);
rp3d_test(test2[0][1] == 3);
rp3d_test(test2[0][2] == 4);
rp3d_test(test2[1][0] == 5);
rp3d_test(test2[1][1] == 6);
rp3d_test(test2[1][2] == 7);
rp3d_test(test2[2][0] == 8);
rp3d_test(test2[2][1] == 9);
rp3d_test(test2[2][2] == 10);
test(test3 == mMatrix1);
rp3d_test(test3 == mMatrix1);
}
/// Test the getter and setter methods
@ -106,27 +106,27 @@ class TestMatrix3x3 : public Test {
// Test method to set all the values
Matrix3x3 test2;
test2.setAllValues(2, 24, 4, 5, -6, 234, -15, 11, 66);
test(test2 == mMatrix1);
rp3d_test(test2 == mMatrix1);
// Test method to set to zero
test2.setToZero();
test(test2 == Matrix3x3(0, 0, 0, 0, 0, 0, 0, 0, 0));
rp3d_test(test2 == Matrix3x3(0, 0, 0, 0, 0, 0, 0, 0, 0));
// Test method that returns a column
Vector3 column1 = mMatrix1.getColumn(0);
Vector3 column2 = mMatrix1.getColumn(1);
Vector3 column3 = mMatrix1.getColumn(2);
test(column1 == Vector3(2, 5, -15));
test(column2 == Vector3(24, -6, 11));
test(column3 == Vector3(4, 234, 66));
rp3d_test(column1 == Vector3(2, 5, -15));
rp3d_test(column2 == Vector3(24, -6, 11));
rp3d_test(column3 == Vector3(4, 234, 66));
// Test method that returns a row
Vector3 row1 = mMatrix1.getRow(0);
Vector3 row2 = mMatrix1.getRow(1);
Vector3 row3 = mMatrix1.getRow(2);
test(row1 == Vector3(2, 24, 4));
test(row2 == Vector3(5, -6, 234));
test(row3 == Vector3(-15, 11, 66));
rp3d_test(row1 == Vector3(2, 24, 4));
rp3d_test(row2 == Vector3(5, -6, 234));
rp3d_test(row3 == Vector3(-15, 11, 66));
}
/// Test the identity methods
@ -136,17 +136,17 @@ class TestMatrix3x3 : public Test {
Matrix3x3 test1;
test1.setToIdentity();
test(identity[0][0] == 1);
test(identity[0][1] == 0);
test(identity[0][2] == 0);
test(identity[1][0] == 0);
test(identity[1][1] == 1);
test(identity[1][2] == 0);
test(identity[2][0] == 0);
test(identity[2][1] == 0);
test(identity[2][2] == 1);
rp3d_test(identity[0][0] == 1);
rp3d_test(identity[0][1] == 0);
rp3d_test(identity[0][2] == 0);
rp3d_test(identity[1][0] == 0);
rp3d_test(identity[1][1] == 1);
rp3d_test(identity[1][2] == 0);
rp3d_test(identity[2][0] == 0);
rp3d_test(identity[2][1] == 0);
rp3d_test(identity[2][2] == 1);
test(test1 == Matrix3x3::identity());
rp3d_test(test1 == Matrix3x3::identity());
}
/// Test the zero method
@ -154,15 +154,15 @@ class TestMatrix3x3 : public Test {
Matrix3x3 zero = Matrix3x3::zero();
test(zero[0][0] == 0);
test(zero[0][1] == 0);
test(zero[0][2] == 0);
test(zero[1][0] == 0);
test(zero[1][1] == 0);
test(zero[1][2] == 0);
test(zero[2][0] == 0);
test(zero[2][1] == 0);
test(zero[2][2] == 0);
rp3d_test(zero[0][0] == 0);
rp3d_test(zero[0][1] == 0);
rp3d_test(zero[0][2] == 0);
rp3d_test(zero[1][0] == 0);
rp3d_test(zero[1][1] == 0);
rp3d_test(zero[1][2] == 0);
rp3d_test(zero[2][0] == 0);
rp3d_test(zero[2][1] == 0);
rp3d_test(zero[2][2] == 0);
}
/// Test others methods
@ -170,54 +170,54 @@ class TestMatrix3x3 : public Test {
// Test transpose
Matrix3x3 transpose = mMatrix1.getTranspose();
test(transpose == Matrix3x3(2, 5, -15, 24, -6, 11, 4, 234, 66));
rp3d_test(transpose == Matrix3x3(2, 5, -15, 24, -6, 11, 4, 234, 66));
// Test trace
test(mMatrix1.getTrace() == 62);
test(Matrix3x3::identity().getTrace() == 3);
rp3d_test(mMatrix1.getTrace() == 62);
rp3d_test(Matrix3x3::identity().getTrace() == 3);
// Test determinant
Matrix3x3 matrix(-24, 64, 253, -35, 52, 72, 21, -35, -363);
test(mMatrix1.getDeterminant() == -98240);
test(matrix.getDeterminant() == -290159);
test(mIdentity.getDeterminant() == 1);
rp3d_test(mMatrix1.getDeterminant() == -98240);
rp3d_test(matrix.getDeterminant() == -290159);
rp3d_test(mIdentity.getDeterminant() == 1);
// Test inverse
Matrix3x3 inverseMatrix = matrix.getInverse();
test(approxEqual(inverseMatrix[0][0], decimal(0.056369), decimal(10e-6)));
test(approxEqual(inverseMatrix[0][1], decimal(-0.049549), decimal(10e-6)));
test(approxEqual(inverseMatrix[0][2], decimal(0.029460), decimal(10e-6)));
test(approxEqual(inverseMatrix[1][0], decimal(0.038575), decimal(10e-6)));
test(approxEqual(inverseMatrix[1][1], decimal(-0.011714), decimal(10e-6)));
test(approxEqual(inverseMatrix[1][2], decimal(0.024562), decimal(10e-6)));
test(approxEqual(inverseMatrix[2][0], decimal(-0.000458), decimal(10e-6)));
test(approxEqual(inverseMatrix[2][1], decimal(-0.001737), decimal(10e-6)));
test(approxEqual(inverseMatrix[2][2], decimal(-0.003419), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[0][0], decimal(0.056369), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[0][1], decimal(-0.049549), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[0][2], decimal(0.029460), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[1][0], decimal(0.038575), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[1][1], decimal(-0.011714), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[1][2], decimal(0.024562), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[2][0], decimal(-0.000458), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[2][1], decimal(-0.001737), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix[2][2], decimal(-0.003419), decimal(10e-6)));
Matrix3x3 inverseMatrix1 = mMatrix1.getInverse();
test(approxEqual(inverseMatrix1[0][0], decimal(0.030232), decimal(10e-6)));
test(approxEqual(inverseMatrix1[0][1], decimal(0.015676), decimal(10e-6)));
test(approxEqual(inverseMatrix1[0][2], decimal(-0.057410), decimal(10e-6)));
test(approxEqual(inverseMatrix1[1][0], decimal(0.039088), decimal(10e-6)));
test(approxEqual(inverseMatrix1[1][1], decimal(-0.001954), decimal(10e-6)));
test(approxEqual(inverseMatrix1[1][2], decimal(0.004560), decimal(10e-6)));
test(approxEqual(inverseMatrix1[2][0], decimal(0.000356), decimal(10e-6)));
test(approxEqual(inverseMatrix1[2][1], decimal(0.003888), decimal(10e-6)));
test(approxEqual(inverseMatrix1[2][2], decimal(0.001344), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[0][0], decimal(0.030232), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[0][1], decimal(0.015676), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[0][2], decimal(-0.057410), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[1][0], decimal(0.039088), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[1][1], decimal(-0.001954), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[1][2], decimal(0.004560), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[2][0], decimal(0.000356), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[2][1], decimal(0.003888), decimal(10e-6)));
rp3d_test(approxEqual(inverseMatrix1[2][2], decimal(0.001344), decimal(10e-6)));
// Test absolute matrix
Matrix3x3 matrix2(-2, -3, -4, -5, -6, -7, -8, -9, -10);
test(matrix.getAbsoluteMatrix() == Matrix3x3(24, 64, 253, 35, 52, 72, 21, 35, 363));
rp3d_test(matrix.getAbsoluteMatrix() == Matrix3x3(24, 64, 253, 35, 52, 72, 21, 35, 363));
Matrix3x3 absoluteMatrix = matrix2.getAbsoluteMatrix();
test(absoluteMatrix == Matrix3x3(2, 3, 4, 5, 6, 7, 8, 9, 10));
rp3d_test(absoluteMatrix == Matrix3x3(2, 3, 4, 5, 6, 7, 8, 9, 10));
// Test method that computes skew-symmetric matrix for cross product
Vector3 vector1(3, -5, 6);
Vector3 vector2(73, 42, 26);
Matrix3x3 skewMatrix = Matrix3x3::computeSkewSymmetricMatrixForCrossProduct(vector1);
test(skewMatrix == Matrix3x3(0, -6, -5, 6, 0, -3, 5, 3, 0));
rp3d_test(skewMatrix == Matrix3x3(0, -6, -5, 6, 0, -3, 5, 3, 0));
Vector3 crossProduct1 = vector1.cross(vector2);
Vector3 crossProduct2 = skewMatrix * vector2;
test(crossProduct1 == crossProduct2);
rp3d_test(crossProduct1 == crossProduct2);
}
/// Test the operators
@ -229,59 +229,59 @@ class TestMatrix3x3 : public Test {
Matrix3x3 addition1 = matrix1 + matrix2;
Matrix3x3 addition2(matrix1);
addition2 += matrix2;
test(addition1 == Matrix3x3(0, 6, -1, 15, 10, 14, 10, 14, 18));
test(addition2 == Matrix3x3(0, 6, -1, 15, 10, 14, 10, 14, 18));
rp3d_test(addition1 == Matrix3x3(0, 6, -1, 15, 10, 14, 10, 14, 18));
rp3d_test(addition2 == Matrix3x3(0, 6, -1, 15, 10, 14, 10, 14, 18));
// Test substraction
Matrix3x3 substraction1 = matrix1 - matrix2;
Matrix3x3 substraction2(matrix1);
substraction2 -= matrix2;
test(substraction1 == Matrix3x3(4, 0, 9, -5, 2, 0, 6, 4, 2));
test(substraction2 == Matrix3x3(4, 0, 9, -5, 2, 0, 6, 4, 2));
rp3d_test(substraction1 == Matrix3x3(4, 0, 9, -5, 2, 0, 6, 4, 2));
rp3d_test(substraction2 == Matrix3x3(4, 0, 9, -5, 2, 0, 6, 4, 2));
// Test negative operator
Matrix3x3 negative = -matrix1;
test(negative == Matrix3x3(-2, -3, -4, -5, -6, -7, -8, -9, -10));
rp3d_test(negative == Matrix3x3(-2, -3, -4, -5, -6, -7, -8, -9, -10));
// Test multiplication with a number
Matrix3x3 multiplication1 = 3 * matrix1;
Matrix3x3 multiplication2 = matrix1 * 3;
Matrix3x3 multiplication3(matrix1);
multiplication3 *= 3;
test(multiplication1 == Matrix3x3(6, 9, 12, 15, 18, 21, 24, 27, 30));
test(multiplication2 == Matrix3x3(6, 9, 12, 15, 18, 21, 24, 27, 30));
test(multiplication3 == Matrix3x3(6, 9, 12, 15, 18, 21, 24, 27, 30));
rp3d_test(multiplication1 == Matrix3x3(6, 9, 12, 15, 18, 21, 24, 27, 30));
rp3d_test(multiplication2 == Matrix3x3(6, 9, 12, 15, 18, 21, 24, 27, 30));
rp3d_test(multiplication3 == Matrix3x3(6, 9, 12, 15, 18, 21, 24, 27, 30));
// Test multiplication with a matrix
Matrix3x3 multiplication4 = matrix1 * matrix2;
Matrix3x3 multiplication5 = matrix2 * matrix1;
test(multiplication4 == Matrix3x3(34, 38, 43, 64, 74, 73, 94, 110, 103));
test(multiplication5 == Matrix3x3(-29, -33, -37, 96, 117, 138, 93, 108, 123));
rp3d_test(multiplication4 == Matrix3x3(34, 38, 43, 64, 74, 73, 94, 110, 103));
rp3d_test(multiplication5 == Matrix3x3(-29, -33, -37, 96, 117, 138, 93, 108, 123));
// Test multiplication with a vector
Vector3 vector1(3, -32, 59);
Vector3 vector2(-31, -422, 34);
Vector3 test1 = matrix1 * vector1;
Vector3 test2 = matrix2 * vector2;
test(test1 == Vector3(146, 236, 326));
test(test2 == Vector3(-1374, -1760, -1900));
rp3d_test(test1 == Vector3(146, 236, 326));
rp3d_test(test2 == Vector3(-1374, -1760, -1900));
// Test equality operators
test(Matrix3x3(34, 38, 43, 64, 74, 73, 94, 110, 103) ==
rp3d_test(Matrix3x3(34, 38, 43, 64, 74, 73, 94, 110, 103) ==
Matrix3x3(34, 38, 43, 64, 74, 73, 94, 110, 103));
test(Matrix3x3(34, 64, 43, 7, -1, 73, 94, 110, 103) !=
rp3d_test(Matrix3x3(34, 64, 43, 7, -1, 73, 94, 110, 103) !=
Matrix3x3(34, 38, 43, 64, 74, 73, 94, 110, 103));
// Test operator to read a value
test(mMatrix1[0][0] == 2);
test(mMatrix1[0][1] == 24);
test(mMatrix1[0][2] == 4);
test(mMatrix1[1][0] == 5);
test(mMatrix1[1][1] == -6);
test(mMatrix1[1][2] == 234);
test(mMatrix1[2][0] == -15);
test(mMatrix1[2][1] == 11);
test(mMatrix1[2][2] == 66);
rp3d_test(mMatrix1[0][0] == 2);
rp3d_test(mMatrix1[0][1] == 24);
rp3d_test(mMatrix1[0][2] == 4);
rp3d_test(mMatrix1[1][0] == 5);
rp3d_test(mMatrix1[1][1] == -6);
rp3d_test(mMatrix1[1][2] == 234);
rp3d_test(mMatrix1[2][0] == -15);
rp3d_test(mMatrix1[2][1] == 11);
rp3d_test(mMatrix1[2][2] == 66);
// Test operator to set a value
Matrix3x3 test3;
@ -294,7 +294,7 @@ class TestMatrix3x3 : public Test {
test3[2][0] = -15;
test3[2][1] = 11;
test3[2][2] = 66;
test(test3 == mMatrix1);
rp3d_test(test3 == mMatrix1);
}
};

View File

@ -76,19 +76,19 @@ class TestQuaternion : public Test {
void testConstructors() {
Quaternion quaternion1(mQuaternion1);
test(mQuaternion1 == quaternion1);
rp3d_test(mQuaternion1 == quaternion1);
Quaternion quaternion2(4, 5, 6, 7);
test(quaternion2 == Quaternion(4, 5, 6, 7));
rp3d_test(quaternion2 == Quaternion(4, 5, 6, 7));
Quaternion quaternion3(8, Vector3(3, 5, 2));
test(quaternion3 == Quaternion(3, 5, 2, 8));
rp3d_test(quaternion3 == Quaternion(3, 5, 2, 8));
Quaternion quaternion4(mQuaternion1.getMatrix());
test(approxEqual(quaternion4.x, mQuaternion1.x));
test(approxEqual(quaternion4.y, mQuaternion1.y));
test(approxEqual(quaternion4.z, mQuaternion1.z));
test(approxEqual(quaternion4.w, mQuaternion1.w));
rp3d_test(approxEqual(quaternion4.x, mQuaternion1.x));
rp3d_test(approxEqual(quaternion4.y, mQuaternion1.y));
rp3d_test(approxEqual(quaternion4.z, mQuaternion1.z));
rp3d_test(approxEqual(quaternion4.w, mQuaternion1.w));
// Test conversion from Euler angles to quaternion
@ -97,26 +97,26 @@ class TestQuaternion : public Test {
Quaternion quaternion5 = Quaternion::fromEulerAngles(PI_OVER_2, 0, 0);
Quaternion quaternionTest5(std::sin(PI_OVER_4), 0, 0, std::cos(PI_OVER_4));
quaternionTest5.normalize();
test(approxEqual(quaternion5.x, quaternionTest5.x));
test(approxEqual(quaternion5.y, quaternionTest5.y));
test(approxEqual(quaternion5.z, quaternionTest5.z));
test(approxEqual(quaternion5.w, quaternionTest5.w));
rp3d_test(approxEqual(quaternion5.x, quaternionTest5.x));
rp3d_test(approxEqual(quaternion5.y, quaternionTest5.y));
rp3d_test(approxEqual(quaternion5.z, quaternionTest5.z));
rp3d_test(approxEqual(quaternion5.w, quaternionTest5.w));
Quaternion quaternion6 = Quaternion::fromEulerAngles(0, PI_OVER_2, 0);
Quaternion quaternionTest6(0, std::sin(PI_OVER_4), 0, std::cos(PI_OVER_4));
quaternionTest6.normalize();
test(approxEqual(quaternion6.x, quaternionTest6.x));
test(approxEqual(quaternion6.y, quaternionTest6.y));
test(approxEqual(quaternion6.z, quaternionTest6.z));
test(approxEqual(quaternion6.w, quaternionTest6.w));
rp3d_test(approxEqual(quaternion6.x, quaternionTest6.x));
rp3d_test(approxEqual(quaternion6.y, quaternionTest6.y));
rp3d_test(approxEqual(quaternion6.z, quaternionTest6.z));
rp3d_test(approxEqual(quaternion6.w, quaternionTest6.w));
Quaternion quaternion7 = Quaternion::fromEulerAngles(Vector3(0, 0, PI_OVER_2));
Quaternion quaternionTest7(0, 0, std::sin(PI_OVER_4), std::cos(PI_OVER_4));
quaternionTest7.normalize();
test(approxEqual(quaternion7.x, quaternionTest7.x));
test(approxEqual(quaternion7.y, quaternionTest7.y));
test(approxEqual(quaternion7.z, quaternionTest7.z));
test(approxEqual(quaternion7.w, quaternionTest7.w));
rp3d_test(approxEqual(quaternion7.x, quaternionTest7.x));
rp3d_test(approxEqual(quaternion7.y, quaternionTest7.y));
rp3d_test(approxEqual(quaternion7.z, quaternionTest7.z));
rp3d_test(approxEqual(quaternion7.w, quaternionTest7.w));
}
/// Test unit, length, normalize methods
@ -124,15 +124,15 @@ class TestQuaternion : public Test {
// Test method that returns the length
Quaternion quaternion(2, 3, -4, 5);
test(approxEqual(quaternion.length(), std::sqrt(decimal(54.0))));
rp3d_test(approxEqual(quaternion.length(), std::sqrt(decimal(54.0))));
// Test method that returns a unit quaternion
test(approxEqual(quaternion.getUnit().length(), 1.0));
rp3d_test(approxEqual(quaternion.getUnit().length(), 1.0));
// Test the normalization method
Quaternion quaternion2(4, 5, 6, 7);
quaternion2.normalize();
test(approxEqual(quaternion2.length(), 1.0));
rp3d_test(approxEqual(quaternion2.length(), 1.0));
}
/// Test others methods
@ -141,80 +141,80 @@ class TestQuaternion : public Test {
// Test the method to set the values
Quaternion quaternion;
quaternion.setAllValues(1, 2, 3, 4);
test(quaternion == Quaternion(1, 2, 3, 4));
rp3d_test(quaternion == Quaternion(1, 2, 3, 4));
// Test the method to set the quaternion to zero
quaternion.setToZero();
test(quaternion == Quaternion(0, 0, 0, 0));
rp3d_test(quaternion == Quaternion(0, 0, 0, 0));
// Tes the methods to get or set to identity
Quaternion identity1(1, 2, 3, 4);
identity1.setToIdentity();
test(identity1 == Quaternion(0, 0, 0, 1));
test(Quaternion::identity() == Quaternion(0, 0, 0, 1));
rp3d_test(identity1 == Quaternion(0, 0, 0, 1));
rp3d_test(Quaternion::identity() == Quaternion(0, 0, 0, 1));
// Test the method to get the vector (x, y, z)
Vector3 v = mQuaternion1.getVectorV();
test(v.x == mQuaternion1.x);
test(v.y == mQuaternion1.y);
test(v.z == mQuaternion1.z);
rp3d_test(v.x == mQuaternion1.x);
rp3d_test(v.y == mQuaternion1.y);
rp3d_test(v.z == mQuaternion1.z);
// Test the conjugate method
Quaternion conjugate = mQuaternion1.getConjugate();
test(conjugate.x == -mQuaternion1.x);
test(conjugate.y == -mQuaternion1.y);
test(conjugate.z == -mQuaternion1.z);
test(conjugate.w == mQuaternion1.w);
rp3d_test(conjugate.x == -mQuaternion1.x);
rp3d_test(conjugate.y == -mQuaternion1.y);
rp3d_test(conjugate.z == -mQuaternion1.z);
rp3d_test(conjugate.w == mQuaternion1.w);
// Test the inverse methods
Quaternion inverse1 = mQuaternion1.getInverse();
Quaternion inverse2(mQuaternion1);
inverse2.inverse();
test(inverse2 == inverse1);
rp3d_test(inverse2 == inverse1);
Quaternion product = mQuaternion1 * inverse1;
test(approxEqual(product.x, mIdentity.x, decimal(10e-6)));
test(approxEqual(product.y, mIdentity.y, decimal(10e-6)));
test(approxEqual(product.z, mIdentity.z, decimal(10e-6)));
test(approxEqual(product.w, mIdentity.w, decimal(10e-6)));
rp3d_test(approxEqual(product.x, mIdentity.x, decimal(10e-6)));
rp3d_test(approxEqual(product.y, mIdentity.y, decimal(10e-6)));
rp3d_test(approxEqual(product.z, mIdentity.z, decimal(10e-6)));
rp3d_test(approxEqual(product.w, mIdentity.w, decimal(10e-6)));
// Test the dot product
Quaternion quaternion1(2, 3, 4, 5);
Quaternion quaternion2(6, 7, 8, 9);
decimal dotProduct = quaternion1.dot(quaternion2);
test(dotProduct == 110);
rp3d_test(dotProduct == 110);
// Test the method that returns the rotation angle and axis
Vector3 axis;
decimal angle;
Vector3 originalAxis = Vector3(2, 3, 4).getUnit();
mQuaternion1.getRotationAngleAxis(angle, axis);
test(approxEqual(axis.x, originalAxis.x));
test(approxEqual(angle, decimal(PI/4.0), decimal(10e-6)));
rp3d_test(approxEqual(axis.x, originalAxis.x));
rp3d_test(approxEqual(angle, decimal(PI/4.0), decimal(10e-6)));
// Test the method that returns the corresponding matrix
Matrix3x3 matrix = mQuaternion1.getMatrix();
Vector3 vector(56, -2, 82);
Vector3 vector1 = matrix * vector;
Vector3 vector2 = mQuaternion1 * vector;
test(approxEqual(vector1.x, vector2.x, decimal(10e-6)));
test(approxEqual(vector1.y, vector2.y, decimal(10e-6)));
test(approxEqual(vector1.z, vector2.z, decimal(10e-6)));
rp3d_test(approxEqual(vector1.x, vector2.x, decimal(10e-6)));
rp3d_test(approxEqual(vector1.y, vector2.y, decimal(10e-6)));
rp3d_test(approxEqual(vector1.z, vector2.z, decimal(10e-6)));
// Test slerp method
Quaternion quatStart = quaternion1.getUnit();
Quaternion quatEnd = quaternion2.getUnit();
Quaternion test1 = Quaternion::slerp(quatStart, quatEnd, 0.0);
Quaternion test2 = Quaternion::slerp(quatStart, quatEnd, 1.0);
test(test1 == quatStart);
test(test2 == quatEnd);
rp3d_test(test1 == quatStart);
rp3d_test(test2 == quatEnd);
decimal sinA = sin(decimal(PI/4.0));
decimal cosA = cos(decimal(PI/4.0));
Quaternion quat(sinA, 0, 0, cosA);
Quaternion test3 = Quaternion::slerp(mIdentity, quat, decimal(0.5));
test(approxEqual(test3.x, sin(decimal(PI/8.0))));
test(approxEqual(test3.y, 0.0));
test(approxEqual(test3.z, 0.0));
test(approxEqual(test3.w, cos(decimal(PI/8.0)), decimal(10e-6)));
rp3d_test(approxEqual(test3.x, sin(decimal(PI/8.0))));
rp3d_test(approxEqual(test3.y, 0.0));
rp3d_test(approxEqual(test3.z, 0.0));
rp3d_test(approxEqual(test3.w, cos(decimal(PI/8.0)), decimal(10e-6)));
}
/// Test overloaded operators
@ -226,43 +226,43 @@ class TestQuaternion : public Test {
Quaternion test1 = quat1 + quat2;
Quaternion test11(-6, 52, 2, 8);
test11 += quat1;
test(test1 == Quaternion(2, 12, 10, 13));
test(test11 == Quaternion(-2, 57, 4, 18));
rp3d_test(test1 == Quaternion(2, 12, 10, 13));
rp3d_test(test11 == Quaternion(-2, 57, 4, 18));
// Test substraction
Quaternion test2 = quat1 - quat2;
Quaternion test22(-73, 62, 25, 9);
test22 -= quat1;
test(test2 == Quaternion(6, -2, -6, 7));
test(test22 == Quaternion(-77, 57, 23, -1));
rp3d_test(test2 == Quaternion(6, -2, -6, 7));
rp3d_test(test22 == Quaternion(-77, 57, 23, -1));
// Test multiplication with a number
Quaternion test3 = quat1 * 3.0;
test(test3 == Quaternion(12, 15, 6, 30));
rp3d_test(test3 == Quaternion(12, 15, 6, 30));
// Test multiplication between two quaternions
Quaternion test4 = quat1 * quat2;
Quaternion test5 = mQuaternion1 * mIdentity;
test(test4 == Quaternion(18, 49, 124, -13));
test(test5 == mQuaternion1);
rp3d_test(test4 == Quaternion(18, 49, 124, -13));
rp3d_test(test5 == mQuaternion1);
// Test multiplication between a quaternion and a point
Vector3 point(5, -24, 563);
Vector3 vector1 = mIdentity * point;
Vector3 vector2 = mQuaternion1 * point;
Vector3 testVector2 = mQuaternion1.getMatrix() * point;
test(vector1 == point);
test(approxEqual(vector2.x, testVector2.x, decimal(10e-5)));
test(approxEqual(vector2.y, testVector2.y, decimal(10e-5)));
test(approxEqual(vector2.z, testVector2.z, decimal(10e-5)));
rp3d_test(vector1 == point);
rp3d_test(approxEqual(vector2.x, testVector2.x, decimal(10e-5)));
rp3d_test(approxEqual(vector2.y, testVector2.y, decimal(10e-5)));
rp3d_test(approxEqual(vector2.z, testVector2.z, decimal(10e-5)));
// Test assignment operator
Quaternion quaternion;
quaternion = mQuaternion1;
test(quaternion == mQuaternion1);
rp3d_test(quaternion == mQuaternion1);
// Test equality operator
test(mQuaternion1 == mQuaternion1);
rp3d_test(mQuaternion1 == mQuaternion1);
}
};

View File

@ -90,25 +90,25 @@ class TestTransform : public Test {
Transform transform1(Vector3(1, 2, 3), Quaternion(6, 7, 8, 9));
Transform transform2(Vector3(4, 5, 6), Matrix3x3(1, 0, 0, 0, 1, 0, 0, 0, 1));
Transform transform3(transform1);
test(transform1.getPosition() == Vector3(1, 2, 3));
test(transform1.getOrientation() == Quaternion(6, 7, 8, 9));
test(transform2.getPosition() == Vector3(4, 5, 6));
test(transform2.getOrientation() == Quaternion::identity());
test(transform3 == transform1);
rp3d_test(transform1.getPosition() == Vector3(1, 2, 3));
rp3d_test(transform1.getOrientation() == Quaternion(6, 7, 8, 9));
rp3d_test(transform2.getPosition() == Vector3(4, 5, 6));
rp3d_test(transform2.getOrientation() == Quaternion::identity());
rp3d_test(transform3 == transform1);
}
/// Test getter and setter
void testGetSet() {
test(mIdentityTransform.getPosition() == Vector3(0, 0, 0));
test(mIdentityTransform.getOrientation() == Quaternion::identity());
rp3d_test(mIdentityTransform.getPosition() == Vector3(0, 0, 0));
rp3d_test(mIdentityTransform.getOrientation() == Quaternion::identity());
Transform transform;
transform.setPosition(Vector3(5, 7, 8));
transform.setOrientation(Quaternion(1, 2, 3, 1));
test(transform.getPosition() == Vector3(5, 7, 8));
test(transform.getOrientation() == Quaternion(1, 2, 3, 1));
rp3d_test(transform.getPosition() == Vector3(5, 7, 8));
rp3d_test(transform.getOrientation() == Quaternion(1, 2, 3, 1));
transform.setToIdentity();
test(transform.getPosition() == Vector3(0, 0, 0));
test(transform.getOrientation() == Quaternion::identity());
rp3d_test(transform.getPosition() == Vector3(0, 0, 0));
rp3d_test(transform.getOrientation() == Quaternion::identity());
}
/// Test the inverse
@ -117,9 +117,9 @@ class TestTransform : public Test {
Vector3 vector(2, 3, 4);
Vector3 tempVector = mTransform1 * vector;
Vector3 tempVector2 = inverseTransform * tempVector;
test(approxEqual(tempVector2.x, vector.x, decimal(10e-6)));
test(approxEqual(tempVector2.y, vector.y, decimal(10e-6)));
test(approxEqual(tempVector2.z, vector.z, decimal(10e-6)));
rp3d_test(approxEqual(tempVector2.x, vector.x, decimal(10e-6)));
rp3d_test(approxEqual(tempVector2.y, vector.y, decimal(10e-6)));
rp3d_test(approxEqual(tempVector2.z, vector.z, decimal(10e-6)));
}
/// Test methods to set and get transform matrix from and to OpenGL
@ -137,30 +137,30 @@ class TestTransform : public Test {
transform.setFromOpenGL(openglMatrix);
decimal openglMatrix2[16];
transform.getOpenGLMatrix(openglMatrix2);
test(approxEqual(openglMatrix2[0], orientation[0][0]));
test(approxEqual(openglMatrix2[1], orientation[1][0]));
test(approxEqual(openglMatrix2[2], orientation[2][0]));
test(approxEqual(openglMatrix2[3], 0));
test(approxEqual(openglMatrix2[4], orientation[0][1]));
test(approxEqual(openglMatrix2[5], orientation[1][1]));
test(approxEqual(openglMatrix2[6], orientation[2][1]));
test(approxEqual(openglMatrix2[7], 0));
test(approxEqual(openglMatrix2[8], orientation[0][2]));
test(approxEqual(openglMatrix2[9], orientation[1][2]));
test(approxEqual(openglMatrix2[10], orientation[2][2]));
test(approxEqual(openglMatrix2[11], 0));
test(approxEqual(openglMatrix2[12], position.x));
test(approxEqual(openglMatrix2[13], position.y));
test(approxEqual(openglMatrix2[14], position.z));
test(approxEqual(openglMatrix2[15], 1));
rp3d_test(approxEqual(openglMatrix2[0], orientation[0][0]));
rp3d_test(approxEqual(openglMatrix2[1], orientation[1][0]));
rp3d_test(approxEqual(openglMatrix2[2], orientation[2][0]));
rp3d_test(approxEqual(openglMatrix2[3], 0));
rp3d_test(approxEqual(openglMatrix2[4], orientation[0][1]));
rp3d_test(approxEqual(openglMatrix2[5], orientation[1][1]));
rp3d_test(approxEqual(openglMatrix2[6], orientation[2][1]));
rp3d_test(approxEqual(openglMatrix2[7], 0));
rp3d_test(approxEqual(openglMatrix2[8], orientation[0][2]));
rp3d_test(approxEqual(openglMatrix2[9], orientation[1][2]));
rp3d_test(approxEqual(openglMatrix2[10], orientation[2][2]));
rp3d_test(approxEqual(openglMatrix2[11], 0));
rp3d_test(approxEqual(openglMatrix2[12], position.x));
rp3d_test(approxEqual(openglMatrix2[13], position.y));
rp3d_test(approxEqual(openglMatrix2[14], position.z));
rp3d_test(approxEqual(openglMatrix2[15], 1));
}
/// Test the method to interpolate transforms
void testInterpolateTransform() {
Transform transformStart = Transform::interpolateTransforms(mTransform1, mTransform2,0);
Transform transformEnd = Transform::interpolateTransforms(mTransform1, mTransform2,1);
test(transformStart == mTransform1);
test(transformEnd == mTransform2);
rp3d_test(transformStart == mTransform1);
rp3d_test(transformEnd == mTransform2);
decimal sinA = sin(PI/3.0f);
decimal cosA = cos(PI/3.0f);
@ -171,46 +171,46 @@ class TestTransform : public Test {
Transform transform = Transform::interpolateTransforms(transform1, transform2, 0.5);
Vector3 position = transform.getPosition();
Quaternion orientation = transform.getOrientation();
test(approxEqual(position.x, 6));
test(approxEqual(position.y, 8));
test(approxEqual(position.z, 11));
test(approxEqual(orientation.x, sinB));
test(approxEqual(orientation.y, sinB));
test(approxEqual(orientation.z, sinB));
test(approxEqual(orientation.w, cosB));
rp3d_test(approxEqual(position.x, 6));
rp3d_test(approxEqual(position.y, 8));
rp3d_test(approxEqual(position.z, 11));
rp3d_test(approxEqual(orientation.x, sinB));
rp3d_test(approxEqual(orientation.y, sinB));
rp3d_test(approxEqual(orientation.z, sinB));
rp3d_test(approxEqual(orientation.w, cosB));
}
/// Test the identity methods
void testIdentity() {
Transform transform = Transform::identity();
test(transform.getPosition() == Vector3(0, 0, 0));
test(transform.getOrientation() == Quaternion::identity());
rp3d_test(transform.getPosition() == Vector3(0, 0, 0));
rp3d_test(transform.getOrientation() == Quaternion::identity());
Transform transform2(Vector3(5, 6, 2), Quaternion(3, 5, 1, 6));
transform2.setToIdentity();
test(transform2.getPosition() == Vector3(0, 0, 0));
test(transform2.getOrientation() == Quaternion::identity());
rp3d_test(transform2.getPosition() == Vector3(0, 0, 0));
rp3d_test(transform2.getOrientation() == Quaternion::identity());
}
/// Test the overloaded operators
void testOperators() {
// Equality, inequality operator
test(mTransform1 == mTransform1);
test(mTransform1 != mTransform2);
rp3d_test(mTransform1 == mTransform1);
rp3d_test(mTransform1 != mTransform2);
// Assignment operator
Transform transform;
transform = mTransform1;
test(transform == mTransform1);
rp3d_test(transform == mTransform1);
// Multiplication
Vector3 vector(7, 53, 5);
Vector3 vector2 = mTransform2 * (mTransform1 * vector);
Vector3 vector3 = (mTransform2 * mTransform1) * vector;
test(approxEqual(vector2.x, vector3.x, decimal(10e-6)));
test(approxEqual(vector2.y, vector3.y, decimal(10e-6)));
test(approxEqual(vector2.z, vector3.z, decimal(10e-6)));
rp3d_test(approxEqual(vector2.x, vector3.x, decimal(10e-6)));
rp3d_test(approxEqual(vector2.y, vector3.y, decimal(10e-6)));
rp3d_test(approxEqual(vector2.z, vector3.z, decimal(10e-6)));
}
};

View File

@ -69,46 +69,46 @@ class TestVector2 : public Test {
void testConstructors() {
// Test constructor
test(mVectorZero.x == 0.0);
test(mVectorZero.y == 0.0);
test(mVector34.x == 3.0);
test(mVector34.y == 4.0);
rp3d_test(mVectorZero.x == 0.0);
rp3d_test(mVectorZero.y == 0.0);
rp3d_test(mVector34.x == 3.0);
rp3d_test(mVector34.y == 4.0);
// Test copy-constructor
Vector2 newVector(mVector34);
test(newVector.x == 3.0);
test(newVector.y == 4.0);
rp3d_test(newVector.x == 3.0);
rp3d_test(newVector.y == 4.0);
// Test method to set values
Vector2 newVector2;
newVector2.setAllValues(decimal(6.1), decimal(7.2));
test(approxEqual(newVector2.x, decimal(6.1)));
test(approxEqual(newVector2.y, decimal(7.2)));
rp3d_test(approxEqual(newVector2.x, decimal(6.1)));
rp3d_test(approxEqual(newVector2.y, decimal(7.2)));
// Test method to set to zero
newVector2.setToZero();
test(newVector2 == Vector2(0, 0));
rp3d_test(newVector2 == Vector2(0, 0));
}
/// Test the length, unit vector and normalize methods
void testLengthMethods() {
// Test length methods
test(mVectorZero.length() == 0.0);
test(mVectorZero.lengthSquare() == 0.0);
test(Vector2(1, 0).length() == 1.0);
test(Vector2(0, 1).length() == 1.0);
test(mVector34.lengthSquare() == 25.0);
rp3d_test(mVectorZero.length() == 0.0);
rp3d_test(mVectorZero.lengthSquare() == 0.0);
rp3d_test(Vector2(1, 0).length() == 1.0);
rp3d_test(Vector2(0, 1).length() == 1.0);
rp3d_test(mVector34.lengthSquare() == 25.0);
// Test unit vector methods
test(Vector2(1, 0).isUnit());
test(Vector2(0, 1).isUnit());
test(!mVector34.isUnit());
test(Vector2(5, 0).getUnit() == Vector2(1, 0));
test(Vector2(0, 5).getUnit() == Vector2(0, 1));
rp3d_test(Vector2(1, 0).isUnit());
rp3d_test(Vector2(0, 1).isUnit());
rp3d_test(!mVector34.isUnit());
rp3d_test(Vector2(5, 0).getUnit() == Vector2(1, 0));
rp3d_test(Vector2(0, 5).getUnit() == Vector2(0, 1));
test(!mVector34.isZero());
test(mVectorZero.isZero());
rp3d_test(!mVector34.isZero());
rp3d_test(mVectorZero.isZero());
// Test normalization method
Vector2 mVector10(1, 0);
@ -119,100 +119,100 @@ class TestVector2 : public Test {
mVector01.normalize();
mVector50.normalize();
mVector05.normalize();
test(mVector10 == Vector2(1, 0));
test(mVector01 == Vector2(0, 1));
test(mVector50 == Vector2(1, 0));
test(mVector05 == Vector2(0, 1));
rp3d_test(mVector10 == Vector2(1, 0));
rp3d_test(mVector01 == Vector2(0, 1));
rp3d_test(mVector50 == Vector2(1, 0));
rp3d_test(mVector05 == Vector2(0, 1));
}
/// Test the dot product
void testDotProduct() {
// Test the dot product
test(Vector2(5, 0).dot(Vector2(0, 8)) == 0);
test(Vector2(5, 8).dot(Vector2(0, 0)) == 0);
test(Vector2(12, 45).dot(Vector2(0, 0)) == 0);
test(Vector2(5, 7).dot(Vector2(5, 7)) == 74);
test(Vector2(3, 6).dot(Vector2(-3, -6)) == -45);
test(Vector2(2, 3).dot(Vector2(-7, 4)) == -2);
test(Vector2(4, 3).dot(Vector2(8, 9)) == 59);
rp3d_test(Vector2(5, 0).dot(Vector2(0, 8)) == 0);
rp3d_test(Vector2(5, 8).dot(Vector2(0, 0)) == 0);
rp3d_test(Vector2(12, 45).dot(Vector2(0, 0)) == 0);
rp3d_test(Vector2(5, 7).dot(Vector2(5, 7)) == 74);
rp3d_test(Vector2(3, 6).dot(Vector2(-3, -6)) == -45);
rp3d_test(Vector2(2, 3).dot(Vector2(-7, 4)) == -2);
rp3d_test(Vector2(4, 3).dot(Vector2(8, 9)) == 59);
}
/// Test others methods
void testOthersMethods() {
// Test the method that returns the absolute vector
test(Vector2(4, 5).getAbsoluteVector() == Vector2(4, 5));
test(Vector2(-7, -24).getAbsoluteVector() == Vector2(7, 24));
rp3d_test(Vector2(4, 5).getAbsoluteVector() == Vector2(4, 5));
rp3d_test(Vector2(-7, -24).getAbsoluteVector() == Vector2(7, 24));
// Test the method that returns the minimal element
test(Vector2(6, 35).getMinAxis() == 0);
test(Vector2(564, 45).getMinAxis() == 1);
test(Vector2(98, 23).getMinAxis() == 1);
test(Vector2(-53, -25).getMinAxis() == 0);
rp3d_test(Vector2(6, 35).getMinAxis() == 0);
rp3d_test(Vector2(564, 45).getMinAxis() == 1);
rp3d_test(Vector2(98, 23).getMinAxis() == 1);
rp3d_test(Vector2(-53, -25).getMinAxis() == 0);
// Test the method that returns the maximal element
test(Vector2(6, 35).getMaxAxis() == 1);
test(Vector2(7, 537).getMaxAxis() == 1);
test(Vector2(98, 23).getMaxAxis() == 0);
test(Vector2(-53, -25).getMaxAxis() == 1);
rp3d_test(Vector2(6, 35).getMaxAxis() == 1);
rp3d_test(Vector2(7, 537).getMaxAxis() == 1);
rp3d_test(Vector2(98, 23).getMaxAxis() == 0);
rp3d_test(Vector2(-53, -25).getMaxAxis() == 1);
// Test the methot that return a max/min vector
Vector2 vec1(-5, 4);
Vector2 vec2(-8, 6);
test(Vector2::min(vec1, vec2) == Vector2(-8, 4));
test(Vector2::max(vec1, vec2) == Vector2(-5, 6));
rp3d_test(Vector2::min(vec1, vec2) == Vector2(-8, 4));
rp3d_test(Vector2::max(vec1, vec2) == Vector2(-5, 6));
}
/// Test the operators
void testOperators() {
// Test the [] operator
test(mVector34[0] == 3);
test(mVector34[1] == 4);
rp3d_test(mVector34[0] == 3);
rp3d_test(mVector34[1] == 4);
// Assignment operator
Vector2 newVector(6, 4);
newVector = Vector2(7, 8);
test(newVector == Vector2(7, 8));
rp3d_test(newVector == Vector2(7, 8));
// Equality, inequality operators
test(Vector2(5, 7) == Vector2(5, 7));
test(Vector2(63, 64) != Vector2(63, 84));
test(Vector2(63, 64) != Vector2(12, 64));
rp3d_test(Vector2(5, 7) == Vector2(5, 7));
rp3d_test(Vector2(63, 64) != Vector2(63, 84));
rp3d_test(Vector2(63, 64) != Vector2(12, 64));
// Addition, substraction
Vector2 vector1(6, 33);
Vector2 vector2(7, 68);
test(Vector2(63, 24) + Vector2(3, 4) == Vector2(66, 28));
test(Vector2(63, 24) - Vector2(3, 4) == Vector2(60, 20));
rp3d_test(Vector2(63, 24) + Vector2(3, 4) == Vector2(66, 28));
rp3d_test(Vector2(63, 24) - Vector2(3, 4) == Vector2(60, 20));
vector1 += Vector2(5, 10);
vector2 -= Vector2(10, 21);
test(vector1 == Vector2(11, 43));
test(vector2 == Vector2(-3, 47));
rp3d_test(vector1 == Vector2(11, 43));
rp3d_test(vector2 == Vector2(-3, 47));
// Multiplication, division
Vector2 vector3(6, 33);
Vector2 vector4(15, 60);
test(Vector2(63, 24) * 3 == Vector2(189, 72));
test(3 * Vector2(63, 24) == Vector2(189, 72));
test(Vector2(14, 8) / 2 == Vector2(7, 4));
rp3d_test(Vector2(63, 24) * 3 == Vector2(189, 72));
rp3d_test(3 * Vector2(63, 24) == Vector2(189, 72));
rp3d_test(Vector2(14, 8) / 2 == Vector2(7, 4));
vector3 *= 10;
vector4 /= 3;
test(vector3 == Vector2(60, 330));
test(vector4 == Vector2(5, 20));
rp3d_test(vector3 == Vector2(60, 330));
rp3d_test(vector4 == Vector2(5, 20));
Vector2 vector5(21, 80);
Vector2 vector6(7, 10);
Vector2 vector7 = vector5 * vector6;
test(vector7 == Vector2(147, 800));
rp3d_test(vector7 == Vector2(147, 800));
Vector2 vector8 = vector5 / vector6;
test(approxEqual(vector8.x, 3));
test(approxEqual(vector8.y, 8));
rp3d_test(approxEqual(vector8.x, 3));
rp3d_test(approxEqual(vector8.y, 8));
// Negative operator
Vector2 vector9(-34, 5);
Vector2 negative = -vector9;
test(negative == Vector2(34, -5));
rp3d_test(negative == Vector2(34, -5));
}
};

View File

@ -69,53 +69,53 @@ class TestVector3 : public Test {
void testConstructors() {
// Test constructor
test(mVectorZero.x == 0.0);
test(mVectorZero.y == 0.0);
test(mVectorZero.z == 0.0);
test(mVector345.x == 3.0);
test(mVector345.y == 4.0);
test(mVector345.z == 5.0);
rp3d_test(mVectorZero.x == 0.0);
rp3d_test(mVectorZero.y == 0.0);
rp3d_test(mVectorZero.z == 0.0);
rp3d_test(mVector345.x == 3.0);
rp3d_test(mVector345.y == 4.0);
rp3d_test(mVector345.z == 5.0);
// Test copy-constructor
Vector3 newVector(mVector345);
test(newVector.x == 3.0);
test(newVector.y == 4.0);
test(newVector.z == 5.0);
rp3d_test(newVector.x == 3.0);
rp3d_test(newVector.y == 4.0);
rp3d_test(newVector.z == 5.0);
// Test method to set values
Vector3 newVector2;
newVector2.setAllValues(decimal(6.1), decimal(7.2), decimal(8.6));
test(approxEqual(newVector2.x, decimal(6.1)));
test(approxEqual(newVector2.y, decimal(7.2)));
test(approxEqual(newVector2.z, decimal(8.6)));
rp3d_test(approxEqual(newVector2.x, decimal(6.1)));
rp3d_test(approxEqual(newVector2.y, decimal(7.2)));
rp3d_test(approxEqual(newVector2.z, decimal(8.6)));
// Test method to set to zero
newVector2.setToZero();
test(newVector2 == Vector3(0, 0, 0));
rp3d_test(newVector2 == Vector3(0, 0, 0));
}
/// Test the length, unit vector and normalize methods
void testLengthMethods() {
// Test length methods
test(mVectorZero.length() == 0.0);
test(mVectorZero.lengthSquare() == 0.0);
test(Vector3(1, 0, 0).length() == 1.0);
test(Vector3(0, 1, 0).length() == 1.0);
test(Vector3(0, 0, 1).length() == 1.0);
test(mVector345.lengthSquare() == 50.0);
rp3d_test(mVectorZero.length() == 0.0);
rp3d_test(mVectorZero.lengthSquare() == 0.0);
rp3d_test(Vector3(1, 0, 0).length() == 1.0);
rp3d_test(Vector3(0, 1, 0).length() == 1.0);
rp3d_test(Vector3(0, 0, 1).length() == 1.0);
rp3d_test(mVector345.lengthSquare() == 50.0);
// Test unit vector methods
test(Vector3(1, 0, 0).isUnit());
test(Vector3(0, 1, 0).isUnit());
test(Vector3(0, 0, 1).isUnit());
test(!mVector345.isUnit());
test(Vector3(5, 0, 0).getUnit() == Vector3(1, 0, 0));
test(Vector3(0, 5, 0).getUnit() == Vector3(0, 1, 0));
test(Vector3(0, 0, 5).getUnit() == Vector3(0, 0, 1));
rp3d_test(Vector3(1, 0, 0).isUnit());
rp3d_test(Vector3(0, 1, 0).isUnit());
rp3d_test(Vector3(0, 0, 1).isUnit());
rp3d_test(!mVector345.isUnit());
rp3d_test(Vector3(5, 0, 0).getUnit() == Vector3(1, 0, 0));
rp3d_test(Vector3(0, 5, 0).getUnit() == Vector3(0, 1, 0));
rp3d_test(Vector3(0, 0, 5).getUnit() == Vector3(0, 0, 1));
test(!mVector345.isZero());
test(mVectorZero.isZero());
rp3d_test(!mVector345.isZero());
rp3d_test(mVectorZero.isZero());
// Test normalization method
Vector3 mVector100(1, 0, 0);
@ -130,114 +130,114 @@ class TestVector3 : public Test {
mVector500.normalize();
mVector050.normalize();
mVector005.normalize();
test(mVector100 == Vector3(1, 0, 0));
test(mVector010 == Vector3(0, 1, 0));
test(mVector001 == Vector3(0, 0, 1));
test(mVector500 == Vector3(1, 0, 0));
test(mVector050 == Vector3(0, 1, 0));
test(mVector005 == Vector3(0, 0, 1));
rp3d_test(mVector100 == Vector3(1, 0, 0));
rp3d_test(mVector010 == Vector3(0, 1, 0));
rp3d_test(mVector001 == Vector3(0, 0, 1));
rp3d_test(mVector500 == Vector3(1, 0, 0));
rp3d_test(mVector050 == Vector3(0, 1, 0));
rp3d_test(mVector005 == Vector3(0, 0, 1));
}
/// Test the dot and cross products
void testDotCrossProducts() {
// Test the dot product
test(Vector3(5, 0, 0).dot(Vector3(0, 8, 0)) == 0);
test(Vector3(5, 8, 0).dot(Vector3(0, 0, 6)) == 0);
test(Vector3(12, 45, 83).dot(Vector3(0, 0, 0)) == 0);
test(Vector3(5, 7, 8).dot(Vector3(5, 7, 8)) == 138);
test(Vector3(3, 6, 78).dot(Vector3(-3, -6, -78)) == -6129);
test(Vector3(2, 3, 5).dot(Vector3(2, 3, 5)) == 38);
test(Vector3(4, 3, 2).dot(Vector3(8, 9, 10)) == 79);
rp3d_test(Vector3(5, 0, 0).dot(Vector3(0, 8, 0)) == 0);
rp3d_test(Vector3(5, 8, 0).dot(Vector3(0, 0, 6)) == 0);
rp3d_test(Vector3(12, 45, 83).dot(Vector3(0, 0, 0)) == 0);
rp3d_test(Vector3(5, 7, 8).dot(Vector3(5, 7, 8)) == 138);
rp3d_test(Vector3(3, 6, 78).dot(Vector3(-3, -6, -78)) == -6129);
rp3d_test(Vector3(2, 3, 5).dot(Vector3(2, 3, 5)) == 38);
rp3d_test(Vector3(4, 3, 2).dot(Vector3(8, 9, 10)) == 79);
// Test the cross product
test(Vector3(0, 0, 0).cross(Vector3(0, 0, 0)) == Vector3(0, 0, 0));
test(Vector3(6, 7, 2).cross(Vector3(6, 7, 2)) == Vector3(0, 0, 0));
test(Vector3(1, 0, 0).cross(Vector3(0, 1, 0)) == Vector3(0, 0, 1));
test(Vector3(0, 1, 0).cross(Vector3(0, 0, 1)) == Vector3(1, 0, 0));
test(Vector3(0, 0, 1).cross(Vector3(0, 1, 0)) == Vector3(-1, 0, 0));
test(Vector3(4, 7, 24).cross(Vector3(8, 13, 11)) == Vector3(-235, 148, -4));
test(Vector3(-4, 42, -2).cross(Vector3(35, 7, -21)) == Vector3(-868, -154, -1498));
rp3d_test(Vector3(0, 0, 0).cross(Vector3(0, 0, 0)) == Vector3(0, 0, 0));
rp3d_test(Vector3(6, 7, 2).cross(Vector3(6, 7, 2)) == Vector3(0, 0, 0));
rp3d_test(Vector3(1, 0, 0).cross(Vector3(0, 1, 0)) == Vector3(0, 0, 1));
rp3d_test(Vector3(0, 1, 0).cross(Vector3(0, 0, 1)) == Vector3(1, 0, 0));
rp3d_test(Vector3(0, 0, 1).cross(Vector3(0, 1, 0)) == Vector3(-1, 0, 0));
rp3d_test(Vector3(4, 7, 24).cross(Vector3(8, 13, 11)) == Vector3(-235, 148, -4));
rp3d_test(Vector3(-4, 42, -2).cross(Vector3(35, 7, -21)) == Vector3(-868, -154, -1498));
}
/// Test others methods
void testOthersMethods() {
// Test the method that returns the absolute vector
test(Vector3(4, 5, 6).getAbsoluteVector() == Vector3(4, 5, 6));
test(Vector3(-7, -24, -12).getAbsoluteVector() == Vector3(7, 24, 12));
rp3d_test(Vector3(4, 5, 6).getAbsoluteVector() == Vector3(4, 5, 6));
rp3d_test(Vector3(-7, -24, -12).getAbsoluteVector() == Vector3(7, 24, 12));
// Test the method that returns the minimal element
test(Vector3(6, 35, 82).getMinAxis() == 0);
test(Vector3(564, 45, 532).getMinAxis() == 1);
test(Vector3(98, 23, 3).getMinAxis() == 2);
test(Vector3(-53, -25, -63).getMinAxis() == 2);
rp3d_test(Vector3(6, 35, 82).getMinAxis() == 0);
rp3d_test(Vector3(564, 45, 532).getMinAxis() == 1);
rp3d_test(Vector3(98, 23, 3).getMinAxis() == 2);
rp3d_test(Vector3(-53, -25, -63).getMinAxis() == 2);
// Test the method that returns the maximal element
test(Vector3(6, 35, 82).getMaxAxis() == 2);
test(Vector3(7, 533, 36).getMaxAxis() == 1);
test(Vector3(98, 23, 3).getMaxAxis() == 0);
test(Vector3(-53, -25, -63).getMaxAxis() == 1);
rp3d_test(Vector3(6, 35, 82).getMaxAxis() == 2);
rp3d_test(Vector3(7, 533, 36).getMaxAxis() == 1);
rp3d_test(Vector3(98, 23, 3).getMaxAxis() == 0);
rp3d_test(Vector3(-53, -25, -63).getMaxAxis() == 1);
// Test the methot that return a max/min vector
Vector3 vec1(-5, 4, 2);
Vector3 vec2(-8, 6, -1);
test(Vector3::min(vec1, vec2) == Vector3(-8, 4, -1));
test(Vector3::max(vec1, vec2) == Vector3(-5, 6, 2));
rp3d_test(Vector3::min(vec1, vec2) == Vector3(-8, 4, -1));
rp3d_test(Vector3::max(vec1, vec2) == Vector3(-5, 6, 2));
}
/// Test the operators
void testOperators() {
// Test the [] operator
test(mVector345[0] == 3);
test(mVector345[1] == 4);
test(mVector345[2] == 5);
rp3d_test(mVector345[0] == 3);
rp3d_test(mVector345[1] == 4);
rp3d_test(mVector345[2] == 5);
// Assignment operator
Vector3 newVector(6, 4, 2);
newVector = Vector3(7, 8, 9);
test(newVector == Vector3(7, 8, 9));
rp3d_test(newVector == Vector3(7, 8, 9));
// Equality, inequality operators
test(Vector3(5, 7, 3) == Vector3(5, 7, 3));
test(Vector3(63, 64, 24) != Vector3(63, 64, 5));
test(Vector3(63, 64, 24) != Vector3(12, 64, 24));
test(Vector3(63, 64, 24) != Vector3(63, 8, 24));
rp3d_test(Vector3(5, 7, 3) == Vector3(5, 7, 3));
rp3d_test(Vector3(63, 64, 24) != Vector3(63, 64, 5));
rp3d_test(Vector3(63, 64, 24) != Vector3(12, 64, 24));
rp3d_test(Vector3(63, 64, 24) != Vector3(63, 8, 24));
// Addition, substraction
Vector3 vector1(6, 33, 62);
Vector3 vector2(7, 68, 35);
test(Vector3(63, 24, 5) + Vector3(3, 4, 2) == Vector3(66, 28, 7));
test(Vector3(63, 24, 5) - Vector3(3, 4, 2) == Vector3(60, 20, 3));
rp3d_test(Vector3(63, 24, 5) + Vector3(3, 4, 2) == Vector3(66, 28, 7));
rp3d_test(Vector3(63, 24, 5) - Vector3(3, 4, 2) == Vector3(60, 20, 3));
vector1 += Vector3(5, 10, 12);
vector2 -= Vector3(10, 21, 5);
test(vector1 == Vector3(11, 43, 74));
test(vector2 == Vector3(-3, 47, 30));
rp3d_test(vector1 == Vector3(11, 43, 74));
rp3d_test(vector2 == Vector3(-3, 47, 30));
// Multiplication, division
Vector3 vector3(6, 33, 62);
Vector3 vector4(15, 60, 33);
test(Vector3(63, 24, 5) * 3 == Vector3(189, 72, 15));
test(3 * Vector3(63, 24, 5) == Vector3(189, 72, 15));
test(Vector3(14, 8, 50) / 2 == Vector3(7, 4, 25));
rp3d_test(Vector3(63, 24, 5) * 3 == Vector3(189, 72, 15));
rp3d_test(3 * Vector3(63, 24, 5) == Vector3(189, 72, 15));
rp3d_test(Vector3(14, 8, 50) / 2 == Vector3(7, 4, 25));
vector3 *= 10;
vector4 /= 3;
test(vector3 == Vector3(60, 330, 620));
test(vector4 == Vector3(5, 20, 11));
rp3d_test(vector3 == Vector3(60, 330, 620));
rp3d_test(vector4 == Vector3(5, 20, 11));
Vector3 vector5(21, 80, 45);
Vector3 vector6(7, 10, 3);
Vector3 vector7 = vector5 * vector6;
test(vector7 == Vector3(147, 800, 135));
rp3d_test(vector7 == Vector3(147, 800, 135));
Vector3 vector8 = vector5 / vector6;
test(approxEqual(vector8.x, 3));
test(approxEqual(vector8.y, 8));
test(approxEqual(vector8.z, 15));
rp3d_test(approxEqual(vector8.x, 3));
rp3d_test(approxEqual(vector8.y, 8));
rp3d_test(approxEqual(vector8.z, 15));
// Negative operator
Vector3 vector9(-34, 5, 422);
Vector3 negative = -vector9;
test(negative == Vector3(34, -5, -422));
rp3d_test(negative == Vector3(34, -5, -422));
}
};