mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
Normalize the clip plane before adding it to the bsp.
This commit is contained in:
parent
aad204e80c
commit
ba2a5838fd
3 changed files with 23 additions and 16 deletions
|
@ -72,6 +72,16 @@ brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum);
|
|||
*/
|
||||
int PlaneTypeForNormal (const vec3_t normal);
|
||||
|
||||
/** Make the plane canonical.
|
||||
|
||||
A cononical plane is one whose normal points towards +inf on its primary
|
||||
axis. The primary axis is that which has the largest magnitude of the
|
||||
vector's components.
|
||||
|
||||
\param dp The plane to make canonical.
|
||||
*/
|
||||
void NormalizePlane (plane_t *dp);
|
||||
|
||||
/** Add a plane to the global list of planes.
|
||||
|
||||
Make the plane canonical, and add it to the global list of planes if it
|
||||
|
|
|
@ -173,7 +173,8 @@ PlaneTypeForNormal (const vec3_t normal)
|
|||
if (normal[2] == 1.0)
|
||||
return PLANE_Z;
|
||||
if (normal[0] == -1.0 || normal[1] == -1.0 || normal[2] == -1.0)
|
||||
Sys_Error ("PlaneTypeForNormal: not a canonical vector");
|
||||
Sys_Error ("PlaneTypeForNormal: not a canonical vector (%g %g %g)",
|
||||
normal[0], normal[1], normal[2]);
|
||||
|
||||
ax = fabs(normal[0]);
|
||||
ay = fabs(normal[1]);
|
||||
|
@ -186,22 +187,15 @@ PlaneTypeForNormal (const vec3_t normal)
|
|||
else
|
||||
type = PLANE_ANYZ;
|
||||
if (normal[type - PLANE_ANYX] < 0)
|
||||
Sys_Error ("PlaneTypeForNormal: not a canonical vector");
|
||||
Sys_Error ("PlaneTypeForNormal: not a canonical vector (%g %g %g) %d",
|
||||
normal[0], normal[1], normal[2], type);
|
||||
return type;
|
||||
}
|
||||
|
||||
#define DISTEPSILON 0.01
|
||||
#define ANGLEEPSILON 0.00001
|
||||
|
||||
/** Make the plane canonical.
|
||||
|
||||
A cononical plane is one whose normal points towards +inf on its primary
|
||||
axis. The primary axis is that which has the largest magnitude of the
|
||||
vector's components.
|
||||
|
||||
\param dp The plane to make canonical.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
NormalizePlane (plane_t *dp)
|
||||
{
|
||||
vec_t ax, ay, az;
|
||||
|
|
|
@ -268,10 +268,10 @@ ReadClipHull (int hullnum)
|
|||
{
|
||||
FILE *f;
|
||||
dclipnode_t d;
|
||||
dplane_t p;
|
||||
plane_t p;
|
||||
dplane_t dp;
|
||||
float f1, f2, f3, f4;
|
||||
int firstclipnode, junk, c1, c2, i, j, n;
|
||||
vec3_t norm;
|
||||
|
||||
options.hullfile[strlen (options.hullfile) - 1] = '0' + hullnum;
|
||||
|
||||
|
@ -306,13 +306,16 @@ ReadClipHull (int hullnum)
|
|||
|
||||
VectorSet (f1, f2, f3, p.normal);
|
||||
p.dist = f4;
|
||||
NormalizePlane (&p);
|
||||
|
||||
VectorSet (f1, f2, f3, norm);
|
||||
p.type = PlaneTypeForNormal (norm);
|
||||
VectorCopy (p.normal, dp.normal);
|
||||
dp.dist = p.dist;
|
||||
dp.type = p.type;
|
||||
|
||||
d.children[0] = c1 >= 0 ? c1 + firstclipnode : c1;
|
||||
d.children[1] = c2 >= 0 ? c2 + firstclipnode : c2;
|
||||
d.planenum = FindFinalPlane (&p);
|
||||
|
||||
d.planenum = FindFinalPlane (&dp);
|
||||
BSP_AddClipnode (bsp, &d);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue