mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 23:52:22 +00:00
Trace to adjoining leafs when necessary.
When the trace stradles a plane in the current leaf, check the other side of the portal, too, as it is possible that leaf will restrict the movement of the trace. All current tests pass! However, I can think of some situations (and I already have a solution) where things will fail, but that's next.
This commit is contained in:
parent
4c17ca9583
commit
8fe703d747
1 changed files with 20 additions and 8 deletions
|
@ -650,8 +650,8 @@ typedef struct {
|
|||
const vec_t *end_point;
|
||||
} trace_state_t;
|
||||
|
||||
static void
|
||||
trace_to_leaf (const hull_t *hull, const clipleaf_t *leaf,
|
||||
static vec_t
|
||||
trace_to_leaf (const hull_t *hull, clipleaf_t *leaf,
|
||||
const trace_t *trace, const trace_state_t *state, vec3_t stop)
|
||||
{
|
||||
clipport_t *portal;
|
||||
|
@ -660,7 +660,9 @@ trace_to_leaf (const hull_t *hull, const clipleaf_t *leaf,
|
|||
vec_t frac = 1;
|
||||
vec_t t1, t2, offset, f;
|
||||
qboolean clipped = false;
|
||||
clipleaf_t *l;
|
||||
|
||||
leaf->test_count = test_count;
|
||||
for (portal = leaf->portals; portal; portal = portal->next[side]) {
|
||||
side = portal->leafs[1] == leaf;
|
||||
plane = hull->planes + portal->planenum;
|
||||
|
@ -668,6 +670,10 @@ trace_to_leaf (const hull_t *hull, const clipleaf_t *leaf,
|
|||
t2 = PlaneDiff (state->end_point, plane);
|
||||
offset = calc_offset (trace, plane);
|
||||
f = (t1 + (t1 < 0 ? offset : -offset)) / (t1 - t2);
|
||||
l = portal->leafs[side^1];
|
||||
if (f < 0 && l->contents != CONTENTS_SOLID
|
||||
&& l->test_count != test_count)
|
||||
f = trace_to_leaf (hull, l, trace, state, 0);
|
||||
if (f > 0) {
|
||||
clipped = true;
|
||||
if (f < frac)
|
||||
|
@ -676,7 +682,9 @@ trace_to_leaf (const hull_t *hull, const clipleaf_t *leaf,
|
|||
}
|
||||
if (!clipped)
|
||||
frac = 0;
|
||||
VectorMultAdd (state->start_point, frac, state->dist, stop);
|
||||
if (stop)
|
||||
VectorMultAdd (state->start_point, frac, state->dist, stop);
|
||||
return frac;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -695,11 +703,15 @@ visit_leaf (hull_t *hull, int num, clipleaf_t *leaf, trace_t *trace,
|
|||
&& !trace_enters_leaf (hull, trace, leaf, state->split_plane,
|
||||
state->dist, state->origin))
|
||||
return 0; // we're not here
|
||||
//FIXME this is probably slow
|
||||
trace_to_leaf (hull, leaf, trace, state, origin);
|
||||
test_count++;
|
||||
trace->contents = 0;
|
||||
contents = trace_contents (hull, trace, leaf, origin);
|
||||
contents = leaf->contents;
|
||||
if (contents != CONTENTS_SOLID) {
|
||||
//FIXME this is probably slow
|
||||
test_count++;
|
||||
trace_to_leaf (hull, leaf, trace, state, origin);
|
||||
test_count++;
|
||||
trace->contents = 0;
|
||||
contents = trace_contents (hull, trace, leaf, origin);
|
||||
}
|
||||
} else {
|
||||
contents = num;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue