move _omitbrushes to the loading phase; this will greatly improve performance of loading a map with a ton of brushes that has most of them omitted.

This commit is contained in:
Jonathan 2022-08-20 09:53:23 -04:00
parent bfe56b0663
commit 7422776f38
2 changed files with 14 additions and 7 deletions

View File

@ -653,12 +653,6 @@ std::optional<bspbrush_t> LoadBrush(const mapentity_t &src, mapbrush_t &mapbrush
static void Brush_LoadEntity(mapentity_t &dst, mapentity_t &src, hull_index_t hullnum, content_stats_base_t &stats, bspbrush_t::container &brushes, logging::percent_clock &clock, size_t &num_clipped)
{
// _omitbrushes 1 just discards all brushes in the entity.
// could be useful for geometry guides, selective compilation, etc.
if (src.epairs.get_int("_omitbrushes")) {
return;
}
clock.max += src.mapbrushes.size();
bool all_detail, all_detail_fence, all_detail_illusionary;

View File

@ -2207,6 +2207,10 @@ bool ParseEntity(parser_t &parser, mapentity_t &entity)
entity.mapbrushes.clear();
// _omitbrushes 1 just discards all brushes in the entity.
// could be useful for geometry guides, selective compilation, etc.
bool omit = entity.epairs.get_int("_omitbrushes");
do {
if (!parser.parse_token())
FError("Unexpected EOF (no closing brace)");
@ -2216,7 +2220,16 @@ bool ParseEntity(parser_t &parser, mapentity_t &entity)
// once we run into the first brush, set up textures state.
EnsureTexturesLoaded();
entity.mapbrushes.emplace_back(ParseBrush(parser, entity));
if (omit) {
// skip until a } since we don't care to load brushes on this entity
do {
if (!parser.parse_token()) {
FError("Unexpected EOF (no closing brace)");
}
} while (parser.token != "}");
} else {
entity.mapbrushes.emplace_back(ParseBrush(parser, entity));
}
} else {
ParseEpair(parser, entity);
}