qbsp: start pulling some of the global state for FillOutside onto the stack
Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
462792e03b
commit
546aa817d8
|
|
@ -21,10 +21,19 @@
|
||||||
|
|
||||||
#include "qbsp.h"
|
#include "qbsp.h"
|
||||||
|
|
||||||
static int outleafs;
|
typedef struct {
|
||||||
static int fillmark
|
int outleafs;
|
||||||
static int hit_occupied;
|
int backdraw;
|
||||||
static int backdraw;
|
int hit_occupied;
|
||||||
|
} fillstate_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool fill;
|
||||||
|
int hullnum;
|
||||||
|
int numportals;
|
||||||
|
} fillparms_t;
|
||||||
|
|
||||||
|
static int fillmark;
|
||||||
static int numports;
|
static int numports;
|
||||||
static bool firstone = true;
|
static bool firstone = true;
|
||||||
static FILE *LeakFile;
|
static FILE *LeakFile;
|
||||||
|
|
@ -142,7 +151,7 @@ MarkLeakTrail
|
||||||
*/
|
*/
|
||||||
__attribute__((noinline))
|
__attribute__((noinline))
|
||||||
static void
|
static void
|
||||||
MarkLeakTrail(portal_t *n2, const int numportals)
|
MarkLeakTrail(portal_t *n2, int hit_occupied, const int numportals)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
vec3_t p1, p2;
|
vec3_t p1, p2;
|
||||||
|
|
@ -321,7 +330,7 @@ Returns true if an occupied leaf is reached
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
RecursiveFillOutside(node_t *node, bool fill, const int hullnum, const int numportals)
|
RecursiveFillOutside(fillstate_t *state, const fillparms_t *parms, node_t *node)
|
||||||
{
|
{
|
||||||
portal_t *p;
|
portal_t *p;
|
||||||
int side;
|
int side;
|
||||||
|
|
@ -333,28 +342,28 @@ RecursiveFillOutside(node_t *node, bool fill, const int hullnum, const int numpo
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (node->occupied) {
|
if (node->occupied) {
|
||||||
hit_occupied = node->occupied;
|
state->hit_occupied = node->occupied;
|
||||||
leakNode = node;
|
leakNode = node;
|
||||||
backdraw = 4000;
|
state->backdraw = 4000;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->fillmark = fillmark;
|
node->fillmark = fillmark;
|
||||||
|
|
||||||
// fill it and it's neighbors
|
// fill it and it's neighbors
|
||||||
if (fill) {
|
if (parms->fill) {
|
||||||
node->contents = CONTENTS_SOLID;
|
node->contents = CONTENTS_SOLID;
|
||||||
outleafs++;
|
state->outleafs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (p = node->portals; p; p = p->next[!side]) {
|
for (p = node->portals; p; p = p->next[!side]) {
|
||||||
side = (p->nodes[0] == node);
|
side = (p->nodes[0] == node);
|
||||||
if (RecursiveFillOutside(p->nodes[side], fill, hullnum, numportals)) {
|
if (RecursiveFillOutside(state, parms, p->nodes[side])) {
|
||||||
/* leaked, so stop filling */
|
/* leaked, so stop filling */
|
||||||
if (backdraw) {
|
if (state->backdraw) {
|
||||||
backdraw--;
|
state->backdraw--;
|
||||||
if (hullnum == 2) /* FIXME!!! */
|
if (parms->hullnum == 2) /* FIXME!!! */
|
||||||
MarkLeakTrail(p, numportals);
|
MarkLeakTrail(p, state->hit_occupied, parms->numportals);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -405,6 +414,8 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
||||||
vec_t *v;
|
vec_t *v;
|
||||||
int i;
|
int i;
|
||||||
bool inside;
|
bool inside;
|
||||||
|
fillstate_t fillstate;
|
||||||
|
fillparms_t fillparms;
|
||||||
const mapentity_t *entity;
|
const mapentity_t *entity;
|
||||||
node_t *fillnode;
|
node_t *fillnode;
|
||||||
|
|
||||||
|
|
@ -428,11 +439,6 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// first check to see if an occupied leaf is hit
|
|
||||||
outleafs = 0;
|
|
||||||
numleaks = 0;
|
|
||||||
fillmark++;
|
|
||||||
|
|
||||||
if (hullnum == 2) {
|
if (hullnum == 2) {
|
||||||
pLeaks = AllocMem(OTHER, sizeof(portal_t *) * numportals, true);
|
pLeaks = AllocMem(OTHER, sizeof(portal_t *) * numportals, true);
|
||||||
StripExtension(options.szBSPName);
|
StripExtension(options.szBSPName);
|
||||||
|
|
@ -455,10 +461,21 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set up state and parameters for the recursive fill */
|
||||||
|
fillparms.hullnum = hullnum;
|
||||||
|
fillparms.numportals = numportals;
|
||||||
|
fillstate.outleafs = 0;
|
||||||
|
fillstate.backdraw = 0;
|
||||||
|
fillstate.hit_occupied = 0;
|
||||||
|
numleaks = 0;
|
||||||
|
fillmark++;
|
||||||
|
|
||||||
|
/* first check to see if an occupied leaf is hit */
|
||||||
|
fillparms.fill = false;
|
||||||
side = !(outside_node.portals->nodes[1] == &outside_node);
|
side = !(outside_node.portals->nodes[1] == &outside_node);
|
||||||
fillnode = outside_node.portals->nodes[side];
|
fillnode = outside_node.portals->nodes[side];
|
||||||
if (RecursiveFillOutside(fillnode, false, hullnum, numportals)) {
|
if (RecursiveFillOutside(&fillstate, &fillparms, fillnode)) {
|
||||||
v = map.entities[hit_occupied].origin;
|
v = map.entities[fillstate.hit_occupied].origin;
|
||||||
Message(msgWarning, warnMapLeak, v[0], v[1], v[2]);
|
Message(msgWarning, warnMapLeak, v[0], v[1], v[2]);
|
||||||
if (hullnum == 2) {
|
if (hullnum == 2) {
|
||||||
if (!options.fOldleak)
|
if (!options.fOldleak)
|
||||||
|
|
@ -500,14 +517,16 @@ FillOutside(node_t *node, const int hullnum, const int numportals)
|
||||||
fclose(PorFile);
|
fclose(PorFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now go back and fill things in
|
|
||||||
fillmark++;
|
|
||||||
fillnode = outside_node.portals->nodes[side];
|
|
||||||
RecursiveFillOutside(fillnode, true, hullnum, numportals);
|
|
||||||
|
|
||||||
// remove faces from filled in leafs
|
/* now go back and fill things in */
|
||||||
|
fillmark++;
|
||||||
|
fillparms.fill = true;
|
||||||
|
fillnode = outside_node.portals->nodes[side];
|
||||||
|
RecursiveFillOutside(&fillstate, &fillparms, fillnode);
|
||||||
|
|
||||||
|
/* remove faces from filled in leafs */
|
||||||
ClearOutFaces(node);
|
ClearOutFaces(node);
|
||||||
|
|
||||||
Message(msgStat, "%4i outleafs", outleafs);
|
Message(msgStat, "%4i outleafs", fillstate.outleafs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue