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
See file, 'COPYING', for details.
$Id$
*/
// bsp5.h

View file

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

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details.
*/
// brush.c
static const char rcsid[] =
"$Id$";
#ifdef HAVE_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
CheckFace (face_t *f)
@ -103,8 +101,6 @@ CheckFace (face_t *f)
}
}
//===========================================================================
void
ClearBounds (brushset_t *bs)
{
@ -130,14 +126,12 @@ AddToBounds (brushset_t *bs, vec3_t v)
}
}
//===========================================================================
int
PlaneTypeForNormal (vec3_t normal)
{
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)
return PLANE_X;
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
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
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;
if (numbrushplanes == MAX_MAP_PLANES)
@ -295,7 +286,7 @@ FindPlane_old (plane_t *dplane, int *side)
*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)
dp->type = PLANE_X;
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;
@ -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] = {
@ -463,12 +448,10 @@ AddBrushPlane (plane_t *plane)
}
/*
============
TestAddPlane
TestAddPlane
Adds the given plane to the brush description if all of the original brush
vertexes can be put on the front side
=============
Adds the given plane to the brush description if all of the original brush
vertexes can be put on the front side
*/
void
TestAddPlane (plane_t *plane)
@ -481,7 +464,7 @@ TestAddPlane (plane_t *plane)
vec_t *corner;
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++) {
pl = &faces[i].plane;
if (_VectorCompare (plane->normal, pl->normal)
@ -492,7 +475,7 @@ TestAddPlane (plane_t *plane)
&& 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;
c = num_hull_points * 8;
@ -511,8 +494,7 @@ TestAddPlane (plane_t *plane)
counts[2]++;
}
// the plane is a seperator
// the plane is a seperator
if (counts[0]) {
VectorSubtract (vec3_origin, plane->normal, flip.normal);
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
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
AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
@ -626,12 +604,12 @@ ExpandBrush (int hullnum)
num_hull_points = 0;
num_hull_edges = 0;
// create all the hull points
// create all the hull points
for (f = brush_faces; f; f = f->next)
for (i = 0; i < f->numpoints; i++)
AddHullPoint (f->pts[i], hullnum);
// expand all of the planes
// expand all of the planes
for (i = 0; i < numbrushfaces; i++) {
p = &faces[i].plane;
VectorCopy (vec3_origin, corner);
@ -644,7 +622,7 @@ ExpandBrush (int hullnum)
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 (s = -1; s <= 1; s += 2) {
// add the plane
@ -657,20 +635,16 @@ ExpandBrush (int hullnum)
AddBrushPlane (&plane);
}
// add all of the edge bevels
// add all of the edge bevels
for (f = brush_faces; f; f = f->next)
for (i = 0; i < f->numpoints; i++)
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 *
LoadBrush (mbrush_t *mb, int hullnum)
@ -680,12 +654,11 @@ LoadBrush (mbrush_t *mb, int hullnum)
int contents;
mface_t *f;
// check texture name for attributes
// check texture name for attributes
name = miptex[bsp->texinfo[mb->faces->texinfo].miptex];
if (!strcasecmp (name, "clip") && hullnum == 0)
return NULL; // "clip" brushes don't show up in
// the draw hull
return NULL; // "clip" brushes don't show up in the draw hull
if (name[0] == '*' && worldmodel) { // entities never use water merging
if (!strncasecmp (name + 1, "lava", 4))
@ -700,12 +673,11 @@ LoadBrush (mbrush_t *mb, int hullnum)
contents = CONTENTS_SOLID;
if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY)
return NULL; // water brushes don't show up in
// clipping hulls
return NULL; // water brushes don't show up in clipping hulls
// no seperate textures on clip hull
// no seperate textures on clip hull
// create the faces
// create the faces
brush_faces = NULL;
numbrushfaces = 0;
@ -728,7 +700,7 @@ LoadBrush (mbrush_t *mb, int hullnum)
CreateBrushFaces ();
}
// create the brush
// create the brush
b = AllocBrush ();
b->contents = contents;
@ -739,8 +711,6 @@ LoadBrush (mbrush_t *mb, int hullnum)
return b;
}
//=============================================================================
void
Brush_DrawAll (brushset_t *bs)
{
@ -788,7 +758,7 @@ Brush_LoadEntity (entity_t *ent, int hullnum)
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) {
next = b->next;
b->next = other;

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details.
*/
// csg4.c
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
@ -32,9 +32,10 @@
#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];
@ -52,12 +53,10 @@ DrawList (face_t *list)
}
/*
==================
NewFaceFromFace
NewFaceFromFace
Duplicates the non point information of a face, used by SplitFace and
MergeFace.
==================
Duplicates the non point information of a face, used by SplitFace and
MergeFace.
*/
face_t *
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");
counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point
// determine sides for each point
for (i = 0; i < in->numpoints; i++) {
dot = DotProduct (in->pts[i], split->normal);
dot -= split->dist;
@ -122,7 +121,7 @@ SplitFace (face_t *in, plane_t *split, face_t **front, face_t **back)
*back = newf = 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++) {
if (newf->numpoints > MAXEDGES || new2->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)
Sys_Error ("SplitFace: numpoints > MAXEDGES");
#if 0
CheckFace (newf);
CheckFace (new2);
#endif
// free the original face now that is is represented by the fragments
// free the original face now that is is represented by the fragments
FreeFace (in);
}
/*
=================
ClipInside
ClipInside
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.
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.
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
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
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
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
faces.
==================
Returns a chain of all the external surfaces with one or more visible
faces.
*/
surface_t *
BuildSurfaces (void)
@ -322,7 +306,7 @@ BuildSurfaces (void)
if (!*f)
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->planenum = i;
s->next = surfhead;
@ -336,8 +320,6 @@ BuildSurfaces (void)
return surfhead;
}
//==========================================================================
void
CopyFacesToOutside (brush_t *b)
{
@ -347,16 +329,6 @@ CopyFacesToOutside (brush_t *b)
for (f = b->faces; f; f = f->next) {
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 = *f;
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 *
CSGFaces (brushset_t *bs)
@ -390,7 +360,7 @@ CSGFaces (brushset_t *bs)
Draw_ClearWindow ();
// do the solid faces
// do the solid faces
for (b1 = bs->brushes; b1; b1 = b1->next) {
// set outside to a copy of the brush's faces
CopyFacesToOutside (b1);

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details.
*/
// map.c
static const char rcsid[] =
"$Id$";
#ifdef HAVE_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
FindTexinfo (texinfo_t *t)
@ -76,7 +74,7 @@ FindTexinfo (texinfo_t *t)
int i, j;
texinfo_t *tex;
// set the special flag
// set the special flag
if (miptex[t->miptex][0] == '*'
|| !strncasecmp (miptex[t->miptex], "sky", 3))
t->flags |= TEX_SPECIAL;
@ -97,14 +95,12 @@ FindTexinfo (texinfo_t *t)
return i;
}
// allocate a new texture
// allocate a new texture
BSP_AddTexinfo (bsp, t);
return i;
}
//============================================================================
#define MAXTOKEN 128
char token[MAXTOKEN];
@ -128,7 +124,7 @@ GetToken (qboolean crossline)
if (unget) // is a token allready waiting?
return true;
// skip space
// skip space
skipspace:
while (*script_p <= 32) {
if (!*script_p) {
@ -155,7 +151,7 @@ GetToken (qboolean crossline)
goto skipspace;
}
// copy token
// copy token
token_p = token;
if (*script_p == '"') {
@ -186,8 +182,6 @@ UngetToken ()
unget = true;
}
//============================================================================
entity_t *mapent;
void
@ -209,8 +203,6 @@ ParseEpair (void)
e->value = strdup (token);
}
//============================================================================
vec3_t baseaxis[18] = {
{0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor
{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);
}
//=============================================================================
void
ParseBrush (void)
{
@ -517,7 +507,7 @@ GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
k = ValueForKey (ent, key);
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);
vec[0] = v1;
vec[1] = v2;

View file

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

View file

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

View file

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

View file

@ -17,6 +17,8 @@
See file, 'COPYING', for details.
*/
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
@ -53,7 +55,7 @@ RemovePortalFromNode (portal_t *portal, node_t *l)
{
portal_t **pp, *t;
// remove reference to the current portal
// remove reference to the current portal
pp = &l->portals;
while (1) {
t = *pp;
@ -80,8 +82,6 @@ RemovePortalFromNode (portal_t *portal, node_t *l)
}
}
//============================================================================
void
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
MakeHeadnodePortals (node_t *node)
@ -111,7 +109,7 @@ MakeHeadnodePortals (node_t *node)
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++) {
bounds[0][i] = brushset->mins[i] - SIDESPACE;
bounds[1][i] = brushset->maxs[i] + SIDESPACE;
@ -145,7 +143,7 @@ MakeHeadnodePortals (node_t *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 (j = 0; j < 6; j++) {
if (j == i)
@ -198,7 +196,7 @@ PlaneFromWinding (winding_t *w, plane_t *plane)
{
vec3_t v1, v2;
// calc plane
// calc plane
VectorSubtract (w->points[2], w->points[1], v1);
VectorSubtract (w->points[0], w->points[1], v2);
CrossProduct (v2, v1, plane->normal);
@ -261,7 +259,7 @@ CutNodePortals_r (node_t *node)
// CheckLeafPortalConsistancy (node);
// seperate the portals on node into it's children
// seperate the portals on node into it's children
if (node->contents)
return; // at a leaf, no more dividing
@ -270,13 +268,13 @@ CutNodePortals_r (node_t *node)
f = node->children[0];
b = node->children[1];
// create the new portal by taking the full plane winding for the cutting plane
// and clipping it by all of the planes from the other portals
// create the new portal by taking the full plane winding for the cutting
// plane and clipping it by all of the planes from the other portals
new_portal = AllocPortal ();
new_portal->planenum = node->planenum;
w = BaseWindingForPlane (&planes[node->planenum]);
side = 0; // shut up compiler warning
side = 0;
for (p = node->portals; p; p = p->next[side]) {
clipplane = planes[p->planenum];
if (p->nodes[0] == node)
@ -301,7 +299,7 @@ CutNodePortals_r (node_t *node)
AddPortalToNodes (new_portal, f, b);
}
// partition the portals
// partition the portals
for (p = node->portals; p; p = next_portal) {
if (p->nodes[0] == node)
side = 0;
@ -315,7 +313,7 @@ CutNodePortals_r (node_t *node)
RemovePortalFromNode (p, p->nodes[0]);
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);
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
PortalizeWorld (node_t *headnode)
@ -393,7 +389,7 @@ FreeAllPortals (node_t *node)
}
}
// PORTAL FILE GENERATION =====================================================
// PORTAL FILE GENERATION
#define PORTALFILE "PRT1"
@ -467,7 +463,8 @@ NumberLeafs_r (node_t *node)
{
portal_t *p;
if (!node->contents) { // decision node
if (!node->contents) {
// decision node
node->visleafnum = -99;
NumberLeafs_r (node->children[0]);
NumberLeafs_r (node->children[1]);
@ -477,8 +474,8 @@ NumberLeafs_r (node_t *node)
Draw_ClearWindow ();
DrawLeaf (node, 1);
if (node->contents == CONTENTS_SOLID) { // solid block, viewpoint never
// inside
if (node->contents == CONTENTS_SOLID) {
// solid block, viewpoint never inside
node->visleafnum = -1;
return;
}
@ -486,8 +483,8 @@ NumberLeafs_r (node_t *node)
node->visleafnum = num_visleafs++;
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)
num_visportals++;
p = p->next[0];
@ -499,12 +496,13 @@ NumberLeafs_r (node_t *node)
void
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_visportals = 0;
NumberLeafs_r (headnode);
// write the file
// write the file
printf ("writing %s\n", options.portfile);
pf = fopen (options.portfile, "w");
if (!pf)

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details.
*/
// bsp5.c
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
@ -43,6 +43,10 @@ bsp_t *bsp;
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;
char *argv0; // changed after fork();
@ -73,7 +77,7 @@ BaseWindingForPlane (plane_t *p)
vec3_t org, vright, vup;
winding_t *w;
// find the major axis
// find the major axis
max = -BOGUS_RANGE;
x = -1;
@ -109,7 +113,7 @@ BaseWindingForPlane (plane_t *p)
VectorScale (vup, 8192, vup);
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);
VectorSubtract (org, vright, w->points[0]);
@ -141,27 +145,21 @@ CopyWinding (winding_t *w)
return c;
}
/*
==================
CheckWinding
Check for possible errors
==================
*/
void
CheckWinding (winding_t * w)
{
}
/*
==================
ClipWinding
ClipWinding
Clips the winding to the plane, returning the new winding on the positive side
Frees the input winding.
If keepon is true, an exactly on-plane winding will be saved, otherwise
it will be clipped away.
==================
Clips the winding to the plane, returning the new winding on the positive
side.
Frees the input winding.
If keepon is true, an exactly on-plane winding will be saved, otherwise
it will be clipped away.
*/
winding_t *
ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
@ -177,7 +175,7 @@ ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point
// determine sides for each point
for (i = 0; i < in->numpoints; i++) {
dot = DotProduct (in->points[i], split->normal);
dot -= split->dist;
@ -245,21 +243,19 @@ ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
if (neww->numpoints > maxpts)
Sys_Error ("ClipWinding: points exceeded estimate");
// free the original winding
// free the original winding
FreeWinding (in);
return neww;
}
/*
==================
DivideWinding
DivideWinding
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
returned winding will be the input winding. If on both sides, two
new windings will be created.
==================
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
returned winding will be the input winding. If on both sides, two
new windings will be created.
*/
void
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;
// determine sides for each point
// determine sides for each point
for (i = 0; i < in->numpoints; i++) {
dot = DotProduct (in->points[i], split->normal);
dot -= split->dist;
@ -357,14 +353,6 @@ DivideWinding (winding_t *in, plane_t *split, winding_t **front,
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
PrintMemory (void)
{
@ -421,7 +409,6 @@ void
FreeFace (face_t *f)
{
c_activefaces--;
// memset (f, 0xff, sizeof (face_t));
free (f);
}
@ -491,8 +478,6 @@ AllocBrush (void)
return b;
}
//===========================================================================
void
ProcessEntity (int entnum)
{
@ -520,8 +505,8 @@ ProcessEntity (int entnum)
} else
worldmodel = true;
// take the brush_ts and clip off all overlapping and contained faces,
// leaving a perfect skin of the model with no hidden faces
// take the brush_ts and clip off all overlapping and contained faces,
// leaving a perfect skin of the model with no hidden faces
bs = Brush_LoadEntity (ent, hullnum);
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
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
ReadClipHull (int hullnum)
@ -728,7 +709,7 @@ CreateSingleHull (void)
{
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++) {
ProcessEntity (entnum);
if (options.verbosity < 2)
@ -742,27 +723,27 @@ CreateSingleHull (void)
void
CreateHulls (void)
{
// commanded to create a single hull only
// commanded to create a single hull only
if (hullnum) {
CreateSingleHull ();
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) {
CreateSingleHull ();
return;
}
// commanded to ignore the hulls altogether
// commanded to ignore the hulls altogether
if (options.noclip) {
CreateSingleHull ();
return;
}
// create all the hulls
// create all the hulls
#ifdef __alpha
printf ("forking hull processes...\n");
// fork a process for each clipping hull
// fork a process for each clipping hull
fflush (stdout);
if (!fork ()) {
hullnum = 1;
@ -784,7 +765,7 @@ CreateHulls (void)
wait (NULL); // wait for clip hull process to finish
#else
// create the hulls sequentially
// create the hulls sequentially
printf ("building hulls sequentially...\n");
hullnum = 1;
@ -808,8 +789,7 @@ CreateHulls (void)
void
ProcessFile ()
{
// create filenames
// create filenames
COM_StripExtension (options.bspfile, options.hullfile);
strcat (options.hullfile, ".h0");
@ -831,16 +811,16 @@ ProcessFile ()
remove (options.pointfile);
}
bsp = BSP_New ();
// load brushes and entities
// load brushes and entities
LoadMapFile (options.mapfile);
if (options.onlyents) {
UpdateEntLump ();
return;
}
// init the tables to be shared by all models
// init the tables to be shared by all models
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 ();
ReadClipHull (1);
@ -857,17 +837,15 @@ main (int argc, char **argv)
char destname[1024];
double start, end;
// malloc_debug (15);
// check command line flags
// check command line flags
DecodeArgs (argc, argv);
// XXX SetQdirFromPath (argv[i]);
// let forked processes change name for ps status
// let forked processes change name for ps status
argv0 = argv[0];
// do it!
// do it!
start = Sys_DoubleTime ();
ProcessFile (sourcename, destname);
end = Sys_DoubleTime ();

View file

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

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details.
*/
// solidbsp.c
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
@ -39,11 +39,9 @@ qboolean usemidsplit;
/*
==================
FaceSide
FaceSide
For BSP hueristic
==================
For BSP hueristic
*/
int
FaceSide (face_t *in, plane_t *split)
@ -54,7 +52,7 @@ FaceSide (face_t *in, plane_t *split)
frontcount = backcount = 0;
// axial planes are fast
// axial planes are fast
if (split->type < 3)
for (i = 0, p = in->pts[0] + split->type; i < in->numpoints;
i++, p += 3) {
@ -68,7 +66,7 @@ FaceSide (face_t *in, plane_t *split)
backcount = 1;
}
} else
// sloping planes take longer
// sloping planes take longer
for (i = 0, p = in->pts[0]; i < in->numpoints; i++, p += 3) {
dot = DotProduct (p, split->normal);
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 *
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;
vec_t bestvalue, value, dist;
// pick the plane that splits the least
// pick the plane that splits the least
bestvalue = 6 * 8192 * 8192;
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 *
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;
vec_t bestvalue, bestdistribution, value, dist;
// pick the plane that splits the least
// pick the plane that splits the least
bestvalue = 99999;
bestsurface = NULL;
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
returns NULL if the surface list can not be divided any more (a leaf)
==================
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)
*/
surface_t *
SelectPartition (surface_t *surfaces)
@ -252,7 +244,7 @@ SelectPartition (surface_t *surfaces)
surface_t *p, *bestsurface;
vec3_t mins, maxs;
// count onnode surfaces
// count onnode surfaces
i = 0;
bestsurface = NULL;
for (p = surfaces; p; p = p->next)
@ -267,7 +259,7 @@ SelectPartition (surface_t *surfaces)
if (i == 1)
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++) {
mins[i] = 99999;
maxs[i] = -99999;
@ -284,7 +276,7 @@ SelectPartition (surface_t *surfaces)
if (usemidsplit) // do fast way for clipping hull
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
bestsurface = ChoosePlaneFromList (surfaces, mins, maxs, false);
if (bestsurface)
@ -296,11 +288,9 @@ SelectPartition (surface_t *surfaces)
//============================================================================
/*
=================
CalcSurfaceInfo
CalcSurfaceInfo
Calculates the bounding box
=================
Calculates the bounding box
*/
void
CalcSurfaceInfo (surface_t * surf)
@ -311,7 +301,7 @@ CalcSurfaceInfo (surface_t * surf)
if (!surf->faces)
Sys_Error ("CalcSurfaceInfo: surface without a face");
// calculate a bounding box
// calculate a bounding box
for (i = 0; i < 3; i++) {
surf->mins[i] = 99999;
surf->maxs[i] = -99999;
@ -342,11 +332,11 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
inplane = &planes[in->planenum];
// parallel case is easy
// parallel case is easy
if (_VectorCompare (inplane->normal, split->normal)) {
// check for exactly on node
if (inplane->dist == split->dist) { // divide the facets to the front
// and back sides
// check for exactly on node
if (inplane->dist == split->dist) {
// divide the facets to the front and back sides
news = AllocSurface ();
*news = *in;
@ -386,8 +376,8 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
}
return;
}
// do a real split. may still end up entirely on one side
// OPTIMIZE: use bounding box for fast test
// do a real split. may still end up entirely on one side
// OPTIMIZE: use bounding box for fast test
frontlist = 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) {
*front = NULL;
*back = in;
@ -418,7 +408,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
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 = *in;
news->faces = backlist;
@ -427,7 +417,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
in->faces = frontlist;
*front = in;
// recalc bboxes and flags
// recalc bboxes and flags
CalcSurfaceInfo (news);
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[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)
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
original faces that have some fragment inside this leaf
==================
Determines the contents of the leaf and creates the final list of
original faces that have some fragment inside this leaf
*/
void
LinkConvexFaces (surface_t *planelist, node_t *leafnode)
@ -498,7 +486,7 @@ LinkConvexFaces (surface_t *planelist, node_t *leafnode)
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;
leafnode->markfaces = malloc (sizeof (face_t *) * (count + 1));
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 *
LinkNodeFaces (surface_t *surface)
@ -529,7 +515,7 @@ LinkNodeFaces (surface_t *surface)
list = NULL;
// subdivide
// subdivide
prevptr = &surface->faces;
while (1) {
f = *prevptr;
@ -540,7 +526,7 @@ LinkNodeFaces (surface_t *surface)
prevptr = &f->next;
}
// copy
// copy
for (f = surface->faces; f; f = f->next) {
nodefaces++;
new = AllocFace ();
@ -578,7 +564,8 @@ PartitionSurfaces (surface_t *surfaces, node_t *node)
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;
backlist = NULL;
@ -640,13 +627,13 @@ SolidBSP (surface_t *surfhead, qboolean midsplit)
headnode = AllocNode ();
usemidsplit = midsplit;
// calculate a bounding box for the entire model
// calculate a bounding box for the entire model
for (i = 0; i < 3; i++) {
headnode->mins[i] = brushset->mins[i] - SIDESPACE;
headnode->maxs[i] = brushset->maxs[i] + SIDESPACE;
}
// recursively partition everything
// recursively partition everything
Draw_ClearWindow ();
splitnodes = 0;
leaffaces = 0;

View file

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

View file

@ -17,8 +17,8 @@
See file, 'COPYING', for details.
*/
// tjunc.c
static const char rcsid[] =
"$Id$";
#ifdef HAVE_CONFIG_H
# include "config.h"
@ -65,8 +65,6 @@ PrintFace (face_t *f)
f->pts[i][2]);
}
//============================================================================
#define NUM_HASH 1024
wedge_t *wedge_hash[NUM_HASH];
@ -109,8 +107,6 @@ HashVec (vec3_t vec)
return h;
}
//============================================================================
void
CanonicalVector (vec3_t vec)
{
@ -220,7 +216,7 @@ AddVert (wedge_t *w, vec_t t)
v = v->next;
} while (1);
// insert a new wvert before v
// insert a new wvert before v
if (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
byte superfacebuf[8192];
face_t *superface = (face_t *) superfacebuf;
@ -276,9 +270,9 @@ SplitFaceForTjunc (face_t *f, face_t *original)
chain = NULL;
do {
if (f->numpoints <= MAXPOINTS) { // the face is now small enough
// without more cutting
// so copy it back to the original
if (f->numpoints <= MAXPOINTS) {
// the face is now small enough without more cutting so copy it
// back to the original
*original = *f;
original->original = chain;
original->next = newlist;
@ -387,7 +381,7 @@ FixFaceEdges (face_t *f)
newlist = f;
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);
}
@ -441,9 +435,9 @@ tjunc (node_t *headnode)
if (options.notjunc)
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++) {
if (fabs (brushset->maxs[i]) > fabs (brushset->mins[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);
// add extra vertexes on edges where needed
// add extra vertexes on edges where needed
tjuncs = tjuncfaces = 0;
tjunc_fix_r (headnode);

View file

@ -17,6 +17,8 @@
See file, 'COPYING', for details.
*/
static const char rcsid[] =
"$Id$";
#ifdef HAVE_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
FindFinalPlane (dplane_t *p)
@ -69,7 +69,7 @@ FindFinalPlane (dplane_t *p)
return i;
}
// new plane
// new plane
if (bsp->numplanes == MAX_MAP_PLANES)
Sys_Error ("numplanes == MAX_MAP_PLANES");
BSP_AddPlane (bsp, p);
@ -113,21 +113,19 @@ WriteNodePlanes (node_t *nodes)
WriteNodePlanes_r (nodes);
}
//===========================================================================
int
WriteClipNodes_r (node_t *node)
{
dclipnode_t cn;
int num, c, i;
// FIXME: free more stuff?
// FIXME: free more stuff?
if (node->planenum == -1) {
num = node->contents;
free (node);
return num;
}
// emit a clipnode
// emit a clipnode
c = bsp->numclipnodes;
cn.planenum = node->outputplanenum;
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
representation and frees the original memory.
==================
Called after the clipping hull is completed. Generates a disk format
representation and frees the original memory.
*/
void
WriteClipNodes (node_t *nodes)
@ -153,24 +149,22 @@ WriteClipNodes (node_t *nodes)
WriteClipNodes_r (nodes);
}
//===========================================================================
void
WriteLeaf (node_t *node)
{
dleaf_t leaf_p;
face_t **fp, *f;
// emit a leaf
// emit a leaf
leaf_p.contents = node->contents;
// write bounding box info
// write bounding box info
VectorCopy (node->mins, leaf_p.mins);
VectorCopy (node->maxs, leaf_p.maxs);
leaf_p.visofs = -1; // no vis info yet
// write the marksurfaces
// write the marksurfaces
leaf_p.firstmarksurface = bsp->nummarksurfaces;
for (fp = node->markfaces; *fp; fp++) {
@ -196,7 +190,7 @@ WriteDrawNodes_r (node_t *node)
int i;
int nodenum = bsp->numnodes;
// emit a node
// emit a node
if (bsp->numnodes == MAX_MAP_NODES)
Sys_Error ("numnodes == MAX_MAP_NODES");
BSP_AddNode (bsp, &dummy);
@ -209,7 +203,7 @@ WriteDrawNodes_r (node_t *node)
n->firstface = node->firstface;
n->numfaces = node->numfaces;
// recursively output the other nodes
// recursively output the other nodes
for (i = 0; i < 2; i++) {
n = &bsp->nodes[nodenum];
if (node->children[i]->planenum == -1) {
@ -237,7 +231,7 @@ WriteDrawNodes (node_t *headnode)
Sys_Error ("FinishBSPModel: empty model");
#endif
// emit a model
// emit a model
if (bsp->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;
}
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
BumpModel (int hullnum)
{
static dmodel_t bm;
// emit a model
// emit a model
bm.headnode[hullnum] = headclipnode;
BSP_AddModel (bsp, &bm);
}
//=============================================================================
typedef struct {
char identification[4]; // should be WAD2
int numlumps;
@ -496,17 +486,15 @@ WriteMiptex (void)
BSP_AddTextures (bsp, data->str, data->size);
}
//===========================================================================
void
BeginBSPFile (void)
{
static dedge_t edge;
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);
// leaf 0 is common solid with no faces
// leaf 0 is common solid with no faces
leaf.contents = CONTENTS_SOLID;
BSP_AddLeaf (bsp, &leaf);