mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qfbsp] Remove all arbitrary bsp limits
Planes, verts, etc can now all get crazy big.
This commit is contained in:
parent
2e33503c4c
commit
60d23bdc8f
15 changed files with 59 additions and 80 deletions
|
@ -31,6 +31,8 @@
|
||||||
#ifndef __QF_darray_h
|
#ifndef __QF_darray_h
|
||||||
#define __QF_darray_h
|
#define __QF_darray_h
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
/** \defgroup darray Dynamic Arrays
|
/** \defgroup darray Dynamic Arrays
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#ifndef qfbsp_brush_h
|
#ifndef qfbsp_brush_h
|
||||||
#define qfbsp_brush_h
|
#define qfbsp_brush_h
|
||||||
|
|
||||||
|
#include "QF/darray.h"
|
||||||
#include "QF/mathlib.h"
|
#include "QF/mathlib.h"
|
||||||
|
|
||||||
#include "bsp5.h"
|
#include "bsp5.h"
|
||||||
|
@ -48,8 +49,8 @@ typedef struct brushset_s {
|
||||||
brush_t *brushes; // NULL terminated list
|
brush_t *brushes; // NULL terminated list
|
||||||
} brushset_t;
|
} brushset_t;
|
||||||
|
|
||||||
extern int numbrushplanes;
|
typedef struct DARRAY_TYPE (plane_t) planeset_t;
|
||||||
extern plane_t planes[MAX_MAP_PLANES];
|
extern planeset_t planes;
|
||||||
|
|
||||||
/** Allocate a new brush.
|
/** Allocate a new brush.
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define qfbsp_csg4_h
|
#define qfbsp_csg4_h
|
||||||
|
|
||||||
#include "QF/bspfile.h"
|
#include "QF/bspfile.h"
|
||||||
|
#include "QF/darray.h"
|
||||||
|
|
||||||
/** \defgroup qfbsp_csg4 CSG Functions
|
/** \defgroup qfbsp_csg4 CSG Functions
|
||||||
\ingroup qfbsp
|
\ingroup qfbsp
|
||||||
|
@ -34,7 +35,8 @@ struct visfacet_s;
|
||||||
struct brushset_s;
|
struct brushset_s;
|
||||||
struct surface_s;
|
struct surface_s;
|
||||||
|
|
||||||
extern struct visfacet_s *validfaces[MAX_MAP_PLANES];
|
typedef struct DARRAY_TYPE (struct visfacet_s *) visfacetset_t;
|
||||||
|
extern visfacetset_t validfaces;
|
||||||
|
|
||||||
/** Build the surface lists for the brushset.
|
/** Build the surface lists for the brushset.
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,7 @@
|
||||||
*/
|
*/
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
int numbrushplanes;
|
planeset_t planes = DARRAY_STATIC_INIT (1024);
|
||||||
plane_t planes[MAX_MAP_PLANES];
|
|
||||||
|
|
||||||
int numbrushfaces;
|
int numbrushfaces;
|
||||||
mface_t faces[MAX_FACES]; // beveled clipping hull can generate many extra
|
mface_t faces[MAX_FACES]; // beveled clipping hull can generate many extra
|
||||||
|
@ -78,7 +77,7 @@ CheckFace (const face_t *f)
|
||||||
if (f->points->numpoints < 3)
|
if (f->points->numpoints < 3)
|
||||||
Sys_Error ("CheckFace: %i points", f->points->numpoints);
|
Sys_Error ("CheckFace: %i points", f->points->numpoints);
|
||||||
|
|
||||||
VectorCopy (planes[f->planenum].normal, facenormal);
|
VectorCopy (planes.a[f->planenum].normal, facenormal);
|
||||||
if (f->planeside)
|
if (f->planeside)
|
||||||
VectorNegate (facenormal, facenormal);
|
VectorNegate (facenormal, facenormal);
|
||||||
|
|
||||||
|
@ -92,14 +91,14 @@ CheckFace (const face_t *f)
|
||||||
j = i + 1 == f->points->numpoints ? 0 : i + 1;
|
j = i + 1 == f->points->numpoints ? 0 : i + 1;
|
||||||
|
|
||||||
// check the point is on the face plane
|
// check the point is on the face plane
|
||||||
d = PlaneDiff (p1, &planes[f->planenum]);
|
d = PlaneDiff (p1, &planes.a[f->planenum]);
|
||||||
|
|
||||||
// point off plane autofix
|
// point off plane autofix
|
||||||
if (d < -ON_EPSILON || d > ON_EPSILON)
|
if (d < -ON_EPSILON || d > ON_EPSILON)
|
||||||
if (options.verbosity > 1)
|
if (options.verbosity > 1)
|
||||||
printf ("CheckFace: point off plane: %g @ (%g %g %g)\n", d,
|
printf ("CheckFace: point off plane: %g @ (%g %g %g)\n", d,
|
||||||
p1[0], p1[1], p1[2]);
|
p1[0], p1[1], p1[2]);
|
||||||
VectorMultSub (p1, d, planes[f->planenum].normal, p1);
|
VectorMultSub (p1, d, planes.a[f->planenum].normal, p1);
|
||||||
|
|
||||||
// check the edge isn't degenerate
|
// check the edge isn't degenerate
|
||||||
p2 = f->points->points[j];
|
p2 = f->points->points[j];
|
||||||
|
@ -257,7 +256,6 @@ NormalizePlane (plane_t *dp)
|
||||||
int
|
int
|
||||||
FindPlane (const plane_t *dplane, int *side)
|
FindPlane (const plane_t *dplane, int *side)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
plane_t *dp, pl;
|
plane_t *dp, pl;
|
||||||
vec_t dot;
|
vec_t dot;
|
||||||
|
|
||||||
|
@ -272,8 +270,8 @@ FindPlane (const plane_t *dplane, int *side)
|
||||||
else
|
else
|
||||||
*side = 1;
|
*side = 1;
|
||||||
|
|
||||||
dp = planes;
|
dp = planes.a;
|
||||||
for (i = 0; i < numbrushplanes; i++, dp++) {
|
for (size_t i = 0; i < planes.size; i++, dp++) {
|
||||||
dot = DotProduct (dp->normal, pl.normal);
|
dot = DotProduct (dp->normal, pl.normal);
|
||||||
if (dot > 1.0 - ANGLEEPSILON
|
if (dot > 1.0 - ANGLEEPSILON
|
||||||
&& fabs(dp->dist - pl.dist) < DISTEPSILON) { // regular match
|
&& fabs(dp->dist - pl.dist) < DISTEPSILON) { // regular match
|
||||||
|
@ -281,14 +279,9 @@ FindPlane (const plane_t *dplane, int *side)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numbrushplanes == MAX_MAP_PLANES)
|
DARRAY_APPEND (&planes, pl);
|
||||||
Sys_Error ("numbrushplanes == MAX_MAP_PLANES");
|
|
||||||
|
|
||||||
planes[numbrushplanes] = pl;
|
return planes.size - 1;
|
||||||
|
|
||||||
numbrushplanes++;
|
|
||||||
|
|
||||||
return numbrushplanes - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
tjunction
|
tjunction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
face_t *validfaces[MAX_MAP_PLANES];
|
visfacetset_t validfaces = DARRAY_STATIC_INIT (1024);
|
||||||
face_t *inside, *outside;
|
face_t *inside, *outside;
|
||||||
int brushfaces;
|
int brushfaces;
|
||||||
int csgfaces;
|
int csgfaces;
|
||||||
|
@ -134,7 +134,7 @@ ClipInside (int splitplane, int frontside, qboolean precedence)
|
||||||
face_t *frags[2];
|
face_t *frags[2];
|
||||||
plane_t *split;
|
plane_t *split;
|
||||||
|
|
||||||
split = &planes[splitplane];
|
split = &planes.a[splitplane];
|
||||||
|
|
||||||
insidelist = NULL;
|
insidelist = NULL;
|
||||||
for (f = inside; f; f = next) {
|
for (f = inside; f; f = next) {
|
||||||
|
@ -195,12 +195,12 @@ SaveOutside (qboolean mirror)
|
||||||
newf->contents[0] = f->contents[1];
|
newf->contents[0] = f->contents[1];
|
||||||
newf->contents[1] = f->contents[0];
|
newf->contents[1] = f->contents[0];
|
||||||
|
|
||||||
validfaces[planenum] = MergeFaceToList (newf,
|
validfaces.a[planenum] = MergeFaceToList (newf,
|
||||||
validfaces[planenum]);
|
validfaces.a[planenum]);
|
||||||
}
|
}
|
||||||
|
|
||||||
validfaces[planenum] = MergeFaceToList (f, validfaces[planenum]);
|
validfaces.a[planenum] = MergeFaceToList (f, validfaces.a[planenum]);
|
||||||
validfaces[planenum] = FreeMergeListScraps (validfaces[planenum]);
|
validfaces.a[planenum] = FreeMergeListScraps (validfaces.a[planenum]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,13 +234,12 @@ BuildSurfaces (void)
|
||||||
{
|
{
|
||||||
face_t *count;
|
face_t *count;
|
||||||
face_t **f;
|
face_t **f;
|
||||||
int i;
|
|
||||||
surface_t *surfhead, *s;
|
surface_t *surfhead, *s;
|
||||||
|
|
||||||
surfhead = NULL;
|
surfhead = NULL;
|
||||||
|
|
||||||
f = validfaces;
|
f = validfaces.a;
|
||||||
for (i = 0; i < numbrushplanes; i++, f++) {
|
for (size_t i = 0; i < planes.size; i++, f++) {
|
||||||
if (!*f)
|
if (!*f)
|
||||||
continue; // nothing left on this plane
|
continue; // nothing left on this plane
|
||||||
|
|
||||||
|
@ -304,7 +303,8 @@ CSGFaces (brushset_t *bs)
|
||||||
|
|
||||||
qprintf ("---- CSGFaces ----\n");
|
qprintf ("---- CSGFaces ----\n");
|
||||||
|
|
||||||
memset (validfaces, 0, sizeof (validfaces));
|
DARRAY_RESIZE (&validfaces, planes.size);
|
||||||
|
memset (validfaces.a, 0, validfaces.size * sizeof (validfaces.a[0]));
|
||||||
|
|
||||||
csgfaces = brushfaces = csgmergefaces = 0;
|
csgfaces = brushfaces = csgmergefaces = 0;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ static lumpinfo_t lump_info[] = {
|
||||||
void
|
void
|
||||||
bspinfo ()
|
bspinfo ()
|
||||||
{
|
{
|
||||||
printf ("version: %d\n", bsp->header->version);
|
printf ("version: %x\n", bsp->header->version);
|
||||||
for (int i = 0; i < HEADER_LUMPS; i++) {
|
for (int i = 0; i < HEADER_LUMPS; i++) {
|
||||||
lump_t *lump = &bsp->header->lumps[i];
|
lump_t *lump = &bsp->header->lumps[i];
|
||||||
lumpinfo_t *info = &lump_info[i];
|
lumpinfo_t *info = &lump_info[i];
|
||||||
|
|
|
@ -96,7 +96,7 @@ TryMerge (const face_t *f1, const face_t *f2)
|
||||||
found_edge:
|
found_edge:
|
||||||
// check slope of connected lines
|
// check slope of connected lines
|
||||||
// if the slopes are colinear, the point can be removed
|
// if the slopes are colinear, the point can be removed
|
||||||
plane = &planes[f1->planenum];
|
plane = &planes.a[f1->planenum];
|
||||||
VectorCopy (plane->normal, planenormal);
|
VectorCopy (plane->normal, planenormal);
|
||||||
if (f1->planeside)
|
if (f1->planeside)
|
||||||
VectorNegate (planenormal, planenormal);
|
VectorNegate (planenormal, planenormal);
|
||||||
|
|
|
@ -47,8 +47,8 @@ PointInLeaf (node_t *node, const vec3_t point)
|
||||||
vec_t d;
|
vec_t d;
|
||||||
|
|
||||||
while (!node->contents) {
|
while (!node->contents) {
|
||||||
d = DotProduct (planes[node->planenum].normal, point);
|
d = DotProduct (planes.a[node->planenum].normal, point);
|
||||||
node = node->children[d <= planes[node->planenum].dist];
|
node = node->children[d <= planes.a[node->planenum].dist];
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ CutNodePortals_r (node_t *node)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plane = &planes[node->planenum];
|
plane = &planes.a[node->planenum];
|
||||||
|
|
||||||
f = node->children[0];
|
f = node->children[0];
|
||||||
b = node->children[1];
|
b = node->children[1];
|
||||||
|
@ -281,7 +281,7 @@ CutNodePortals_r (node_t *node)
|
||||||
/// portals on the node.
|
/// portals on the node.
|
||||||
w = BaseWindingForPlane (plane);
|
w = BaseWindingForPlane (plane);
|
||||||
for (p = node->portals; p; p = p->next[side]) {
|
for (p = node->portals; p; p = p->next[side]) {
|
||||||
clipplane = planes[p->planenum]; // copy the plane
|
clipplane = planes.a[p->planenum]; // copy the plane
|
||||||
if (p->nodes[0] == node)
|
if (p->nodes[0] == node)
|
||||||
side = 0;
|
side = 0;
|
||||||
else if (p->nodes[1] == node) {
|
else if (p->nodes[1] == node) {
|
||||||
|
@ -511,7 +511,7 @@ WritePortalFile_r (const node_t *node)
|
||||||
// sometimes planes get turned around when they are very near the
|
// sometimes planes get turned around when they are very near the
|
||||||
// changeover point between different axis. interpret the plane
|
// changeover point between different axis. interpret the plane
|
||||||
// the same way vis will, and flip the side orders if needed
|
// the same way vis will, and flip the side orders if needed
|
||||||
pl = &planes[p->planenum];
|
pl = &planes.a[p->planenum];
|
||||||
PlaneFromWinding (w, &plane2);
|
PlaneFromWinding (w, &plane2);
|
||||||
if (DotProduct (pl->normal, plane2.normal) < 0.99) { // backwards..
|
if (DotProduct (pl->normal, plane2.normal) < 0.99) { // backwards..
|
||||||
fprintf (pf, "%i %i %i ", w->numpoints,
|
fprintf (pf, "%i %i %i ", w->numpoints,
|
||||||
|
|
|
@ -296,8 +296,6 @@ ReadClipHull (int hullnum)
|
||||||
firstclipnode = bsp->numclipnodes;
|
firstclipnode = bsp->numclipnodes;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (bsp->numclipnodes == MAX_MAP_CLIPNODES)
|
|
||||||
Sys_Error ("ReadClipHull: MAX_MAP_CLIPNODES");
|
|
||||||
if (fscanf (f, "%d : %f %f %f %f : %d %d\n", &junk, &f1, &f2, &f3, &f4,
|
if (fscanf (f, "%d : %f %f %f %f : %d %d\n", &junk, &f1, &f2, &f3, &f4,
|
||||||
&c1, &c2) != 7)
|
&c1, &c2) != 7)
|
||||||
Sys_Error ("Error parsing %s", options.hullfile);
|
Sys_Error ("Error parsing %s", options.hullfile);
|
||||||
|
|
|
@ -101,16 +101,17 @@ static void
|
||||||
load_planes (void)
|
load_planes (void)
|
||||||
{
|
{
|
||||||
const dplane_t *p;
|
const dplane_t *p;
|
||||||
|
plane_t tp = { };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset (planes, 0, sizeof (planes));
|
planes.size = 0;
|
||||||
for (i = 0; i < bsp->numplanes; i++) {
|
for (i = 0; i < bsp->numplanes; i++) {
|
||||||
p = bsp->planes + i;
|
p = bsp->planes + i;
|
||||||
VectorCopy (p->normal, planes[i].normal);
|
VectorCopy (p->normal, tp.normal);
|
||||||
planes[i].dist = p->dist;
|
tp.dist = p->dist;
|
||||||
planes[i].type = p->type;
|
tp.type = p->type;
|
||||||
|
DARRAY_APPEND (&planes, tp);
|
||||||
}
|
}
|
||||||
numbrushplanes = bsp->numplanes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -160,13 +160,6 @@ RecursiveGrowRegion (dface_t *r, face_t *f)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int numedges;
|
|
||||||
int edges[2];
|
|
||||||
} checkpoint_t;
|
|
||||||
|
|
||||||
checkpoint_t checkpoints[MAX_MAP_VERTS];
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CountRealNumbers (void)
|
CountRealNumbers (void)
|
||||||
{
|
{
|
||||||
|
@ -207,8 +200,6 @@ GrowNodeRegion_r (node_t * node)
|
||||||
// continue; // allready grown into an earlier region
|
// continue; // allready grown into an earlier region
|
||||||
|
|
||||||
// emit a region
|
// emit a region
|
||||||
if (bsp->numfaces == MAX_MAP_FACES)
|
|
||||||
Sys_Error ("MAX_MAP_FACES");
|
|
||||||
f->outputnumber = bsp->numfaces;
|
f->outputnumber = bsp->numfaces;
|
||||||
|
|
||||||
r.planenum = node->outputplanenum;
|
r.planenum = node->outputplanenum;
|
||||||
|
|
|
@ -138,7 +138,7 @@ ChooseMidPlaneFromList (surface_t *surfaces,
|
||||||
if (p->onnode)
|
if (p->onnode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
plane = &planes[p->planenum];
|
plane = &planes.a[p->planenum];
|
||||||
|
|
||||||
// check for axis aligned surfaces
|
// check for axis aligned surfaces
|
||||||
l = plane->type;
|
l = plane->type;
|
||||||
|
@ -215,7 +215,7 @@ ChoosePlaneFromList (surface_t *surfaces, const vec3_t mins, const vec3_t maxs,
|
||||||
if (!p->has_struct && !usedetail)
|
if (!p->has_struct && !usedetail)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
plane = &planes[p->planenum];
|
plane = &planes.a[p->planenum];
|
||||||
k = 0;
|
k = 0;
|
||||||
|
|
||||||
if (!usefloors && plane->normal[2] == 1)
|
if (!usefloors && plane->normal[2] == 1)
|
||||||
|
@ -393,7 +393,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
|
||||||
|
|
||||||
int have[2][2]; // [front|back][detail|struct]
|
int have[2][2]; // [front|back][detail|struct]
|
||||||
|
|
||||||
inplane = &planes[in->planenum];
|
inplane = &planes.a[in->planenum];
|
||||||
|
|
||||||
// parallel case is easy
|
// parallel case is easy
|
||||||
if (_VectorCompare (inplane->normal, split->normal)) {
|
if (_VectorCompare (inplane->normal, split->normal)) {
|
||||||
|
@ -638,7 +638,7 @@ PartitionSurfaces (surface_t *surfaces, node_t *node)
|
||||||
node->children[1] = AllocNode ();
|
node->children[1] = AllocNode ();
|
||||||
node->planenum = split->planenum;
|
node->planenum = split->planenum;
|
||||||
|
|
||||||
splitplane = &planes[split->planenum];
|
splitplane = &planes.a[split->planenum];
|
||||||
|
|
||||||
// multiple surfaces, so split all the polysurfaces into front and back
|
// multiple surfaces, so split all the polysurfaces into front and back
|
||||||
// lists
|
// lists
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "QF/progs.h" // for PR_RESMAP
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
#include "tools/qfbsp/include/bsp5.h"
|
#include "tools/qfbsp/include/bsp5.h"
|
||||||
|
#include "tools/qfbsp/include/brush.h"
|
||||||
#include "tools/qfbsp/include/csg4.h"
|
#include "tools/qfbsp/include/csg4.h"
|
||||||
#include "tools/qfbsp/include/options.h"
|
#include "tools/qfbsp/include/options.h"
|
||||||
#include "tools/qfbsp/include/region.h"
|
#include "tools/qfbsp/include/region.h"
|
||||||
|
@ -162,8 +164,8 @@ GatherNodeFaces_r (node_t *node)
|
||||||
if (!f->points) { // face was removed outside
|
if (!f->points) { // face was removed outside
|
||||||
FreeFace (f);
|
FreeFace (f);
|
||||||
} else {
|
} else {
|
||||||
f->next = validfaces[f->planenum];
|
f->next = validfaces.a[f->planenum];
|
||||||
validfaces[f->planenum] = f;
|
validfaces.a[f->planenum] = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +182,8 @@ GatherNodeFaces_r (node_t *node)
|
||||||
surface_t *
|
surface_t *
|
||||||
GatherNodeFaces (node_t *headnode)
|
GatherNodeFaces (node_t *headnode)
|
||||||
{
|
{
|
||||||
memset (validfaces, 0, sizeof (validfaces));
|
DARRAY_RESIZE (&validfaces, planes.size);
|
||||||
|
memset (validfaces.a, 0, validfaces.size * sizeof (validfaces.a[0]));
|
||||||
GatherNodeFaces_r (headnode);
|
GatherNodeFaces_r (headnode);
|
||||||
return BuildSurfaces ();
|
return BuildSurfaces ();
|
||||||
}
|
}
|
||||||
|
@ -198,8 +201,7 @@ typedef struct hashvert_s {
|
||||||
|
|
||||||
int c_cornerverts;
|
int c_cornerverts;
|
||||||
|
|
||||||
hashvert_t hvertex[MAX_MAP_VERTS];
|
static PR_RESMAP (hashvert_t) hvertex;
|
||||||
hashvert_t *hvert_p;
|
|
||||||
|
|
||||||
#define EDGEFACE_CHUNK 4096
|
#define EDGEFACE_CHUNK 4096
|
||||||
int numedgefaces = 0;
|
int numedgefaces = 0;
|
||||||
|
@ -241,7 +243,7 @@ InitHash (void)
|
||||||
hash_scale[1] = newsize[1] / size[1];
|
hash_scale[1] = newsize[1] / size[1];
|
||||||
hash_scale[2] = newsize[1];
|
hash_scale[2] = newsize[1];
|
||||||
|
|
||||||
hvert_p = hvertex;
|
PR_RESRESET (hvertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calulate the hash value of a vector.
|
/** Calulate the hash value of a vector.
|
||||||
|
@ -302,7 +304,7 @@ GetVertex (const vec3_t in, int planenum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hv = hvert_p;
|
hv = PR_RESNEW (hvertex);
|
||||||
hv->numedges = 1;
|
hv->numedges = 1;
|
||||||
hv->numplanes = 1;
|
hv->numplanes = 1;
|
||||||
hv->planenums[0] = planenum;
|
hv->planenums[0] = planenum;
|
||||||
|
@ -310,14 +312,8 @@ GetVertex (const vec3_t in, int planenum)
|
||||||
hashverts[h] = hv;
|
hashverts[h] = hv;
|
||||||
VectorCopy (vert, hv->point);
|
VectorCopy (vert, hv->point);
|
||||||
hv->num = bsp->numvertexes;
|
hv->num = bsp->numvertexes;
|
||||||
if (hv->num == MAX_MAP_VERTS)
|
|
||||||
Sys_Error ("GetVertex: MAX_MAP_VERTS");
|
|
||||||
hvert_p++;
|
|
||||||
|
|
||||||
// emit a vertex
|
// emit a vertex
|
||||||
if (bsp->numvertexes == MAX_MAP_VERTS)
|
|
||||||
Sys_Error ("numvertexes == MAX_MAP_VERTS");
|
|
||||||
|
|
||||||
v.point[0] = vert[0];
|
v.point[0] = vert[0];
|
||||||
v.point[1] = vert[1];
|
v.point[1] = vert[1];
|
||||||
v.point[2] = vert[2];
|
v.point[2] = vert[2];
|
||||||
|
|
|
@ -67,14 +67,12 @@ FindFinalPlane (const dplane_t *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// new plane
|
// new plane
|
||||||
if (bsp->numplanes == MAX_MAP_PLANES)
|
|
||||||
Sys_Error ("numplanes == MAX_MAP_PLANES");
|
|
||||||
BSP_AddPlane (bsp, p);
|
BSP_AddPlane (bsp, p);
|
||||||
|
|
||||||
return bsp->numplanes - 1;
|
return bsp->numplanes - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int planemapping[MAX_MAP_PLANES];
|
static struct DARRAY_TYPE(int) planemapping = DARRAY_STATIC_INIT (1024);
|
||||||
|
|
||||||
/** Recursively write the nodes' planes to the bsp file.
|
/** Recursively write the nodes' planes to the bsp file.
|
||||||
|
|
||||||
|
@ -91,10 +89,10 @@ WriteNodePlanes_r (node_t *node)
|
||||||
|
|
||||||
if (node->planenum == -1)
|
if (node->planenum == -1)
|
||||||
return;
|
return;
|
||||||
if (planemapping[node->planenum] == -1) { // a new plane
|
if (planemapping.a[node->planenum] == -1) { // a new plane
|
||||||
planemapping[node->planenum] = bsp->numplanes;
|
planemapping.a[node->planenum] = bsp->numplanes;
|
||||||
|
|
||||||
plane = &planes[node->planenum];
|
plane = &planes.a[node->planenum];
|
||||||
|
|
||||||
VectorCopy (plane->normal, dplane.normal);
|
VectorCopy (plane->normal, dplane.normal);
|
||||||
dplane.dist = plane->dist;
|
dplane.dist = plane->dist;
|
||||||
|
@ -102,7 +100,7 @@ WriteNodePlanes_r (node_t *node)
|
||||||
BSP_AddPlane (bsp, &dplane);
|
BSP_AddPlane (bsp, &dplane);
|
||||||
}
|
}
|
||||||
|
|
||||||
node->outputplanenum = planemapping[node->planenum];
|
node->outputplanenum = planemapping.a[node->planenum];
|
||||||
|
|
||||||
WriteNodePlanes_r (node->children[0]);
|
WriteNodePlanes_r (node->children[0]);
|
||||||
WriteNodePlanes_r (node->children[1]);
|
WriteNodePlanes_r (node->children[1]);
|
||||||
|
@ -111,7 +109,8 @@ WriteNodePlanes_r (node_t *node)
|
||||||
void
|
void
|
||||||
WriteNodePlanes (node_t *nodes)
|
WriteNodePlanes (node_t *nodes)
|
||||||
{
|
{
|
||||||
memset (planemapping, -1, sizeof (planemapping));
|
DARRAY_RESIZE (&planemapping, planes.size);
|
||||||
|
memset (planemapping.a, -1, planemapping.size * sizeof (planemapping.a[0]));
|
||||||
WriteNodePlanes_r (nodes);
|
WriteNodePlanes_r (nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,8 +175,6 @@ WriteLeaf (const node_t *node)
|
||||||
|
|
||||||
for (fp = node->markfaces; *fp; fp++) {
|
for (fp = node->markfaces; *fp; fp++) {
|
||||||
// emit a marksurface
|
// emit a marksurface
|
||||||
if (bsp->nummarksurfaces == MAX_MAP_MARKSURFACES)
|
|
||||||
Sys_Error ("nummarksurfaces == MAX_MAP_MARKSURFACES");
|
|
||||||
f = *fp;
|
f = *fp;
|
||||||
if (f->texturenum < 0)
|
if (f->texturenum < 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -206,8 +203,6 @@ WriteDrawNodes_r (const node_t *node)
|
||||||
int nodenum = bsp->numnodes;
|
int nodenum = bsp->numnodes;
|
||||||
|
|
||||||
// emit a node
|
// emit a node
|
||||||
if (bsp->numnodes == MAX_MAP_NODES)
|
|
||||||
Sys_Error ("numnodes == MAX_MAP_NODES");
|
|
||||||
BSP_AddNode (bsp, &dummy);
|
BSP_AddNode (bsp, &dummy);
|
||||||
n = &bsp->nodes[nodenum];
|
n = &bsp->nodes[nodenum];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue