From dadfb7899246907abe71a69c8933d57b03bf1c3f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 3 Dec 2011 20:20:33 +0900 Subject: [PATCH] Split out the hull data so it can be used in other tests. --- libs/models/test/Makefile.am | 4 +- libs/models/test/hulls.c | 277 ++++++++++++++++++++++++++++++++++ libs/models/test/hulls.h | 12 ++ libs/models/test/testclip.c | 279 +---------------------------------- 4 files changed, 293 insertions(+), 279 deletions(-) create mode 100644 libs/models/test/hulls.c create mode 100644 libs/models/test/hulls.h diff --git a/libs/models/test/Makefile.am b/libs/models/test/Makefile.am index 66525bb42..792e7ed30 100644 --- a/libs/models/test/Makefile.am +++ b/libs/models/test/Makefile.am @@ -3,9 +3,9 @@ AUTOMAKE_OPTIONS= foreign INCLUDES= -I$(srcdir) -I$(top_srcdir)/include check_PROGRAMS=testclip -EXTRA_DIST= trace-id.c trace-qf-bad.c +EXTRA_DIST= trace-id.c trace-qf-bad.c hulls.h -testclip_SOURCES=testclip.c +testclip_SOURCES=testclip.c hulls.c testclip_LDADD= $(top_builddir)/libs/models/libQFmodels.la $(top_builddir)/libs/util/libQFutil.la testclip_DEPENDENCIES= $(top_builddir)/libs/models/libQFmodels.la $(top_builddir)/libs/util/libQFutil.la diff --git a/libs/models/test/hulls.c b/libs/models/test/hulls.c new file mode 100644 index 000000000..4b363a6a9 --- /dev/null +++ b/libs/models/test/hulls.c @@ -0,0 +1,277 @@ +#include "hulls.h" + +// 0,0 +// |\ . +// |s\ . +// |ss\ . +// 0 1 + +static mclipnode_t clipnodes_simple_wedge[] = { + { 0, { 1, CONTENTS_EMPTY}}, + { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, +}; + +static plane_t planes_simple_wedge[] = { + {{1, 0, 0}, 0, 0, 0}, // 0 + {{0.8, 0, 0.6}, 0, 4, 0}, // 1 +}; + +hull_t hull_simple_wedge = { + clipnodes_simple_wedge, + planes_simple_wedge, + 0, + 1, + {0, 0, 0}, + {0, 0, 0}, +}; + +// -32 32 48 +// sss|sss| |sss +// sss|sss| |sss +// 0 1 2 + +static mclipnode_t clipnodes_tpp1[] = { + { 0, { 1, CONTENTS_SOLID}}, + { 1, { 2, CONTENTS_SOLID}}, + { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, +}; + +static plane_t planes_tpp1[] = { + {{1, 0, 0}, -32, 0, 0}, + {{1, 0, 0}, 32, 0, 0}, + {{1, 0, 0}, 48, 0, 0}, +}; + +hull_t hull_tpp1 = { + clipnodes_tpp1, + planes_tpp1, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// -32 32 48 +// sss|sss| |sss +// sss|sss| |sss +// 1 0 2 + +static mclipnode_t clipnodes_tpp2[] = { + { 0, { 2, 1}}, + { 1, {CONTENTS_SOLID, CONTENTS_SOLID}}, + { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, +}; + +static plane_t planes_tpp2[] = { + {{1, 0, 0}, 32, 0, 0}, + {{1, 0, 0}, -32, 0, 0}, + {{1, 0, 0}, 48, 0, 0}, +}; + +hull_t hull_tpp2 = { + clipnodes_tpp2, + planes_tpp2, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// -32 32 48 +// sss| |www|sss +// sss| |www|sss +// 1 0 2 + +static mclipnode_t clipnodes_tppw[] = { + { 0, { 2, 1}}, + { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, + { 2, {CONTENTS_SOLID, CONTENTS_WATER}}, +}; + +static plane_t planes_tppw[] = { + {{1, 0, 0}, 32, 0, 0}, + {{1, 0, 0}, -32, 0, 0}, + {{1, 0, 0}, 48, 0, 0}, +}; + +hull_t hull_tppw = { + clipnodes_tppw, + planes_tppw, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// 2 +// eee|eee +// 0,32+--- 1 +// eee|sss +// ---+--- 0 +// ss0,0ss +static mclipnode_t clipnodes_step1[] = { + { 0, { 1, CONTENTS_SOLID}}, + { 1, {CONTENTS_EMPTY, 2}}, + { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, +}; + +static plane_t planes_step1[] = { + {{0, 0, 1}, 0, 2, 0}, + {{0, 0, 1}, 32, 2, 0}, + {{1, 0, 0}, 0, 0, 0}, +}; + +hull_t hull_step1 = { + clipnodes_step1, + planes_step1, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// 0 +// eee|eee +// 0,32+--- 1 +// eee|sss +// ---+sss 2 +// ss0,0ss +static mclipnode_t clipnodes_step2[] = { + { 0, { 1, 2}}, + { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, + { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, +}; + +static plane_t planes_step2[] = { + {{1, 0, 0}, 0, 0, 0}, + {{0, 0, 1}, 32, 2, 0}, + {{0, 0, 1}, 0, 2, 0}, +}; + +hull_t hull_step2 = { + clipnodes_step2, + planes_step2, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// 0 +// eee|eee +// 2---+0,32 +// sss|eee +// sss+--- 1 +// ss0,0ss +static mclipnode_t clipnodes_step3[] = { + { 0, { 1, 2}}, + { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, + { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, +}; + +static plane_t planes_step3[] = { + {{1, 0, 0}, 0, 0, 0}, + {{0, 0, 1}, 0, 2, 0}, + {{0, 0, 1}, 32, 2, 0}, +}; + +hull_t hull_step3 = { + clipnodes_step3, + planes_step3, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// 3 2 +// s|e|eee +// 4-+e|-20,40 +// e|e|eee +// 0,32+--- 1 +// eee|sss +// ---+--- 0 +// ss0,0ss +static mclipnode_t clipnodes_covered_step[] = { + { 0, { 1, CONTENTS_SOLID}}, + { 1, { 3, 2}}, + { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, + { 3, {CONTENTS_EMPTY, 4}}, + { 4, {CONTENTS_SOLID, CONTENTS_EMPTY}}, +}; + +static plane_t planes_covered_step[] = { + {{0, 0, 1}, 0, 2, 0}, + {{0, 0, 1}, 32, 2, 0}, + {{1, 0, 0}, 0, 0, 0}, + {{1, 0, 0}, -20, 0, 0}, + {{0, 0, 1}, 40, 2, 0}, +}; + +hull_t hull_covered_step = { + clipnodes_covered_step, + planes_covered_step, + 0, + 4, + {0, 0, 0}, + {0, 0, 0}, +}; + +// 0 +// eee|eee +// eee+--- 1 +// ee/0,0s +// 2 ssss +static mclipnode_t clipnodes_ramp[] = { + { 0, { 1, 2}}, + { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, + { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, +}; + +static plane_t planes_ramp[] = { + {{ 1, 0, 0}, 0, 0, 0}, + {{ 0, 0, 1}, 0, 2, 0}, + {{-0.6, 0, 0.8}, 0, 4, 0}, +}; + +hull_t hull_ramp = { + clipnodes_ramp, + planes_ramp, + 0, + 2, + {0, 0, 0}, + {0, 0, 0}, +}; + +// 2 1 +// ss|sss|ss +// ss+-3-+ss 8 +// ss|eee|ss +// ss+-4-+ss -8 +// ss|sss|ss +// -8 8 +// looking at plane 0: back of 0 is empty, front of 0 has above hole +static mclipnode_t clipnodes_hole[] = { + { 0, { 1, CONTENTS_EMPTY}}, + { 1, {CONTENTS_SOLID, 2}}, + { 2, { 3, CONTENTS_SOLID}}, + { 3, {CONTENTS_SOLID, 4}}, + { 4, {CONTENTS_EMPTY, CONTENTS_SOLID}}, +}; + +static plane_t planes_hole[] = { + {{ 0, 1, 0}, 0, 1, 0}, + {{ 1, 0, 0}, 8, 0, 0}, + {{ 1, 0, 0}, -8, 0, 0}, + {{ 0, 0, 1}, 8, 2, 0}, + {{ 0, 0, 1}, -8, 2, 0}, +}; + +hull_t hull_hole = { + clipnodes_hole, + planes_hole, + 0, + 4, + {0, 0, 0}, + {0, 0, 0}, +}; diff --git a/libs/models/test/hulls.h b/libs/models/test/hulls.h new file mode 100644 index 000000000..a8976f3ee --- /dev/null +++ b/libs/models/test/hulls.h @@ -0,0 +1,12 @@ +#include "world.h" + +extern hull_t hull_simple_wedge; +extern hull_t hull_tpp1; +extern hull_t hull_tpp2; +extern hull_t hull_tppw; +extern hull_t hull_step1; +extern hull_t hull_step2; +extern hull_t hull_step3; +extern hull_t hull_covered_step; +extern hull_t hull_ramp; +extern hull_t hull_hole; diff --git a/libs/models/test/testclip.c b/libs/models/test/testclip.c index 1f0c6578f..165121918 100644 --- a/libs/models/test/testclip.c +++ b/libs/models/test/testclip.c @@ -4,6 +4,8 @@ #include "getopt.h" #include "world.h" +#include "hulls.h" + #undef DIST_EPSILON #define DIST_EPSILON 0 @@ -22,283 +24,6 @@ && FloatCompare (x[2], y[2])) -// 0,0 -// |\ . -// |s\ . -// |ss\ . -// 0 1 - -mclipnode_t clipnodes_simple_wedge[] = { - { 0, { 1, CONTENTS_EMPTY}}, - { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, -}; - -plane_t planes_simple_wedge[] = { - {{1, 0, 0}, 0, 0, 0}, // 0 - {{0.8, 0, 0.6}, 0, 4, 0}, // 1 -}; - -hull_t hull_simple_wedge = { - clipnodes_simple_wedge, - planes_simple_wedge, - 0, - 1, - {0, 0, 0}, - {0, 0, 0}, -}; - -// -32 32 48 -// sss|sss| |sss -// sss|sss| |sss -// 0 1 2 - -mclipnode_t clipnodes_tpp1[] = { - { 0, { 1, CONTENTS_SOLID}}, - { 1, { 2, CONTENTS_SOLID}}, - { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, -}; - -plane_t planes_tpp1[] = { - {{1, 0, 0}, -32, 0, 0}, - {{1, 0, 0}, 32, 0, 0}, - {{1, 0, 0}, 48, 0, 0}, -}; - -hull_t hull_tpp1 = { - clipnodes_tpp1, - planes_tpp1, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// -32 32 48 -// sss|sss| |sss -// sss|sss| |sss -// 1 0 2 - -mclipnode_t clipnodes_tpp2[] = { - { 0, { 2, 1}}, - { 1, {CONTENTS_SOLID, CONTENTS_SOLID}}, - { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, -}; - -plane_t planes_tpp2[] = { - {{1, 0, 0}, 32, 0, 0}, - {{1, 0, 0}, -32, 0, 0}, - {{1, 0, 0}, 48, 0, 0}, -}; - -hull_t hull_tpp2 = { - clipnodes_tpp2, - planes_tpp2, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// -32 32 48 -// sss| |www|sss -// sss| |www|sss -// 1 0 2 - -mclipnode_t clipnodes_tppw[] = { - { 0, { 2, 1}}, - { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, - { 2, {CONTENTS_SOLID, CONTENTS_WATER}}, -}; - -plane_t planes_tppw[] = { - {{1, 0, 0}, 32, 0, 0}, - {{1, 0, 0}, -32, 0, 0}, - {{1, 0, 0}, 48, 0, 0}, -}; - -hull_t hull_tppw = { - clipnodes_tppw, - planes_tppw, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// 2 -// eee|eee -// 0,32+--- 1 -// eee|sss -// ---+--- 0 -// ss0,0ss -mclipnode_t clipnodes_step1[] = { - { 0, { 1, CONTENTS_SOLID}}, - { 1, {CONTENTS_EMPTY, 2}}, - { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, -}; - -plane_t planes_step1[] = { - {{0, 0, 1}, 0, 2, 0}, - {{0, 0, 1}, 32, 2, 0}, - {{1, 0, 0}, 0, 0, 0}, -}; - -hull_t hull_step1 = { - clipnodes_step1, - planes_step1, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// 0 -// eee|eee -// 0,32+--- 1 -// eee|sss -// ---+sss 2 -// ss0,0ss -mclipnode_t clipnodes_step2[] = { - { 0, { 1, 2}}, - { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, - { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, -}; - -plane_t planes_step2[] = { - {{1, 0, 0}, 0, 0, 0}, - {{0, 0, 1}, 32, 2, 0}, - {{0, 0, 1}, 0, 2, 0}, -}; - -hull_t hull_step2 = { - clipnodes_step2, - planes_step2, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// 0 -// eee|eee -// 2---+0,32 -// sss|eee -// sss+--- 1 -// ss0,0ss -mclipnode_t clipnodes_step3[] = { - { 0, { 1, 2}}, - { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, - { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, -}; - -plane_t planes_step3[] = { - {{1, 0, 0}, 0, 0, 0}, - {{0, 0, 1}, 0, 2, 0}, - {{0, 0, 1}, 32, 2, 0}, -}; - -hull_t hull_step3 = { - clipnodes_step3, - planes_step3, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// 3 2 -// s|e|eee -// 4-+e|-20,40 -// e|e|eee -// 0,32+--- 1 -// eee|sss -// ---+--- 0 -// ss0,0ss -mclipnode_t clipnodes_covered_step[] = { - { 0, { 1, CONTENTS_SOLID}}, - { 1, { 3, 2}}, - { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, - { 3, {CONTENTS_EMPTY, 4}}, - { 4, {CONTENTS_SOLID, CONTENTS_EMPTY}}, -}; - -plane_t planes_covered_step[] = { - {{0, 0, 1}, 0, 2, 0}, - {{0, 0, 1}, 32, 2, 0}, - {{1, 0, 0}, 0, 0, 0}, - {{1, 0, 0}, -20, 0, 0}, - {{0, 0, 1}, 40, 2, 0}, -}; - -hull_t hull_covered_step = { - clipnodes_covered_step, - planes_covered_step, - 0, - 4, - {0, 0, 0}, - {0, 0, 0}, -}; - -// 0 -// eee|eee -// eee+--- 1 -// ee/0,0s -// 2 ssss -mclipnode_t clipnodes_ramp[] = { - { 0, { 1, 2}}, - { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, - { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, -}; - -plane_t planes_ramp[] = { - {{ 1, 0, 0}, 0, 0, 0}, - {{ 0, 0, 1}, 0, 2, 0}, - {{-0.6, 0, 0.8}, 0, 4, 0}, -}; - -hull_t hull_ramp = { - clipnodes_ramp, - planes_ramp, - 0, - 2, - {0, 0, 0}, - {0, 0, 0}, -}; - -// 2 1 -// ss|sss|ss -// ss+-3-+ss 8 -// ss|eee|ss -// ss+-4-+ss -8 -// ss|sss|ss -// -8 8 -// looking at plane 0: back of 0 is empty, front of 0 has above hole -mclipnode_t clipnodes_hole[] = { - { 0, { 1, CONTENTS_EMPTY}}, - { 1, {CONTENTS_SOLID, 2}}, - { 2, { 3, CONTENTS_SOLID}}, - { 3, {CONTENTS_SOLID, 4}}, - { 4, {CONTENTS_EMPTY, CONTENTS_SOLID}}, -}; - -plane_t planes_hole[] = { - {{ 0, 1, 0}, 0, 1, 0}, - {{ 1, 0, 0}, 8, 0, 0}, - {{ 1, 0, 0}, -8, 0, 0}, - {{ 0, 0, 1}, 8, 2, 0}, - {{ 0, 0, 1}, -8, 2, 0}, -}; - -hull_t hull_hole = { - clipnodes_hole, - planes_hole, - 0, - 4, - {0, 0, 0}, - {0, 0, 0}, -}; - - typedef struct { vec3_t extents; } box_t;