Trace to the current portal rather than the portal's plane.

This commit is contained in:
Bill Currie 2011-12-07 12:17:51 +09:00
parent 9d2914474c
commit 5af88d33fe

View file

@ -665,24 +665,25 @@ trace_to_leaf (const hull_t *hull, clipleaf_t *leaf,
const trace_t *trace, const trace_state_t *state, vec3_t stop) const trace_t *trace, const trace_state_t *state, vec3_t stop)
{ {
clipport_t *portal; clipport_t *portal;
plane_t *plane;
int side; int side;
vec_t frac = 1; vec_t frac = 1;
vec_t t1, t2, offset, f; plane_t *plane;
vec_t f;
qboolean clipped = false; qboolean clipped = false;
clipleaf_t *l; clipleaf_t *l;
trace_state_t lstate = *state;
leaf->test_count = test_count; leaf->test_count = test_count;
for (portal = leaf->portals; portal; portal = portal->next[side]) { for (portal = leaf->portals; portal; portal = portal->next[side]) {
side = portal->leafs[1] == leaf; side = portal->leafs[1] == leaf;
plane = hull->planes + portal->planenum;
if (plane == state->split_plane)
continue;
if (!trace_hits_portal (hull, trace, portal, if (!trace_hits_portal (hull, trace, portal,
state->start_point, state->dist)) state->start_point, state->dist))
continue; continue;
plane = hull->planes + portal->planenum; lstate.split_plane = plane;
t1 = PlaneDiff (state->start_point, plane); f = box_portal_dist (hull, portal, &lstate);
t2 = PlaneDiff (state->end_point, plane);
offset = calc_offset (trace, plane);
f = (t1 + (t1 < 0 ? offset : -offset)) / (t1 - t2);
l = portal->leafs[side^1]; l = portal->leafs[side^1];
if (f < 0 && l->contents != CONTENTS_SOLID if (f < 0 && l->contents != CONTENTS_SOLID
&& l->test_count != test_count) && l->test_count != test_count)