use vector for vis state
set autoclean default to true, make it invertable
This commit is contained in:
parent
70d87a52d6
commit
ee596f3ff1
|
|
@ -229,7 +229,7 @@ public:
|
|||
this, "visdist", 0.0, &advanced_group, "control the distance required for a portal to be considered seen"};
|
||||
setting_bool nostate{this, "nostate", false, &advanced_group, "ignore saved state files, for forced re-runs"};
|
||||
setting_bool phsonly{this, "phsonly", false, &advanced_group, "re-calculate the PHS of a Quake II BSP without touching the PVS"};
|
||||
setting_bool autoclean{this, "autoclean", false, &output_group, "remove any extra files on successful completion"};
|
||||
setting_invertible_bool autoclean{this, "autoclean", true, &output_group, "remove any extra files on successful completion"};
|
||||
|
||||
fs::path sourceMap;
|
||||
|
||||
|
|
|
|||
|
|
@ -1511,7 +1511,7 @@ static std::unique_ptr<mapface_t> ParseBrushFace(parser_t &parser, const mapbrus
|
|||
bool normal_ok;
|
||||
maptexinfo_t tx;
|
||||
int i, j;
|
||||
std::unique_ptr<mapface_t> face{new mapface_t};
|
||||
std::unique_ptr<mapface_t> face = std::make_unique<mapface_t>();
|
||||
|
||||
face->linenum = parser.linenum;
|
||||
ParsePlaneDef(parser, planepts);
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ static int tjuncfaces;
|
|||
static int cWVerts;
|
||||
static int cWEdges;
|
||||
|
||||
static wvert_t *pWVerts;
|
||||
static wedge_t *pWEdges;
|
||||
static std::vector<wvert_t> pWVerts;
|
||||
static std::vector<wedge_t> pWEdges;
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ static wedge_t *FindEdge(const qvec3d &p1, const qvec3d &p2, vec_t &t1, vec_t &t
|
|||
|
||||
if (numwedges >= cWEdges)
|
||||
FError("Internal error: didn't allocate enough edges for tjuncs?");
|
||||
edge = pWEdges + numwedges;
|
||||
edge = &pWEdges[numwedges];
|
||||
numwedges++;
|
||||
|
||||
edge->next = wedge_hash[h];
|
||||
|
|
@ -192,7 +192,7 @@ static void AddVert(wedge_t *edge, vec_t t)
|
|||
if (numwverts >= cWVerts)
|
||||
FError("Internal error: didn't allocate enough vertices for tjuncs?");
|
||||
|
||||
newv = pWVerts + numwverts;
|
||||
newv = &pWVerts[numwverts];
|
||||
numwverts++;
|
||||
|
||||
newv->t = t;
|
||||
|
|
@ -418,9 +418,11 @@ void TJunc(const mapentity_t *entity, node_t *headnode)
|
|||
tjunc_count_r(headnode);
|
||||
cWEdges = cWVerts;
|
||||
cWVerts *= 2;
|
||||
|
||||
pWVerts = new wvert_t[cWVerts]{};
|
||||
pWEdges = new wedge_t[cWEdges]{};
|
||||
|
||||
pWVerts.clear();
|
||||
pWEdges.clear();
|
||||
pWVerts.resize(cWVerts);
|
||||
pWEdges.resize(cWEdges);
|
||||
|
||||
qvec3d maxs;
|
||||
/*
|
||||
|
|
@ -448,9 +450,6 @@ void TJunc(const mapentity_t *entity, node_t *headnode)
|
|||
tjuncs = tjuncfaces = 0;
|
||||
tjunc_fix_r(headnode);
|
||||
|
||||
delete[] pWVerts;
|
||||
delete[] pWEdges;
|
||||
|
||||
logging::print(logging::flag::STAT, " {:8} edges added by tjunctions\n", tjuncs);
|
||||
logging::print(logging::flag::STAT, " {:8} faces added by tjunctions\n", tjuncfaces);
|
||||
}
|
||||
|
|
|
|||
17
vis/state.cc
17
vis/state.cc
|
|
@ -136,8 +136,6 @@ void SaveVisState(void)
|
|||
const portal_t *p;
|
||||
dvisstate_t state;
|
||||
dportal_t pstate;
|
||||
uint8_t *vis;
|
||||
uint8_t *might;
|
||||
|
||||
std::ofstream out(statetmpfile, std::ios_base::out | std::ios_base::binary);
|
||||
out << endianness<std::endian::little>;
|
||||
|
|
@ -152,13 +150,13 @@ void SaveVisState(void)
|
|||
out <= state;
|
||||
|
||||
/* Allocate memory for compressed bitstrings */
|
||||
might = new uint8_t[(portalleafs + 7) >> 3];
|
||||
vis = new uint8_t[(portalleafs + 7) >> 3];
|
||||
std::vector<uint8_t> might((portalleafs + 7) >> 3);
|
||||
std::vector<uint8_t> vis((portalleafs + 7) >> 3);
|
||||
|
||||
for (i = 0, p = portals; i < numportals * 2; i++, p++) {
|
||||
might_len = CompressBits(might, p->mightsee);
|
||||
might_len = CompressBits(might.data(), p->mightsee);
|
||||
if (p->status == pstat_done)
|
||||
vis_len = CompressBits(vis, p->visbits);
|
||||
vis_len = CompressBits(vis.data(), p->visbits);
|
||||
else
|
||||
vis_len = 0;
|
||||
|
||||
|
|
@ -169,16 +167,13 @@ void SaveVisState(void)
|
|||
pstate.numcansee = p->numcansee;
|
||||
|
||||
out <= pstate;
|
||||
out.write((const char *) might, might_len);
|
||||
out.write((const char *) might.data(), might_len);
|
||||
if (vis_len)
|
||||
out.write((const char *) vis, vis_len);
|
||||
out.write((const char *) vis.data(), vis_len);
|
||||
}
|
||||
|
||||
out.close();
|
||||
|
||||
delete[] might;
|
||||
delete[] vis;
|
||||
|
||||
std::error_code ec;
|
||||
|
||||
fs::remove(statefile, ec);
|
||||
|
|
|
|||
Loading…
Reference in New Issue