From 487a6b20ab7bfb09c7f0d482c4420d1064d7cc37 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 4 Dec 2011 09:02:12 +0900 Subject: [PATCH] Test collisions with a ridge smaller than the box. Whee, found a failing test case :) --- libs/models/test/hulls.c | 29 +++++++++++++++++++++++++++++ libs/models/test/hulls.h | 1 + libs/models/test/testclip.c | 3 +++ libs/models/test/testcontents.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/libs/models/test/hulls.c b/libs/models/test/hulls.c index 4b363a6a9..127fe8c04 100644 --- a/libs/models/test/hulls.c +++ b/libs/models/test/hulls.c @@ -275,3 +275,32 @@ hull_t hull_hole = { {0, 0, 0}, {0, 0, 0}, }; + +// 2 3 +// eee|eee|eee +// 0,32+---+--- 1 +// eee|sss|eee +// ---+---+--- 0 +// ss0,0s8,0ss +static mclipnode_t clipnodes_ridge[] = { + { 0, { 1, CONTENTS_SOLID}}, + { 1, {CONTENTS_EMPTY, 2}}, + { 2, { 3, CONTENTS_EMPTY}}, + { 3, {CONTENTS_EMPTY, CONTENTS_SOLID}}, +}; + +static plane_t planes_ridge[] = { + {{0, 0, 1}, 0, 2, 0}, + {{0, 0, 1}, 32, 2, 0}, + {{1, 0, 0}, 0, 0, 0}, + {{1, 0, 0}, 8, 0, 0}, +}; + +hull_t hull_ridge = { + clipnodes_ridge, + planes_ridge, + 0, + 3, + {0, 0, 0}, + {0, 0, 0}, +}; diff --git a/libs/models/test/hulls.h b/libs/models/test/hulls.h index a8976f3ee..440fbfac5 100644 --- a/libs/models/test/hulls.h +++ b/libs/models/test/hulls.h @@ -10,3 +10,4 @@ extern hull_t hull_step3; extern hull_t hull_covered_step; extern hull_t hull_ramp; extern hull_t hull_hole; +extern hull_t hull_ridge; diff --git a/libs/models/test/testclip.c b/libs/models/test/testclip.c index 94f52f675..2ecf0fe9c 100644 --- a/libs/models/test/testclip.c +++ b/libs/models/test/testclip.c @@ -171,6 +171,9 @@ test_t tests[] = { { 1, -16, 0}, { 1, 16, 0}, { 0.25, 0, 0, 1, 0, 13}}, {"Box, Hole. edge", &box, &hull_hole, {-1, -16, 0}, { -1, 16, 0}, { 0.25, 0, 0, 1, 0, 13}}, + + {"Box, ridge", &box, &hull_ridge, + {4, 41, 0}, { 4, 39, 0}, { 0.5, 0, 0, 1, 0, 8}}, }; #define num_tests (sizeof (tests) / sizeof (tests[0])) diff --git a/libs/models/test/testcontents.c b/libs/models/test/testcontents.c index 5d5b66219..d69b01269 100644 --- a/libs/models/test/testcontents.c +++ b/libs/models/test/testcontents.c @@ -95,6 +95,11 @@ test_t tests[] = { { 0, 0, 8}, { CONTENTS_EMPTY, 1}}, {"Box, ramp", &box, &hull_ramp, { 0, 0, 7}, { CONTENTS_SOLID, 3}}, + + {"Box, ridge", &box, &hull_ridge, + { 4, 0, 40}, { CONTENTS_EMPTY, 1}}, + {"Box, ridge", &box, &hull_ridge, + { 4, 0, 39}, { CONTENTS_SOLID, 3}}, }; #define num_tests (sizeof (tests) / sizeof (tests[0]))