Remove almost all of my boxclip developement.

This is to prevent others accidently getting headaches from my code.
This commit is contained in:
Bill Currie 2010-08-20 14:13:23 +09:00
parent fd24170b32
commit 2185a3dcd0
7 changed files with 1 additions and 825 deletions

View file

@ -119,17 +119,6 @@ if test "x$enable_typecheck_progs" = xyes; then
AC_DEFINE(TYPECHECK_PROGS, 1, [Define this if you want progs typechecking])
fi
AC_ARG_ENABLE(boxclip,
[ --enable-boxclip enable box clipping],
boxclip=$enable_boxclip,
boxclip=no
)
if test "x$boxclip" != xno; then
AC_DEFINE(ENABLE_BOXCLIP, 1, [Define if you want boxclipping])
else
AC_DEFINE(ENABLE_BOXCLIP, 0, [Define if you want boxclipping])
fi
dnl Output files
m4_include(config.d/rpm.m4)

View file

@ -4,12 +4,6 @@ SUBDIRS= alias brush sprite
CFLAGS+= @PREFER_PIC@
INCLUDES= -I$(top_srcdir)/include
noinst_PROGRAMS= testclip
testclip_SOURCES=testclip.c
testclip_LDADD= libQFmodels.la $(top_builddir)/libs/util/libQFutil.la
testclip_DEPENDENCIES=
lib_LTLIBRARIES= libQFmodels.la @VID_MODEL_TARGETS@
EXTRA_LTLIBRARIES= \
libQFmodels_gl.la libQFmodels_sw.la

View file

@ -1,428 +0,0 @@
#include "QF/va.h"
#include "getopt.h"
#include "world.h"
#undef DIST_EPSILON
#define DIST_EPSILON 0
#define TEST_BOXCLIP
#include "trace.c"
dclipnode_t clipnodes0[] = {
{ 0, { 1, -1}},
{ 1, {-1, -2}},
};
mplane_t planes0[] = {
{{1, 0, 0}, 0, 0, 0}, // 0
{{0.8, 0, 0.6}, 0, 4, 0}, // 1
};
hull_t hull0 = {
clipnodes0,
planes0,
0,
1,
{0, 0, 0},
{0, 0, 0},
};
dclipnode_t clipnodes1[] = {
{ 0, { 1, -2}},
{ 1, {-2, 2}},
{ 2, {-2, 3}},
{ 3, { 4, -2}},
{ 4, { 5, 6}},
{ 5, {-2, -1}},
{ 6, { 7, 8}},
{ 7, {-1, -2}},
{ 8, { 9, 13}},
{ 9, {10, -1}},
{ 10, {-1, 11}},
{ 11, {12, -2}},
{ 12, {-2, -1}},
{ 13, {-1, -2}},
};
mplane_t planes1[] = {
{{0, 1, 0}, -96, 1, 0}, // 0 wall at right
{{0, 1, 0}, 96, 1, 0}, // 1 wall at left (with ditch)
{{1, 0, 0}, 128, 0, 0}, // 2 wall at front (with shelves)
{{1, 0, 0}, -32, 0, 0}, // 3 wall at back
{{0, 0, 1}, 32, 2, 0}, // 4 top of shelves
{{0, 0, 1}, 104, 2, 0}, // 5 ceiling
{{0, 1, 0}, 32, 1, 0}, // 6 edge of ditch
{{0, 0, 1}, -24, 2, 0}, // 7 floor of ditch
{{0, 0, 1}, 24, 2, 0}, // 8 bottom of selves
{{1, 0, 0}, 64, 0, 0}, // 9 end of shelves
{{0, 1, 0}, -16, 1, 0}, // 10 ditch side of 2nd shelf
{{0, 1, 0}, -64, 1, 0}, // 11 ditch side of 1st shelf
{{0, 1, 0}, -48, 1, 0}, // 12 1st shelf side of 2nd shelf
{{0, 0, 1}, 8, 2, 0}, // 13 main floor
};
hull_t hull1 = {
clipnodes1,
planes1,
0,
13,
{0, 0, 0},
{0, 0, 0},
};
dclipnode_t clipnodes2[] = {
{0, {1, 12}}, // 0
{1, {-1, 2}}, // 1
{2, {3, 6}}, // 2
{3, {-1, 4}}, // 3
{4, {5, -1}}, // 4
{5, {-1, -2}}, // 5
{6, {7, 9}}, // 6
{7, {-1, 8}}, // 7
{4, {-2, -1}}, // 8
{8, {10, -1}}, // 9
{5, {-1, 11}}, // 10
{4, {-2, -1}}, // 11
{9, {13, 25}}, // 12
{2, {-1, 14}}, // 13
{6, {15, 19}}, // 14
{10, {-1, 16}}, // 15
{11, {17, 18}}, // 16
{7, {-1, -2}}, // 17
{4, {-2, -1}}, // 18
{11, {20, 23}}, // 19
{12, {-1, 21}}, // 20
{8, {22, -1}}, // 21
{5, {-1, -2}}, // 22
{8, {24, -1}}, // 23
{4, {-2, -1}}, // 24
{3, {-1, 26}}, // 25
{8, {27, -1}}, // 26
{11, {28, -1}}, // 27
{12, {-1, 29}}, // 28
{13, {-2, -1}}, // 29
};
mplane_t planes2[] = {
{{1, 0, 0}, 912, 0, 0, {0, 0}}, // 0 0
{{1, 0, 0}, 1168, 0, 0, {0, 0}}, // 1 1
{{0, 1, 0}, 2112, 1, 0, {0, 0}}, // 2 2 13
{{0, 1, 0}, 2128, 1, 0, {0, 0}}, // 3 3 25
{{0.229038, 0, 0.973417}, 18.3218, 5, 0, {0, 0}}, // 4 4 8 11 18 24
{{0.229038, -0, 0.973417}, 57.2585, 5, 0, {0, 0}}, // 5 5 10 22
{{0, 1, 0}, 1984, 1, 0, {0, 0}}, // 6 6 14
{{0.229039, -0, 0.973417}, 33.8978, 5, 0, {0, 0}}, // 7 7 17
{{0, 1, 0}, 1968, 1, 0, {0, 0}}, // 8 9 21 23 26
{{1, 0, 0}, 736, 0, 0, {0, 0}}, // 9 12
{{0, 0, 1}, -176, 2, 0, {0, 0}}, // 10 15
{{0, 0, 1}, -192, 2, 0, {0, 0}}, // 11 16 19 27
{{0, 0, 1}, -152, 2, 0, {0, 0}}, // 12 20 28
{{1, 0, 0}, 720, 0, 0, {0, 0}}, // 13 29
};
hull_t hull2 = {
clipnodes2,
planes2,
0,
6,
{0, 0, 0},
{0, 0, 0},
};
dclipnode_t clipnodes3[] = {
{0, {1, 12}}, // 0
{1, {2, 7}}, // 1
{2, {-2, 3}}, // 2
{3, {4, -2}}, // 3
{4, {-2, 5}}, // 4
{5, {-2, 6}}, // 5
{6, {-1, -2}}, // 6
{7, {-2, 8}}, // 7
{8, {9, -2}}, // 8
{9, {10, 11}}, // 9
{10, {-2, -1}}, // 10
{6, {-1, -2}}, // 11
{3, {13, -2}}, // 12
{11, {14, -2}}, // 13
{4, {-2, 15}}, // 14
{2, {-2, 16}}, // 15
{9, {-1, -2}}, // 16
};
mplane_t planes3[] = {
{{0, 1, 0}, -224, 1, 0, {0, 0}}, // 0
{{0, 1, 0}, -192, 1, 0, {0, 0}}, // 1
{{0, 0, 1}, 192, 2, 0, {0, 0}}, // 2
{{1, 0, 0}, 384, 0, 0, {0, 0}}, // 3
{{1, 0, 0}, 576, 0, 0, {0, 0}}, // 4
{{0, 1, 0}, -16, 1, 0, {0, 0}}, // 5
{{-0, 0.242536, 0.970142}, -3.88057, 5, 0, {0, 0}}, // 6
{{1, 0, 0}, 552, 0, 0, {0, 0}}, // 7
{{1, 0, 0}, 408, 0, 0, {0, 0}}, // 8
{{0, 0, 1}, 48, 2, 0, {0, 0}}, // 9
{{0, 0, 1}, 160, 2, 0, {0, 0}}, // 10
{{0, 1, 0}, -416, 1, 0, {0, 0}}, // 11
};
hull_t hull3 = {
clipnodes3,
planes3,
0,
16,
{0, 0, 0},
{0, 0, 0},
};
dclipnode_t clipnodes4[] = {
{0, {1, 25}}, // 0
{1, {-1, 2}}, // 1
{2, {3, 11}}, // 2
{3, {4, -1}}, // 3
{4, {5, 8}}, // 4
{5, {-1, 6}}, // 5
{6, {-1, 7}}, // 6
{7, {-1, -2}}, // 7
{5, {-1, 9}}, // 8
{8, {10, -1}}, // 9
{7, {-1, -2}}, // 10
{9, {12, 17}}, // 11
{4, {13, 15}}, // 12
{6, {-1, 14}}, // 13
{7, {-1, -2}}, // 14
{7, {-1, 16}}, // 15
{8, {-2, -1}}, // 16
{10, {-1, 18}}, // 17
{4, {19, 22}}, // 18
{11, {20, -1}}, // 19
{6, {-1, 21}}, // 20
{7, {-1, -2}}, // 21
{11, {23, -1}}, // 22
{7, {-1, 24}}, // 23
{8, {-2, -1}}, // 24
{11, {26, -1}}, // 25
{5, {-1, 27}}, // 26
{12, {28, -1}}, // 27
{13, {-1, 29}}, // 28
{14, {-2, -1}}, // 29
};
mplane_t planes4[] = {
{{0, 1, 0}, 832, 1, 0, {0, 0}}, // 0
{{0, 1, 0}, 1216, 1, 0, {0, 0}}, // 1
{{1, 0, 0}, 608, 0, 0, {0, 0}}, // 2
{{1, 0, 0}, 624, 0, 0, {0, 0}}, // 3
{{0, 0, 1}, -40, 2, 0, {0, 0}}, // 4
{{1, 0, 0}, 672, 0, 0, {0, 0}}, // 5
{{0, 0, 1}, -24, 2, 0, {0, 0}}, // 6
{{0, -0.242536, 0.970142}, -256.118, 5, 0, {0, 0}}, // 7
{{-0, -0.242536, 0.970142}, -271.64, 5, 0, {0, 0}}, // 8
{{1, 0, 0}, 480, 0, 0, {0, 0}}, // 9
{{1, 0, 0}, 464, 0, 0, {0, 0}}, // 10
{{1, 0, 0}, 416, 0, 0, {0, 0}}, // 11
{{0, 1, 0}, 768, 1, 0, {0, 0}}, // 12
{{0, 0, 1}, -64, 2, 0, {0, 0}}, // 13
{{0, 0, 1}, -80, 2, 0, {0, 0}}, // 14
};
hull_t hull4 = {
clipnodes4,
planes4,
0,
6,
{0, 0, 0},
{0, 0, 0},
};
typedef struct {
const char *desc;
hull_t *hull;
vec3_t start;
vec3_t end;
struct {
float frac;
qboolean allsolid;
qboolean startsolid;
qboolean inopen;
qboolean inwater;
} expect;
} test_t;
test_t tests[] = {
{0, &hull0, {-20, 0, 28}, {20, 0, 28}, {1, 0, 0, 1, 0}},
{0, &hull0, {-20, 0, 27}, {20, 0, 27}, {0.1, 0, 0, 1, 0}},
{0, &hull0, {-20, 0, -76}, {20, 0, -76}, {0.1, 0, 0, 1, 0}},
{0, &hull0, {-20, 0, -77}, {20, 0, -77}, {0.1, 0, 0, 1, 0}},
{"drop on trench edge",
&hull1, {0, 47, 40}, {0, 47, 32}, {0.5, 0, 0, 1, 0}},
{"drop past trench edge",
&hull1, {0, 48, 40}, {0, 48, 32}, {1, 0, 0, 1, 0}},
{"run into trench edge",
&hull1, {0, 52, 35}, {0, 44, 35}, {0.5, 0, 0, 1, 0}},
{"run over trench edge",
&hull1, {0, 52, 36}, {0, 44, 36}, {1, 0, 0, 1, 0}},
{"run into end of 2nd shelf",
&hull1, {47, -32, 36}, {49, -32, 36}, {0.5, 0, 0, 1, 0}},
{"run inside end of 2nd shelf",
&hull1, {48, -32, 36}, {50, -32, 36}, {1, 1, 1, 0, 0}},
{"run into end of 2nd shelf p2",
&hull1, {44, -32, 59}, {52, -32, 59}, {0.5, 0, 0, 1, 0}},
{"run over end of 2nd shelf",
&hull1, {44, -32, 60}, {52, -32, 60}, {1, 0, 0, 1, 0}},
{"drop past end of 2nd shelf",
&hull1, {47, -32, 76}, {47, -32, 44}, {1, 0, 1, 1, 0}},
{"drop onto end of 2nd shelf",
&hull1, {48, -32, 76}, {48, -32, 44}, {0.5, 0, 1, 1, 0}},
{"drop onto top of ramp: hull2",
&hull2, {896, 2048, -144}, {896, 2048, -152}, {0.5, 0, 0, 1, 0}},
{"drop onto edge of 2nd shelf p1",
&hull1, {96, -47, 61}, {96, -47, 59}, {0.5, 0, 0, 1, 0}},
{"drop onto edge of 2nd shelf p2",
&hull1, {96, -47.9612, 61}, {96, -47.1025, 59}, {0.5, 0, 0, 1, 0}},
{"drop onto edge of 2nd shelf p3",
&hull1, {94.8916, -34.8506, 61}, {94.8146, -28.5696, 59},
{0.5, 0, 0, 1, 0}},
{"run over top of ramp: hull3",
&hull3, {480, -216, 76}, {480, -200, 76}, {1, 0, 0, 1, 0}},
{"drop onto top of ramp, A: hull3",
&hull3, {480, -207.977, 77}, {468, -207.977, 75}, {0.5, 0, 0, 1, 0}},
{"drop onto top of ramp, B: hull3",
&hull3, {480, -208.873, 77}, {468, -208.873, 75}, {0.5, 0, 0, 1, 0}},
{"diagonal drop onto top of ramp: hull3",
&hull3, {480, -208.873, 77}, {468, -207.977, 75}, {0.5, 0, 0, 1, 0}},
{"drop onto thin bridge",
&hull4, {544, 1080, 5}, {544, 1080, 3}, {0.5, 0, 0, 1, 0}},
{"long drop onto thin bridge",
&hull4, {544, 1080, 78}, {544, 1080, -70}, {0.5, 0, 0, 1, 0}},
};
const int num_tests = sizeof (tests) / sizeof (tests[0]);
int verbose = 0;
static trace_t
do_trace (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;
trace.extents[0] = 16;
trace.extents[1] = 16;
trace.extents[2] = 28;
trace.isbox = true;
VectorCopy (end, trace.endpos);
MOD_TraceLine (hull, 0, start, end, &trace);
return trace;
}
static int
run_test (test_t *test)
{
const char *desc;
vec3_t end;
int res = 0;
VectorSubtract (test->end, test->start, end);
VectorMultAdd (test->start, test->expect.frac, end, end);
if (verbose)
printf ("expect: (%g %g %g) -> (%g %g %g) => (%g %g %g)"
" %3g %d %d %d %d\n",
test->start[0], test->start[1], test->start[2],
test->end[0], test->end[1], test->end[2],
end[0], end[1], end[2],
test->expect.frac,
test->expect.allsolid, test->expect.startsolid,
test->expect.inopen, test->expect.inwater);
trace_t trace = do_trace (test->hull, test->start, test->end);
if (verbose)
printf (" got: (%g %g %g) -> (%g %g %g) => (%g %g %g)"
" %3g %d %d %d %d\n",
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],
trace.fraction,
trace.allsolid, trace.startsolid,
trace.inopen, trace.inwater);
if (VectorCompare (end, trace.endpos)
&& 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)
res = 1;
if (test->desc)
desc = va ("(%d) %s", (int)(long)(test - tests), test->desc);
else
desc = va ("test #%d", (int)(long)(test - tests));
printf ("%s: %s\n", res ? "PASS" : "FAIL", desc);
return res;
}
int
main (int argc, char **argv)
{
vec3_t start, end;
int c, i;
int pass = 1;
int test = -1;
while ((c = getopt (argc, argv, "vt:")) != EOF) {
switch (c) {
case 'v':
verbose = 1;
break;
case 't':
test = atoi (optarg);
break;
default:
fprintf (stderr,
"-v (verbose) and/or -t TEST (test number)\n");
return 1;
}
}
if (test == -1) {
for (i = 0; i < num_tests; i++) {
if (verbose && i)
puts ("");
pass &= run_test (&tests[i]);
}
} else if (test >= 0 && test < num_tests) {
pass &= run_test (&tests[test]);
} else {
fprintf (stderr, "Bad test number (0 - %d)\n", num_tests);
return 1;
}
for (i = 0; i < 0; i++) {
start[0] = 480;
start[1] = -240 + i;
start[2] = 77;
VectorCopy (start, end);
end[2] -= 16;
do_trace (&hull3, start, end);
}
// start[0] = 480;
// start[1] = -207.253967;
// start[2] = 76.03125;
// VectorCopy (start, end);
// end[1] += 16;
// do_trace (&hull3, start, end);
return !pass;
}

View file

@ -83,356 +83,7 @@ calc_impact (trace_t *trace, const vec3_t start, const vec3_t end,
VectorSubtract (end, start, dist);
VectorMultAdd (start, frac, dist, trace->endpos);
}
#if ENABLE_BOXCLIP || defined(TEST_BOXCLIP)
#define ALLSOLID 1
#define STARTSOLID 2
#define INOPEN 4
#define INWATER 8
#define SOLID (ALLSOLID | STARTSOLID)
typedef struct {
mplane_t *plane;
vec3_t point; // arbitrary point on plane
int side;
} tp_t;
typedef struct {
vec3_t p;
vec3_t v;
} line_t;
typedef struct {
const vec_t *start;
const vec_t *end;
const vec_t *extents;
qboolean isbox;
hull_t hull;
tp_t split;
tp_t impact;
float fraction;
int flags;
} tl_t;
static inline void
set_split (tl_t *tl, tp_t *n, tp_t *o)
{
if (o)
*o = tl->split;
if (n) {
tl->split = *n;
} else {
tl->split.plane = 0;
VectorZero (tl->split.point);
tl->split.side = 0;
}
}
static inline void
set_impact (tl_t *tl, mplane_t *plane, int side)
{
tl->impact.plane = plane;
tl->impact.side = side;
}
#define print_tp(tp) \
Sys_Printf ("%s [(%g %g %g) %g %d]\n", #tp, \
(tp).plane->normal[0], (tp).plane->normal[1], \
(tp).plane->normal[2], (tp).plane->dist, (tp).side)
static inline vec_t
sgn (vec_t v)
{
return v < 0 ? -1 : (v > 0 ? 1 : 0);
}
static inline float
calc_offset (tl_t *tl, mplane_t *plane)
{
if (tl->isbox) {
if (plane->type < 3)
return tl->extents[plane->type];
else
return (fabs (tl->extents[0] * plane->normal[0])
+ fabs (tl->extents[1] * plane->normal[1])
+ fabs (tl->extents[2] * plane->normal[2]));
}
return 0;
}
static void
impact (tl_t *tl, tp_t *split)
{
float t1, t2, offset, frac;
int side = 0;
t1 = PlaneDiff (tl->start, split->plane);
t2 = PlaneDiff (tl->end, split->plane);
offset = calc_offset (tl, split->plane);
if (t1 < t2) {
side = -1;
frac = (t1 + offset) / (t1 - t2);
} else if (t1 > t2) {
side = 0;
frac = (t1 - offset) / (t1 - t2);
} else {
frac = 0;
Sys_DPrintf ("help! help! the world is falling apart!\n");
}
if (frac >= 0) {
tl->fraction = frac;
set_impact (tl, split->plane, side);
// print_tp (tl->impact);
}
}
static void
select_vertex (tl_t *tl, tp_t *split, vec3_t vert)
{
int axis;
for (axis = 0; axis < 3; axis++) {
vec_t s = sgn (tl->split.plane->normal[axis]);
if (!tl->split.side)
s = -s;
if (!s) {
s = sgn (split->plane->normal[axis]);
if (split->side)
s = -s;
if (!s)
s = 1;
}
vert[axis] = tl->extents[axis] * s;
}
}
static int
intersection_point (const mplane_t *plane, const vec3_t _p1, const vec3_t _p2,
const vec3_t offs, vec3_t point)
{
vec_t t1, t2;
vec3_t p1, p2;
VectorAdd (_p1, offs, p1);
VectorAdd (_p2, offs, p2);
t1 = PlaneDiff (p1, plane);
t2 = PlaneDiff (p2, plane);
if (!(t1 - t2))
return 0;
VectorSubtract (p2, p1, point);
VectorMultAdd (p1, t1 / (t1 - t2), point, point);
return 1;
}
static int
intersection_line (tl_t *tl, tp_t *split, const vec3_t p1, const vec3_t p2,
line_t *line)
{
const vec_t *pn1 = tl->split.plane->normal;
const vec_t *pp1 = tl->split.point;
const vec_t *pn2 = split->plane->normal;
const vec_t *pp2 = split->point;
vec3_t pvec;
vec_t t;
// find the line of intersection of the two planes, both direction
// and a point on the line.
CrossProduct (pn1, pn2, line->v);
if (VectorIsZero (line->v))
//planes are parallel, no intersection
return 0;
CrossProduct (pn1, line->v, pvec);
VectorSubtract (pp2, pp1, line->p);
t = DotProduct (line->p, pn2) / DotProduct (pvec, pn2);
VectorMultAdd (pp1, t, line->p, line->p);
return 1;
}
static int
traceline (int num, float p1f, float p2f, const vec3_t p1, const vec3_t p2,
tl_t *tl)
{
dclipnode_t *node;
mplane_t *plane;
float t1, t2, frac, frac2, midf, offset;
int side, cross;
vec3_t mid;
int c1, c2;
tp_t split, save;
line_t line;
vec3_t dist, vert, vert2, point;
int check_intersection;
do {
// Skip past non-intersecting nodes
// Sys_Printf ("%d\n", num);
while (num >= 0) {
node = tl->hull.clipnodes + num;
plane = tl->hull.planes + node->planenum;
t1 = PlaneDiff (p1, plane);
t2 = PlaneDiff (p2, plane);
offset = calc_offset (tl, plane);
if (t1 >= offset && t2 >= offset) {
num = node->children[side = 0];
} else if (t1 < -offset && t2 < -offset) {
num = node->children[side = 1];
} else {
break;
}
// Sys_Printf ("%d\n", num);
}
if (num < 0) {
return num;
}
split.plane = plane;
split.side = t1 < t2;
VectorSubtract (p2, p1, dist);
VectorMultAdd (p1, t1 / (t1 - t2), dist, split.point);
if (tl->split.plane) {
select_vertex (tl, &split, vert);
if ((t1 >= -offset && t1 < offset)
&& (t2 < -offset || t2 >= offset)) {
// p1 straddles the plane, p2 is clear of the plane
intersection_point (tl->split.plane, p1, p2, vert, point);
if ((PlaneDiff (point, plane) < 0) != (t1 < t2)) {
// the trace misses the intersection of the two planes, so
// both ends of the trace are really on the same side of
// the plane
num = node->children[!(t1 < t2)];
continue;
}
}
}
break;
} while (1);
check_intersection = 0;
if (tl->split.plane) {
VectorNegate (vert, vert2);
intersection_point (tl->split.plane, p1, p2, vert2, point);
if ((PlaneDiff (point, plane) < 0) != (t1 < t2)) {
// the two edges of the hypercube of motion are on opposite sides
// of the line of intersection of the two planes, so the box hits
// the intersection somewhere
check_intersection = 1;
}
}
cross = !(t1 >= -offset && t1 < offset && t2 >= -offset && t2 < offset);
if (t1 < t2) {
side = 1;
frac = (t1 - offset) / (t1 - t2);
frac2 = (t1 + offset) / (t1 - t2);
} else {
side = 0;
frac = (t1 + offset) / (t1 - t2);
frac2 = (t1 - offset) / (t1 - t2);
}
if (check_intersection) {
intersection_line (tl, &split, p1, p2, &line);
}
set_split (tl, &split, &save);
if (cross) {
frac = bound (0, frac, 1);
midf = p1f + (p2f - p1f) * frac;
VectorMultAdd (p1, frac, dist, mid);
c1 = c2 = traceline (node->children[side], p1f, midf, p1, mid, tl);
frac2 = bound (0, frac2, 1);
midf = p1f + (p2f - p1f) * frac2;
if (!tl->impact.plane || midf < tl->fraction) {
VectorMultAdd (p1, frac2, dist, mid);
c2 = traceline (node->children[side ^ 1], midf, p2f, mid, p2, tl);
}
} else {
c1 = c2 = traceline (node->children[side], p1f, p2f, p1, mid, tl);
if (c1 != CONTENTS_SOLID)
c2 = traceline (node->children[side ^ 1], p1f, p2f, mid, p2, tl);
if (c1 == CONTENTS_SOLID || c2 == CONTENTS_SOLID)
c1 = c2 = CONTENTS_SOLID;
else
c1 = c2 = min (c1, c2);
}
set_split (tl, &save, 0);
if (cross) {
if (c1 != CONTENTS_SOLID && c2 == CONTENTS_SOLID)
impact (tl, &split);
if (c1 == CONTENTS_SOLID && !(tl->flags & SOLID))
tl->flags |= STARTSOLID;
if (c1 == CONTENTS_EMPTY || c2 == CONTENTS_EMPTY) {
tl->flags &= ~ALLSOLID;
tl->flags |= INOPEN;
}
if (c1 < CONTENTS_SOLID || c2 < CONTENTS_SOLID) {
tl->flags &= ~ALLSOLID;
tl->flags |= INWATER;
}
return c1;
//return frac2 ? c1 : c2;
} else {
if (c1 == CONTENTS_SOLID || c2 == CONTENTS_SOLID) {
if (!p1f) {
tl->flags &= SOLID;
tl->flags |= STARTSOLID;
}
return CONTENTS_SOLID;
}
if (c1 == CONTENTS_EMPTY && c2 == CONTENTS_EMPTY) {
tl->flags &= ~ALLSOLID;
tl->flags |= INOPEN;
} else {
tl->flags &= ~ALLSOLID;
tl->flags |= INWATER;
}
return min (c1, c2); //FIXME correct?
}
}
VISIBLE void
MOD_TraceLine (hull_t *hull, int num,
const vec3_t start_point, const vec3_t end_point,
trace_t *trace)
{
tl_t tl;
int c;
tl.start = start_point;
tl.end = end_point;
tl.extents = trace->extents;
tl.isbox = trace->isbox;
tl.hull = *hull;
set_split (&tl, 0, 0);
set_impact (&tl, 0, 0);
tl.fraction = 1;
tl.flags = ALLSOLID;
c = traceline (num, 0, 1, start_point, end_point, &tl);
if (c == CONTENTS_EMPTY) {
tl.flags &= ~ALLSOLID;
tl.flags |= INOPEN;
}
if (c < CONTENTS_SOLID) {
tl.flags &= ~ALLSOLID;
tl.flags |= INOPEN;
}
if (tl.fraction < 1) {
calc_impact (trace, start_point, end_point, tl.impact.plane);
}
trace->allsolid = (tl.flags & ALLSOLID) != 0;
trace->startsolid = (tl.flags & STARTSOLID) != 0;
trace->inopen = (tl.flags & INOPEN) != 0;
trace->inwater = (tl.flags & INWATER) != 0;
}
#else
typedef struct {
vec3_t end;
int side;
@ -572,4 +223,3 @@ MOD_TraceLine (hull_t *hull, int num,
num = node->children[side];
}
}
#endif

View file

@ -56,10 +56,6 @@ SV_CheckStuck (edict_t *ent)
int i, j, z;
vec3_t org;
#if ENABLE_BOXCLIP
return;
#endif
if (!SV_TestEntityPosition (ent)) {
VectorCopy (SVvector (ent, origin), SVvector (ent, oldorigin));
return;

View file

@ -237,23 +237,14 @@ SV_FlyMove (edict_t *ent, float time, trace_t *steptrace)
time_left = time;
for (bumpcount = 0; bumpcount < numbumps; bumpcount++) {
#if ENABLE_BOXCLIP
extern int dp;
#endif
if (VectorIsZero (SVvector (ent, velocity)))
break;
VectorMultAdd (SVvector (ent, origin), time_left,
SVvector (ent, velocity), end);
#if ENABLE_BOXCLIP
dp = 1;
#endif
trace = SV_Move (SVvector (ent, origin), SVvector (ent, mins),
SVvector (ent, maxs), end, false, ent);
#if ENABLE_BOXCLIP
dp = 0;
#endif
if (trace.allsolid) { // entity is trapped in another solid
VectorZero (SVvector (ent, velocity));

View file

@ -500,10 +500,6 @@ SV_TestEntityPosition (edict_t *ent)
return NULL;
}
#if ENABLE_BOXCLIP
int dp;
#endif
/*
SV_ClipMoveToEntity
@ -523,7 +519,7 @@ SV_ClipMoveToEntity (edict_t *touched, edict_t *mover, const vec3_t start,
trace.fraction = 1;
trace.allsolid = true;
trace.isbox = ENABLE_BOXCLIP ? true : false;//XXX box clipping test
trace.isbox = 0;
VectorCopy (end, trace.endpos);
// get the clipping hull
@ -540,18 +536,6 @@ SV_ClipMoveToEntity (edict_t *touched, edict_t *mover, const vec3_t start,
if (trace.fraction != 1)
VectorAdd (trace.endpos, offset, trace.endpos);
#if ENABLE_BOXCLIP
if (dp)
printf ("(%g %g %g) -> (%g %g %g) => (%g %g %g)"
" %3g %d %d %d %d\n",
start_l[0], start_l[1], start_l[2],
end_l[0], end_l[1], end_l[2],
trace.endpos[0], trace.endpos[1], trace.endpos[2],
trace.fraction,
trace.allsolid, trace.startsolid,
trace.inopen, trace.inwater);
#endif
// did we clip the move?
if (trace.fraction < 1 || trace.startsolid)
trace.ent = touched;