From 7da6df9dfbe4911c8070fb0204c623ab984fe0a7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 4 Dec 2011 19:14:35 +0900 Subject: [PATCH] Use the "real" contents of the trace's location when visiting a leaf. When visiting a leaf in box mode, use trace_contents() to get the highest priority contents of any leafs touched by the box in the current location. I'm now down to one failing test case, and it's an "allsolid" issue that might be an incorrect assumption in my test case. --- libs/models/trace.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libs/models/trace.c b/libs/models/trace.c index a7f83233d..f02544c08 100644 --- a/libs/models/trace.c +++ b/libs/models/trace.c @@ -646,14 +646,23 @@ static int visit_leaf (hull_t *hull, int num, clipleaf_t *leaf, trace_t *trace, trace_state_t *state) { + int contents; + // it's not possible to not be in the leaf when doing a point trace // if leaf is null, assume we're in the leaf // if plane is null, the trace did not cross the last node plane - int in_leaf = 1; - if (trace->type != tr_point && leaf && state->split_plane) - in_leaf = check_in_leaf (hull, trace, leaf, state->split_plane, - state->vel, state->origin); - if (in_leaf && num == CONTENTS_SOLID) { + if (trace->type != tr_point) { + if (state->split_plane + && !check_in_leaf (hull, trace, leaf, state->split_plane, + state->vel, state->origin)) + return 0; // we're not here + //FIXME this is probably slow + test_count++; + contents = trace_contents (hull, trace, leaf, state->origin); + } else { + contents = num; + } + if (contents == CONTENTS_SOLID) { if (!state->seen_empty && !state->seen_solid) { // this is the first leaf visited, thus the start leaf trace->startsolid = state->seen_solid = true; @@ -677,10 +686,10 @@ visit_leaf (hull_t *hull, int num, clipleaf_t *leaf, trace_t *trace, if (trace->type == tr_point) return 1; } - } else if (in_leaf) { + } else { state->seen_empty = true; trace->allsolid = false; - if (num == CONTENTS_EMPTY) + if (contents == CONTENTS_EMPTY) trace->inopen = true; else trace->inwater = true;