2016-01-03 07:18:14 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-12-06 06:30:56 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "QF/va.h"
|
|
|
|
|
|
|
|
#include "getopt.h"
|
2021-02-05 12:42:35 +00:00
|
|
|
#include "mod_internal.h"
|
2010-12-06 06:30:56 +00:00
|
|
|
#include "world.h"
|
|
|
|
|
2011-12-03 11:20:33 +00:00
|
|
|
#include "hulls.h"
|
|
|
|
|
2010-12-06 06:30:56 +00:00
|
|
|
#undef DIST_EPSILON
|
|
|
|
#define DIST_EPSILON 0
|
|
|
|
|
|
|
|
#ifdef TEST_ID
|
|
|
|
# include "trace-id.c"
|
2011-09-27 08:09:04 +00:00
|
|
|
#elif defined(TEST_QF_BAD)
|
|
|
|
# include "trace-qf-bad.c"
|
2010-12-06 06:30:56 +00:00
|
|
|
#else
|
2011-06-12 07:12:52 +00:00
|
|
|
# include "../trace.c"
|
2010-12-06 06:30:56 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-28 08:03:56 +00:00
|
|
|
#define FloatCompare(a, b) (fabs (a - b) < 1e-5)
|
2011-11-27 05:19:05 +00:00
|
|
|
#undef VectorCompare
|
|
|
|
#define VectorCompare(x, y) \
|
|
|
|
(FloatCompare (x[0], y[0]) && FloatCompare (x[1], y[1]) \
|
|
|
|
&& FloatCompare (x[2], y[2]))
|
|
|
|
|
|
|
|
|
2010-12-06 06:30:56 +00:00
|
|
|
typedef struct {
|
|
|
|
vec3_t extents;
|
|
|
|
} box_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char *desc;
|
|
|
|
box_t *box;
|
|
|
|
hull_t *hull;
|
|
|
|
vec3_t start;
|
|
|
|
vec3_t end;
|
|
|
|
struct {
|
|
|
|
float frac;
|
|
|
|
qboolean allsolid;
|
|
|
|
qboolean startsolid;
|
|
|
|
qboolean inopen;
|
|
|
|
qboolean inwater;
|
|
|
|
} expect;
|
|
|
|
} test_t;
|
|
|
|
|
2011-12-07 06:31:33 +00:00
|
|
|
box_t point = { { 0, 0, 0} };
|
|
|
|
box_t box = { { 8, 8, 8} };
|
|
|
|
box_t bigbox = { { 8, 8, 24} };
|
2010-12-06 06:30:56 +00:00
|
|
|
box_t player = { {16, 16, 28} };
|
|
|
|
|
|
|
|
test_t tests[] = {
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 1", &point, &hull_tpp1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-64, 0, 0}, { 64, 0, 0}, { 1, 1, 1, 0, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 1", &point, &hull_tpp1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 40, 0, 0}, { 1, 0, 1, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 1", &point, &hull_tpp1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 40, 0, 0}, {-88, 0, 0}, {0.0625, 0, 0, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 1", &point, &hull_tpp1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 64, 0, 0}, { 0.75, 0, 1, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 1", &point, &hull_tpp1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 0, 8, 0}, { 1, 1, 1, 0, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 1", &point, &hull_tpp1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 40, 0, 0}, { 40, 8, 0}, { 1, 0, 0, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
|
|
|
|
{"Point, Three parallel planes 2", &point, &hull_tpp2,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-64, 0, 0}, { 64, 0, 0}, { 1, 1, 1, 0, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 2", &point, &hull_tpp2,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 40, 0, 0}, { 1, 0, 1, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 2", &point, &hull_tpp2,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 40, 0, 0}, {-88, 0, 0}, {0.0625, 0, 0, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes 2", &point, &hull_tpp2,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 64, 0, 0}, { 0.75, 0, 1, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
|
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-64, 0, 0}, { 64, 0, 0}, { 0.875, 0, 1, 1, 1}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 40, 0, 0}, { 1, 0, 0, 1, 1}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 40, 0, 0}, {-88, 0, 0}, {0.5625, 0, 0, 1, 1}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 64, 0, 0}, { 0.75, 0, 0, 1, 1}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 0, 8, 0}, { 1, 0, 0, 1, 0}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 40, 0, 0}, { 40, 8, 0}, { 1, 0, 0, 0, 1}},
|
2011-06-12 08:03:51 +00:00
|
|
|
{"Point, Three parallel planes with water", &point, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 0}, { 40, 0, 0}, { 1, 0, 0, 1, 1}},
|
2011-12-05 00:03:04 +00:00
|
|
|
{"Box, Three parallel planes with water", &box, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-32, 0, 0}, { 40, 0, 0}, { 1, 0, 1, 1, 1}},
|
2011-12-05 00:03:04 +00:00
|
|
|
{"Box, Three parallel planes with water", &box, &hull_tppw,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-32, 0, 0}, { 20, 0, 0}, { 1, 0, 1, 1, 0}},
|
2011-10-02 12:06:56 +00:00
|
|
|
|
|
|
|
{"Point, Step 1", &point, &hull_step1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -16, 0, 8}, {16, 0, 24}, { 0.5, 0, 0, 1, 0}},
|
2011-10-02 12:06:56 +00:00
|
|
|
{"Box, Step 1", &box, &hull_step1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -16, 0, 8}, {16, 0, 24}, { 0.25, 0, 0, 1, 0}},
|
2011-11-12 09:12:56 +00:00
|
|
|
{"Box, Step 1", &box, &hull_step1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -16, 0, 8}, {16, 0, 40}, { 0.25, 0, 0, 1, 0}},
|
2011-11-12 09:53:05 +00:00
|
|
|
{"Box, Step 1", &box, &hull_step1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -16, 0, 8}, {16, 0, 135}, { 0.25, 0, 0, 1, 0}},
|
2011-11-12 09:53:05 +00:00
|
|
|
{"Box, Step 1", &box, &hull_step1,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -16, 0, 8}, {16, 0, 136}, { 1, 0, 0, 1, 0}},
|
2011-11-12 11:42:44 +00:00
|
|
|
|
|
|
|
{"Point, Covered Step", &point, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -24, 0, 8}, {-24, 0, 72}, { 0.5, 0, 0, 1, 0}},
|
2011-11-12 11:42:44 +00:00
|
|
|
{"Box, Covered Step", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -32, 0, 8}, {-32, 0, 72}, { 0.375, 0, 0, 1, 0}},
|
2011-11-12 11:42:44 +00:00
|
|
|
{"Box, Covered Step", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -24, 0, 8}, {-24, 0, 72}, { 0.375, 0, 0, 1, 0}},
|
2011-11-12 11:42:44 +00:00
|
|
|
{"Box, Covered Step", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -25, 0, 8}, { 7, 0, 72}, { 0.375, 0, 0, 1, 0}},
|
2011-11-12 12:30:45 +00:00
|
|
|
{"Box, Covered Step", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -8, 0, 40}, {-16, 0, 40}, { 0.5, 0, 0, 1, 0}},
|
2011-11-12 12:30:45 +00:00
|
|
|
{"Box, Covered Step", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -17, 0, 8}, { -1, 0, 72}, { 1, 0, 0, 1, 0}},
|
2011-11-12 11:42:44 +00:00
|
|
|
{"Box, Covered Step", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -8, 0, 40}, { 8, 0, 72}, { 1, 0, 0, 1, 0}},
|
2011-11-28 08:12:39 +00:00
|
|
|
{"Box, Covered Step touch backside", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -8, 0, 8}, {-12, 0, 12}, { 1, 0, 0, 1, 0}},
|
2011-11-28 08:12:39 +00:00
|
|
|
{"Point, Covered Step touch backside", &point, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 8}, {-12, 0, 12}, { 1, 0, 1, 1, 0}},
|
2011-12-04 12:12:12 +00:00
|
|
|
{"Point, Covered Step start solid", &point, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, -4}, {-16, 0, 12}, { 1, 0, 1, 1, 0}},
|
2011-12-04 12:12:12 +00:00
|
|
|
{"Point, Covered Step start solid", &point, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 4, 0, -4}, {-12, 0, 12}, { 1, 1, 1, 0, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -4, 0, 4}, {-12, 0, 12}, { 1, 0, 1, 1, 0}},
|
2011-12-04 12:12:12 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -17, 0, 4}, {-17, 0, 12}, { 1, 0, 1, 1, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -4, 0, 4}, {-16, 0, 36}, { 0.875, 0, 1, 1, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -4, 0, 4}, {-16, 0, 4}, { 1, 1, 1, 0, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -12, 0, 4}, {-16, 0, 4}, { 1, 1, 1, 0, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -16, 0, 4}, { -4, 0, 4}, { 1, 1, 1, 0, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 16, 0, -16}, { 16, 0, 64}, { 1, 1, 1, 0, 0}},
|
2011-11-28 11:28:37 +00:00
|
|
|
{"Box, Covered Step start solid", &box, &hull_covered_step,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 16, 0, 16}, { 16, 0, 64}, { 1, 0, 1, 1, 0}},
|
2011-11-12 12:30:45 +00:00
|
|
|
|
|
|
|
{"Box, Step 2", &box, &hull_step2,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 64}, {0, 0, 0}, { 0.375, 0, 0, 1, 0}},
|
2011-11-12 12:30:45 +00:00
|
|
|
{"Box, Step 3", &box, &hull_step3,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 64}, {0, 0, 0}, { 0.375, 0, 0, 1, 0}},
|
2011-11-14 00:26:31 +00:00
|
|
|
|
|
|
|
{"Box, Ramp", &box, &hull_ramp,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 16}, { 0, 0, 0}, { 0.5, 0, 0, 1, 0}},
|
2011-11-27 05:22:32 +00:00
|
|
|
{"Box, Ramp", &box, &hull_ramp,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-16, 0, 8}, {16, 0, 8}, { 1, 0, 0, 1, 0}},
|
2011-11-27 05:22:32 +00:00
|
|
|
{"Box, Ramp", &box, &hull_ramp,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-16, 0, 5}, {16, 0, 5}, { 0.125, 0, 0, 1, 0}},
|
2011-11-28 08:03:56 +00:00
|
|
|
|
|
|
|
{"Box, Simple Wedge", &box, &hull_simple_wedge,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 0, 16}, { 0, 0, 0}, { 0.5, 0, 0, 1, 0}},
|
2011-11-28 08:03:56 +00:00
|
|
|
{"Box, Simple Wedge", &box, &hull_simple_wedge,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-16, 0, 8}, {16, 0, 8}, { 1, 0, 0, 1, 0}},
|
2011-11-28 08:03:56 +00:00
|
|
|
{"Box, Simple Wedge", &box, &hull_simple_wedge,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-16, 0, 5}, {16, 0, 5}, { 0.25, 0, 0, 1, 0}},
|
2011-11-28 08:03:56 +00:00
|
|
|
{"Box, Simple Wedge", &box, &hull_simple_wedge,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-16, 0, 12}, {16, 0, 4}, { 0.5, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
|
|
|
|
{"Box, Hole. slide in", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, -16, 0}, { 0, 16, 0}, { 1, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. slide out", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 16, 0}, { 0, -16, 0}, { 1, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. tight", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 16, 0}, { 0, 16, 16}, { 0, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. tight", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 16, 0}, { 0, 16, -16}, { 0, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. tight", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 16, 0}, { 16, 16, 0}, { 0, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. tight", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, 16, 0}, {-16, 16, 0}, { 0, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. edge", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, -16, 1}, { 0, 16, 1}, { 0.25, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. edge", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 0, -16, -1}, { 0, 16, -1}, { 0.25, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. edge", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 1, -16, 0}, { 1, 16, 0}, { 0.25, 0, 0, 1, 0}},
|
2011-11-28 10:07:00 +00:00
|
|
|
{"Box, Hole. edge", &box, &hull_hole,
|
2011-12-08 05:59:35 +00:00
|
|
|
{-1, -16, 0}, { -1, 16, 0}, { 0.25, 0, 0, 1, 0}},
|
2011-12-04 00:02:12 +00:00
|
|
|
|
|
|
|
{"Box, ridge", &box, &hull_ridge,
|
2011-12-08 05:59:35 +00:00
|
|
|
{4, 0, 41}, { 4, 0, 39}, { 0.5, 0, 0, 1, 0}},
|
2011-12-04 02:00:38 +00:00
|
|
|
{"Box, ridge, all solid", &box, &hull_ridge,
|
2011-12-08 05:59:35 +00:00
|
|
|
{4, 41, 0}, { 4, 39, 0}, { 1, 1, 1, 0, 0}},
|
2011-12-06 11:47:57 +00:00
|
|
|
|
|
|
|
{"Box, cave. start solid", &box, &hull_cave,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 4, 0, -16}, { 4, 0, 0}, { 0.5, 0, 1, 0, 1}},
|
2011-12-06 11:47:57 +00:00
|
|
|
{"Box, cave. start solid", &box, &hull_cave,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ -8, 0, -16}, { -8, 0, 0}, { 0.5, 0, 1, 0, 1}},
|
2011-12-07 04:31:21 +00:00
|
|
|
{"Box, cave. start solid", &box, &hull_cave,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 54, 0, -16}, { 54, 0, 56}, { 0.5, 0, 1, 1, 0}},
|
2011-12-07 04:31:21 +00:00
|
|
|
{"Box, cave", &box, &hull_cave,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 54, 0, 12}, { 54, 0, 28}, { 0.5, 0, 0, 1, 0}},
|
2011-12-07 06:31:33 +00:00
|
|
|
{"Big Box, cave. start solid", &bigbox, &hull_cave,
|
2011-12-08 05:59:35 +00:00
|
|
|
{ 54, 0, 0}, { 54, 0, 8}, { 0.5, 0, 1, 1, 0}},
|
2010-12-06 06:30:56 +00:00
|
|
|
};
|
|
|
|
#define num_tests (sizeof (tests) / sizeof (tests[0]))
|
|
|
|
|
|
|
|
int verbose = 0;
|
|
|
|
|
|
|
|
static trace_t
|
|
|
|
do_trace (box_t *box, hull_t *hull, vec3_t start, vec3_t end)
|
|
|
|
{
|
|
|
|
trace_t trace;
|
|
|
|
|
|
|
|
trace.allsolid = true;
|
|
|
|
trace.startsolid = false;
|
|
|
|
trace.inopen = false;
|
|
|
|
trace.inwater = false;
|
|
|
|
trace.fraction = 1;
|
|
|
|
VectorCopy (box->extents, trace.extents);
|
2011-11-20 03:02:56 +00:00
|
|
|
// FIXME specify tract type in test spec
|
|
|
|
trace.type = box == &point ? tr_point : tr_box;
|
2010-12-06 06:30:56 +00:00
|
|
|
VectorCopy (end, trace.endpos);
|
|
|
|
MOD_TraceLine (hull, 0, start, end, &trace);
|
|
|
|
return trace;
|
|
|
|
}
|
|
|
|
|
2011-11-15 03:57:08 +00:00
|
|
|
typedef struct portlist_s {
|
|
|
|
struct portlist_s *next;
|
|
|
|
clipport_t *portal;
|
|
|
|
} portlist_t;
|
|
|
|
|
|
|
|
static portlist_t *
|
|
|
|
collect_portals (clipport_t *portal, portlist_t *portal_list)
|
|
|
|
{
|
|
|
|
portlist_t *p;
|
|
|
|
|
|
|
|
if (!portal)
|
|
|
|
return portal_list;
|
|
|
|
for (p = portal_list; p; p = p->next)
|
|
|
|
if (p->portal == portal)
|
|
|
|
return portal_list;
|
|
|
|
p = malloc (sizeof (portlist_t));
|
|
|
|
p->portal = portal;
|
|
|
|
p->next = portal_list;
|
|
|
|
portal_list = p;
|
|
|
|
portal_list = collect_portals (portal->next[0], portal_list);
|
|
|
|
portal_list = collect_portals (portal->next[1], portal_list);
|
|
|
|
return portal_list;
|
|
|
|
}
|
|
|
|
|
2010-12-06 06:30:56 +00:00
|
|
|
static int
|
|
|
|
run_test (test_t *test)
|
|
|
|
{
|
|
|
|
const char *desc;
|
|
|
|
vec3_t end;
|
2011-12-06 11:48:31 +00:00
|
|
|
int err = 0;
|
2010-12-06 06:30:56 +00:00
|
|
|
char *expect;
|
|
|
|
char *got;
|
|
|
|
static int output = 0;
|
2011-11-15 03:57:08 +00:00
|
|
|
portlist_t *portal_list = 0;
|
|
|
|
|
2012-11-28 12:29:03 +00:00
|
|
|
if (!test->hull->depth)
|
|
|
|
Mod_FindClipDepth (test->hull);
|
2011-11-15 03:57:08 +00:00
|
|
|
if (!test->hull->nodeleafs) {
|
|
|
|
hull_t *hull = test->hull;
|
|
|
|
int i, j;
|
|
|
|
portlist_t *p;
|
|
|
|
clipleaf_t *leaf;
|
|
|
|
|
|
|
|
hull->nodeleafs = MOD_BuildBrushes (hull);
|
|
|
|
for (i = hull->firstclipnode; i <= hull->lastclipnode; i++) {
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
leaf = hull->nodeleafs[i].leafs[j];
|
|
|
|
if (!leaf)
|
|
|
|
continue;
|
|
|
|
portal_list = collect_portals (leaf->portals, portal_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (p = portal_list; p; p = p->next) {
|
2011-11-27 23:57:42 +00:00
|
|
|
for (j = 0; j < p->portal->winding->numpoints; j++) {
|
|
|
|
p->portal->winding->points[j][0]
|
|
|
|
= bound (-8192, p->portal->winding->points[j][0], 8192);
|
|
|
|
p->portal->winding->points[j][1]
|
|
|
|
= bound (-8192, p->portal->winding->points[j][1], 8192);
|
|
|
|
p->portal->winding->points[j][2]
|
|
|
|
= bound (-8192, p->portal->winding->points[j][2], 8192);
|
|
|
|
}
|
2011-12-07 03:16:58 +00:00
|
|
|
FreeWinding (p->portal->edges);
|
|
|
|
p->portal->edges = WindingVectors (p->portal->winding, 0);
|
2011-11-15 03:57:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (portal_list) {
|
|
|
|
portlist_t *t = portal_list;
|
|
|
|
portal_list = portal_list->next;
|
|
|
|
free (t);
|
|
|
|
}
|
2010-12-06 06:30:56 +00:00
|
|
|
|
|
|
|
VectorSubtract (test->end, test->start, end);
|
|
|
|
VectorMultAdd (test->start, test->expect.frac, end, end);
|
|
|
|
expect = nva ("expect: (%g %g %g) -> (%g %g %g) => (%g %g %g)"
|
2011-12-05 00:34:43 +00:00
|
|
|
" %3g as:%d ss:%d io:%d iw:%d",
|
2010-12-06 06:30:56 +00:00
|
|
|
test->start[0], test->start[1], test->start[2],
|
|
|
|
test->end[0], test->end[1], test->end[2],
|
|
|
|
end[0], end[1], end[2],
|
2012-05-21 23:23:22 +00:00
|
|
|
test->expect.frac,
|
2010-12-06 06:30:56 +00:00
|
|
|
test->expect.allsolid, test->expect.startsolid,
|
|
|
|
test->expect.inopen, test->expect.inwater);
|
|
|
|
trace_t trace = do_trace (test->box, test->hull, test->start, test->end);
|
|
|
|
got = nva (" got: (%g %g %g) -> (%g %g %g) => (%g %g %g)"
|
2011-12-05 00:34:43 +00:00
|
|
|
" %3g as:%d ss:%d io:%d iw:%d",
|
2010-12-06 06:30:56 +00:00
|
|
|
test->start[0], test->start[1], test->start[2],
|
|
|
|
test->end[0], test->end[1], test->end[2],
|
|
|
|
trace.endpos[0], trace.endpos[1], trace.endpos[2],
|
2012-05-21 23:23:22 +00:00
|
|
|
trace.fraction,
|
2010-12-06 06:30:56 +00:00
|
|
|
trace.allsolid, trace.startsolid,
|
|
|
|
trace.inopen, trace.inwater);
|
2011-12-06 11:48:31 +00:00
|
|
|
if (!(VectorCompare (end, trace.endpos)
|
|
|
|
&& FloatCompare (test->expect.frac, trace.fraction)
|
|
|
|
&& test->expect.allsolid == trace.allsolid
|
|
|
|
&& test->expect.startsolid == trace.startsolid
|
|
|
|
&& test->expect.inopen == trace.inopen
|
|
|
|
&& test->expect.inwater == trace.inwater))
|
|
|
|
err = 1;
|
2010-12-06 06:30:56 +00:00
|
|
|
|
|
|
|
if (test->desc)
|
2021-02-05 12:42:35 +00:00
|
|
|
desc = va (0, "(%d) %s", (int)(long)(test - tests), test->desc);
|
2010-12-06 06:30:56 +00:00
|
|
|
else
|
2021-02-05 12:42:35 +00:00
|
|
|
desc = va (0, "test #%d", (int)(long)(test - tests));
|
2011-12-06 11:48:31 +00:00
|
|
|
if (verbose >= 0 || err) {
|
2010-12-06 06:30:56 +00:00
|
|
|
if (output)
|
|
|
|
puts("");
|
|
|
|
output = 1;
|
|
|
|
puts (expect);
|
|
|
|
puts (got);
|
2011-12-06 11:48:31 +00:00
|
|
|
printf ("%s: %s\n", !err ? "PASS" : "FAIL", desc);
|
2010-12-06 06:30:56 +00:00
|
|
|
}
|
|
|
|
free (expect);
|
|
|
|
free (got);
|
2011-12-06 11:48:31 +00:00
|
|
|
return !err;
|
2010-12-06 06:30:56 +00:00
|
|
|
}
|
|
|
|
|
2011-12-03 12:13:01 +00:00
|
|
|
#include "main.c"
|