more accurate expects and don't recurse for non-crossings

This commit is contained in:
Bill Currie 2007-09-23 08:33:26 +00:00 committed by Jeff Teunissen
parent 3d79256653
commit 0ee9e1cf3e
2 changed files with 23 additions and 23 deletions

View file

@ -67,8 +67,8 @@ int main (int argc, char **argv)
{
int i;
vec3_t start, end;
/*
puts ("\nexpect <=0.5, 1 (0 0 1 0), (0 0 1 0)");
puts ("\nexpect 0.496094, 1 (0 0 1 0), (0 0 1 0)");
for (i = 0; i < 2; i++) {
start[0] = 0;
start[1] = 47 + i;
@ -78,7 +78,7 @@ int main (int argc, char **argv)
do_trace (start, end);
}
puts ("\nexpect <=0.5, 1 (0 0 1 0), (0 0 1 0)");
puts ("\nexpect 0.496094, 1 (0 0 1 0), (0 0 1 0)");
for (i = 0; i < 2; i++) {
start[0] = 0;
start[1] = 52;
@ -87,8 +87,8 @@ int main (int argc, char **argv)
end[1] -= 8;
do_trace (start, end);
}
*/
puts ("\nexpect <=0.5, 1 (0 0 1 0), (1 1 0 0)");
puts ("\nexpect 0.484375, 1 (0 0 1 0), (1 1 0 0)");
for (i = 0; i < 2; i++) {
start[0] = 47 + i;
start[1] = -80;
@ -98,7 +98,7 @@ int main (int argc, char **argv)
do_trace (start, end);
}
puts ("\nexpect <=0.5, 1 (0 0 1 0), (0 0 1 0)");
puts ("\nexpect 0.496094, 1 (0 0 1 0), (0 0 1 0)");
for (i = 0; i < 2; i++) {
start[0] = 44;
start[1] = -80;
@ -108,7 +108,7 @@ int main (int argc, char **argv)
do_trace (start, end);
}
puts ("\nexpect 1, <=0.5 (0 1 1 0), (0 1 1 0)");
puts ("\nexpect 1, 0.499023 (0 1 1 0), (0 1 1 0)");
for (i = 0; i < 2; i++) {
start[0] = 47 + i;
start[1] = -80;

View file

@ -134,6 +134,22 @@ traceline (int num, float p1f, float p2f, const vec3_t p1, const vec3_t p2,
vec3_t mid;
mplane_t *op;
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->trace, plane);
if (t1 >= offset && t2 >= offset) {
num = node->children[0];
} if (t1 < -offset && t2 < -offset) {
num = node->children[1];
} else {
break;
}
}
if (num < 0) {
check_contents (num, &tl->trace);
t1 = t2 = -3.14;
@ -156,22 +172,6 @@ traceline (int num, float p1f, float p2f, const vec3_t p1, const vec3_t p2,
return;
}
node = tl->hull.clipnodes + num;
plane = tl->hull.planes + node->planenum;
t1 = PlaneDiff (p1, plane);
t2 = PlaneDiff (p2, plane);
offset = calc_offset (&tl->trace, plane);
if (t1 >= offset && t2 >= offset) {
traceline (node->children[0], p1f, p2f, p1, p2, tl);
return;
}
if (t1 < -offset && t2 < -offset) {
traceline (node->children[1], p1f, p2f, p1, p2, tl);
return;
}
if (t1 < t2) {
side = 1;
frac = (t1 - offset) / (t1 - t2);