Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (41 sloc) 1.51 kb
48a1a18 Luke Benstead Add a test for a new (unimplemented) kmAABBIntersectsTriangle function
authored
1 #include <unittest++/UnitTest++.h>
2 #include <limits>
3
e25d39d Luke Benstead Massive file reorganization to make it easier to drop kazmath into a pro...
authored
4 #include "../kazmath/aabb.h"
48a1a18 Luke Benstead Add a test for a new (unimplemented) kmAABBIntersectsTriangle function
authored
5
6 TEST(test_aabb_triangle_intersection) {
7
8 kmAABB box;
9 box.min.x = -5.0f;
10 box.min.y = -5.0f;
11 box.min.z = std::numeric_limits<kmScalar>::min();
12
13 box.max.x = 5.0f;
14 box.max.y = 5.0f;
15 box.max.z = std::numeric_limits<kmScalar>::max();
16
17 //Triangle that is entirely within the bounds of the box
18 kmVec3 tri1 [] = {
19 { -1.0f, 0.0f, 0.0f },
20 { 1.0f, 0.0f, 0.0f },
21 { 1.0f, 1.0f, 0.0f },
22 };
23
24 //Should intersect
25 CHECK(kmAABBIntersectsTriangle(&box, &tri1[0], &tri1[1], &tri1[2]));
26
27 //Triangle that entirely surrounds the box (should still return true)
28 kmVec3 tri2 [] = {
29 { -100.0f, 0.0f, 0.0f },
30 { 100.0f, 0.0f, 0.0f },
31 { 100.0f, 100.0f, 0.0f },
32 };
33 CHECK(kmAABBIntersectsTriangle(&box, &tri2[0], &tri2[1], &tri2[2]));
34
35 //Triangle that is entirely outside of the box (should return false)
36 kmVec3 tri3 [] = {
37 { 10.0f, 0.0f, 0.0f },
38 { 20.0f, 0.0f, 0.0f },
39 { 20.0f, 10.0f, 0.0f },
40 };
41
42 CHECK(!kmAABBIntersectsTriangle(&box, &tri3[0], &tri3[1], &tri3[2]));
43
44 //Triangle that intersects the box (should return true)
45 kmVec3 tri4 [] = {
46 { 0.0f, 0.0f, 0.0f },
47 { 10.0f, 0.0f, 0.0f },
48 { 10.0f, 10.0f, 0.0f },
49 };
50
51 CHECK(kmAABBIntersectsTriangle(&box, &tri4[0], &tri4[1], &tri4[2]));
52 }
53
5d22574 Luke Benstead Restructure the tests. Write some tests for the new plane functions
authored
54
Something went wrong with that request. Please try again.