mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
Flip the nodes when flipping the plane.
This commit is contained in:
parent
ce96e6b055
commit
d470094a55
3 changed files with 17 additions and 9 deletions
|
@ -79,8 +79,9 @@ int PlaneTypeForNormal (const vec3_t normal);
|
|||
vector's components.
|
||||
|
||||
\param dp The plane to make canonical.
|
||||
\return 1 if the plane was flipped, otherwise 0.
|
||||
*/
|
||||
void NormalizePlane (plane_t *dp);
|
||||
int NormalizePlane (plane_t *dp);
|
||||
|
||||
/** Add a plane to the global list of planes.
|
||||
|
||||
|
|
|
@ -195,21 +195,25 @@ PlaneTypeForNormal (const vec3_t normal)
|
|||
#define DISTEPSILON 0.01
|
||||
#define ANGLEEPSILON 0.00001
|
||||
|
||||
void
|
||||
int
|
||||
NormalizePlane (plane_t *dp)
|
||||
{
|
||||
vec_t ax, ay, az;
|
||||
vec_t ax, ay, az;
|
||||
int flip = 0;
|
||||
|
||||
// Make axis aligned planes point to +inf.
|
||||
if (dp->normal[0] == -1.0) {
|
||||
dp->normal[0] = 1.0;
|
||||
dp->dist = -dp->dist;
|
||||
flip = 1;
|
||||
} else if (dp->normal[1] == -1.0) {
|
||||
dp->normal[1] = 1.0;
|
||||
dp->dist = -dp->dist;
|
||||
flip = 1;
|
||||
} else if (dp->normal[2] == -1.0) {
|
||||
dp->normal[2] = 1.0;
|
||||
dp->dist = -dp->dist;
|
||||
flip = 1;
|
||||
}
|
||||
|
||||
// For axis aligned planes, set the plane type and ensure the normal
|
||||
|
@ -217,17 +221,17 @@ NormalizePlane (plane_t *dp)
|
|||
if (dp->normal[0] == 1.0) {
|
||||
dp->type = PLANE_X;
|
||||
dp->normal[1] = dp->normal[2] = 0.0;
|
||||
return;
|
||||
return flip;
|
||||
}
|
||||
if (dp->normal[1] == 1.0) {
|
||||
dp->type = PLANE_Y;
|
||||
dp->normal[0] = dp->normal[2] = 0.0;
|
||||
return;
|
||||
return flip;
|
||||
}
|
||||
if (dp->normal[2] == 1.0) {
|
||||
dp->type = PLANE_Z;
|
||||
dp->normal[0] = dp->normal[1] = 0.0;
|
||||
return;
|
||||
return flip;
|
||||
}
|
||||
|
||||
// Find out with which axis the plane is most aligned.
|
||||
|
@ -245,7 +249,9 @@ NormalizePlane (plane_t *dp)
|
|||
if (dp->normal[dp->type - PLANE_ANYX] < 0) {
|
||||
VectorNegate (dp->normal, dp->normal);
|
||||
dp->dist = -dp->dist;
|
||||
flip = 1;
|
||||
}
|
||||
return flip;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -272,6 +272,7 @@ ReadClipHull (int hullnum)
|
|||
dplane_t dp;
|
||||
float f1, f2, f3, f4;
|
||||
int firstclipnode, junk, c1, c2, i, j, n;
|
||||
int flip;
|
||||
|
||||
options.hullfile[strlen (options.hullfile) - 1] = '0' + hullnum;
|
||||
|
||||
|
@ -306,14 +307,14 @@ ReadClipHull (int hullnum)
|
|||
|
||||
VectorSet (f1, f2, f3, p.normal);
|
||||
p.dist = f4;
|
||||
NormalizePlane (&p);
|
||||
flip = NormalizePlane (&p);
|
||||
|
||||
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.children[flip] = c1 >= 0 ? c1 + firstclipnode : c1;
|
||||
d.children[!flip] = c2 >= 0 ? c2 + firstclipnode : c2;
|
||||
|
||||
d.planenum = FindFinalPlane (&dp);
|
||||
BSP_AddClipnode (bsp, &d);
|
||||
|
|
Loading…
Reference in a new issue