aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_collision.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/unittest/test_collision.cpp b/src/unittest/test_collision.cpp
index 332d3fa13..2f39c2489 100644
--- a/src/unittest/test_collision.cpp
+++ b/src/unittest/test_collision.cpp
@@ -50,38 +50,38 @@ void TestCollision::testAxisAlignedCollision()
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx-2, by, bz, bx-1, by+1, bz+1);
v3f v(1, 0, 0);
- f32 dtime = 0;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 1.000) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx-2, by, bz, bx-1, by+1, bz+1);
v3f v(-1, 0, 0);
- f32 dtime = 0;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == -1);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == -1);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx-2, by+1.5, bz, bx-1, by+2.5, bz-1);
v3f v(1, 0, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == -1);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == -1);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx-2, by-1.5, bz, bx-1.5, by+0.5, bz+1);
v3f v(0.5, 0.1, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 3.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 3.000) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx-2, by-1.5, bz, bx-1.5, by+0.5, bz+1);
v3f v(0.5, 0.1, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 3.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 3.000) < 0.001);
}
@@ -90,38 +90,38 @@ void TestCollision::testAxisAlignedCollision()
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx+2, by, bz, bx+3, by+1, bz+1);
v3f v(-1, 0, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 1.000) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx+2, by, bz, bx+3, by+1, bz+1);
v3f v(1, 0, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == -1);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == -1);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx+2, by, bz+1.5, bx+3, by+1, bz+3.5);
v3f v(-1, 0, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == -1);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == -1);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx+2, by-1.5, bz, bx+2.5, by-0.5, bz+1);
v3f v(-0.5, 0.2, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 1); // Y, not X!
+ f32 dtime = 2.5f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 1); // Y, not X!
UASSERT(fabs(dtime - 2.500) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+1, by+1, bz+1);
aabb3f m(bx+2, by-1.5, bz, bx+2.5, by-0.5, bz+1);
v3f v(-0.5, 0.3, 0);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 2.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 2.000) < 0.001);
}
@@ -132,48 +132,48 @@ void TestCollision::testAxisAlignedCollision()
aabb3f s(bx, by, bz, bx+2, by+2, bz+2);
aabb3f m(bx+2.3, by+2.29, bz+2.29, bx+4.2, by+4.2, bz+4.2);
v3f v(-1./3, -1./3, -1./3);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 0.9) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+2, by+2, bz+2);
aabb3f m(bx+2.29, by+2.3, bz+2.29, bx+4.2, by+4.2, bz+4.2);
v3f v(-1./3, -1./3, -1./3);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 1);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 1);
UASSERT(fabs(dtime - 0.9) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+2, by+2, bz+2);
aabb3f m(bx+2.29, by+2.29, bz+2.3, bx+4.2, by+4.2, bz+4.2);
v3f v(-1./3, -1./3, -1./3);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 2);
+ f32 dtime = 1.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 2);
UASSERT(fabs(dtime - 0.9) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+2, by+2, bz+2);
aabb3f m(bx-4.2, by-4.2, bz-4.2, bx-2.3, by-2.29, bz-2.29);
v3f v(1./7, 1./7, 1./7);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 0);
+ f32 dtime = 17.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 0);
UASSERT(fabs(dtime - 16.1) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+2, by+2, bz+2);
aabb3f m(bx-4.2, by-4.2, bz-4.2, bx-2.29, by-2.3, bz-2.29);
v3f v(1./7, 1./7, 1./7);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 1);
+ f32 dtime = 17.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 1);
UASSERT(fabs(dtime - 16.1) < 0.001);
}
{
aabb3f s(bx, by, bz, bx+2, by+2, bz+2);
aabb3f m(bx-4.2, by-4.2, bz-4.2, bx-2.29, by-2.29, bz-2.3);
v3f v(1./7, 1./7, 1./7);
- f32 dtime;
- UASSERT(axisAlignedCollision(s, m, v, 0, &dtime) == 2);
+ f32 dtime = 17.0f;
+ UASSERT(axisAlignedCollision(s, m, v, &dtime) == 2);
UASSERT(fabs(dtime - 16.1) < 0.001);
}
}