whitespace cleanup and add rcsid tags

This commit is contained in:
Bill Currie 2002-09-23 16:27:17 +00:00
parent 6721cd05e3
commit 4bf8ac58f1
15 changed files with 308 additions and 454 deletions

View file

@ -16,6 +16,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details. See file, 'COPYING', for details.
$Id$
*/ */
// bsp5.h // bsp5.h

View file

@ -16,6 +16,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details. See file, 'COPYING', for details.
$Id$
*/ */
#define MAX_FACES 128 #define MAX_FACES 128

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// brush.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
@ -43,11 +43,9 @@ mface_t faces[128]; // beveled clipping hull can generate many extra
/* /*
================= CheckFace
CheckFace
Note: this will not catch 0 area polygons Note: this will not catch 0 area polygons
=================
*/ */
void void
CheckFace (face_t *f) CheckFace (face_t *f)
@ -103,8 +101,6 @@ CheckFace (face_t *f)
} }
} }
//===========================================================================
void void
ClearBounds (brushset_t *bs) ClearBounds (brushset_t *bs)
{ {
@ -130,14 +126,12 @@ AddToBounds (brushset_t *bs, vec3_t v)
} }
} }
//===========================================================================
int int
PlaneTypeForNormal (vec3_t normal) PlaneTypeForNormal (vec3_t normal)
{ {
float ax, ay, az; float ax, ay, az;
// NOTE: should these have an epsilon around 1.0? // NOTE: should these have an epsilon around 1.0?
if (normal[0] == 1.0) if (normal[0] == 1.0)
return PLANE_X; return PLANE_X;
if (normal[1] == 1.0) if (normal[1] == 1.0)
@ -209,11 +203,9 @@ NormalizePlane (plane_t *dp)
} }
/* /*
=============== FindPlane
FindPlane
Returns a global plane number and the side that will be the front 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)
@ -253,11 +245,9 @@ FindPlane (plane_t *dplane, int *side)
} }
/* /*
=============== FindPlane_old
FindPlane_old
Returns a global plane number and the side that will be the front Returns a global plane number and the side that will be the front
===============
*/ */
int int
FindPlane_old (plane_t *dplane, int *side) FindPlane_old (plane_t *dplane, int *side)
@ -286,7 +276,8 @@ FindPlane_old (plane_t *dplane, int *side)
} }
} }
// allocate a new plane, flipping normal to a consistant direction if needed // allocate a new plane, flipping normal to a consistant direction if
// needed
*dp = *dplane; *dp = *dplane;
if (numbrushplanes == MAX_MAP_PLANES) if (numbrushplanes == MAX_MAP_PLANES)
@ -295,7 +286,7 @@ FindPlane_old (plane_t *dplane, int *side)
*side = 0; *side = 0;
// NOTE: should these have an epsilon around 1.0? // NOTE: should these have an epsilon around 1.0?
if (dplane->normal[0] == 1.0) if (dplane->normal[0] == 1.0)
dp->type = PLANE_X; dp->type = PLANE_X;
else if (dplane->normal[1] == 1.0) else if (dplane->normal[1] == 1.0)
@ -339,11 +330,7 @@ FindPlane_old (plane_t *dplane, int *side)
} }
/* /*
============================================================================= Turn brushes into groups of faces.
TURN BRUSHES INTO GROUPS OF FACES
=============================================================================
*/ */
vec3_t brush_mins, brush_maxs; vec3_t brush_mins, brush_maxs;
@ -414,12 +401,10 @@ CreateBrushFaces (void)
} }
/* /*
============================================================================== BEVELED CLIPPING HULL GENERATION
BEVELED CLIPPING HULL GENERATION This is done by brute force, and could easily get a lot faster if anyone
cares.
This is done by brute force, and could easily get a lot faster if anyone cares.
==============================================================================
*/ */
vec3_t hull_size[3][2] = { vec3_t hull_size[3][2] = {
@ -463,12 +448,10 @@ AddBrushPlane (plane_t *plane)
} }
/* /*
============ TestAddPlane
TestAddPlane
Adds the given plane to the brush description if all of the original brush Adds the given plane to the brush description if all of the original brush
vertexes can be put on the front side vertexes can be put on the front side
=============
*/ */
void void
TestAddPlane (plane_t *plane) TestAddPlane (plane_t *plane)
@ -481,7 +464,7 @@ TestAddPlane (plane_t *plane)
vec_t *corner; vec_t *corner;
vec3_t inv; vec3_t inv;
// see if the plane has allready been added // see if the plane has allready been added
for (i = 0; i < numbrushfaces; i++) { for (i = 0; i < numbrushfaces; i++) {
pl = &faces[i].plane; pl = &faces[i].plane;
if (_VectorCompare (plane->normal, pl->normal) if (_VectorCompare (plane->normal, pl->normal)
@ -492,7 +475,7 @@ TestAddPlane (plane_t *plane)
&& fabs (plane->dist + pl->dist) < ON_EPSILON) return; && fabs (plane->dist + pl->dist) < ON_EPSILON) return;
} }
// check all the corner points // check all the corner points
counts[0] = counts[1] = counts[2] = 0; counts[0] = counts[1] = counts[2] = 0;
c = num_hull_points * 8; c = num_hull_points * 8;
@ -511,8 +494,7 @@ TestAddPlane (plane_t *plane)
counts[2]++; counts[2]++;
} }
// the plane is a seperator // the plane is a seperator
if (counts[0]) { if (counts[0]) {
VectorSubtract (vec3_origin, plane->normal, flip.normal); VectorSubtract (vec3_origin, plane->normal, flip.normal);
flip.dist = -plane->dist; flip.dist = -plane->dist;
@ -523,11 +505,9 @@ TestAddPlane (plane_t *plane)
} }
/* /*
============ AddHullPoint
AddHullPoint
Doesn't add if duplicated Doesn't add if duplicated
=============
*/ */
int int
AddHullPoint (vec3_t p, int hullnum) AddHullPoint (vec3_t p, int hullnum)
@ -561,11 +541,9 @@ AddHullPoint (vec3_t p, int hullnum)
} }
/* /*
============ AddHullEdge
AddHullEdge
Creates all of the hull planes around the given edge, if not done already Creates all of the hull planes around the given edge, if not done already
=============
*/ */
void void
AddHullEdge (vec3_t p1, vec3_t p2, int hullnum) AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
@ -626,12 +604,12 @@ ExpandBrush (int hullnum)
num_hull_points = 0; num_hull_points = 0;
num_hull_edges = 0; num_hull_edges = 0;
// create all the hull points // create all the hull points
for (f = brush_faces; f; f = f->next) for (f = brush_faces; f; f = f->next)
for (i = 0; i < f->numpoints; i++) for (i = 0; i < f->numpoints; i++)
AddHullPoint (f->pts[i], hullnum); AddHullPoint (f->pts[i], hullnum);
// expand all of the planes // expand all of the planes
for (i = 0; i < numbrushfaces; i++) { for (i = 0; i < numbrushfaces; i++) {
p = &faces[i].plane; p = &faces[i].plane;
VectorCopy (vec3_origin, corner); VectorCopy (vec3_origin, corner);
@ -644,7 +622,7 @@ ExpandBrush (int hullnum)
p->dist += DotProduct (corner, p->normal); p->dist += DotProduct (corner, p->normal);
} }
// add any axis planes not contained in the brush to bevel off corners // add any axis planes not contained in the brush to bevel off corners
for (x = 0; x < 3; x++) for (x = 0; x < 3; x++)
for (s = -1; s <= 1; s += 2) { for (s = -1; s <= 1; s += 2) {
// add the plane // add the plane
@ -657,20 +635,16 @@ ExpandBrush (int hullnum)
AddBrushPlane (&plane); AddBrushPlane (&plane);
} }
// add all of the edge bevels // add all of the edge bevels
for (f = brush_faces; f; f = f->next) for (f = brush_faces; f; f = f->next)
for (i = 0; i < f->numpoints; i++) for (i = 0; i < f->numpoints; i++)
AddHullEdge (f->pts[i], f->pts[(i + 1) % f->numpoints], hullnum); AddHullEdge (f->pts[i], f->pts[(i + 1) % f->numpoints], hullnum);
} }
//============================================================================
/* /*
=============== LoadBrush
LoadBrush
Converts a mapbrush to a bsp brush Converts a mapbrush to a bsp brush
===============
*/ */
brush_t * brush_t *
LoadBrush (mbrush_t *mb, int hullnum) LoadBrush (mbrush_t *mb, int hullnum)
@ -680,12 +654,11 @@ LoadBrush (mbrush_t *mb, int hullnum)
int contents; int contents;
mface_t *f; mface_t *f;
// check texture name for attributes // check texture name for attributes
name = miptex[bsp->texinfo[mb->faces->texinfo].miptex]; name = miptex[bsp->texinfo[mb->faces->texinfo].miptex];
if (!strcasecmp (name, "clip") && hullnum == 0) if (!strcasecmp (name, "clip") && hullnum == 0)
return NULL; // "clip" brushes don't show up in return NULL; // "clip" brushes don't show up in the draw hull
// the draw hull
if (name[0] == '*' && worldmodel) { // entities never use water merging if (name[0] == '*' && worldmodel) { // entities never use water merging
if (!strncasecmp (name + 1, "lava", 4)) if (!strncasecmp (name + 1, "lava", 4))
@ -700,12 +673,11 @@ LoadBrush (mbrush_t *mb, int hullnum)
contents = CONTENTS_SOLID; contents = CONTENTS_SOLID;
if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY) if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY)
return NULL; // water brushes don't show up in return NULL; // water brushes don't show up in clipping hulls
// clipping hulls
// no seperate textures on clip hull // no seperate textures on clip hull
// create the faces // create the faces
brush_faces = NULL; brush_faces = NULL;
numbrushfaces = 0; numbrushfaces = 0;
@ -728,7 +700,7 @@ LoadBrush (mbrush_t *mb, int hullnum)
CreateBrushFaces (); CreateBrushFaces ();
} }
// create the brush // create the brush
b = AllocBrush (); b = AllocBrush ();
b->contents = contents; b->contents = contents;
@ -739,8 +711,6 @@ LoadBrush (mbrush_t *mb, int hullnum)
return b; return b;
} }
//=============================================================================
void void
Brush_DrawAll (brushset_t *bs) Brush_DrawAll (brushset_t *bs)
{ {
@ -788,7 +758,7 @@ Brush_LoadEntity (entity_t *ent, int hullnum)
AddToBounds (bset, b->maxs); AddToBounds (bset, b->maxs);
} }
// add all of the water textures at the start // add all of the water textures at the start
for (b = water; b; b = next) { for (b = water; b; b = next) {
next = b->next; next = b->next;
b->next = other; b->next = other;

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// csg4.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -32,9 +32,10 @@
#include "bsp5.h" #include "bsp5.h"
/* /*
NOTES NOTES
Brushes that touch still need to be split at the cut point to make a tjunction Brushes that touch still need to be split at the cut point to make a
tjunction
*/ */
face_t *validfaces[MAX_MAP_PLANES]; face_t *validfaces[MAX_MAP_PLANES];
@ -52,12 +53,10 @@ DrawList (face_t *list)
} }
/* /*
================== NewFaceFromFace
NewFaceFromFace
Duplicates the non point information of a face, used by SplitFace and Duplicates the non point information of a face, used by SplitFace and
MergeFace. MergeFace.
==================
*/ */
face_t * face_t *
NewFaceFromFace (face_t *in) NewFaceFromFace (face_t *in)
@ -92,7 +91,7 @@ SplitFace (face_t *in, plane_t *split, face_t **front, face_t **back)
Sys_Error ("SplitFace: freed face"); Sys_Error ("SplitFace: freed face");
counts[0] = counts[1] = counts[2] = 0; counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point // determine sides for each point
for (i = 0; i < in->numpoints; i++) { for (i = 0; i < in->numpoints; i++) {
dot = DotProduct (in->pts[i], split->normal); dot = DotProduct (in->pts[i], split->normal);
dot -= split->dist; dot -= split->dist;
@ -122,7 +121,7 @@ SplitFace (face_t *in, plane_t *split, face_t **front, face_t **back)
*back = newf = NewFaceFromFace (in); *back = newf = NewFaceFromFace (in);
*front = new2 = NewFaceFromFace (in); *front = new2 = NewFaceFromFace (in);
// distribute the points and generate splits // distribute the points and generate splits
for (i = 0; i < in->numpoints; i++) { for (i = 0; i < in->numpoints; i++) {
if (newf->numpoints > MAXEDGES || new2->numpoints > MAXEDGES) if (newf->numpoints > MAXEDGES || new2->numpoints > MAXEDGES)
Sys_Error ("SplitFace: numpoints > MAXEDGES"); Sys_Error ("SplitFace: numpoints > MAXEDGES");
@ -170,26 +169,19 @@ SplitFace (face_t *in, plane_t *split, face_t **front, face_t **back)
if (newf->numpoints > MAXEDGES || new2->numpoints > MAXEDGES) if (newf->numpoints > MAXEDGES || new2->numpoints > MAXEDGES)
Sys_Error ("SplitFace: numpoints > MAXEDGES"); Sys_Error ("SplitFace: numpoints > MAXEDGES");
#if 0 // free the original face now that is is represented by the fragments
CheckFace (newf);
CheckFace (new2);
#endif
// free the original face now that is is represented by the fragments
FreeFace (in); FreeFace (in);
} }
/* /*
================= ClipInside
ClipInside
Clips all of the faces in the inside list, possibly moving them to the Clips all of the faces in the inside list, possibly moving them to the
outside list or spliting it into a piece in each list. outside list or spliting it into a piece in each list.
Faces exactly on the plane will stay inside unless overdrawn by later brush Faces exactly on the plane will stay inside unless overdrawn by later brush
frontside is the side of the plane that holds the outside list frontside is the side of the plane that holds the outside list
=================
*/ */
void void
ClipInside (int splitplane, int frontside, qboolean precedence) ClipInside (int splitplane, int frontside, qboolean precedence)
@ -231,11 +223,9 @@ ClipInside (int splitplane, int frontside, qboolean precedence)
} }
/* /*
================== SaveOutside
SaveOutside
Saves all of the faces in the outside list to the bsp plane list Saves all of the faces in the outside list to the bsp plane list
==================
*/ */
void void
SaveOutside (qboolean mirror) SaveOutside (qboolean mirror)
@ -274,11 +264,9 @@ SaveOutside (qboolean mirror)
} }
/* /*
================== FreeInside
FreeInside
Free all the faces that got clipped out Free all the faces that got clipped out
==================
*/ */
void void
FreeInside (int contents) FreeInside (int contents)
@ -297,15 +285,11 @@ FreeInside (int contents)
} }
} }
//==========================================================================
/* /*
================== BuildSurfaces
BuildSurfaces
Returns a chain of all the external surfaces with one or more visible Returns a chain of all the external surfaces with one or more visible
faces. faces.
==================
*/ */
surface_t * surface_t *
BuildSurfaces (void) BuildSurfaces (void)
@ -322,7 +306,7 @@ BuildSurfaces (void)
if (!*f) if (!*f)
continue; // nothing left on this plane continue; // nothing left on this plane
// create a new surface to hold the faces on this plane // create a new surface to hold the faces on this plane
s = AllocSurface (); s = AllocSurface ();
s->planenum = i; s->planenum = i;
s->next = surfhead; s->next = surfhead;
@ -336,8 +320,6 @@ BuildSurfaces (void)
return surfhead; return surfhead;
} }
//==========================================================================
void void
CopyFacesToOutside (brush_t *b) CopyFacesToOutside (brush_t *b)
{ {
@ -347,16 +329,6 @@ CopyFacesToOutside (brush_t *b)
for (f = b->faces; f; f = f->next) { for (f = b->faces; f; f = f->next) {
brushfaces++; brushfaces++;
#if 0
{
int i;
for (i = 0; i < f->numpoints; i++)
printf ("(%f,%f,%f) ", f->pts[i][0], f->pts[i][1],
f->pts[i][2]);
printf ("\n");
}
#endif
newf = AllocFace (); newf = AllocFace ();
*newf = *f; *newf = *f;
newf->next = outside; newf->next = outside;
@ -367,11 +339,9 @@ CopyFacesToOutside (brush_t *b)
} }
/* /*
================== CSGFaces
CSGFaces
Returns a list of surfaces containing aall of the faces Returns a list of surfaces containing aall of the faces
==================
*/ */
surface_t * surface_t *
CSGFaces (brushset_t *bs) CSGFaces (brushset_t *bs)
@ -390,7 +360,7 @@ CSGFaces (brushset_t *bs)
Draw_ClearWindow (); Draw_ClearWindow ();
// do the solid faces // do the solid faces
for (b1 = bs->brushes; b1; b1 = b1->next) { for (b1 = bs->brushes; b1; b1 = b1->next) {
// set outside to a copy of the brush's faces // set outside to a copy of the brush's faces
CopyFacesToOutside (b1); CopyFacesToOutside (b1);

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// map.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -64,11 +64,9 @@ FindMiptex (char *name)
} }
/* /*
=============== FindTexinfo
FindTexinfo
Returns a global texinfo number Returns a global texinfo number
===============
*/ */
int int
FindTexinfo (texinfo_t *t) FindTexinfo (texinfo_t *t)
@ -76,7 +74,7 @@ FindTexinfo (texinfo_t *t)
int i, j; int i, j;
texinfo_t *tex; texinfo_t *tex;
// set the special flag // set the special flag
if (miptex[t->miptex][0] == '*' if (miptex[t->miptex][0] == '*'
|| !strncasecmp (miptex[t->miptex], "sky", 3)) || !strncasecmp (miptex[t->miptex], "sky", 3))
t->flags |= TEX_SPECIAL; t->flags |= TEX_SPECIAL;
@ -97,14 +95,12 @@ FindTexinfo (texinfo_t *t)
return i; return i;
} }
// allocate a new texture // allocate a new texture
BSP_AddTexinfo (bsp, t); BSP_AddTexinfo (bsp, t);
return i; return i;
} }
//============================================================================
#define MAXTOKEN 128 #define MAXTOKEN 128
char token[MAXTOKEN]; char token[MAXTOKEN];
@ -128,7 +124,7 @@ GetToken (qboolean crossline)
if (unget) // is a token allready waiting? if (unget) // is a token allready waiting?
return true; return true;
// skip space // skip space
skipspace: skipspace:
while (*script_p <= 32) { while (*script_p <= 32) {
if (!*script_p) { if (!*script_p) {
@ -155,7 +151,7 @@ GetToken (qboolean crossline)
goto skipspace; goto skipspace;
} }
// copy token // copy token
token_p = token; token_p = token;
if (*script_p == '"') { if (*script_p == '"') {
@ -186,8 +182,6 @@ UngetToken ()
unget = true; unget = true;
} }
//============================================================================
entity_t *mapent; entity_t *mapent;
void void
@ -209,8 +203,6 @@ ParseEpair (void)
e->value = strdup (token); e->value = strdup (token);
} }
//============================================================================
vec3_t baseaxis[18] = { vec3_t baseaxis[18] = {
{0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor {0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor
{0, 0, -1}, {1, 0, 0}, {0, -1, 0}, // ceiling {0, 0, -1}, {1, 0, 0}, {0, -1, 0}, // ceiling
@ -241,8 +233,6 @@ TextureAxisFromPlane (plane_t *pln, vec3_t xv, vec3_t yv)
VectorCopy (baseaxis[bestaxis * 3 + 2], yv); VectorCopy (baseaxis[bestaxis * 3 + 2], yv);
} }
//=============================================================================
void void
ParseBrush (void) ParseBrush (void)
{ {
@ -517,7 +507,7 @@ GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
k = ValueForKey (ent, key); k = ValueForKey (ent, key);
v1 = v2 = v3 = 0; v1 = v2 = v3 = 0;
// scanf into doubles, then assign, so it is vec_t size independent // scanf into doubles, then assign, so it is vec_t size independent
sscanf (k, "%lf %lf %lf", &v1, &v2, &v3); sscanf (k, "%lf %lf %lf", &v1, &v2, &v3);
vec[0] = v1; vec[0] = v1;
vec[1] = v2; vec[1] = v2;

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// merge.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -38,8 +38,8 @@ CheckColinear (face_t *f)
vec3_t v1, v2; vec3_t v1, v2;
for (i = 0; i < f->numpoints; i++) { for (i = 0; i < f->numpoints; i++) {
// skip the point if the vector from the previous point is the same as the // skip the point if the vector from the previous point is the same as
// vector to the next point // the vector to the next point
j = (i - 1 < 0) ? f->numpoints - 1 : i - 1; j = (i - 1 < 0) ? f->numpoints - 1 : i - 1;
VectorSubtract (f->pts[i], f->pts[j], v1); VectorSubtract (f->pts[i], f->pts[j], v1);
VectorNormalize (v1); VectorNormalize (v1);
@ -55,15 +55,13 @@ CheckColinear (face_t *f)
} }
/* /*
============= TryMerge
TryMerge
If two polygons share a common edge and the edges that meet at the common If two polygons share a common edge and the edges that meet at the common
points are both inside the other polygons, merge them points are both inside the other polygons, merge them
Returns NULL if the faces couldn't be merged, or the new face. Returns NULL if the faces couldn't be merged, or the new face.
The originals will NOT be freed. The originals will NOT be freed.
=============
*/ */
face_t * face_t *
TryMerge (face_t *f1, face_t *f2) TryMerge (face_t *f1, face_t *f2)
@ -87,7 +85,7 @@ TryMerge (face_t *f1, face_t *f2)
if (f1->contents[1] != f2->contents[1]) if (f1->contents[1] != f2->contents[1])
return NULL; return NULL;
// find a common edge // find a common edge
p1 = p2 = NULL; // stop compiler warning p1 = p2 = NULL; // stop compiler warning
j = 0; j = 0;
@ -113,8 +111,8 @@ TryMerge (face_t *f1, face_t *f2)
if (i == f1->numpoints) if (i == f1->numpoints)
return NULL; // no matching edges return NULL; // no matching edges
// check slope of connected lines // check slope of connected lines
// if the slopes are colinear, the point can be removed // if the slopes are colinear, the point can be removed
plane = &planes[f1->planenum]; plane = &planes[f1->planenum];
VectorCopy (plane->normal, planenormal); VectorCopy (plane->normal, planenormal);
if (f1->planeside) if (f1->planeside)
@ -144,7 +142,7 @@ TryMerge (face_t *f1, face_t *f2)
return NULL; // not a convex polygon return NULL; // not a convex polygon
keep2 = dot < -CONTINUOUS_EPSILON; keep2 = dot < -CONTINUOUS_EPSILON;
// build the new polygon // build the new polygon
if (f1->numpoints + f2->numpoints > MAXEDGES) { if (f1->numpoints + f2->numpoints > MAXEDGES) {
// Sys_Error ("TryMerge: too many edges!"); // Sys_Error ("TryMerge: too many edges!");
return NULL; return NULL;
@ -152,7 +150,7 @@ TryMerge (face_t *f1, face_t *f2)
newf = NewFaceFromFace (f1); newf = NewFaceFromFace (f1);
// copy first polygon // copy first polygon
for (k = (i + 1) % f1->numpoints; k != i; k = (k + 1) % f1->numpoints) { for (k = (i + 1) % f1->numpoints; k != i; k = (k + 1) % f1->numpoints) {
if (k == (i + 1) % f1->numpoints && !keep2) if (k == (i + 1) % f1->numpoints && !keep2)
continue; continue;
@ -161,7 +159,7 @@ TryMerge (face_t *f1, face_t *f2)
newf->numpoints++; newf->numpoints++;
} }
// copy second polygon // copy second polygon
for (l = (j + 1) % f2->numpoints; l != j; l = (l + 1) % f2->numpoints) { for (l = (j + 1) % f2->numpoints; l != j; l = (l + 1) % f2->numpoints) {
if (l == (j + 1) % f2->numpoints && !keep1) if (l == (j + 1) % f2->numpoints && !keep1)
continue; continue;
@ -194,7 +192,7 @@ MergeFaceToList (face_t *face, face_t *list)
return MergeFaceToList (newf, list); return MergeFaceToList (newf, list);
} }
// didn't merge, so add at start // didn't merge, so add at start
face->next = list; face->next = list;
return face; return face;
} }
@ -230,7 +228,7 @@ MergePlaneFaces (surface_t *plane)
merged = MergeFaceToList (f1, merged); merged = MergeFaceToList (f1, merged);
} }
// chain all of the non-empty faces to the plane // chain all of the non-empty faces to the plane
plane->faces = FreeMergeListScraps (merged); plane->faces = FreeMergeListScraps (merged);
} }

View file

@ -17,6 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
"$Id$";
#include "bsp5.h" #include "bsp5.h"

View file

@ -16,6 +16,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -105,12 +107,10 @@ int hit_occupied;
int backdraw; int backdraw;
/* /*
================== RecursiveFillOutside
RecursiveFillOutside
If fill is false, just check, don't fill If fill is false, just check, don't fill
Returns true if an occupied leaf is reached Returns true if an occupied leaf is reached
==================
*/ */
qboolean qboolean
RecursiveFillOutside (node_t *l, qboolean fill) RecursiveFillOutside (node_t *l, qboolean fill)
@ -136,7 +136,7 @@ RecursiveFillOutside (node_t *l, qboolean fill)
l->valid = valid; l->valid = valid;
// fill it and it's neighbors // fill it and it's neighbors
if (fill) if (fill)
l->contents = CONTENTS_SOLID; l->contents = CONTENTS_SOLID;
outleafs++; outleafs++;
@ -144,8 +144,8 @@ RecursiveFillOutside (node_t *l, qboolean fill)
for (p = l->portals; p;) { for (p = l->portals; p;) {
s = (p->nodes[0] == l); s = (p->nodes[0] == l);
if (RecursiveFillOutside (p->nodes[s], fill)) { // leaked, so stop if (RecursiveFillOutside (p->nodes[s], fill)) {
// filling // leaked, so stop filling
if (backdraw-- > 0) { if (backdraw-- > 0) {
MarkLeakTrail (p); MarkLeakTrail (p);
DrawLeaf (l, 2); DrawLeaf (l, 2);
@ -178,8 +178,6 @@ ClearOutFaces (node_t *node)
node->faces = NULL; node->faces = NULL;
} }
//=============================================================================
qboolean qboolean
FillOutside (node_t *node) FillOutside (node_t *node)
{ {
@ -210,7 +208,7 @@ FillOutside (node_t *node)
s = !(outside_node.portals->nodes[1] == &outside_node); s = !(outside_node.portals->nodes[1] == &outside_node);
// first check to see if an occupied leaf is hit // first check to see if an occupied leaf is hit
outleafs = 0; outleafs = 0;
valid++; valid++;
@ -237,11 +235,11 @@ FillOutside (node_t *node)
if (!options.hullnum) if (!options.hullnum)
fclose (leakfile); fclose (leakfile);
// now go back and fill things in // now go back and fill things in
valid++; valid++;
RecursiveFillOutside (outside_node.portals->nodes[s], true); RecursiveFillOutside (outside_node.portals->nodes[s], true);
// remove faces from filled in leafs // remove faces from filled in leafs
ClearOutFaces (node); ClearOutFaces (node);
qprintf ("%4i outleafs\n", outleafs); qprintf ("%4i outleafs\n", outleafs);

View file

@ -17,6 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -53,7 +55,7 @@ RemovePortalFromNode (portal_t *portal, node_t *l)
{ {
portal_t **pp, *t; portal_t **pp, *t;
// remove reference to the current portal // remove reference to the current portal
pp = &l->portals; pp = &l->portals;
while (1) { while (1) {
t = *pp; t = *pp;
@ -80,8 +82,6 @@ RemovePortalFromNode (portal_t *portal, node_t *l)
} }
} }
//============================================================================
void void
PrintPortal (portal_t *p) PrintPortal (portal_t *p)
{ {
@ -95,11 +95,9 @@ PrintPortal (portal_t *p)
} }
/* /*
================ MakeHeadnodePortals
MakeHeadnodePortals
The created portals will face the global outside_node The created portals will face the global outside_node
================
*/ */
void void
MakeHeadnodePortals (node_t *node) MakeHeadnodePortals (node_t *node)
@ -111,7 +109,7 @@ MakeHeadnodePortals (node_t *node)
Draw_ClearWindow (); Draw_ClearWindow ();
// pad with some space so there will never be null volume leafs // pad with some space so there will never be null volume leafs
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
bounds[0][i] = brushset->mins[i] - SIDESPACE; bounds[0][i] = brushset->mins[i] - SIDESPACE;
bounds[1][i] = brushset->maxs[i] + SIDESPACE; bounds[1][i] = brushset->maxs[i] + SIDESPACE;
@ -145,7 +143,7 @@ MakeHeadnodePortals (node_t *node)
AddPortalToNodes (p, node, &outside_node); AddPortalToNodes (p, node, &outside_node);
} }
// clip the basewindings by all the other planes // clip the basewindings by all the other planes
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
if (j == i) if (j == i)
@ -198,7 +196,7 @@ PlaneFromWinding (winding_t *w, plane_t *plane)
{ {
vec3_t v1, v2; vec3_t v1, v2;
// calc plane // calc plane
VectorSubtract (w->points[2], w->points[1], v1); VectorSubtract (w->points[2], w->points[1], v1);
VectorSubtract (w->points[0], w->points[1], v2); VectorSubtract (w->points[0], w->points[1], v2);
CrossProduct (v2, v1, plane->normal); CrossProduct (v2, v1, plane->normal);
@ -261,7 +259,7 @@ CutNodePortals_r (node_t *node)
// CheckLeafPortalConsistancy (node); // CheckLeafPortalConsistancy (node);
// seperate the portals on node into it's children // seperate the portals on node into it's children
if (node->contents) if (node->contents)
return; // at a leaf, no more dividing return; // at a leaf, no more dividing
@ -270,13 +268,13 @@ CutNodePortals_r (node_t *node)
f = node->children[0]; f = node->children[0];
b = node->children[1]; b = node->children[1];
// create the new portal by taking the full plane winding for the cutting plane // create the new portal by taking the full plane winding for the cutting
// and clipping it by all of the planes from the other portals // plane and clipping it by all of the planes from the other portals
new_portal = AllocPortal (); new_portal = AllocPortal ();
new_portal->planenum = node->planenum; new_portal->planenum = node->planenum;
w = BaseWindingForPlane (&planes[node->planenum]); w = BaseWindingForPlane (&planes[node->planenum]);
side = 0; // shut up compiler warning side = 0;
for (p = node->portals; p; p = p->next[side]) { for (p = node->portals; p; p = p->next[side]) {
clipplane = planes[p->planenum]; clipplane = planes[p->planenum];
if (p->nodes[0] == node) if (p->nodes[0] == node)
@ -301,7 +299,7 @@ CutNodePortals_r (node_t *node)
AddPortalToNodes (new_portal, f, b); AddPortalToNodes (new_portal, f, b);
} }
// partition the portals // partition the portals
for (p = node->portals; p; p = next_portal) { for (p = node->portals; p; p = next_portal) {
if (p->nodes[0] == node) if (p->nodes[0] == node)
side = 0; side = 0;
@ -315,7 +313,7 @@ CutNodePortals_r (node_t *node)
RemovePortalFromNode (p, p->nodes[0]); RemovePortalFromNode (p, p->nodes[0]);
RemovePortalFromNode (p, p->nodes[1]); RemovePortalFromNode (p, p->nodes[1]);
// cut the portal into two portals, one on each side of the cut plane // cut the portal into two portals, one on each side of the cut plane
DivideWinding (p->winding, plane, &frontwinding, &backwinding); DivideWinding (p->winding, plane, &frontwinding, &backwinding);
if (!frontwinding) { if (!frontwinding) {
@ -356,11 +354,9 @@ CutNodePortals_r (node_t *node)
} }
/* /*
================== PortalizeWorld
PortalizeWorld
Builds the exact polyhedrons for the nodes and leafs Builds the exact polyhedrons for the nodes and leafs
==================
*/ */
void void
PortalizeWorld (node_t *headnode) PortalizeWorld (node_t *headnode)
@ -393,7 +389,7 @@ FreeAllPortals (node_t *node)
} }
} }
// PORTAL FILE GENERATION ===================================================== // PORTAL FILE GENERATION
#define PORTALFILE "PRT1" #define PORTALFILE "PRT1"
@ -467,7 +463,8 @@ NumberLeafs_r (node_t *node)
{ {
portal_t *p; portal_t *p;
if (!node->contents) { // decision node if (!node->contents) {
// decision node
node->visleafnum = -99; node->visleafnum = -99;
NumberLeafs_r (node->children[0]); NumberLeafs_r (node->children[0]);
NumberLeafs_r (node->children[1]); NumberLeafs_r (node->children[1]);
@ -477,8 +474,8 @@ NumberLeafs_r (node_t *node)
Draw_ClearWindow (); Draw_ClearWindow ();
DrawLeaf (node, 1); DrawLeaf (node, 1);
if (node->contents == CONTENTS_SOLID) { // solid block, viewpoint never if (node->contents == CONTENTS_SOLID) {
// inside // solid block, viewpoint never inside
node->visleafnum = -1; node->visleafnum = -1;
return; return;
} }
@ -486,8 +483,8 @@ NumberLeafs_r (node_t *node)
node->visleafnum = num_visleafs++; node->visleafnum = num_visleafs++;
for (p = node->portals; p;) { for (p = node->portals; p;) {
if (p->nodes[0] == node) // only write out from first leaf if (p->nodes[0] == node) {
{ // only write out from first leaf
if (p->nodes[0]->contents == p->nodes[1]->contents) if (p->nodes[0]->contents == p->nodes[1]->contents)
num_visportals++; num_visportals++;
p = p->next[0]; p = p->next[0];
@ -499,12 +496,13 @@ NumberLeafs_r (node_t *node)
void void
WritePortalfile (node_t *headnode) WritePortalfile (node_t *headnode)
{ {
// set the visleafnum field in every leaf and count the total number of portals // set the visleafnum field in every leaf and count the total number of
// portals
num_visleafs = 0; num_visleafs = 0;
num_visportals = 0; num_visportals = 0;
NumberLeafs_r (headnode); NumberLeafs_r (headnode);
// write the file // write the file
printf ("writing %s\n", options.portfile); printf ("writing %s\n", options.portfile);
pf = fopen (options.portfile, "w"); pf = fopen (options.portfile, "w");
if (!pf) if (!pf)

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// bsp5.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -43,6 +43,10 @@ bsp_t *bsp;
brushset_t *brushset; brushset_t *brushset;
int c_activefaces, c_peakfaces;
int c_activesurfaces, c_peaksurfaces;
int c_activewindings, c_peakwindings;
int c_activeportals, c_peakportals;
int valid; int valid;
char *argv0; // changed after fork(); char *argv0; // changed after fork();
@ -65,7 +69,7 @@ qprintf (char *fmt, ...)
va_end (argptr); va_end (argptr);
} }
winding_t * winding_t *
BaseWindingForPlane (plane_t *p) BaseWindingForPlane (plane_t *p)
{ {
int i, x; int i, x;
@ -73,7 +77,7 @@ BaseWindingForPlane (plane_t *p)
vec3_t org, vright, vup; vec3_t org, vright, vup;
winding_t *w; winding_t *w;
// find the major axis // find the major axis
max = -BOGUS_RANGE; max = -BOGUS_RANGE;
x = -1; x = -1;
@ -109,7 +113,7 @@ BaseWindingForPlane (plane_t *p)
VectorScale (vup, 8192, vup); VectorScale (vup, 8192, vup);
VectorScale (vright, 8192, vright); VectorScale (vright, 8192, vright);
// project a really big axis aligned box onto the plane // project a really big axis aligned box onto the plane
w = NewWinding (4); w = NewWinding (4);
VectorSubtract (org, vright, w->points[0]); VectorSubtract (org, vright, w->points[0]);
@ -129,7 +133,7 @@ BaseWindingForPlane (plane_t *p)
return w; return w;
} }
winding_t * winding_t *
CopyWinding (winding_t *w) CopyWinding (winding_t *w)
{ {
int size; int size;
@ -141,29 +145,23 @@ CopyWinding (winding_t *w)
return c; return c;
} }
/*
==================
CheckWinding
Check for possible errors
==================
*/
void void
CheckWinding (winding_t * w) CheckWinding (winding_t * w)
{ {
} }
/* /*
================== ClipWinding
ClipWinding
Clips the winding to the plane, returning the new winding on the positive side Clips the winding to the plane, returning the new winding on the positive
Frees the input winding. side.
If keepon is true, an exactly on-plane winding will be saved, otherwise
it will be clipped away. Frees the input winding.
==================
If keepon is true, an exactly on-plane winding will be saved, otherwise
it will be clipped away.
*/ */
winding_t * winding_t *
ClipWinding (winding_t *in, plane_t *split, qboolean keepon) ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
{ {
int maxpts, i, j; int maxpts, i, j;
@ -177,7 +175,7 @@ ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
counts[0] = counts[1] = counts[2] = 0; counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point // determine sides for each point
for (i = 0; i < in->numpoints; i++) { for (i = 0; i < in->numpoints; i++) {
dot = DotProduct (in->points[i], split->normal); dot = DotProduct (in->points[i], split->normal);
dot -= split->dist; dot -= split->dist;
@ -245,21 +243,19 @@ ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
if (neww->numpoints > maxpts) if (neww->numpoints > maxpts)
Sys_Error ("ClipWinding: points exceeded estimate"); Sys_Error ("ClipWinding: points exceeded estimate");
// free the original winding // free the original winding
FreeWinding (in); FreeWinding (in);
return neww; return neww;
} }
/* /*
================== DivideWinding
DivideWinding
Divides a winding by a plane, producing one or two windings. The Divides a winding by a plane, producing one or two windings. The
original winding is not damaged or freed. If only on one side, the original winding is not damaged or freed. If only on one side, the
returned winding will be the input winding. If on both sides, two returned winding will be the input winding. If on both sides, two
new windings will be created. new windings will be created.
==================
*/ */
void void
DivideWinding (winding_t *in, plane_t *split, winding_t **front, DivideWinding (winding_t *in, plane_t *split, winding_t **front,
@ -276,7 +272,7 @@ DivideWinding (winding_t *in, plane_t *split, winding_t **front,
counts[0] = counts[1] = counts[2] = 0; counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point // determine sides for each point
for (i = 0; i < in->numpoints; i++) { for (i = 0; i < in->numpoints; i++) {
dot = DotProduct (in->points[i], split->normal); dot = DotProduct (in->points[i], split->normal);
dot -= split->dist; dot -= split->dist;
@ -305,7 +301,7 @@ DivideWinding (winding_t *in, plane_t *split, winding_t **front,
} }
maxpts = in->numpoints + 4; // can't use counts[0]+2 because maxpts = in->numpoints + 4; // can't use counts[0]+2 because
// of fp grouping errors // of fp grouping errors
*front = f = NewWinding (maxpts); *front = f = NewWinding (maxpts);
*back = b = NewWinding (maxpts); *back = b = NewWinding (maxpts);
@ -357,14 +353,6 @@ DivideWinding (winding_t *in, plane_t *split, winding_t **front,
Sys_Error ("ClipWinding: points exceeded estimate"); Sys_Error ("ClipWinding: points exceeded estimate");
} }
//===========================================================================
int c_activefaces, c_peakfaces;
int c_activesurfaces, c_peaksurfaces;
int c_activewindings, c_peakwindings;
int c_activeportals, c_peakportals;
void void
PrintMemory (void) PrintMemory (void)
{ {
@ -374,7 +362,7 @@ PrintMemory (void)
printf ("portals : %6i (%6i)\n", c_activeportals, c_peakportals); printf ("portals : %6i (%6i)\n", c_activeportals, c_peakportals);
} }
winding_t * winding_t *
NewWinding (int points) NewWinding (int points)
{ {
int size; int size;
@ -401,7 +389,7 @@ FreeWinding (winding_t *w)
free (w); free (w);
} }
face_t * face_t *
AllocFace (void) AllocFace (void)
{ {
face_t *f; face_t *f;
@ -421,11 +409,10 @@ void
FreeFace (face_t *f) FreeFace (face_t *f)
{ {
c_activefaces--; c_activefaces--;
// memset (f, 0xff, sizeof (face_t));
free (f); free (f);
} }
surface_t * surface_t *
AllocSurface (void) AllocSurface (void)
{ {
surface_t *s; surface_t *s;
@ -447,7 +434,7 @@ FreeSurface (surface_t *s)
free (s); free (s);
} }
portal_t * portal_t *
AllocPortal (void) AllocPortal (void)
{ {
portal_t *p; portal_t *p;
@ -469,7 +456,7 @@ FreePortal (portal_t *p)
free (p); free (p);
} }
node_t * node_t *
AllocNode (void) AllocNode (void)
{ {
node_t *n; node_t *n;
@ -480,7 +467,7 @@ AllocNode (void)
return n; return n;
} }
brush_t * brush_t *
AllocBrush (void) AllocBrush (void)
{ {
brush_t *b; brush_t *b;
@ -491,8 +478,6 @@ AllocBrush (void)
return b; return b;
} }
//===========================================================================
void void
ProcessEntity (int entnum) ProcessEntity (int entnum)
{ {
@ -520,8 +505,8 @@ ProcessEntity (int entnum)
} else } else
worldmodel = true; worldmodel = true;
// take the brush_ts and clip off all overlapping and contained faces, // take the brush_ts and clip off all overlapping and contained faces,
// leaving a perfect skin of the model with no hidden faces // leaving a perfect skin of the model with no hidden faces
bs = Brush_LoadEntity (ent, hullnum); bs = Brush_LoadEntity (ent, hullnum);
if (!bs->brushes) { if (!bs->brushes) {
@ -617,11 +602,9 @@ UpdateEntLump (void)
} }
/* /*
================= WriteClipHull
WriteClipHull
Write the clipping hull out to a text file so the parent process can get it Write the clipping hull out to a text file so the parent process can get it
=================
*/ */
void void
WriteClipHull (void) WriteClipHull (void)
@ -660,11 +643,9 @@ WriteClipHull (void)
} }
/* /*
================= ReadClipHull
ReadClipHull
Read the files written out by the child processes Read the files written out by the child processes
=================
*/ */
void void
ReadClipHull (int hullnum) ReadClipHull (int hullnum)
@ -728,7 +709,7 @@ CreateSingleHull (void)
{ {
int entnum; int entnum;
// for each entity in the map file that has geometry // for each entity in the map file that has geometry
for (entnum = 0; entnum < num_entities; entnum++) { for (entnum = 0; entnum < num_entities; entnum++) {
ProcessEntity (entnum); ProcessEntity (entnum);
if (options.verbosity < 2) if (options.verbosity < 2)
@ -742,27 +723,27 @@ CreateSingleHull (void)
void void
CreateHulls (void) CreateHulls (void)
{ {
// commanded to create a single hull only // commanded to create a single hull only
if (hullnum) { if (hullnum) {
CreateSingleHull (); CreateSingleHull ();
exit (0); exit (0);
} }
// commanded to use the allready existing hulls 1 and 2 // commanded to use the allready existing hulls 1 and 2
if (options.usehulls) { if (options.usehulls) {
CreateSingleHull (); CreateSingleHull ();
return; return;
} }
// commanded to ignore the hulls altogether // commanded to ignore the hulls altogether
if (options.noclip) { if (options.noclip) {
CreateSingleHull (); CreateSingleHull ();
return; return;
} }
// create all the hulls // create all the hulls
#ifdef __alpha #ifdef __alpha
printf ("forking hull processes...\n"); printf ("forking hull processes...\n");
// fork a process for each clipping hull // fork a process for each clipping hull
fflush (stdout); fflush (stdout);
if (!fork ()) { if (!fork ()) {
hullnum = 1; hullnum = 1;
@ -784,7 +765,7 @@ CreateHulls (void)
wait (NULL); // wait for clip hull process to finish wait (NULL); // wait for clip hull process to finish
#else #else
// create the hulls sequentially // create the hulls sequentially
printf ("building hulls sequentially...\n"); printf ("building hulls sequentially...\n");
hullnum = 1; hullnum = 1;
@ -808,8 +789,7 @@ CreateHulls (void)
void void
ProcessFile () ProcessFile ()
{ {
// create filenames // create filenames
COM_StripExtension (options.bspfile, options.hullfile); COM_StripExtension (options.bspfile, options.hullfile);
strcat (options.hullfile, ".h0"); strcat (options.hullfile, ".h0");
@ -831,16 +811,16 @@ ProcessFile ()
remove (options.pointfile); remove (options.pointfile);
} }
bsp = BSP_New (); bsp = BSP_New ();
// load brushes and entities // load brushes and entities
LoadMapFile (options.mapfile); LoadMapFile (options.mapfile);
if (options.onlyents) { if (options.onlyents) {
UpdateEntLump (); UpdateEntLump ();
return; return;
} }
// init the tables to be shared by all models // init the tables to be shared by all models
BeginBSPFile (); BeginBSPFile ();
// the clipping hulls will be written out to text files by forked processes // the clipping hulls will be written out to text files by forked processes
CreateHulls (); CreateHulls ();
ReadClipHull (1); ReadClipHull (1);
@ -857,17 +837,15 @@ main (int argc, char **argv)
char destname[1024]; char destname[1024];
double start, end; double start, end;
// malloc_debug (15); // check command line flags
// check command line flags
DecodeArgs (argc, argv); DecodeArgs (argc, argv);
// XXX SetQdirFromPath (argv[i]); // XXX SetQdirFromPath (argv[i]);
// let forked processes change name for ps status // let forked processes change name for ps status
argv0 = argv[0]; argv0 = argv[0];
// do it! // do it!
start = Sys_DoubleTime (); start = Sys_DoubleTime ();
ProcessFile (sourcename, destname); ProcessFile (sourcename, destname);
end = Sys_DoubleTime (); end = Sys_DoubleTime ();

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// region.h "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -99,7 +99,7 @@ CanJoinFaces (face_t *f, face_t *f2)
printf ("CanJoinFaces: edge with different contents"); printf ("CanJoinFaces: edge with different contents");
return false; return false;
} }
// check size constraints // check size constraints
if (!(bsp->texinfo[f->texturenum].flags & TEX_SPECIAL)) { if (!(bsp->texinfo[f->texturenum].flags & TEX_SPECIAL)) {
VectorCopy (region_mins, oldmins); VectorCopy (region_mins, oldmins);
VectorCopy (region_maxs, oldmaxs); VectorCopy (region_maxs, oldmaxs);
@ -117,7 +117,7 @@ CanJoinFaces (face_t *f, face_t *f2)
return false; // a huge water or sky polygon return false; // a huge water or sky polygon
} }
// check edge count constraints // check edge count constraints
return true; return true;
} }
@ -134,7 +134,7 @@ RecursiveGrowRegion (dface_t *r, face_t *f)
Sys_Error ("RecursiveGrowRegion: region collision"); Sys_Error ("RecursiveGrowRegion: region collision");
f->outputnumber = bsp->numfaces; f->outputnumber = bsp->numfaces;
// add edges // add edges
for (i = 0; i < f->numpoints; i++) { for (i = 0; i < f->numpoints; i++) {
e = f->edges[i]; e = f->edges[i];
if (!edgefaces[abs (e)][0]) if (!edgefaces[abs (e)][0])
@ -222,12 +222,10 @@ FindEdgeUse (int v)
int edgemapping[MAX_MAP_EDGES]; int edgemapping[MAX_MAP_EDGES];
/* /*
================ HealEdges
HealEdges
Extends e1 so that it goes all the way to e2, and removes all references Extends e1 so that it goes all the way to e2, and removes all references
to e2 to e2
================
*/ */
void void
HealEdges (int e1, int e2) HealEdges (int e1, int e2)
@ -243,7 +241,7 @@ HealEdges (int e1, int e2)
e1 = edgemapping[e1]; e1 = edgemapping[e1];
e2 = edgemapping[e2]; e2 = edgemapping[e2];
// extend e1 to e2 // extend e1 to e2
ed = &bsp->edges[e1]; ed = &bsp->edges[e1];
ed2 = &bsp->edges[e2]; ed2 = &bsp->edges[e2];
VectorSubtract (bsp->vertexes[ed->v[1]].point, VectorSubtract (bsp->vertexes[ed->v[1]].point,
@ -271,7 +269,7 @@ HealEdges (int e1, int e2)
edgemapping[e2] = e1; edgemapping[e2] = e1;
saved = 0; saved = 0;
// remove all uses of e2 // remove all uses of e2
for (i = firstmodelface; i < bsp->numfaces; i++) { for (i = firstmodelface; i < bsp->numfaces; i++) {
df = &bsp->faces[i]; df = &bsp->faces[i];
for (j = 0; j < df->numedges; j++) { for (j = 0; j < df->numedges; j++) {
@ -316,11 +314,11 @@ RemoveColinearEdges (void)
checkpoint_t *cp; checkpoint_t *cp;
int c0, c1, c2, c3, i, j, v; int c0, c1, c2, c3, i, j, v;
// no edges remapped yet // no edges remapped yet
for (i = 0; i < bsp->numedges; i++) for (i = 0; i < bsp->numedges; i++)
edgemapping[i] = i; edgemapping[i] = i;
// find vertexes that only have two edges // find vertexes that only have two edges
memset (checkpoints, 0, sizeof (checkpoints)); memset (checkpoints, 0, sizeof (checkpoints));
for (i = firstmodeledge; i < bsp->numedges; i++) { for (i = firstmodeledge; i < bsp->numedges; i++) {
@ -335,7 +333,7 @@ RemoveColinearEdges (void)
} }
} }
// if a vertex only has two edges and they are colinear, it can be removed // if a vertex only has two edges and they are colinear, it can be removed
c0 = c1 = c2 = c3 = 0; c0 = c1 = c2 = c3 = 0;
for (i = 0; i < bsp->numvertexes; i++) { for (i = 0; i < bsp->numvertexes; i++) {
@ -384,8 +382,6 @@ CountRealNumbers (void)
qprintf ("%5i real edges\n", c); qprintf ("%5i real edges\n", c);
} }
//=============================================================================
void void
GrowNodeRegion_r (node_t * node) GrowNodeRegion_r (node_t * node)
{ {
@ -450,20 +446,19 @@ GrowNodeRegions (node_t *headnode)
} }
/* /*
=============================================================================== Turn the faces on a plane into optimal non-convex regions
Turn the faces on a plane into optimal non-convex regions The edges may still be split later as a result of tjunctions
The edges may still be split later as a result of tjunctions
typedef struct typedef struct
{ {
vec3_t dir; vec3_t dir;
vec3_t origin; vec3_t origin;
vec3_t p[2]; vec3_t p[2];
} }
for all faces for all faces
for all edges for all edges
for all edges so far for all edges so far
if overlap if overlap
split split
*/ */

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// solidbsp.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -39,11 +39,9 @@ qboolean usemidsplit;
/* /*
================== FaceSide
FaceSide
For BSP hueristic For BSP hueristic
==================
*/ */
int int
FaceSide (face_t *in, plane_t *split) FaceSide (face_t *in, plane_t *split)
@ -54,7 +52,7 @@ FaceSide (face_t *in, plane_t *split)
frontcount = backcount = 0; frontcount = backcount = 0;
// axial planes are fast // axial planes are fast
if (split->type < 3) if (split->type < 3)
for (i = 0, p = in->pts[0] + split->type; i < in->numpoints; for (i = 0, p = in->pts[0] + split->type; i < in->numpoints;
i++, p += 3) { i++, p += 3) {
@ -68,7 +66,7 @@ FaceSide (face_t *in, plane_t *split)
backcount = 1; backcount = 1;
} }
} else } else
// sloping planes take longer // sloping planes take longer
for (i = 0, p = in->pts[0]; i < in->numpoints; i++, p += 3) { for (i = 0, p = in->pts[0]; i < in->numpoints; i++, p += 3) {
dot = DotProduct (p, split->normal); dot = DotProduct (p, split->normal);
dot -= split->dist; dot -= split->dist;
@ -92,11 +90,9 @@ FaceSide (face_t *in, plane_t *split)
} }
/* /*
================== ChooseMidPlaneFromList
ChooseMidPlaneFromList
The clipping hull BSP doesn't worry about avoiding splits The clipping hull BSP doesn't worry about avoiding splits
==================
*/ */
surface_t * surface_t *
ChooseMidPlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs) ChooseMidPlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs)
@ -106,7 +102,7 @@ ChooseMidPlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs)
surface_t *p, *bestsurface; surface_t *p, *bestsurface;
vec_t bestvalue, value, dist; vec_t bestvalue, value, dist;
// pick the plane that splits the least // pick the plane that splits the least
bestvalue = 6 * 8192 * 8192; bestvalue = 6 * 8192 * 8192;
bestsurface = NULL; bestsurface = NULL;
@ -152,11 +148,9 @@ ChooseMidPlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs)
} }
/* /*
================== ChoosePlaneFromList
ChoosePlaneFromList
The real BSP hueristic The real BSP hueristic
==================
*/ */
surface_t * surface_t *
ChoosePlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs, ChoosePlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs,
@ -168,7 +162,7 @@ ChoosePlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs,
surface_t *p, *p2, *bestsurface; surface_t *p, *p2, *bestsurface;
vec_t bestvalue, bestdistribution, value, dist; vec_t bestvalue, bestdistribution, value, dist;
// pick the plane that splits the least // pick the plane that splits the least
bestvalue = 99999; bestvalue = 99999;
bestsurface = NULL; bestsurface = NULL;
bestdistribution = 9e30; bestdistribution = 9e30;
@ -238,12 +232,10 @@ ChoosePlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs,
} }
/* /*
================== SelectPartition
SelectPartition
Selects a surface from a linked list of surfaces to split the group on Selects a surface from a linked list of surfaces to split the group on
returns NULL if the surface list can not be divided any more (a leaf) returns NULL if the surface list can not be divided any more (a leaf)
==================
*/ */
surface_t * surface_t *
SelectPartition (surface_t *surfaces) SelectPartition (surface_t *surfaces)
@ -252,7 +244,7 @@ SelectPartition (surface_t *surfaces)
surface_t *p, *bestsurface; surface_t *p, *bestsurface;
vec3_t mins, maxs; vec3_t mins, maxs;
// count onnode surfaces // count onnode surfaces
i = 0; i = 0;
bestsurface = NULL; bestsurface = NULL;
for (p = surfaces; p; p = p->next) for (p = surfaces; p; p = p->next)
@ -267,7 +259,7 @@ SelectPartition (surface_t *surfaces)
if (i == 1) if (i == 1)
return bestsurface; // this is a final split return bestsurface; // this is a final split
// calculate a bounding box of the entire surfaceset // calculate a bounding box of the entire surfaceset
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
mins[i] = 99999; mins[i] = 99999;
maxs[i] = -99999; maxs[i] = -99999;
@ -284,7 +276,7 @@ SelectPartition (surface_t *surfaces)
if (usemidsplit) // do fast way for clipping hull if (usemidsplit) // do fast way for clipping hull
return ChooseMidPlaneFromList (surfaces, mins, maxs); return ChooseMidPlaneFromList (surfaces, mins, maxs);
// do slow way to save poly splits for drawing hull // do slow way to save poly splits for drawing hull
#if 0 #if 0
bestsurface = ChoosePlaneFromList (surfaces, mins, maxs, false); bestsurface = ChoosePlaneFromList (surfaces, mins, maxs, false);
if (bestsurface) if (bestsurface)
@ -296,11 +288,9 @@ SelectPartition (surface_t *surfaces)
//============================================================================ //============================================================================
/* /*
================= CalcSurfaceInfo
CalcSurfaceInfo
Calculates the bounding box Calculates the bounding box
=================
*/ */
void void
CalcSurfaceInfo (surface_t * surf) CalcSurfaceInfo (surface_t * surf)
@ -311,7 +301,7 @@ CalcSurfaceInfo (surface_t * surf)
if (!surf->faces) if (!surf->faces)
Sys_Error ("CalcSurfaceInfo: surface without a face"); Sys_Error ("CalcSurfaceInfo: surface without a face");
// calculate a bounding box // calculate a bounding box
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
surf->mins[i] = 99999; surf->mins[i] = 99999;
surf->maxs[i] = -99999; surf->maxs[i] = -99999;
@ -342,11 +332,11 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
inplane = &planes[in->planenum]; inplane = &planes[in->planenum];
// parallel case is easy // parallel case is easy
if (_VectorCompare (inplane->normal, split->normal)) { if (_VectorCompare (inplane->normal, split->normal)) {
// check for exactly on node // check for exactly on node
if (inplane->dist == split->dist) { // divide the facets to the front if (inplane->dist == split->dist) {
// and back sides // divide the facets to the front and back sides
news = AllocSurface (); news = AllocSurface ();
*news = *in; *news = *in;
@ -386,8 +376,8 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
} }
return; return;
} }
// do a real split. may still end up entirely on one side // do a real split. may still end up entirely on one side
// OPTIMIZE: use bounding box for fast test // OPTIMIZE: use bounding box for fast test
frontlist = NULL; frontlist = NULL;
backlist = NULL; backlist = NULL;
@ -404,7 +394,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
} }
} }
// if nothing actually got split, just move the in plane // if nothing actually got split, just move the in plane
if (frontlist == NULL) { if (frontlist == NULL) {
*front = NULL; *front = NULL;
*back = in; *back = in;
@ -418,7 +408,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
return; return;
} }
// stuff got split, so allocate one new plane and reuse in // stuff got split, so allocate one new plane and reuse in
news = AllocSurface (); news = AllocSurface ();
*news = *in; *news = *in;
news->faces = backlist; news->faces = backlist;
@ -427,7 +417,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
in->faces = frontlist; in->faces = frontlist;
*front = in; *front = in;
// recalc bboxes and flags // recalc bboxes and flags
CalcSurfaceInfo (news); CalcSurfaceInfo (news);
CalcSurfaceInfo (in); CalcSurfaceInfo (in);
} }
@ -440,7 +430,7 @@ DivideNodeBounds (node_t *node, plane_t *split)
VectorCopy (node->maxs, node->children[0]->maxs); VectorCopy (node->maxs, node->children[0]->maxs);
VectorCopy (node->maxs, node->children[1]->maxs); VectorCopy (node->maxs, node->children[1]->maxs);
// OPTIMIZE: sloping cuts can give a better bbox than this... // OPTIMIZE: sloping cuts can give a better bbox than this...
if (split->type > 2) if (split->type > 2)
return; return;
@ -449,12 +439,10 @@ DivideNodeBounds (node_t *node, plane_t *split)
} }
/* /*
================== LinkConvexFaces
LinkConvexFaces
Determines the contents of the leaf and creates the final list of Determines the contents of the leaf and creates the final list of
original faces that have some fragment inside this leaf original faces that have some fragment inside this leaf
==================
*/ */
void void
LinkConvexFaces (surface_t *planelist, node_t *leafnode) LinkConvexFaces (surface_t *planelist, node_t *leafnode)
@ -498,7 +486,7 @@ LinkConvexFaces (surface_t *planelist, node_t *leafnode)
Sys_Error ("LinkConvexFaces: bad contents number"); Sys_Error ("LinkConvexFaces: bad contents number");
} }
// write the list of faces, and free the originals // write the list of faces, and free the originals
leaffaces += count; leaffaces += count;
leafnode->markfaces = malloc (sizeof (face_t *) * (count + 1)); leafnode->markfaces = malloc (sizeof (face_t *) * (count + 1));
i = 0; i = 0;
@ -516,11 +504,9 @@ LinkConvexFaces (surface_t *planelist, node_t *leafnode)
} }
/* /*
================== LinkNodeFaces
LinkNodeFaces
Returns a duplicated list of all faces on surface Returns a duplicated list of all faces on surface
==================
*/ */
face_t * face_t *
LinkNodeFaces (surface_t *surface) LinkNodeFaces (surface_t *surface)
@ -529,7 +515,7 @@ LinkNodeFaces (surface_t *surface)
list = NULL; list = NULL;
// subdivide // subdivide
prevptr = &surface->faces; prevptr = &surface->faces;
while (1) { while (1) {
f = *prevptr; f = *prevptr;
@ -540,7 +526,7 @@ LinkNodeFaces (surface_t *surface)
prevptr = &f->next; prevptr = &f->next;
} }
// copy // copy
for (f = surface->faces; f; f = f->next) { for (f = surface->faces; f; f = f->next) {
nodefaces++; nodefaces++;
new = AllocFace (); new = AllocFace ();
@ -578,7 +564,8 @@ PartitionSurfaces (surface_t *surfaces, node_t *node)
DivideNodeBounds (node, splitplane); DivideNodeBounds (node, splitplane);
// multiple surfaces, so split all the polysurfaces into front and back lists // multiple surfaces, so split all the polysurfaces into front and back
// lists
frontlist = NULL; frontlist = NULL;
backlist = NULL; backlist = NULL;
@ -640,13 +627,13 @@ SolidBSP (surface_t *surfhead, qboolean midsplit)
headnode = AllocNode (); headnode = AllocNode ();
usemidsplit = midsplit; usemidsplit = midsplit;
// calculate a bounding box for the entire model // calculate a bounding box for the entire model
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
headnode->mins[i] = brushset->mins[i] - SIDESPACE; headnode->mins[i] = brushset->mins[i] - SIDESPACE;
headnode->maxs[i] = brushset->maxs[i] + SIDESPACE; headnode->maxs[i] = brushset->maxs[i] + SIDESPACE;
} }
// recursively partition everything // recursively partition everything
Draw_ClearWindow (); Draw_ClearWindow ();
splitnodes = 0; splitnodes = 0;
leaffaces = 0; leaffaces = 0;

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// divide.h "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -34,22 +34,20 @@
#include "options.h" #include "options.h"
/* /*
a surface has all of the faces that could be drawn on a given plane a surface has all of the faces that could be drawn on a given plane
the outside filling stage can remove some of them so a better bsp can be the outside filling stage can remove some of them so a better bsp can be
generated generated
*/ */
surface_t newcopy_t; surface_t newcopy_t;
int subdivides; int subdivides;
/* /*
=============== SubdivideFace
SubdivideFace
If the face is >256 in either texture direction, carve a valid sized If the face is >256 in either texture direction, carve a valid sized
piece off and insert the remainder in the next link piece off and insert the remainder in the next link
===============
*/ */
void void
SubdivideFace (face_t *f, face_t **prevptr) SubdivideFace (face_t *f, face_t **prevptr)
@ -61,7 +59,7 @@ SubdivideFace (face_t *f, face_t **prevptr)
texinfo_t *tex; texinfo_t *tex;
vec_t v; vec_t v;
// special (non-surface cached) faces don't need subdivision // special (non-surface cached) faces don't need subdivision
tex = &bsp->texinfo[f->texturenum]; tex = &bsp->texinfo[f->texturenum];
if (tex->flags & TEX_SPECIAL) if (tex->flags & TEX_SPECIAL)
@ -130,12 +128,10 @@ SubdivideFaces (surface_t *surfhead)
} }
/* /*
============================================================================= GatherNodeFaces
GatherNodeFaces
Frees the current node tree and returns a new chain of the surfaces that Frees the current node tree and returns a new chain of the surfaces that
have inside faces. have inside faces.
=============================================================================
*/ */
void void
GatherNodeFaces_r (node_t *node) GatherNodeFaces_r (node_t *node)
@ -143,7 +139,7 @@ GatherNodeFaces_r (node_t *node)
face_t *next, *f; face_t *next, *f;
if (node->planenum != PLANENUM_LEAF) { if (node->planenum != PLANENUM_LEAF) {
// decision node // decision node
for (f = node->faces; f; f = next) { for (f = node->faces; f; f = next) {
next = f->next; next = f->next;
if (!f->numpoints) { // face was removed outside if (!f->numpoints) { // face was removed outside
@ -159,7 +155,7 @@ GatherNodeFaces_r (node_t *node)
free (node); free (node);
} else { } else {
// leaf node // leaf node
free (node); free (node);
} }
} }
@ -291,7 +287,7 @@ GetVertex (vec3_t in, int planenum)
Sys_Error ("GetVertex: MAX_MAP_VERTS"); Sys_Error ("GetVertex: MAX_MAP_VERTS");
hvert_p++; hvert_p++;
// emit a vertex // emit a vertex
if (bsp->numvertexes == MAX_MAP_VERTS) if (bsp->numvertexes == MAX_MAP_VERTS)
Sys_Error ("numvertexes == MAX_MAP_VERTS"); Sys_Error ("numvertexes == MAX_MAP_VERTS");
@ -309,11 +305,9 @@ GetVertex (vec3_t in, int planenum)
int c_tryedges; int c_tryedges;
/* /*
================== GetEdge
GetEdge
Don't allow four way edges Don't allow four way edges
==================
*/ */
int int
GetEdge (vec3_t p1, vec3_t p2, face_t *f) GetEdge (vec3_t p1, vec3_t p2, face_t *f)
@ -336,7 +330,7 @@ GetEdge (vec3_t p1, vec3_t p2, face_t *f)
} }
} }
// emit an edge // emit an edge
if (bsp->numedges == MAX_MAP_EDGES) if (bsp->numedges == MAX_MAP_EDGES)
Sys_Error ("numedges == MAX_MAP_EDGES"); Sys_Error ("numedges == MAX_MAP_EDGES");
edge.v[0] = v1; edge.v[0] = v1;
@ -361,12 +355,6 @@ FindFaceEdges (face_t *face)
(face->pts[i], face->pts[(i + 1) % face->numpoints], face); (face->pts[i], face->pts[(i + 1) % face->numpoints], face);
} }
/*
=============
CheckVertexes
// debugging
=============
*/
void void
CheckVertexes (void) CheckVertexes (void)
{ {
@ -394,12 +382,6 @@ CheckVertexes (void)
qprintf ("%5i 6+ edge points\n", c3); qprintf ("%5i 6+ edge points\n", c3);
} }
/*
=============
CheckEdges
// debugging
=============
*/
void void
CheckEdges (void) CheckEdges (void)
{ {

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
// tjunc.c "$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -65,8 +65,6 @@ PrintFace (face_t *f)
f->pts[i][2]); f->pts[i][2]);
} }
//============================================================================
#define NUM_HASH 1024 #define NUM_HASH 1024
wedge_t *wedge_hash[NUM_HASH]; wedge_t *wedge_hash[NUM_HASH];
@ -109,8 +107,6 @@ HashVec (vec3_t vec)
return h; return h;
} }
//============================================================================
void void
CanonicalVector (vec3_t vec) CanonicalVector (vec3_t vec)
{ {
@ -220,7 +216,7 @@ AddVert (wedge_t *w, vec_t t)
v = v->next; v = v->next;
} while (1); } while (1);
// insert a new wvert before v // insert a new wvert before v
if (numwverts == MAXWVERTS) if (numwverts == MAXWVERTS)
Sys_Error ("AddVert: numwverts == MAXWVERTS"); Sys_Error ("AddVert: numwverts == MAXWVERTS");
@ -256,8 +252,6 @@ AddFaceEdges (face_t *f)
} }
} }
//============================================================================
// a specially allocated face that can hold hundreds of edges if needed // a specially allocated face that can hold hundreds of edges if needed
byte superfacebuf[8192]; byte superfacebuf[8192];
face_t *superface = (face_t *) superfacebuf; face_t *superface = (face_t *) superfacebuf;
@ -276,9 +270,9 @@ SplitFaceForTjunc (face_t *f, face_t *original)
chain = NULL; chain = NULL;
do { do {
if (f->numpoints <= MAXPOINTS) { // the face is now small enough if (f->numpoints <= MAXPOINTS) {
// without more cutting // the face is now small enough without more cutting so copy it
// so copy it back to the original // back to the original
*original = *f; *original = *f;
original->original = chain; original->original = chain;
original->next = newlist; original->next = newlist;
@ -387,7 +381,7 @@ FixFaceEdges (face_t *f)
newlist = f; newlist = f;
return; return;
} }
// the face needs to be split into multiple faces because of too many edges // the face needs to be split into multiple faces because of too many edges
SplitFaceForTjunc (superface, f); SplitFaceForTjunc (superface, f);
} }
@ -441,9 +435,9 @@ tjunc (node_t *headnode)
if (options.notjunc) if (options.notjunc)
return; return;
// identify all points on common edges // identify all points on common edges
// origin points won't allways be inside the map, so extend the hash area // origin points won't allways be inside the map, so extend the hash area
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (fabs (brushset->maxs[i]) > fabs (brushset->mins[i])) if (fabs (brushset->maxs[i]) > fabs (brushset->mins[i]))
maxs[i] = fabs (brushset->maxs[i]); maxs[i] = fabs (brushset->maxs[i]);
@ -460,7 +454,7 @@ tjunc (node_t *headnode)
qprintf ("%i world edges %i edge points\n", numwedges, numwverts); qprintf ("%i world edges %i edge points\n", numwedges, numwverts);
// add extra vertexes on edges where needed // add extra vertexes on edges where needed
tjuncs = tjuncfaces = 0; tjuncs = tjuncfaces = 0;
tjunc_fix_r (headnode); tjunc_fix_r (headnode);

View file

@ -17,6 +17,8 @@
See file, 'COPYING', for details. See file, 'COPYING', for details.
*/ */
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -43,11 +45,9 @@ int firstface;
/* /*
================== FindFinalPlane
FindFinalPlane
Used to find plane index numbers for clip nodes read from child processes Used to find plane index numbers for clip nodes read from child processes
==================
*/ */
int int
FindFinalPlane (dplane_t *p) FindFinalPlane (dplane_t *p)
@ -69,7 +69,7 @@ FindFinalPlane (dplane_t *p)
return i; return i;
} }
// new plane // new plane
if (bsp->numplanes == MAX_MAP_PLANES) if (bsp->numplanes == MAX_MAP_PLANES)
Sys_Error ("numplanes == MAX_MAP_PLANES"); Sys_Error ("numplanes == MAX_MAP_PLANES");
BSP_AddPlane (bsp, p); BSP_AddPlane (bsp, p);
@ -113,21 +113,19 @@ WriteNodePlanes (node_t *nodes)
WriteNodePlanes_r (nodes); WriteNodePlanes_r (nodes);
} }
//===========================================================================
int int
WriteClipNodes_r (node_t *node) WriteClipNodes_r (node_t *node)
{ {
dclipnode_t cn; dclipnode_t cn;
int num, c, i; int num, c, i;
// FIXME: free more stuff? // FIXME: free more stuff?
if (node->planenum == -1) { if (node->planenum == -1) {
num = node->contents; num = node->contents;
free (node); free (node);
return num; return num;
} }
// emit a clipnode // emit a clipnode
c = bsp->numclipnodes; c = bsp->numclipnodes;
cn.planenum = node->outputplanenum; cn.planenum = node->outputplanenum;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
@ -139,12 +137,10 @@ WriteClipNodes_r (node_t *node)
} }
/* /*
================== WriteClipNodes
WriteClipNodes
Called after the clipping hull is completed. Generates a disk format Called after the clipping hull is completed. Generates a disk format
representation and frees the original memory. representation and frees the original memory.
==================
*/ */
void void
WriteClipNodes (node_t *nodes) WriteClipNodes (node_t *nodes)
@ -153,24 +149,22 @@ WriteClipNodes (node_t *nodes)
WriteClipNodes_r (nodes); WriteClipNodes_r (nodes);
} }
//===========================================================================
void void
WriteLeaf (node_t *node) WriteLeaf (node_t *node)
{ {
dleaf_t leaf_p; dleaf_t leaf_p;
face_t **fp, *f; face_t **fp, *f;
// emit a leaf // emit a leaf
leaf_p.contents = node->contents; leaf_p.contents = node->contents;
// write bounding box info // write bounding box info
VectorCopy (node->mins, leaf_p.mins); VectorCopy (node->mins, leaf_p.mins);
VectorCopy (node->maxs, leaf_p.maxs); VectorCopy (node->maxs, leaf_p.maxs);
leaf_p.visofs = -1; // no vis info yet leaf_p.visofs = -1; // no vis info yet
// write the marksurfaces // write the marksurfaces
leaf_p.firstmarksurface = bsp->nummarksurfaces; leaf_p.firstmarksurface = bsp->nummarksurfaces;
for (fp = node->markfaces; *fp; fp++) { for (fp = node->markfaces; *fp; fp++) {
@ -196,7 +190,7 @@ WriteDrawNodes_r (node_t *node)
int i; int i;
int nodenum = bsp->numnodes; int nodenum = bsp->numnodes;
// emit a node // emit a node
if (bsp->numnodes == MAX_MAP_NODES) if (bsp->numnodes == MAX_MAP_NODES)
Sys_Error ("numnodes == MAX_MAP_NODES"); Sys_Error ("numnodes == MAX_MAP_NODES");
BSP_AddNode (bsp, &dummy); BSP_AddNode (bsp, &dummy);
@ -209,7 +203,7 @@ WriteDrawNodes_r (node_t *node)
n->firstface = node->firstface; n->firstface = node->firstface;
n->numfaces = node->numfaces; n->numfaces = node->numfaces;
// recursively output the other nodes // recursively output the other nodes
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
n = &bsp->nodes[nodenum]; n = &bsp->nodes[nodenum];
if (node->children[i]->planenum == -1) { if (node->children[i]->planenum == -1) {
@ -237,7 +231,7 @@ WriteDrawNodes (node_t *headnode)
Sys_Error ("FinishBSPModel: empty model"); Sys_Error ("FinishBSPModel: empty model");
#endif #endif
// emit a model // emit a model
if (bsp->nummodels == MAX_MAP_MODELS) if (bsp->nummodels == MAX_MAP_MODELS)
Sys_Error ("nummodels == MAX_MAP_MODELS"); Sys_Error ("nummodels == MAX_MAP_MODELS");
@ -259,28 +253,24 @@ WriteDrawNodes (node_t *headnode)
bm.maxs[i] = headnode->maxs[i] - SIDESPACE - 1; bm.maxs[i] = headnode->maxs[i] - SIDESPACE - 1;
} }
BSP_AddModel (bsp, &bm); BSP_AddModel (bsp, &bm);
// FIXME: are all the children decendant of padded nodes? // FIXME: are all the children decendant of padded nodes?
} }
/* /*
================== BumpModel
BumpModel
Used by the clipping hull processes that only need to store headclipnode Used by the clipping hull processes that only need to store headclipnode
==================
*/ */
void void
BumpModel (int hullnum) BumpModel (int hullnum)
{ {
static dmodel_t bm; static dmodel_t bm;
// emit a model // emit a model
bm.headnode[hullnum] = headclipnode; bm.headnode[hullnum] = headclipnode;
BSP_AddModel (bsp, &bm); BSP_AddModel (bsp, &bm);
} }
//=============================================================================
typedef struct { typedef struct {
char identification[4]; // should be WAD2 char identification[4]; // should be WAD2
int numlumps; int numlumps;
@ -496,17 +486,15 @@ WriteMiptex (void)
BSP_AddTextures (bsp, data->str, data->size); BSP_AddTextures (bsp, data->str, data->size);
} }
//===========================================================================
void void
BeginBSPFile (void) BeginBSPFile (void)
{ {
static dedge_t edge; static dedge_t edge;
static dleaf_t leaf; static dleaf_t leaf;
// edge 0 is not used, because 0 can't be negated // edge 0 is not used, because 0 can't be negated
BSP_AddEdge (bsp, &edge); BSP_AddEdge (bsp, &edge);
// leaf 0 is common solid with no faces // leaf 0 is common solid with no faces
leaf.contents = CONTENTS_SOLID; leaf.contents = CONTENTS_SOLID;
BSP_AddLeaf (bsp, &leaf); BSP_AddLeaf (bsp, &leaf);