mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
Alter test_sphere to return -1, 0 or 1.
Representing the side of the plane on which the sphere lies is much more useful as more complicated tests can be done using just the one call. -1: the sphere is entirely on the back side of the plane 0: the sphere is intersecting the plane 1: the sphere is entirely on the front side of the plane
This commit is contained in:
parent
b9d71218f6
commit
0cae04d71a
1 changed files with 7 additions and 9 deletions
|
@ -87,17 +87,15 @@ SimpleFlood (portal_t *srcportal, int clusternum)
|
|||
}
|
||||
|
||||
static inline int
|
||||
test_sphere (sphere_t *sphere, plane_t *plane, int test_front)
|
||||
test_sphere (sphere_t *sphere, plane_t *plane)
|
||||
{
|
||||
float d;
|
||||
int pass;
|
||||
int front, back;
|
||||
|
||||
d = DotProduct (sphere->center, plane->normal) - plane->dist;
|
||||
if (test_front)
|
||||
pass = (d >= -sphere->radius);
|
||||
else
|
||||
pass = (d <= sphere->radius);
|
||||
return pass;
|
||||
front = (d >= sphere->radius);
|
||||
back = (d <= -sphere->radius);
|
||||
return front - back;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -121,9 +119,9 @@ BasePortalVis (void)
|
|||
if (j == i)
|
||||
continue;
|
||||
|
||||
if (!test_sphere (&tp->sphere, &portal->plane, 1))
|
||||
if (test_sphere (&tp->sphere, &portal->plane) < 0)
|
||||
continue; // entirely behind
|
||||
if (!test_sphere (&portal->sphere, &tp->plane, 0))
|
||||
if (test_sphere (&portal->sphere, &tp->plane) > 0)
|
||||
continue; // entirely behind
|
||||
|
||||
winding = tp->winding;
|
||||
|
|
Loading…
Reference in a new issue