diff --git a/tools/qfbsp/include/brush.h b/tools/qfbsp/include/brush.h index 492ec56e2..68d6d1d3f 100644 --- a/tools/qfbsp/include/brush.h +++ b/tools/qfbsp/include/brush.h @@ -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 diff --git a/tools/qfbsp/source/brush.c b/tools/qfbsp/source/brush.c index f97838500..7ad39dcf1 100644 --- a/tools/qfbsp/source/brush.c +++ b/tools/qfbsp/source/brush.c @@ -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; diff --git a/tools/qfbsp/source/qfbsp.c b/tools/qfbsp/source/qfbsp.c index c82bad5bd..0c5822226 100644 --- a/tools/qfbsp/source/qfbsp.c +++ b/tools/qfbsp/source/qfbsp.c @@ -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); }