Gobs of whitespace.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2002-09-19 18:51:19 +00:00
parent 4d520d588d
commit 8ae5a8ed2e
15 changed files with 550 additions and 1255 deletions

View file

@ -1,23 +1,23 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// bsp5.h
#include "QF/mathlib.h"
@ -30,7 +30,6 @@ typedef struct
int type;
} plane_t;
#include "map.h"
#define MAX_THREADS 4
@ -44,7 +43,6 @@ typedef struct
//============================================================================
typedef struct
{
int numpoints;
@ -84,7 +82,6 @@ typedef struct visfacet_s
int edges[MAXEDGES];
} face_t;
typedef struct surface_s
{
struct surface_s *next;
@ -92,15 +89,12 @@ typedef struct surface_s
int planenum;
int outputplanenum; // only valid after WriteSurfacePlanes
vec3_t mins, maxs;
qboolean onnode; // true if surface has already been used
qboolean onnode; // true if surface has already been used
// as a splitting node
face_t *faces; // links to all the faces on either side of the surf
} surface_t;
//
// there is a node_t structure for every node and leaf in the bsp tree
//
#define PLANENUM_LEAF -1
typedef struct node_s
@ -124,9 +118,7 @@ typedef struct node_s
int occupied; // light number in leaf for outside filling
} node_t;
//=============================================================================
// brush.c
// brush.c ====================================================================
#define NUM_HULLS 2 // normal and +16
@ -153,9 +145,7 @@ brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum);
int PlaneTypeForNormal (vec3_t normal);
int FindPlane (plane_t *dplane, int *side);
//=============================================================================
// csg4.c
// csg4.c =====================================================================
// build surfaces is also used by GatherNodeFaces
extern face_t *validfaces[MAX_MAP_PLANES];
@ -165,27 +155,21 @@ face_t *NewFaceFromFace (face_t *in);
surface_t *CSGFaces (brushset_t *bs);
void SplitFace (face_t *in, plane_t *split, face_t **front, face_t **back);
//=============================================================================
// solidbsp.c
// solidbsp.c =================================================================
void DivideFacet (face_t *in, plane_t *split, face_t **front, face_t **back);
void CalcSurfaceInfo (surface_t *surf);
void SubdivideFace (face_t *f, face_t **prevptr);
node_t *SolidBSP (surface_t *surfhead, qboolean midsplit);
//=============================================================================
// merge.c
// merge.c ====================================================================
void MergePlaneFaces (surface_t *plane);
face_t *MergeFaceToList (face_t *face, face_t *list);
face_t *FreeMergeListScraps (face_t *merged);
void MergeAll (surface_t *surfhead);
//=============================================================================
// surfaces.c
// surfaces.c =================================================================
extern int c_cornerverts;
extern int c_tryedges;
@ -200,9 +184,7 @@ surface_t *GatherNodeFaces (node_t *headnode);
void MakeFaceEdges (node_t *headnode);
//=============================================================================
// portals.c
// portals.c ==================================================================
typedef struct portal_s
{
@ -218,21 +200,15 @@ void PortalizeWorld (node_t *headnode);
void WritePortalfile (node_t *headnode);
void FreeAllPortals (node_t *node);
//=============================================================================
// region.c
// region.c ===================================================================
void GrowNodeRegions (node_t *headnode);
//=============================================================================
// tjunc.c
// tjunc.c ====================================================================
void tjunc (node_t *headnode);
//=============================================================================
// writebsp.c
// writebsp.c =================================================================
void WriteNodePlanes (node_t *headnode);
void WriteClipNodes (node_t *headnode);
@ -244,9 +220,7 @@ int FindFinalPlane (dplane_t *p);
void BeginBSPFile (void);
void FinishBSPFile (void);
//=============================================================================
// draw.c
// draw.c =====================================================================
void Draw_ClearBounds (void);
void Draw_AddToBounds (vec3_t v);
@ -266,9 +240,7 @@ void DrawBrush (brush_t *b);
void DrawWinding (winding_t *w);
void DrawTri (vec3_t p1, vec3_t p2, vec3_t p3);
//=============================================================================
// outside.c
// outside.c ==================================================================
qboolean FillOutside (node_t *node);
@ -296,7 +268,6 @@ extern char pointfilename[1024];
extern qboolean worldmodel;
// misc functions
face_t *AllocFace (void);

View file

@ -1,24 +1,23 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
#define MAX_FACES 16
typedef struct mface_s
{

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// brush.c
@ -32,16 +33,13 @@
#include "QF/sys.h"
#include "compat.h"
#include "bsp5.h"
int numbrushplanes;
plane_t planes[MAX_MAP_PLANES];
int numbrushfaces;
mface_t faces[128]; // beveled clipping hull can generate
// many extra
mface_t faces[128]; // beveled clipping hull can generate many extra
/*
@ -52,20 +50,19 @@ Note: this will not catch 0 area polygons
=================
*/
void
CheckFace (face_t * f)
CheckFace (face_t *f)
{
int i, j;
vec_t *p1, *p2;
vec_t d, edgedist;
vec3_t dir, edgenormal, facenormal;
int i, j;
vec_t *p1, *p2;
vec_t d, edgedist;
vec3_t dir, edgenormal, facenormal;
if (f->numpoints < 3)
Sys_Error ("CheckFace: %i points", f->numpoints);
VectorCopy (planes[f->planenum].normal, facenormal);
if (f->planeside) {
if (f->planeside)
VectorSubtract (vec3_origin, facenormal, facenormal);
}
for (i = 0; i < f->numpoints; i++) {
p1 = f->pts[i];
@ -77,9 +74,9 @@ CheckFace (face_t * f)
j = i + 1 == f->numpoints ? 0 : i + 1;
// check the point is on the face plane
d =
DotProduct (p1,
planes[f->planenum].normal) - planes[f->planenum].dist;
d = DotProduct (p1, planes[f->planenum].normal)
- planes[f->planenum].dist;
if (d < -ON_EPSILON || d > ON_EPSILON)
Sys_Error ("CheckFace: point off plane");
@ -106,18 +103,12 @@ CheckFace (face_t * f)
}
}
//===========================================================================
/*
=================
ClearBounds
=================
*/
void
ClearBounds (brushset_t * bs)
ClearBounds (brushset_t *bs)
{
int i, j;
int i, j;
for (j = 0; j < NUM_HULLS; j++)
for (i = 0; i < 3; i++) {
@ -126,15 +117,10 @@ ClearBounds (brushset_t * bs)
}
}
/*
=================
AddToBounds
=================
*/
void
AddToBounds (brushset_t * bs, vec3_t v)
AddToBounds (brushset_t *bs, vec3_t v)
{
int i;
int i;
for (i = 0; i < 3; i++) {
if (v[i] < bs->mins[i])
@ -149,9 +135,9 @@ AddToBounds (brushset_t * bs, vec3_t v)
int
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)
return PLANE_X;
if (normal[1] == 1.0)
@ -161,9 +147,9 @@ PlaneTypeForNormal (vec3_t normal)
if (normal[0] == -1.0 || normal[1] == -1.0 || normal[2] == -1.0)
Sys_Error ("PlaneTypeForNormal: not a canonical vector");
ax = fabs (normal[0]);
ay = fabs (normal[1]);
az = fabs (normal[2]);
ax = fabs(normal[0]);
ay = fabs(normal[1]);
az = fabs(normal[2]);
if (ax >= ay && ax >= az)
return PLANE_ANYX;
@ -178,7 +164,7 @@ PlaneTypeForNormal (vec3_t normal)
void
NormalizePlane (plane_t *dp)
{
vec_t ax, ay, az;
vec_t ax, ay, az;
if (dp->normal[0] == -1.0) {
dp->normal[0] = 1.0;
@ -220,7 +206,6 @@ NormalizePlane (plane_t *dp)
VectorSubtract (vec3_origin, dp->normal, dp->normal);
dp->dist = -dp->dist;
}
}
/*
@ -233,11 +218,11 @@ Returns a global plane number and the side that will be the front
int
FindPlane (plane_t *dplane, int *side)
{
int i;
plane_t *dp, pl;
vec_t dot;
int i;
plane_t *dp, pl;
vec_t dot;
dot = VectorLength (dplane->normal);
dot = VectorLength(dplane->normal);
if (dot < 1.0 - ANGLEEPSILON || dot > 1.0 + ANGLEEPSILON)
Sys_Error ("FindPlane: normalization error");
@ -251,8 +236,8 @@ FindPlane (plane_t *dplane, int *side)
dp = planes;
for (i = 0; i < numbrushplanes; i++, dp++) {
dot = DotProduct (dp->normal, pl.normal);
if (dot > 1.0 - ANGLEEPSILON && fabs (dp->dist - pl.dist) < DISTEPSILON) { // regular
// match
if (dot > 1.0 - ANGLEEPSILON
&& fabs(dp->dist - pl.dist) < DISTEPSILON) { // regular match
return i;
}
}
@ -267,7 +252,6 @@ FindPlane (plane_t *dplane, int *side)
return numbrushplanes - 1;
}
/*
===============
FindPlane_old
@ -290,21 +274,19 @@ FindPlane_old (plane_t *dplane, int *side)
for (i = 0; i < numbrushplanes; i++, dp++) {
dot = DotProduct (dplane->normal, dp->normal);
if (dot > 1.0 - ANGLEEPSILON && fabs (dplane->dist - dp->dist) < DISTEPSILON) { // regular
// match
if (dot > 1.0 - ANGLEEPSILON && fabs (dplane->dist - dp->dist)
< DISTEPSILON) { // regular match
*side = 0;
return i;
}
if (dot < -1.0 + ANGLEEPSILON && fabs (dplane->dist + dp->dist) < DISTEPSILON) { // inverse
// of
// vector
if (dot < -1.0 + ANGLEEPSILON && fabs (dplane->dist + dp->dist)
< DISTEPSILON) { // inverse of vector
*side = 1;
return i;
}
}
// 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)
@ -356,8 +338,6 @@ FindPlane_old (plane_t *dplane, int *side)
return i;
}
/*
=============================================================================
@ -369,21 +349,16 @@ FindPlane_old (plane_t *dplane, int *side)
vec3_t brush_mins, brush_maxs;
face_t *brush_faces;
/*
=================
CreateBrushFaces
=================
*/
#define ZERO_EPSILON 0.001
void
CreateBrushFaces (void)
{
int i, j, k;
vec_t r;
face_t *f;
winding_t *w;
plane_t plane;
int i, j, k;
mface_t *mf;
plane_t plane;
vec_t r;
winding_t *w;
brush_mins[0] = brush_mins[1] = brush_mins[2] = 99999;
brush_maxs[0] = brush_maxs[1] = brush_maxs[2] = -99999;
@ -438,8 +413,6 @@ CreateBrushFaces (void)
}
}
/*
==============================================================================
@ -465,17 +438,12 @@ vec3_t hull_corners[MAX_HULL_POINTS * 8];
int num_hull_edges;
int hull_edges[MAX_HULL_EDGES][2];
/*
============
AddBrushPlane
=============
*/
void
AddBrushPlane (plane_t *plane)
{
float l;
int i;
plane_t *pl;
float l;
if (numbrushfaces == MAX_FACES)
Sys_Error ("AddBrushPlane: numbrushfaces == MAX_FACES");
@ -494,7 +462,6 @@ AddBrushPlane (plane_t *plane)
numbrushfaces++;
}
/*
============
TestAddPlane
@ -506,13 +473,13 @@ vertexes can be put on the front side
void
TestAddPlane (plane_t *plane)
{
int i, c;
int c, i;
int counts[3];
plane_t flip;
plane_t *pl;
vec_t d;
vec_t *corner;
plane_t flip;
vec3_t inv;
int counts[3];
plane_t *pl;
// see if the plane has allready been added
for (i = 0; i < numbrushfaces; i++) {
@ -565,9 +532,8 @@ Doesn't add if duplicated
int
AddHullPoint (vec3_t p, int hullnum)
{
int i;
vec_t *c;
int x, y, z;
int i, x, y, z;
vec_t *c;
for (i = 0; i < num_hull_points; i++)
if (VectorCompare (p, hull_points[i]))
@ -594,22 +560,19 @@ AddHullPoint (vec3_t p, int hullnum)
return i;
}
/*
============
AddHullEdge
Creates all of the hull planes around the given edge, if not done allready
Creates all of the hull planes around the given edge, if not done already
=============
*/
void
AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
{
int pt1, pt2;
int i;
int a, b, c, d, e;
vec3_t edgevec, planeorg, planevec;
int pt1, pt2, a, b, c, d, e, i;
plane_t plane;
vec3_t edgevec, planeorg, planevec;
vec_t l;
pt1 = AddHullPoint (p1, hullnum);
@ -618,7 +581,7 @@ AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
for (i = 0; i < num_hull_edges; i++)
if ((hull_edges[i][0] == pt1 && hull_edges[i][1] == pt2)
|| (hull_edges[i][0] == pt2 && hull_edges[i][1] == pt1))
return; // allread added
return; // allready added
if (num_hull_edges == MAX_HULL_EDGES)
Sys_Error ("MAX_HULL_EDGES");
@ -650,22 +613,15 @@ AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
TestAddPlane (&plane);
}
}
}
/*
============
ExpandBrush
=============
*/
void
ExpandBrush (int hullnum)
{
int i, x, s;
vec3_t corner;
face_t *f;
int i, x, s;
plane_t plane, *p;
vec3_t corner;
num_hull_points = 0;
num_hull_edges = 0;
@ -709,7 +665,6 @@ ExpandBrush (int hullnum)
//============================================================================
/*
===============
LoadBrush
@ -718,24 +673,21 @@ Converts a mapbrush to a bsp brush
===============
*/
brush_t *
LoadBrush (mbrush_t * mb, int hullnum)
LoadBrush (mbrush_t *mb, int hullnum)
{
brush_t *b;
int contents;
char *name;
int contents;
mface_t *f;
//
// 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
if (name[0] == '*' && worldmodel) // entities never use water merging
{
if (name[0] == '*' && worldmodel) { // entities never use water merging
if (!strncasecmp (name + 1, "lava", 4))
contents = CONTENTS_LAVA;
else if (!strncasecmp (name + 1, "slime", 5))
@ -753,9 +705,7 @@ LoadBrush (mbrush_t * mb, int hullnum)
// no seperate textures on clip hull
//
// create the faces
//
brush_faces = NULL;
numbrushfaces = 0;
@ -777,9 +727,8 @@ LoadBrush (mbrush_t * mb, int hullnum)
ExpandBrush (hullnum);
CreateBrushFaces ();
}
//
// create the brush
//
b = AllocBrush ();
b->contents = contents;
@ -792,15 +741,8 @@ LoadBrush (mbrush_t * mb, int hullnum)
//=============================================================================
/*
============
Brush_DrawAll
============
*/
void
Brush_DrawAll (brushset_t * bs)
Brush_DrawAll (brushset_t *bs)
{
brush_t *b;
face_t *f;
@ -810,19 +752,13 @@ Brush_DrawAll (brushset_t * bs)
Draw_DrawFace (f);
}
/*
============
Brush_LoadEntity
============
*/
brushset_t *
Brush_LoadEntity (entity_t *ent, int hullnum)
{
brush_t *b, *next, *water, *other;
mbrush_t *mbr;
int numbrushes;
brushset_t *bset;
int numbrushes;
mbrush_t *mbr;
bset = malloc (sizeof (brushset_t));
memset (bset, 0, sizeof (brushset_t));

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// csg4.c
@ -28,29 +29,25 @@
#include "bsp5.h"
/*
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 *inside, *outside;
int brushfaces;
int csgfaces;
int csgmergefaces;
void
DrawList (face_t * list)
DrawList (face_t *list)
{
for (; list; list = list->next)
Draw_DrawFace (list);
}
/*
==================
NewFaceFromFace
@ -60,7 +57,7 @@ MergeFace.
==================
*/
face_t *
NewFaceFromFace (face_t * in)
NewFaceFromFace (face_t *in)
{
face_t *newf;
@ -76,22 +73,15 @@ NewFaceFromFace (face_t * in)
return newf;
}
/*
==================
SplitFace
==================
*/
void
SplitFace (face_t * in, plane_t *split, face_t ** front, face_t ** back)
SplitFace (face_t *in, plane_t *split, face_t **front, face_t **back)
{
vec_t dists[MAXEDGES + 1];
face_t *newf, *new2;
int i, j;
int sides[MAXEDGES + 1];
int counts[3];
vec_t dot;
int i, j;
face_t *newf, *new2;
vec_t dists[MAXEDGES + 1];
vec_t *p1, *p2;
vec3_t mid;
@ -130,7 +120,6 @@ SplitFace (face_t * in, plane_t *split, face_t ** front, face_t ** back)
*front = new2 = NewFaceFromFace (in);
// 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");
@ -160,8 +149,7 @@ SplitFace (face_t * in, plane_t *split, face_t ** front, face_t ** back)
p2 = in->pts[(i + 1) % in->numpoints];
dot = dists[i] / (dists[i] - dists[i + 1]);
for (j = 0; j < 3; j++) { // avoid round off error when
// possible
for (j = 0; j < 3; j++) { // avoid round off error when possible
if (split->normal[j] == 1)
mid[j] = split->dist;
else if (split->normal[j] == -1)
@ -203,9 +191,8 @@ frontside is the side of the plane that holds the outside list
void
ClipInside (int splitplane, int frontside, qboolean precedence)
{
face_t *f, *next;
face_t *insidelist, *next, *f;
face_t *frags[2];
face_t *insidelist;
plane_t *split;
split = &planes[splitplane];
@ -215,9 +202,8 @@ ClipInside (int splitplane, int frontside, qboolean precedence)
next = f->next;
if (f->planenum == splitplane) { // exactly on, handle special
if (frontside != f->planeside || precedence) { // allways clip
// off opposite
// faceing
if (frontside != f->planeside || precedence) { // always clip off
// opposite faceing
frags[frontside] = NULL;
frags[!frontside] = f;
} else { // leave it on the outside
@ -241,7 +227,6 @@ ClipInside (int splitplane, int frontside, qboolean precedence)
inside = insidelist;
}
/*
==================
SaveOutside
@ -253,8 +238,7 @@ void
SaveOutside (qboolean mirror)
{
face_t *f, *next, *newf;
int i;
int planenum;
int planenum, i;
for (f = outside; f; f = next) {
next = f->next;
@ -279,7 +263,8 @@ SaveOutside (qboolean mirror)
validfaces[planenum] = MergeFaceToList (f, validfaces[planenum]);
if (newf)
validfaces[planenum] = MergeFaceToList (newf, validfaces[planenum]);
validfaces[planenum] = MergeFaceToList (newf,
validfaces[planenum]);
validfaces[planenum] = FreeMergeListScraps (validfaces[planenum]);
}
@ -295,7 +280,7 @@ Free all the faces that got clipped out
void
FreeInside (int contents)
{
face_t *f, *next;
face_t *next, *f;
for (f = inside; f; f = next) {
next = f->next;
@ -309,7 +294,6 @@ FreeInside (int contents)
}
}
//==========================================================================
/*
@ -323,11 +307,10 @@ faces.
surface_t *
BuildSurfaces (void)
{
face_t **f;
face_t *count;
face_t **f;
int i;
surface_t *s;
surface_t *surfhead;
surface_t *surfhead, *s;
surfhead = NULL;
@ -352,15 +335,10 @@ BuildSurfaces (void)
//==========================================================================
/*
==================
CopyFacesToOutside
==================
*/
void
CopyFacesToOutside (brush_t * b)
CopyFacesToOutside (brush_t *b)
{
face_t *f, *newf;
face_t *newf, *f;
outside = NULL;
@ -385,7 +363,6 @@ CopyFacesToOutside (brush_t * b)
}
}
/*
==================
CSGFaces
@ -394,12 +371,12 @@ Returns a list of surfaces containing aall of the faces
==================
*/
surface_t *
CSGFaces (brushset_t * bs)
CSGFaces (brushset_t *bs)
{
brush_t *b1, *b2;
face_t *f;
int i;
qboolean overwrite;
face_t *f;
surface_t *surfhead;
qprintf ("---- CSGFaces ----\n");
@ -410,9 +387,7 @@ CSGFaces (brushset_t * bs)
Draw_ClearWindow ();
//
// 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

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// map.c
@ -44,14 +45,7 @@ entity_t entities[MAX_MAP_ENTITIES];
int nummiptex;
char miptex[MAX_MAP_TEXINFO][16];
//============================================================================
/*
===============
FindMiptex
===============
*/
int
FindMiptex (char *name)
{
@ -83,8 +77,8 @@ FindTexinfo (texinfo_t *t)
// set the special flag
if (miptex[t->miptex][0] == '*'
|| !strncasecmp (miptex[t->miptex], "sky", 3)) t->flags |= TEX_SPECIAL;
|| !strncasecmp (miptex[t->miptex], "sky", 3))
t->flags |= TEX_SPECIAL;
tex = bsp->texinfo;
for (i = 0; i < bsp->numtexinfo; i++, tex++) {
@ -111,7 +105,6 @@ FindTexinfo (texinfo_t *t)
return i;
}
//============================================================================
#define MAXTOKEN 128
@ -137,9 +130,7 @@ GetToken (qboolean crossline)
if (unget) // is a token allready waiting?
return true;
//
// skip space
//
skipspace:
while (*script_p <= 32) {
if (!*script_p) {
@ -154,8 +145,7 @@ GetToken (qboolean crossline)
}
}
if (script_p[0] == '/' && script_p[1] == '/') // comment field
{
if (script_p[0] == '/' && script_p[1] == '/') { // comment field
if (!crossline)
Sys_Error ("Line %i is incomplete\n", scriptline);
while (*script_p++ != '\n')
@ -166,9 +156,8 @@ GetToken (qboolean crossline)
}
goto skipspace;
}
//
// copy token
//
token_p = token;
if (*script_p == '"') {
@ -199,16 +188,10 @@ UngetToken ()
unget = true;
}
//============================================================================
entity_t *mapent;
/*
=================
ParseEpair
=================
*/
void
ParseEpair (void)
{
@ -230,12 +213,6 @@ ParseEpair (void)
//============================================================================
/*
==================
textureAxisFromPlane
==================
*/
vec3_t baseaxis[18] = {
{0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor
{0, 0, -1}, {1, 0, 0}, {0, -1, 0}, // ceiling
@ -248,9 +225,8 @@ vec3_t baseaxis[18] = {
void
TextureAxisFromPlane (plane_t *pln, vec3_t xv, vec3_t yv)
{
int bestaxis;
float dot, best;
int i;
int bestaxis, i;
best = 0;
bestaxis = 0;
@ -267,26 +243,19 @@ TextureAxisFromPlane (plane_t *pln, vec3_t xv, vec3_t yv)
VectorCopy (baseaxis[bestaxis * 3 + 2], yv);
}
//=============================================================================
/*
=================
ParseBrush
=================
*/
void
ParseBrush (void)
{
float shift[2], rotate, scale[2];
int i, j;
mbrush_t *b;
mface_t *f, *f2;
texinfo_t tx;
vec3_t planepts[3];
vec3_t t1, t2, t3;
int i, j;
texinfo_t tx;
vec_t d;
float shift[2], rotate, scale[2];
b = &mapbrushes[nummapbrushes];
nummapbrushes++;
@ -314,7 +283,6 @@ ParseBrush (void)
GetToken (false);
if (strcmp (token, ")"))
Sys_Error ("parsing brush");
}
// read the texturedef
@ -332,11 +300,12 @@ ParseBrush (void)
GetToken (false);
scale[1] = atof (token);
// if the three points are all on a previous plane, it is a
// duplicate plane
// if the three points are all on a previous plane, it is a duplicate
// plane
for (f2 = b->faces; f2; f2 = f2->next) {
for (i = 0; i < 3; i++) {
d = DotProduct (planepts[i], f2->plane.normal) - f2->plane.dist;
d = DotProduct (planepts[i], f2->plane.normal)
- f2->plane.dist;
if (d < -ON_EPSILON || d > ON_EPSILON)
break;
}
@ -369,14 +338,11 @@ ParseBrush (void)
VectorNormalize (f->plane.normal);
f->plane.dist = DotProduct (t3, f->plane.normal);
//
// fake proper texture vectors from QuakeEd style
//
{
vec3_t vecs[2];
float ang, sinv, cosv, ns, nt;
int sv, tv;
float ang, sinv, cosv;
float ns, nt;
vec3_t vecs[2];
TextureAxisFromPlane (&f->plane, vecs[0], vecs[1]);
@ -385,7 +351,6 @@ ParseBrush (void)
if (!scale[1])
scale[1] = 1;
// rotate axis
if (rotate == 0) {
sinv = 0;
@ -439,11 +404,6 @@ ParseBrush (void)
} while (1);
}
/*
================
ParseEntity
================
*/
qboolean
ParseEntity (void)
{
@ -474,11 +434,6 @@ ParseEntity (void)
return true;
}
/*
================
LoadMapFile
================
*/
void
LoadMapFile (char *filename)
{
@ -566,13 +521,12 @@ GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
vec[2] = v3;
}
void
WriteEntitiesToString (void)
{
char *buf, *end;
epair_t *ep;
char line[128];
epair_t *ep;
int i;
buf = bsp->entdata;

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// merge.c
@ -27,24 +28,18 @@
#include "bsp5.h"
#define CONTINUOUS_EPSILON 0.001
/*
================
CheckColinear
================
*/
void
CheckColinear (face_t * f)
CheckColinear (face_t *f)
{
int i, j;
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);
@ -59,28 +54,27 @@ CheckColinear (face_t * f)
}
/*
=============
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.
=============
*/
face_t *
TryMerge (face_t * f1, face_t * f2)
TryMerge (face_t *f1, face_t *f2)
{
vec_t *p1, *p2, *p3, *p4, *back;
face_t *newf;
int i, j, k, l;
vec3_t normal, delta, planenormal;
vec_t dot;
plane_t *plane;
qboolean keep1, keep2;
vec3_t normal, delta, planenormal;
vec_t dot;
vec_t *p1, *p2, *p3, *p4, *back;
if (f1->numpoints == -1 || f2->numpoints == -1)
return NULL;
@ -93,11 +87,9 @@ TryMerge (face_t * f1, face_t * f2)
if (f1->contents[1] != f2->contents[1])
return NULL;
//
// find a common edge
//
p1 = p2 = NULL; // stop compiler warning
j = 0; //
j = 0;
for (i = 0; i < f1->numpoints; i++) {
p1 = f1->pts[i];
@ -121,10 +113,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
//
plane = &planes[f1->planenum];
VectorCopy (plane->normal, planenormal);
if (f1->planeside)
@ -154,11 +144,9 @@ TryMerge (face_t * f1, face_t * f2)
return NULL; // not a convex polygon
keep2 = dot < -CONTINUOUS_EPSILON;
//
// build the new polygon
//
if (f1->numpoints + f2->numpoints > MAXEDGES) {
// Sys_Error ("TryMerge: too many edges!");
// Sys_Error ("TryMerge: too many edges!");
return NULL;
}
@ -184,20 +172,14 @@ TryMerge (face_t * f1, face_t * f2)
return newf;
}
/*
===============
MergeFaceToList
===============
*/
qboolean mergedebug;
face_t *
MergeFaceToList (face_t * face, face_t * list)
MergeFaceToList (face_t *face, face_t *list)
{
face_t *newf, *f;
for (f = list; f; f = f->next) {
//CheckColinear (f);
// CheckColinear (f);
if (mergedebug) {
Draw_ClearWindow ();
Draw_DrawFace (face);
@ -217,14 +199,8 @@ MergeFaceToList (face_t * face, face_t * list)
return face;
}
/*
===============
FreeMergeListScraps
===============
*/
face_t *
FreeMergeListScraps (face_t * merged)
FreeMergeListScraps (face_t *merged)
{
face_t *head, *next;
@ -242,17 +218,10 @@ FreeMergeListScraps (face_t * merged)
return head;
}
/*
===============
MergePlaneFaces
===============
*/
void
MergePlaneFaces (surface_t * plane)
MergePlaneFaces (surface_t *plane)
{
face_t *f1, *next;
face_t *merged;
face_t *merged, *next, *f1;
merged = NULL;
@ -265,18 +234,12 @@ MergePlaneFaces (surface_t * plane)
plane->faces = FreeMergeListScraps (merged);
}
/*
============
MergeAll
============
*/
void
MergeAll (surface_t * surfhead)
{
surface_t *surf;
int mergefaces;
face_t *f;
int mergefaces;
surface_t *surf;
printf ("---- MergeAll ----\n");

View file

@ -1,25 +1,26 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
#include "bsp5.h"
void
Draw_ClearBounds (void)
{
@ -31,7 +32,7 @@ Draw_AddToBounds (vec3_t v)
}
void
Draw_DrawFace (face_t * f)
Draw_DrawFace (face_t *f)
{
}
@ -61,17 +62,17 @@ DrawPoint (vec3_t v)
}
void
DrawLeaf (node_t * l, int color)
DrawLeaf (node_t *l, int color)
{
}
void
DrawBrush (brush_t * b)
DrawBrush (brush_t *b)
{
}
void
DrawWinding (winding_t * w)
DrawWinding (winding_t *w)
{
}
@ -81,6 +82,6 @@ DrawTri (vec3_t p1, vec3_t p2, vec3_t p3)
}
void
DrawPortal (portal_t * portal)
DrawPortal (portal_t *portal)
{
}

View file

@ -27,22 +27,16 @@
int outleafs;
/*
===========
PointInLeaf
===========
*/
node_t *
PointInLeaf (node_t * node, vec3_t point)
PointInLeaf (node_t *node, vec3_t point)
{
vec_t d;
if (node->contents)
return node;
d =
DotProduct (planes[node->planenum].normal,
point) - planes[node->planenum].dist;
d = DotProduct (planes[node->planenum].normal, point)
- planes[node->planenum].dist;
if (d > 0)
return PointInLeaf (node->children[0], point);
@ -50,13 +44,8 @@ PointInLeaf (node_t * node, vec3_t point)
return PointInLeaf (node->children[1], point);
}
/*
===========
PlaceOccupant
===========
*/
qboolean
PlaceOccupant (int num, vec3_t point, node_t * headnode)
PlaceOccupant (int num, vec3_t point, node_t *headnode)
{
node_t *n;
@ -67,21 +56,16 @@ PlaceOccupant (int num, vec3_t point, node_t * headnode)
return true;
}
/*
==============
MarkLeakTrail
==============
*/
portal_t *prevleaknode;
FILE *leakfile;
void
MarkLeakTrail (portal_t * n2)
MarkLeakTrail (portal_t *n2)
{
int i, j;
vec3_t p1, p2, dir;
float len;
int i, j;
portal_t *n1;
vec3_t p1, p2, dir;
if (hullnum)
return;
@ -116,6 +100,9 @@ MarkLeakTrail (portal_t * n2)
}
}
int hit_occupied;
int backdraw;
/*
==================
RecursiveFillOutside
@ -124,10 +111,8 @@ If fill is false, just check, don't fill
Returns true if an occupied leaf is reached
==================
*/
int hit_occupied;
int backdraw;
qboolean
RecursiveFillOutside (node_t * l, qboolean fill)
RecursiveFillOutside (node_t *l, qboolean fill)
{
portal_t *p;
int s;
@ -165,14 +150,8 @@ RecursiveFillOutside (node_t * l, qboolean fill)
return false;
}
/*
==================
ClearOutFaces
==================
*/
void
ClearOutFaces (node_t * node)
ClearOutFaces (node_t *node)
{
face_t **fp;
@ -191,22 +170,14 @@ ClearOutFaces (node_t * node)
node->faces = NULL;
}
//=============================================================================
/*
===========
FillOutside
===========
*/
qboolean
FillOutside (node_t * node)
FillOutside (node_t *node)
{
int s;
vec_t *v;
int i;
int i, s;
qboolean inside;
vec_t *v;
qprintf ("----- FillOutside ----\n");
@ -224,9 +195,8 @@ FillOutside (node_t * node)
}
if (!inside) {
printf
("Hullnum %i: No entities in empty space -- no filling performed\n",
hullnum);
printf ("Hullnum %i: No entities in empty space -- no filling "
"performed\n", hullnum);
return false;
}

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
#ifdef HAVE_CONFIG_H
@ -25,20 +26,11 @@
#include "bsp5.h"
node_t outside_node; // portals outside the world face this
node_t outside_node; // portals outside the world face
// this
//=============================================================================
/*
=============
AddPortalToNodes
=============
*/
void
AddPortalToNodes (portal_t * p, node_t * front, node_t * back)
AddPortalToNodes (portal_t *p, node_t *front, node_t *back)
{
if (p->nodes[0] || p->nodes[1])
Sys_Error ("AddPortalToNode: allready included");
@ -52,14 +44,8 @@ AddPortalToNodes (portal_t * p, node_t * front, node_t * back)
back->portals = p;
}
/*
=============
RemovePortalFromNode
=============
*/
void
RemovePortalFromNode (portal_t * portal, node_t * l)
RemovePortalFromNode (portal_t *portal, node_t *l)
{
portal_t **pp, *t;
@ -93,7 +79,7 @@ RemovePortalFromNode (portal_t * portal, node_t * l)
//============================================================================
void
PrintPortal (portal_t * p)
PrintPortal (portal_t *p)
{
int i;
winding_t *w;
@ -112,13 +98,12 @@ The created portals will face the global outside_node
================
*/
void
MakeHeadnodePortals (node_t * node)
MakeHeadnodePortals (node_t *node)
{
vec3_t bounds[2];
int i, j, n;
portal_t *p, *portals[6];
int side, i, j, n;
plane_t bplanes[6], *pl;
int side;
portal_t *p, *portals[6];
vec3_t bounds[2];
Draw_ClearWindow ();
@ -170,7 +155,7 @@ MakeHeadnodePortals (node_t * node)
//============================================================================
void
CheckWindingInNode (winding_t * w, node_t * node)
CheckWindingInNode (winding_t *w, node_t *node)
{
int i, j;
@ -185,10 +170,10 @@ CheckWindingInNode (winding_t * w, node_t * node)
}
void
CheckWindingArea (winding_t * w)
CheckWindingArea (winding_t *w)
{
int i;
float total, add;
int i;
vec3_t v1, v2, cross;
total = 0;
@ -205,7 +190,7 @@ CheckWindingArea (winding_t * w)
void
PlaneFromWinding (winding_t * w, plane_t *plane)
PlaneFromWinding (winding_t *w, plane_t *plane)
{
vec3_t v1, v2;
@ -218,14 +203,13 @@ PlaneFromWinding (winding_t * w, plane_t *plane)
}
void
CheckLeafPortalConsistancy (node_t * node)
CheckLeafPortalConsistancy (node_t *node)
{
int side, side2;
portal_t *p, *p2;
plane_t plane, plane2;
int i;
winding_t *w;
float dist;
int side, side2, i;
plane_t plane, plane2;
portal_t *p, *p2;
winding_t *w;
side = side2 = 0; // quiet compiler warning
@ -258,45 +242,32 @@ CheckLeafPortalConsistancy (node_t * node)
return;
}
}
}
}
}
/*
================
CutNodePortals_r
================
*/
void
CutNodePortals_r (node_t * node)
CutNodePortals_r (node_t *node)
{
plane_t *plane, clipplane;
int side;
node_t *f, *b, *other_node;
plane_t *plane, clipplane;
portal_t *p, *new_portal, *next_portal;
winding_t *w, *frontwinding, *backwinding;
int side;
// CheckLeafPortalConsistancy (node);
//
// seperate the portals on node into it's children
//
if (node->contents) {
if (node->contents)
return; // at a leaf, no more dividing
}
plane = &planes[node->planenum];
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
//
new_portal = AllocPortal ();
new_portal->planenum = node->planenum;
@ -325,9 +296,8 @@ CutNodePortals_r (node_t * node)
new_portal->winding = w;
AddPortalToNodes (new_portal, f, b);
}
//
// partition the portals
//
for (p = node->portals; p; p = next_portal) {
if (p->nodes[0] == node)
side = 0;
@ -341,9 +311,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
//
DivideWinding (p->winding, plane, &frontwinding, &backwinding);
if (!frontwinding) {
@ -381,10 +349,8 @@ CutNodePortals_r (node_t * node)
CutNodePortals_r (f);
CutNodePortals_r (b);
}
/*
==================
PortalizeWorld
@ -393,7 +359,7 @@ Builds the exact polyhedrons for the nodes and leafs
==================
*/
void
PortalizeWorld (node_t * headnode)
PortalizeWorld (node_t *headnode)
{
qprintf ("----- portalize ----\n");
@ -401,15 +367,8 @@ PortalizeWorld (node_t * headnode)
CutNodePortals_r (headnode);
}
/*
==================
FreeAllPortals
==================
*/
void
FreeAllPortals (node_t * node)
FreeAllPortals (node_t *node)
{
portal_t *p, *nextp;
@ -430,13 +389,7 @@ FreeAllPortals (node_t * node)
}
}
/*
==============================================================================
PORTAL FILE GENERATION
==============================================================================
*/
// PORTAL FILE GENERATION =====================================================
#define PORTALFILE "PRT1"
@ -445,7 +398,7 @@ int num_visleafs; // leafs the player can be in
int num_visportals;
void
WriteFloat (FILE * f, vec_t v)
WriteFloat (FILE *f, vec_t v)
{
if (fabs (v - (int) (v + 0.5)) < 0.001)
fprintf (f, "%i ", (int) (v + 0.5));
@ -454,12 +407,12 @@ WriteFloat (FILE * f, vec_t v)
}
void
WritePortalFile_r (node_t * node)
WritePortalFile_r (node_t *node)
{
int i;
plane_t *pl, plane2;
portal_t *p;
winding_t *w;
plane_t *pl, plane2;
if (!node->contents) {
WritePortalFile_r (node->children[0]);
@ -476,18 +429,17 @@ WritePortalFile_r (node_t * node)
&& p->nodes[0]->contents == p->nodes[1]->contents) {
// write out to the file
// sometimes planes get turned around when they are very near
// the changeover point between different axis. interpret the
// plane the same way vis will, and flip the side orders if
// needed
// sometimes planes get turned around when they are very near the
// changeover point between different axis. interpret the plane
// the same way vis will, and flip the side orders if needed
pl = &planes[p->planenum];
PlaneFromWinding (w, &plane2);
if (DotProduct (pl->normal, plane2.normal) < 0.99) { // backwards...
fprintf (pf, "%i %i %i ", w->numpoints, p->nodes[1]->visleafnum,
p->nodes[0]->visleafnum);
if (DotProduct (pl->normal, plane2.normal) < 0.99) { // backwards..
fprintf (pf, "%i %i %i ", w->numpoints,
p->nodes[1]->visleafnum, p->nodes[0]->visleafnum);
} else
fprintf (pf, "%i %i %i ", w->numpoints, p->nodes[0]->visleafnum,
p->nodes[1]->visleafnum);
fprintf (pf, "%i %i %i ", w->numpoints,
p->nodes[0]->visleafnum, p->nodes[1]->visleafnum);
for (i = 0; i < w->numpoints; i++) {
fprintf (pf, "(");
WriteFloat (pf, w->points[i][0]);
@ -506,13 +458,8 @@ WritePortalFile_r (node_t * node)
}
/*
================
NumberLeafs_r
================
*/
void
NumberLeafs_r (node_t * node)
NumberLeafs_r (node_t *node)
{
portal_t *p;
@ -543,17 +490,10 @@ NumberLeafs_r (node_t * node)
} else
p = p->next[1];
}
}
/*
================
WritePortalfile
================
*/
void
WritePortalfile (node_t * headnode)
WritePortalfile (node_t *headnode)
{
// set the visleafnum field in every leaf and count the total number of portals
num_visleafs = 0;

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// bsp5.c
@ -37,9 +38,7 @@
bsp_t *bsp;
//
// command line flags
//
qboolean drawflag;
qboolean nofill;
qboolean notjunc;
@ -66,7 +65,6 @@ qboolean worldmodel;
int hullnum;
//===========================================================================
void
qprintf (char *fmt, ...)
@ -81,11 +79,6 @@ qprintf (char *fmt, ...)
va_end (argptr);
}
/*
=================
BaseWindingForPlane
=================
*/
winding_t *
BaseWindingForPlane (plane_t *p)
{
@ -150,15 +143,8 @@ BaseWindingForPlane (plane_t *p)
return w;
}
/*
==================
CopyWinding
==================
*/
winding_t *
CopyWinding (winding_t * w)
CopyWinding (winding_t *w)
{
int size;
winding_t *c;
@ -169,8 +155,6 @@ CopyWinding (winding_t * w)
return c;
}
/*
==================
CheckWinding
@ -183,7 +167,6 @@ CheckWinding (winding_t * w)
{
}
/*
==================
ClipWinding
@ -195,17 +178,16 @@ it will be clipped away.
==================
*/
winding_t *
ClipWinding (winding_t * in, plane_t *split, qboolean keepon)
ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
{
vec_t dists[MAX_POINTS_ON_WINDING];
int maxpts, i, j;
int sides[MAX_POINTS_ON_WINDING];
int counts[3];
vec_t dot;
int i, j;
vec_t dists[MAX_POINTS_ON_WINDING];
vec_t *p1, *p2;
vec3_t mid;
winding_t *neww;
int maxpts;
counts[0] = counts[1] = counts[2] = 0;
@ -236,8 +218,8 @@ ClipWinding (winding_t * in, plane_t *split, qboolean keepon)
if (!counts[1])
return in;
maxpts = in->numpoints + 4; // can't use counts[0]+2 because
// of fp grouping errors
maxpts = in->numpoints + 4; // can't use counts[0]+2 because of fp
// grouping errors
neww = NewWinding (maxpts);
for (i = 0; i < in->numpoints; i++) {
@ -261,8 +243,7 @@ ClipWinding (winding_t * in, plane_t *split, qboolean keepon)
p2 = in->points[(i + 1) % in->numpoints];
dot = dists[i] / (dists[i] - dists[i + 1]);
for (j = 0; j < 3; j++) { // avoid round off error when
// possible
for (j = 0; j < 3; j++) { // avoid round off error when possible
if (split->normal[j] == 1)
mid[j] = split->dist;
else if (split->normal[j] == -1)
@ -284,7 +265,6 @@ ClipWinding (winding_t * in, plane_t *split, qboolean keepon)
return neww;
}
/*
==================
DivideWinding
@ -296,18 +276,17 @@ new windings will be created.
==================
*/
void
DivideWinding (winding_t * in, plane_t *split, winding_t ** front,
winding_t ** back)
DivideWinding (winding_t *in, plane_t *split, winding_t **front,
winding_t **back)
{
vec_t dists[MAX_POINTS_ON_WINDING];
int maxpts, i, j;
int sides[MAX_POINTS_ON_WINDING];
int counts[3];
vec_t dot;
int i, j;
vec_t dists[MAX_POINTS_ON_WINDING];
vec_t *p1, *p2;
vec3_t mid;
winding_t *f, *b;
int maxpts;
counts[0] = counts[1] = counts[2] = 0;
@ -409,16 +388,11 @@ PrintMemory (void)
printf ("portals : %6i (%6i)\n", c_activeportals, c_peakportals);
}
/*
==================
NewWinding
==================
*/
winding_t *
NewWinding (int points)
{
winding_t *w;
int size;
winding_t *w;
if (points > MAX_POINTS_ON_WINDING)
Sys_Error ("NewWinding: %i points", points);
@ -434,21 +408,13 @@ NewWinding (int points)
return w;
}
void
FreeWinding (winding_t * w)
FreeWinding (winding_t *w)
{
c_activewindings--;
free (w);
}
/*
===========
AllocFace
===========
*/
face_t *
AllocFace (void)
{
@ -465,21 +431,14 @@ AllocFace (void)
return f;
}
void
FreeFace (face_t * f)
FreeFace (face_t *f)
{
c_activefaces--;
// memset (f,0xff,sizeof(face_t));
// memset (f, 0xff, sizeof (face_t));
free (f);
}
/*
===========
AllocSurface
===========
*/
surface_t *
AllocSurface (void)
{
@ -496,17 +455,12 @@ AllocSurface (void)
}
void
FreeSurface (surface_t * s)
FreeSurface (surface_t *s)
{
c_activesurfaces--;
free (s);
}
/*
===========
AllocPortal
===========
*/
portal_t *
AllocPortal (void)
{
@ -523,18 +477,12 @@ AllocPortal (void)
}
void
FreePortal (portal_t * p)
FreePortal (portal_t *p)
{
c_activeportals--;
free (p);
}
/*
===========
AllocNode
===========
*/
node_t *
AllocNode (void)
{
@ -546,11 +494,6 @@ AllocNode (void)
return n;
}
/*
===========
AllocBrush
===========
*/
brush_t *
AllocBrush (void)
{
@ -564,20 +507,14 @@ AllocBrush (void)
//===========================================================================
/*
===============
ProcessEntity
===============
*/
void
ProcessEntity (int entnum)
{
entity_t *ent;
brushset_t *bs;
char mod[80];
entity_t *ent;
surface_t *surfs;
node_t *nodes;
brushset_t *bs;
ent = &entities[entnum];
if (!ent->brushes)
@ -597,11 +534,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
//
bs = Brush_LoadEntity (ent, hullnum);
if (!bs->brushes) {
@ -614,14 +548,11 @@ ProcessEntity (int entnum)
if (hullnum != 0) {
nodes = SolidBSP (surfs, true);
if (entnum == 0 && !nofill) // assume non-world bmodels are
// simple
{
if (entnum == 0 && !nofill) { // assume non-world bmodels are simple
PortalizeWorld (nodes);
if (FillOutside (nodes)) {
surfs = GatherNodeFaces (nodes);
nodes = SolidBSP (surfs, false); // make a really good
// tree
nodes = SolidBSP (surfs, false); // make a really good tree
}
FreeAllPortals (nodes);
}
@ -629,7 +560,6 @@ ProcessEntity (int entnum)
WriteClipNodes (nodes);
BumpModel (hullnum);
} else {
//
// SolidBSP generates a node tree
//
// if not the world, make a good tree first
@ -637,13 +567,9 @@ ProcessEntity (int entnum)
// because the outside filling will force a regeneration later
nodes = SolidBSP (surfs, entnum == 0);
//
// build all the portals in the bsp tree
// some portals are solid polygons, and some are paths to other leafs
//
if (entnum == 0 && !nofill) // assume non-world bmodels are
// simple
{
if (entnum == 0 && !nofill) { // assume non-world bmodels are simple
PortalizeWorld (nodes);
if (FillOutside (nodes)) {
@ -676,12 +602,6 @@ ProcessEntity (int entnum)
}
}
/*
=================
UpdateEntLump
=================
*/
void
UpdateEntLump (void)
{
@ -718,10 +638,10 @@ Write the clipping hull out to a text file so the parent process can get it
void
WriteClipHull (void)
{
FILE *f;
int i;
dplane_t *p;
FILE *f;
dclipnode_t *d;
dplane_t *p;
int i;
hullfilename[strlen (hullfilename) - 1] = '0' + hullnum;
@ -761,15 +681,12 @@ Read the files written out by the child processes
void
ReadClipHull (int hullnum)
{
FILE *f;
int i, j, n;
int firstclipnode;
dplane_t p;
FILE *f;
dclipnode_t *d;
int c1, c2;
float f1, f2, f3, f4;
int junk;
vec3_t norm;
dplane_t p;
float f1, f2, f3, f4;
int firstclipnode, junk, c1, c2, i, j, n;
vec3_t norm;
hullfilename[strlen (hullfilename) - 1] = '0' + hullnum;
@ -798,12 +715,10 @@ ReadClipHull (int hullnum)
Sys_Error ("ReadClipHull: MAX_MAP_CLIPNODES");
d = &bsp->clipnodes[bsp->numclipnodes];
bsp->numclipnodes++;
if (fscanf
(f, "%i : %f %f %f %f : %i %i\n", &junk, &f1, &f2, &f3, &f4, &c1,
&c2) != 7)
if (fscanf (f, "%i : %f %f %f %f : %i %i\n", &junk, &f1, &f2, &f3, &f4,
&c1, &c2) != 7)
Sys_Error ("Error parsing %s", hullfilename);
p.normal[0] = f1;
p.normal[1] = f2;
p.normal[2] = f3;
@ -821,12 +736,6 @@ ReadClipHull (int hullnum)
}
/*
=================
CreateSingleHull
=================
*/
void
CreateSingleHull (void)
{
@ -843,12 +752,6 @@ CreateSingleHull (void)
WriteClipHull ();
}
/*
=================
CreateHulls
=================
*/
void
CreateHulls (void)
{
@ -890,10 +793,8 @@ CreateHulls (void)
if (hullnum)
exit (0);
wait (NULL); // wait for clip hull process to
// finish
wait (NULL); // wait for clip hull process to
// finish
wait (NULL); // wait for clip hull process to finish
wait (NULL); // wait for clip hull process to finish
#else
// create the hulls sequentially
@ -917,12 +818,6 @@ CreateHulls (void)
}
/*
=================
ProcessFile
=================
*/
void
ProcessFile (char *sourcebase, char *bspfilename1)
{
@ -973,26 +868,17 @@ ProcessFile (char *sourcebase, char *bspfilename1)
FinishBSPFile ();
}
/*
==================
main
==================
*/
int
main (int argc, char **argv)
{
int i;
double start, end;
char sourcename[1024];
char destname[1024];
double start, end;
int i;
// malloc_debug (15);
// malloc_debug (15);
//
// check command line flags
//
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-')
break;
@ -1009,8 +895,7 @@ main (int argc, char **argv)
else if (!strcmp (argv[i], "-verbose"))
allverbose = true;
else if (!strcmp (argv[i], "-usehulls"))
usehulls = true; // don't fork -- use the existing
// files
usehulls = true; // don't fork -- use the existing files
else if (!strcmp (argv[i], "-hullnum")) {
hullnum = atoi (argv[i + 1]);
i++;
@ -1025,17 +910,12 @@ main (int argc, char **argv)
Sys_Error
("usage: qbsp [options] sourcefile [destfile]\noptions: -nojunc -nofill -threads[124] -draw -onlyents -verbose -proj <projectpath>");
// XXX SetQdirFromPath (argv[i]);
// XXX SetQdirFromPath (argv[i]);
//
// let forked processes change name for ps status
//
argv0 = argv[0];
//
// create destination name if not specified
//
strcpy (sourcename, argv[i]);
COM_DefaultExtension (sourcename, ".map");
@ -1047,9 +927,7 @@ main (int argc, char **argv)
} else
strcpy (destname, argv[i + 1]);
//
// do it!
//
start = Sys_DoubleTime ();
ProcessFile (sourcename, destname);
end = Sys_DoubleTime ();

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// region.h
@ -28,7 +29,6 @@
#include "bsp5.h"
/*
input
-----
vertexes
@ -42,15 +42,14 @@ smaller set of edges
regions
? triangulated regions
face to region mapping numbers
*/
#define MAX_EDGES_IN_REGION 32
int firstedge;
vec3_t region_mins, region_maxs;
void
AddPointToRegion (vec3_t p)
{
@ -72,7 +71,7 @@ ClearRegionSize (void)
}
void
AddFaceToRegionSize (face_t * f)
AddFaceToRegionSize (face_t *f)
{
int i;
@ -80,16 +79,11 @@ AddFaceToRegionSize (face_t * f)
AddPointToRegion (f->pts[i]);
}
/*
==============
CanJoinFaces
==============
*/
qboolean
CanJoinFaces (face_t * f, face_t * f2)
CanJoinFaces (face_t *f, face_t *f2)
{
vec3_t oldmins, oldmaxs;
int i;
vec3_t oldmins, oldmaxs;
if (f2->planenum != f->planenum
|| f2->planeside != f->planeside || f2->texturenum != f->texturenum)
@ -97,7 +91,7 @@ CanJoinFaces (face_t * f, face_t * f2)
if (f2->outputnumber != -1)
return false;
if (f2->contents[0] != f->contents[0]) { // does this ever happen?
// theyy shouldn't share.
// they shouldn't share.
printf ("CanJoinFaces: edge with different contents");
return false;
}
@ -114,7 +108,8 @@ CanJoinFaces (face_t * f, face_t * f2)
}
}
} else {
if (bsp->numsurfedges - firstedge + f2->numpoints > MAX_EDGES_IN_REGION)
if (bsp->numsurfedges - firstedge + f2->numpoints
> MAX_EDGES_IN_REGION)
return false; // a huge water or sky polygon
}
@ -122,18 +117,11 @@ CanJoinFaces (face_t * f, face_t * f2)
return true;
}
/*
==============
RecursiveGrowRegion
==============
*/
void
RecursiveGrowRegion (dface_t *r, face_t * f)
RecursiveGrowRegion (dface_t *r, face_t *f)
{
int e;
face_t *f2;
int i;
int e, i;
if (f->outputnumber == bsp->numfaces)
return;
@ -175,8 +163,8 @@ RecursiveGrowRegion (dface_t *r, face_t * f)
void
PrintDface (int f)
{ // for debugging
dface_t *df;
dedge_t *e;
dface_t *df;
int i, n;
df = &bsp->faces[f];
@ -193,9 +181,9 @@ PrintDface (int f)
void
FindVertexUse (int v)
{ // for debugging
int i, j, n;
dface_t *df;
dedge_t *e;
dface_t *df;
int i, j, n;
for (i = firstmodelface; i < bsp->numfaces; i++) {
df = &bsp->faces[i];
@ -213,8 +201,8 @@ FindVertexUse (int v)
void
FindEdgeUse (int v)
{ // for debugging
int i, j, n;
dface_t *df;
int i, j, n;
for (i = firstmodelface; i < bsp->numfaces; i++) {
df = &bsp->faces[i];
@ -228,6 +216,8 @@ FindEdgeUse (int v)
}
}
int edgemapping[MAX_MAP_EDGES];
/*
================
HealEdges
@ -236,16 +226,15 @@ Extends e1 so that it goes all the way to e2, and removes all references
to e2
================
*/
int edgemapping[MAX_MAP_EDGES];
void
HealEdges (int e1, int e2)
{
int i, j, n, saved;
dface_t *df;
dedge_t *ed, *ed2;
vec3_t v1, v2;
dface_t *found[2];
int saved, i, j, n;
int foundj[2];
dedge_t *ed, *ed2;
dface_t *df;
dface_t *found[2];
vec3_t v1, v2;
return;
e1 = edgemapping[e1];
@ -318,17 +307,11 @@ typedef struct {
checkpoint_t checkpoints[MAX_MAP_VERTS];
/*
==============
RemoveColinearEdges
==============
*/
void
RemoveColinearEdges (void)
{
int i, j, v;
int c0, c1, c2, c3;
checkpoint_t *cp;
int c0, c1, c2, c3, i, j, v;
// no edges remapped yet
for (i = 0; i < bsp->numedges; i++)
@ -371,23 +354,17 @@ RemoveColinearEdges (void)
}
}
// qprintf ("%5i c0\n", c0);
// qprintf ("%5i c1\n", c1);
// qprintf ("%5i c2\n", c2);
// qprintf ("%5i c3+\n", c3);
// qprintf ("%5i c0\n", c0);
// qprintf ("%5i c1\n", c1);
// qprintf ("%5i c2\n", c2);
// qprintf ("%5i c3+\n", c3);
qprintf ("%5i deges removed by tjunction healing\n", c2);
}
/*
==============
CountRealNumbers
==============
*/
void
CountRealNumbers (void)
{
int i;
int c;
int c, i;
qprintf ("%5i regions\n", bsp->numfaces - firstmodelface);
@ -406,11 +383,6 @@ CountRealNumbers (void)
//=============================================================================
/*
==============
GrowNodeRegion_r
==============
*/
void
GrowNodeRegion_r (node_t * node)
{
@ -424,11 +396,10 @@ GrowNodeRegion_r (node_t * node)
node->firstface = bsp->numfaces;
for (f = node->faces; f; f = f->next) {
// if (f->outputnumber != -1)
// continue; // allready grown into an earlier region
// if (f->outputnumber != -1)
// continue; // allready grown into an earlier region
// emit a region
if (bsp->numfaces == MAX_MAP_FACES)
Sys_Error ("MAX_MAP_FACES");
f->outputnumber = bsp->numfaces;
@ -442,7 +413,6 @@ GrowNodeRegion_r (node_t * node)
r->lightofs = -1;
// add the face and mergable neighbors to it
#if 0
ClearRegionSize ();
AddFaceToRegionSize (f);
@ -467,26 +437,19 @@ GrowNodeRegion_r (node_t * node)
GrowNodeRegion_r (node->children[1]);
}
/*
==============
GrowNodeRegions
==============
*/
void
GrowNodeRegions (node_t * headnode)
GrowNodeRegions (node_t *headnode)
{
qprintf ("---- GrowRegions ----\n");
GrowNodeRegion_r (headnode);
//RemoveColinearEdges ();
// RemoveColinearEdges ();
CountRealNumbers ();
}
/*
===============================================================================
Turn the faces on a plane into optimal non-convex regions
The edges may still be split later as a result of tjunctions
@ -496,12 +459,10 @@ typedef struct
vec3_t origin;
vec3_t p[2];
}
for all faces
for all edges
for all edges so far
if overlap
split
===============================================================================
*/

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// solidbsp.c
@ -36,7 +37,6 @@ int c_solid, c_empty, c_water;
qboolean usemidsplit;
//============================================================================
/*
==================
@ -46,14 +46,12 @@ For BSP hueristic
==================
*/
int
FaceSide (face_t * in, plane_t *split)
FaceSide (face_t *in, plane_t *split)
{
int frontcount, backcount;
int frontcount, backcount, i;
vec_t dot;
int i;
vec_t *p;
frontcount = backcount = 0;
// axial planes are fast
@ -101,16 +99,14 @@ The clipping hull BSP doesn't worry about avoiding splits
==================
*/
surface_t *
ChooseMidPlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs)
ChooseMidPlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs)
{
int j, l;
plane_t *plane;
surface_t *p, *bestsurface;
vec_t bestvalue, value, dist;
plane_t *plane;
//
// pick the plane that splits the least
//
bestvalue = 6 * 8192 * 8192;
bestsurface = NULL;
@ -125,9 +121,7 @@ ChooseMidPlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs)
if (l > PLANE_Z)
continue;
//
// calculate the split metric along axis l, smaller values are better
//
value = 0;
dist = plane->dist * plane->normal[l];
@ -142,9 +136,7 @@ ChooseMidPlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs)
if (value > bestvalue)
continue;
//
// currently the best!
//
bestvalue = value;
bestsurface = p;
}
@ -159,8 +151,6 @@ ChooseMidPlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs)
return bestsurface;
}
/*
==================
ChoosePlaneFromList
@ -169,18 +159,16 @@ The real BSP hueristic
==================
*/
surface_t *
ChoosePlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs,
ChoosePlaneFromList (surface_t *surfaces, vec3_t mins, vec3_t maxs,
qboolean usefloors)
{
face_t *f;
int j, k, l;
plane_t *plane;
surface_t *p, *p2, *bestsurface;
vec_t bestvalue, bestdistribution, value, dist;
plane_t *plane;
face_t *f;
//
// pick the plane that splits the least
//
bestvalue = 99999;
bestsurface = NULL;
bestdistribution = 9e30;
@ -224,10 +212,7 @@ ChoosePlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs,
l = plane->type;
if (l <= PLANE_Z) { // axial aligned
//
//
// calculate the split metric along axis l
//
value = 0;
for (j = 0; j < 3; j++) {
@ -243,20 +228,15 @@ ChoosePlaneFromList (surface_t * surfaces, vec3_t mins, vec3_t maxs,
continue;
bestdistribution = value;
}
//
// currently the best!
//
bestvalue = k;
bestsurface = p;
}
}
return bestsurface;
}
/*
==================
SelectPartition
@ -266,15 +246,13 @@ returns NULL if the surface list can not be divided any more (a leaf)
==================
*/
surface_t *
SelectPartition (surface_t * surfaces)
SelectPartition (surface_t *surfaces)
{
int i, j;
vec3_t mins, maxs;
surface_t *p, *bestsurface;
vec3_t mins, maxs;
//
// count onnode surfaces
//
i = 0;
bestsurface = NULL;
for (p = surfaces; p; p = p->next)
@ -289,9 +267,7 @@ SelectPartition (surface_t * surfaces)
if (i == 1)
return bestsurface; // this is a final split
//
// calculate a bounding box of the entire surfaceset
//
for (i = 0; i < 3; i++) {
mins[i] = 99999;
maxs[i] = -99999;
@ -329,15 +305,13 @@ Calculates the bounding box
void
CalcSurfaceInfo (surface_t * surf)
{
int i, j;
face_t *f;
int i, j;
if (!surf->faces)
Sys_Error ("CalcSurfaceInfo: surface without a face");
//
// calculate a bounding box
//
for (i = 0; i < 3; i++) {
surf->mins[i] = 99999;
surf->maxs[i] = -99999;
@ -356,22 +330,15 @@ CalcSurfaceInfo (surface_t * surf)
}
}
/*
==================
DividePlane
==================
*/
void
DividePlane (surface_t * in, plane_t *split, surface_t ** front,
surface_t ** back)
DividePlane (surface_t *in, plane_t *split, surface_t **front,
surface_t **back)
{
face_t *facet, *next;
face_t *frontlist, *backlist;
face_t *frontfrag, *backfrag;
surface_t *news;
plane_t *inplane;
surface_t *news;
inplane = &planes[in->planenum];
@ -438,14 +405,12 @@ DividePlane (surface_t * in, plane_t *split, surface_t ** front,
}
// if nothing actually got split, just move the in plane
if (frontlist == NULL) {
*front = NULL;
*back = in;
in->faces = backlist;
return;
}
if (backlist == NULL) {
*front = in;
*back = NULL;
@ -467,13 +432,8 @@ DividePlane (surface_t * in, plane_t *split, surface_t ** front,
CalcSurfaceInfo (in);
}
/*
==================
DivideNodeBounds
==================
*/
void
DivideNodeBounds (node_t * node, plane_t *split)
DivideNodeBounds (node_t *node, plane_t *split)
{
VectorCopy (node->mins, node->children[0]->mins);
VectorCopy (node->mins, node->children[1]->mins);
@ -497,11 +457,11 @@ original faces that have some fragment inside this leaf
==================
*/
void
LinkConvexFaces (surface_t * planelist, node_t * leafnode)
LinkConvexFaces (surface_t *planelist, node_t *leafnode)
{
face_t *f, *next;
surface_t *surf, *pnext;
int i, count;
surface_t *surf, *pnext;
leafnode->faces = NULL;
leafnode->contents = 0;
@ -538,9 +498,7 @@ LinkConvexFaces (surface_t * planelist, node_t * leafnode)
Sys_Error ("LinkConvexFaces: bad contents number");
}
//
// write the list of faces, and free the originals
//
leaffaces += count;
leafnode->markfaces = malloc (sizeof (face_t *) * (count + 1));
i = 0;
@ -557,7 +515,6 @@ LinkConvexFaces (surface_t * planelist, node_t * leafnode)
leafnode->markfaces[i] = NULL; // sentinal
}
/*
==================
LinkNodeFaces
@ -566,14 +523,12 @@ Returns a duplicated list of all faces on surface
==================
*/
face_t *
LinkNodeFaces (surface_t * surface)
LinkNodeFaces (surface_t *surface)
{
face_t *f, *new, **prevptr;
face_t *list;
face_t *list, *new, **prevptr, *f;
list = NULL;
// subdivide
prevptr = &surface->faces;
while (1) {
@ -598,14 +553,8 @@ LinkNodeFaces (surface_t * surface)
return list;
}
/*
==================
PartitionSurfaces
==================
*/
void
PartitionSurfaces (surface_t * surfaces, node_t * node)
PartitionSurfaces (surface_t *surfaces, node_t *node)
{
surface_t *split, *p, *next;
surface_t *frontlist, *backlist;
@ -629,10 +578,7 @@ PartitionSurfaces (surface_t * surfaces, node_t * node)
DivideNodeBounds (node, splitplane);
//
// multiple surfaces, so split all the polysurfaces into front and back lists
//
frontlist = NULL;
backlist = NULL;
@ -642,8 +588,8 @@ PartitionSurfaces (surface_t * surfaces, node_t * node)
if (frontfrag && backfrag) {
// the plane was split, which may expose oportunities to merge
// adjacent faces into a single face
// MergePlaneFaces (frontfrag);
// MergePlaneFaces (backfrag);
// MergePlaneFaces (frontfrag);
// MergePlaneFaces (backfrag);
}
if (frontfrag) {
@ -664,13 +610,8 @@ PartitionSurfaces (surface_t * surfaces, node_t * node)
PartitionSurfaces (backlist, node->children[1]);
}
/*
==================
DrawSurface
==================
*/
void
DrawSurface (surface_t * surf)
DrawSurface (surface_t *surf)
{
face_t *f;
@ -678,13 +619,8 @@ DrawSurface (surface_t * surf)
Draw_DrawFace (f);
}
/*
==================
DrawSurfaceList
==================
*/
void
DrawSurfaceList (surface_t * surf)
DrawSurfaceList (surface_t *surf)
{
Draw_ClearWindow ();
while (surf) {
@ -693,13 +629,8 @@ DrawSurfaceList (surface_t * surf)
}
}
/*
==================
SolidBSP
==================
*/
node_t *
SolidBSP (surface_t * surfhead, qboolean midsplit)
SolidBSP (surface_t *surfhead, qboolean midsplit)
{
int i;
node_t *headnode;
@ -709,17 +640,13 @@ SolidBSP (surface_t * surfhead, qboolean midsplit)
headnode = AllocNode ();
usemidsplit = midsplit;
//
// 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
//
Draw_ClearWindow ();
splitnodes = 0;
leaffaces = 0;

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// divide.h
@ -28,16 +29,13 @@
#include "bsp5.h"
surface_t newcopy_t;
/*
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;
@ -50,14 +48,14 @@ piece off and insert the remainder in the next link
===============
*/
void
SubdivideFace (face_t * f, face_t ** prevptr)
SubdivideFace (face_t *f, face_t **prevptr)
{
face_t *front, *back, *next;
float mins, maxs;
vec_t v;
int axis, i;
plane_t plane;
face_t *front, *back, *next;
texinfo_t *tex;
vec_t v;
// special (non-surface cached) faces don't need subdivision
tex = &bsp->texinfo[f->texturenum];
@ -101,17 +99,11 @@ SubdivideFace (face_t * f, face_t ** prevptr)
}
}
/*
================
SubdivideFaces
================
*/
void
SubdivideFaces (surface_t * surfhead)
SubdivideFaces (surface_t *surfhead)
{
surface_t *surf;
face_t *f, **prevptr;
surface_t *surf;
qprintf ("--- SubdivideFaces ---\n");
@ -133,26 +125,21 @@ SubdivideFaces (surface_t * surfhead)
}
/*
=============================================================================
GatherNodeFaces
Frees the current node tree and returns a new chain of the surfaces that
have inside faces.
=============================================================================
*/
void
GatherNodeFaces_r (node_t * node)
GatherNodeFaces_r (node_t *node)
{
face_t *f, *next;
face_t *next, *f;
if (node->planenum != PLANENUM_LEAF) {
//
// decision node
//
for (f = node->faces; f; f = next) {
next = f->next;
if (!f->numpoints) { // face was removed outside
@ -168,21 +155,13 @@ GatherNodeFaces_r (node_t * node)
free (node);
} else {
//
// leaf node
//
free (node);
}
}
/*
================
GatherNodeFaces
================
*/
surface_t *
GatherNodeFaces (node_t * headnode)
GatherNodeFaces (node_t *headnode)
{
memset (validfaces, 0, sizeof (validfaces));
GatherNodeFaces_r (headnode);
@ -222,11 +201,10 @@ static vec3_t hash_min, hash_scale;
static void
InitHash (void)
{
vec3_t size;
vec_t volume;
vec_t scale;
int newsize[2];
int i;
int newsize[2];
vec3_t size;
vec_t scale, volume;
memset (hashverts, 0, sizeof (hashverts));
@ -261,18 +239,11 @@ HashVec (vec3_t vec)
return h;
}
/*
=============
GetVertex
=============
*/
int
GetVertex (vec3_t in, int planenum)
{
int h;
int i;
hashvert_t *hv;
int h, i;
vec3_t vert;
for (i = 0; i < 3; i++) {
@ -290,10 +261,10 @@ GetVertex (vec3_t in, int planenum)
&& fabs (hv->point[2] - vert[2]) < POINT_EPSILON) {
hv->numedges++;
if (hv->numplanes == 3)
return hv->num; // allready known to be a corner
return hv->num; // already known to be a corner
for (i = 0; i < hv->numplanes; i++)
if (hv->planenums[i] == planenum)
return hv->num; // allready know this plane
return hv->num; // already know this plane
if (hv->numplanes == 2)
c_cornerverts++;
else
@ -329,6 +300,7 @@ GetVertex (vec3_t in, int planenum)
//===========================================================================
int c_tryedges;
/*
==================
@ -337,14 +309,11 @@ GetEdge
Don't allow four way edges
==================
*/
int c_tryedges;
int
GetEdge (vec3_t p1, vec3_t p2, face_t * f)
GetEdge (vec3_t p1, vec3_t p2, face_t *f)
{
int v1, v2;
dedge_t *edge;
int i;
int v1, v2, i;
if (!f->contents[0])
Sys_Error ("GetEdge: 0 contents");
@ -374,14 +343,8 @@ GetEdge (vec3_t p1, vec3_t p2, face_t * f)
return i;
}
/*
==================
FindFaceEdges
==================
*/
void
FindFaceEdges (face_t * face)
FindFaceEdges (face_t *face)
{
int i;
@ -403,8 +366,8 @@ CheckVertexes
void
CheckVertexes (void)
{
int cb, c0, c1, c2, c3;
hashvert_t *hv;
int cb, c0, c1, c2, c3;
cb = c0 = c1 = c2 = c3 = 0;
for (hv = hvertex; hv != hvert_p; hv++) {
@ -437,25 +400,22 @@ void
CheckEdges (void)
{
dedge_t *edge;
int i;
dvertex_t *d1, *d2;
face_t *f1, *f2;
int c_nonconvex;
int c_multitexture;
int c_multitexture, c_nonconvex, i;
c_nonconvex = c_multitexture = 0;
// CheckVertexes ();
// CheckVertexes ();
for (i = 1; i < bsp->numedges; i++) {
edge = &bsp->edges[i];
if (!edgefaces[i][1]) {
d1 = &bsp->vertexes[edge->v[0]];
d2 = &bsp->vertexes[edge->v[1]];
qprintf
("unshared edge at: (%8.2f, %8.2f, %8.2f) (%8.2f, %8.2f, %8.2f)\n",
d1->point[0], d1->point[1], d1->point[2], d2->point[0],
d2->point[1], d2->point[2]);
qprintf ("unshared edge at: (%8.2f, %8.2f, %8.2f) (%8.2f, %8.2f, "
"%8.2f)\n", d1->point[0], d1->point[1], d1->point[2],
d2->point[0], d2->point[1], d2->point[2]);
} else {
f1 = edgefaces[i][0];
f2 = edgefaces[i][1];
@ -474,21 +434,15 @@ CheckEdges (void)
}
}
// qprintf ("%5i edges\n", i);
// qprintf ("%5i c_nonconvex\n", c_nonconvex);
// qprintf ("%5i c_multitexture\n", c_multitexture);
// qprintf ("%5i edges\n", i);
// qprintf ("%5i c_nonconvex\n", c_nonconvex);
// qprintf ("%5i c_multitexture\n", c_multitexture);
// CheckVertexes ();
// CheckVertexes ();
}
/*
================
MakeFaceEdges_r
================
*/
void
MakeFaceEdges_r (node_t * node)
MakeFaceEdges_r (node_t *node)
{
face_t *f;
@ -502,13 +456,8 @@ MakeFaceEdges_r (node_t * node)
MakeFaceEdges_r (node->children[1]);
}
/*
================
MakeFaceEdges
================
*/
void
MakeFaceEdges (node_t * headnode)
MakeFaceEdges (node_t *headnode)
{
qprintf ("----- MakeFaceEdges -----\n");
@ -518,7 +467,7 @@ MakeFaceEdges (node_t * headnode)
MakeFaceEdges_r (headnode);
// CheckEdges ();
// CheckEdges ();
GrowNodeRegions (headnode);

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
// tjunc.c
@ -27,7 +28,6 @@
#include "bsp5.h"
typedef struct wvert_s {
vec_t t;
struct wvert_s *prev, *next;
@ -47,13 +47,12 @@ int tjuncfaces;
#define MAXWVERTS 0x20000
#define MAXWEDGES 0x10000
wvert_t wverts[MAXWVERTS];
wedge_t wedges[MAXWEDGES];
void
PrintFace (face_t * f)
PrintFace (face_t *f)
{
int i;
@ -73,10 +72,10 @@ static vec3_t hash_min, hash_scale;
static void
InitHash (vec3_t mins, vec3_t maxs)
{
int newsize[2];
vec3_t size;
vec_t volume;
vec_t scale;
int newsize[2];
VectorCopy (mins, hash_min);
VectorSubtract (maxs, mins, size);
@ -141,11 +140,10 @@ CanonicalVector (vec3_t vec)
wedge_t *
FindEdge (vec3_t p1, vec3_t p2, vec_t *t1, vec_t *t2)
{
vec3_t origin;
vec3_t dir;
wedge_t *w;
vec_t temp;
int h;
vec3_t dir, origin;
vec_t temp;
wedge_t *w;
VectorSubtract (p2, p1, dir);
CanonicalVector (dir);
@ -202,17 +200,10 @@ FindEdge (vec3_t p1, vec3_t p2, vec_t *t1, vec_t *t2)
return w;
}
/*
===============
AddVert
===============
*/
#define T_EPSILON 0.01
void
AddVert (wedge_t * w, vec_t t)
AddVert (wedge_t *w, vec_t t)
{
wvert_t *v, *newv;
@ -239,13 +230,6 @@ AddVert (wedge_t * w, vec_t t)
v->prev = newv;
}
/*
===============
AddEdge
===============
*/
void
AddEdge (vec3_t p1, vec3_t p2)
{
@ -257,14 +241,8 @@ AddEdge (vec3_t p1, vec3_t p2)
AddVert (w, t2);
}
/*
===============
AddFaceEdges
===============
*/
void
AddFaceEdges (face_t * f)
AddFaceEdges (face_t *f)
{
int i, j;
@ -274,7 +252,6 @@ AddFaceEdges (face_t * f)
}
}
//============================================================================
// a specially allocated face that can hold hundreds of edges if needed
@ -286,13 +263,12 @@ void FixFaceEdges (face_t * f);
face_t *newlist;
void
SplitFaceForTjunc (face_t * f, face_t * original)
SplitFaceForTjunc (face_t *f, face_t *original)
{
int i;
face_t *new, *chain;
int firstcorner, lastcorner, i;
vec3_t dir, test;
vec_t v;
int firstcorner, lastcorner;
chain = NULL;
do {
@ -316,29 +292,27 @@ SplitFaceForTjunc (face_t * f, face_t * original)
VectorSubtract (f->pts[lastcorner - 1], f->pts[lastcorner], test);
VectorNormalize (test);
v = DotProduct (test, dir);
if (v < 0.9999 || v > 1.00001) {
if (v < 0.9999 || v > 1.00001)
break;
}
}
// find the first corner
VectorSubtract (f->pts[1], f->pts[0], dir);
VectorNormalize (dir);
for (firstcorner = 1; firstcorner < f->numpoints - 1; firstcorner++) {
VectorSubtract (f->pts[firstcorner + 1], f->pts[firstcorner], test);
VectorSubtract (f->pts[firstcorner + 1], f->pts[firstcorner],
test);
VectorNormalize (test);
v = DotProduct (test, dir);
if (v < 0.9999 || v > 1.00001) {
if (v < 0.9999 || v > 1.00001)
break;
}
}
if (firstcorner + 2 >= MAXPOINTS) {
// rotate the point winding
VectorCopy (f->pts[0], test);
for (i = 1; i < f->numpoints; i++) {
for (i = 1; i < f->numpoints; i++)
VectorCopy (f->pts[i], f->pts[i - 1]);
}
VectorCopy (test, f->pts[f->numpoints - 1]);
goto restart;
}
@ -362,33 +336,22 @@ SplitFaceForTjunc (face_t * f, face_t * original)
else
new->numpoints = MAXPOINTS;
for (i = 0; i < new->numpoints; i++) {
for (i = 0; i < new->numpoints; i++)
VectorCopy (f->pts[i], new->pts[i]);
}
for (i = new->numpoints - 1; i < f->numpoints; i++) {
for (i = new->numpoints - 1; i < f->numpoints; i++)
VectorCopy (f->pts[i], f->pts[i - (new->numpoints - 2)]);
}
f->numpoints -= (new->numpoints - 2);
} while (1);
}
/*
===============
FixFaceEdges
===============
*/
void
FixFaceEdges (face_t * f)
FixFaceEdges (face_t *f)
{
int i, j, k;
vec_t t1, t2;
wedge_t *w;
wvert_t *v;
vec_t t1, t2;
*superface = *f;
@ -423,14 +386,12 @@ FixFaceEdges (face_t * f)
// the face needs to be split into multiple faces because of too many edges
SplitFaceForTjunc (superface, f);
}
//============================================================================
void
tjunc_find_r (node_t * node)
tjunc_find_r (node_t *node)
{
face_t *f;
@ -445,9 +406,9 @@ tjunc_find_r (node_t * node)
}
void
tjunc_fix_r (node_t * node)
tjunc_fix_r (node_t *node)
{
face_t *f, *next;
face_t *next, *f;
if (node->planenum == PLANENUM_LEAF)
return;
@ -465,26 +426,18 @@ tjunc_fix_r (node_t * node)
tjunc_fix_r (node->children[1]);
}
/*
===========
tjunc
===========
*/
void
tjunc (node_t * headnode)
tjunc (node_t *headnode)
{
vec3_t maxs, mins;
int i;
vec3_t maxs, mins;
qprintf ("---- tjunc ----\n");
if (notjunc)
return;
//
// identify all points on common edges
//
// origin points won't allways be inside the map, so extend the hash area
for (i = 0; i < 3; i++) {
@ -503,9 +456,7 @@ tjunc (node_t * headnode)
qprintf ("%i world edges %i edge points\n", numwedges, numwverts);
//
// add extra vertexes on edges where needed
//
tjuncs = tjuncfaces = 0;
tjunc_fix_r (headnode);

View file

@ -1,20 +1,21 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
See file, 'COPYING', for details.
*/
#ifdef HAVE_CONFIG_H
@ -34,11 +35,9 @@
#include "bsp5.h"
int headclipnode;
int firstface;
//===========================================================================
/*
==================
@ -50,8 +49,8 @@ Used to find plane index numbers for clip nodes read from child processes
int
FindFinalPlane (dplane_t *p)
{
int i;
dplane_t *dplane;
int i;
for (i = 0, dplane = bsp->planes; i < bsp->numplanes; i++, dplane++) {
if (p->type != dplane->type)
@ -67,9 +66,7 @@ FindFinalPlane (dplane_t *p)
return i;
}
//
// new plane
//
if (bsp->numplanes == MAX_MAP_PLANES)
Sys_Error ("numplanes == MAX_MAP_PLANES");
dplane = &bsp->planes[bsp->numplanes];
@ -79,15 +76,13 @@ FindFinalPlane (dplane_t *p)
return bsp->numplanes - 1;
}
int planemapping[MAX_MAP_PLANES];
void
WriteNodePlanes_r (node_t * node)
WriteNodePlanes_r (node_t *node)
{
plane_t *plane;
dplane_t *dplane;
plane_t *plane;
if (node->planenum == -1)
return;
@ -113,14 +108,8 @@ WriteNodePlanes_r (node_t * node)
WriteNodePlanes_r (node->children[1]);
}
/*
==================
WriteNodePlanes
==================
*/
void
WriteNodePlanes (node_t * nodes)
WriteNodePlanes (node_t *nodes)
{
memset (planemapping, -1, sizeof (planemapping));
WriteNodePlanes_r (nodes);
@ -128,18 +117,11 @@ WriteNodePlanes (node_t * nodes)
//===========================================================================
/*
==================
WriteClipNodes_r
==================
*/
int
WriteClipNodes_r (node_t * node)
WriteClipNodes_r (node_t *node)
{
int i, c;
dclipnode_t *cn;
int num;
int num, c, i;
// FIXME: free more stuff?
if (node->planenum == -1) {
@ -168,7 +150,7 @@ representation and frees the original memory.
==================
*/
void
WriteClipNodes (node_t * nodes)
WriteClipNodes (node_t *nodes)
{
headclipnode = bsp->numclipnodes;
WriteClipNodes_r (nodes);
@ -176,16 +158,11 @@ WriteClipNodes (node_t * nodes)
//===========================================================================
/*
==================
WriteLeaf
==================
*/
void
WriteLeaf (node_t * node)
WriteLeaf (node_t *node)
{
face_t **fp, *f;
dleaf_t *leaf_p;
face_t **fp, *f;
// emit a leaf
leaf_p = &bsp->leafs[bsp->numleafs];
@ -193,17 +170,13 @@ WriteLeaf (node_t * node)
leaf_p->contents = node->contents;
//
// 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
//
leaf_p->firstmarksurface = bsp->nummarksurfaces;
for (fp = node->markfaces; *fp; fp++) {
@ -221,14 +194,8 @@ WriteLeaf (node_t * node)
leaf_p->nummarksurfaces = bsp->nummarksurfaces - leaf_p->firstmarksurface;
}
/*
==================
WriteDrawNodes_r
==================
*/
void
WriteDrawNodes_r (node_t * node)
WriteDrawNodes_r (node_t *node)
{
dnode_t *n;
int i;
@ -246,10 +213,7 @@ WriteDrawNodes_r (node_t * node)
n->firstface = node->firstface;
n->numfaces = node->numfaces;
//
// recursively output the other nodes
//
for (i = 0; i < 2; i++) {
if (node->children[i]->planenum == -1) {
if (node->children[i]->contents == CONTENTS_SOLID)
@ -265,17 +229,11 @@ WriteDrawNodes_r (node_t * node)
}
}
/*
==================
WriteDrawNodes
==================
*/
void
WriteDrawNodes (node_t * headnode)
WriteDrawNodes (node_t *headnode)
{
int i;
int start;
dmodel_t *bm;
int start, i;
#if 0
if (headnode->contents < 0)
@ -302,14 +260,12 @@ WriteDrawNodes (node_t * headnode)
bm->visleafs = bsp->numleafs - start;
for (i = 0; i < 3; i++) {
bm->mins[i] = headnode->mins[i] + SIDESPACE + 1; // remove the
// padding
bm->mins[i] = headnode->mins[i] + SIDESPACE + 1; // remove the padding
bm->maxs[i] = headnode->maxs[i] - SIDESPACE - 1;
}
// FIXME: are all the children decendant of padded nodes?
}
/*
==================
BumpModel
@ -370,12 +326,6 @@ CleanupName (char *in, char *out)
out[i] = 0;
}
/*
=================
TEX_InitFromWad
=================
*/
void
TEX_InitFromWad (char *path)
{
@ -398,16 +348,11 @@ TEX_InitFromWad (char *path)
}
}
/*
==================
LoadLump
==================
*/
int
LoadLump (char *name, byte * dest)
LoadLump (char *name, byte *dest)
{
int i;
char cname[16];
int i;
CleanupName (name, cname);
@ -423,17 +368,10 @@ LoadLump (char *name, byte * dest)
return 0;
}
/*
==================
AddAnimatingTextures
==================
*/
void
AddAnimatingTextures (void)
{
int base;
int i, j, k;
int base, i, j, k;
char name[32];
base = nummiptex;
@ -449,7 +387,6 @@ AddAnimatingTextures (void)
else
name[1] = 'A' + j - 10; // alternate animation
// see if this name exists in the wadfile
for (k = 0; k < wadinfo.numlumps; k++)
if (!strcmp (name, lumpinfo[k].name)) {
@ -462,19 +399,14 @@ AddAnimatingTextures (void)
printf ("added %i texture frames\n", nummiptex - base);
}
/*
==================
WriteMiptex
==================
*/
void
WriteMiptex (void)
{
int i, len;
byte *data;
dmiptexlump_t *l;
char *path;
char fullpath[1024];
dmiptexlump_t *l;
int i, len;
path = ValueForKey (&entities[0], "_wad");
if (!path || !path[0]) {
@ -510,12 +442,6 @@ WriteMiptex (void)
//===========================================================================
/*
==================
BeginBSPFile
==================
*/
void
BeginBSPFile (void)
{
@ -529,12 +455,6 @@ BeginBSPFile (void)
firstface = 0;
}
/*
==================
FinishBSPFile
==================
*/
void
FinishBSPFile (void)
{
@ -545,7 +465,7 @@ FinishBSPFile (void)
WriteMiptex ();
// XXX PrintBSPFileSizes ();
// XXX PrintBSPFileSizes ();
f = Qopen (bspfilename, "wb");
WriteBSPFile (bsp, f);
Qclose (f);