mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
Add some documentation for the brush code.
This commit is contained in:
parent
9a4c9c506f
commit
5c0a55d818
2 changed files with 30 additions and 5 deletions
|
@ -48,7 +48,24 @@ extern int numbrushplanes;
|
||||||
extern plane_t planes[MAX_MAP_PLANES];
|
extern plane_t planes[MAX_MAP_PLANES];
|
||||||
|
|
||||||
brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum);
|
brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum);
|
||||||
|
|
||||||
|
/** Determine the primary axis of the normal.
|
||||||
|
|
||||||
|
\param normal Must be canonical.
|
||||||
|
*/
|
||||||
int PlaneTypeForNormal (const vec3_t normal);
|
int PlaneTypeForNormal (const vec3_t normal);
|
||||||
|
|
||||||
|
/** Add a plane to the global list of planes.
|
||||||
|
|
||||||
|
Make the plane canonical, and add it to the global list of planes if it
|
||||||
|
does not duplicate a plane that is already in the list. If the plane is
|
||||||
|
flipped while being made canonical, side will be set to 1, otherwise side
|
||||||
|
will be 0.
|
||||||
|
|
||||||
|
\param dplane The plane to add.
|
||||||
|
\param side The side of the plane that will be front.
|
||||||
|
\return global plane number.
|
||||||
|
*/
|
||||||
int FindPlane (plane_t *dplane, int *side);
|
int FindPlane (plane_t *dplane, int *side);
|
||||||
|
|
||||||
#endif//qfbsp_brush_h
|
#endif//qfbsp_brush_h
|
||||||
|
|
|
@ -167,11 +167,20 @@ PlaneTypeForNormal (const vec3_t normal)
|
||||||
#define DISTEPSILON 0.01
|
#define DISTEPSILON 0.01
|
||||||
#define ANGLEEPSILON 0.00001
|
#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
|
static void
|
||||||
NormalizePlane (plane_t *dp)
|
NormalizePlane (plane_t *dp)
|
||||||
{
|
{
|
||||||
vec_t ax, ay, az;
|
vec_t ax, ay, az;
|
||||||
|
|
||||||
|
// Make axis aligned planes point to +inf.
|
||||||
if (dp->normal[0] == -1.0) {
|
if (dp->normal[0] == -1.0) {
|
||||||
dp->normal[0] = 1.0;
|
dp->normal[0] = 1.0;
|
||||||
dp->dist = -dp->dist;
|
dp->dist = -dp->dist;
|
||||||
|
@ -183,6 +192,8 @@ NormalizePlane (plane_t *dp)
|
||||||
dp->dist = -dp->dist;
|
dp->dist = -dp->dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For axis aligned planes, set the plane type and ensure the normal
|
||||||
|
// vector is mathematically correct.
|
||||||
if (dp->normal[0] == 1.0) {
|
if (dp->normal[0] == 1.0) {
|
||||||
dp->type = PLANE_X;
|
dp->type = PLANE_X;
|
||||||
dp->normal[1] = dp->normal[2] = 0.0;
|
dp->normal[1] = dp->normal[2] = 0.0;
|
||||||
|
@ -199,6 +210,7 @@ NormalizePlane (plane_t *dp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find out with which axis the plane is most aligned.
|
||||||
ax = fabs (dp->normal[0]);
|
ax = fabs (dp->normal[0]);
|
||||||
ay = fabs (dp->normal[1]);
|
ay = fabs (dp->normal[1]);
|
||||||
az = fabs (dp->normal[2]);
|
az = fabs (dp->normal[2]);
|
||||||
|
@ -209,17 +221,13 @@ NormalizePlane (plane_t *dp)
|
||||||
dp->type = PLANE_ANYY;
|
dp->type = PLANE_ANYY;
|
||||||
else
|
else
|
||||||
dp->type = PLANE_ANYZ;
|
dp->type = PLANE_ANYZ;
|
||||||
|
// Make the plane's normal point towards +inf along its primary axis.
|
||||||
if (dp->normal[dp->type - PLANE_ANYX] < 0) {
|
if (dp->normal[dp->type - PLANE_ANYX] < 0) {
|
||||||
VectorNegate (dp->normal, dp->normal);
|
VectorNegate (dp->normal, dp->normal);
|
||||||
dp->dist = -dp->dist;
|
dp->dist = -dp->dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
FindPlane
|
|
||||||
|
|
||||||
Returns a global plane number and the side that will be the front
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
FindPlane (plane_t *dplane, int *side)
|
FindPlane (plane_t *dplane, int *side)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue