Split out the hull data so it can be used in other tests.

This commit is contained in:
Bill Currie 2011-12-03 20:20:33 +09:00
parent 9ad298a716
commit dadfb78992
4 changed files with 293 additions and 279 deletions

View file

@ -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

277
libs/models/test/hulls.c Normal file
View file

@ -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},
};

12
libs/models/test/hulls.h Normal file
View file

@ -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;

View file

@ -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;