Fix for engines that require edges reference valid vertices (edge 0 references vertex 0 but it might not be set in some cases)

Change `Brush_GetContents` again so that clip works
This commit is contained in:
Jonathan 2022-02-05 13:18:21 -05:00
parent 686cdf4217
commit 0392698bd3
2 changed files with 9 additions and 4 deletions

View File

@ -668,14 +668,13 @@ static contentflags_t Brush_GetContents(const mapbrush_t *mapbrush)
for (int i = 0; i < mapbrush->numfaces; i++) { for (int i = 0; i < mapbrush->numfaces; i++) {
const mapface_t &mapface = mapbrush->face(i); const mapface_t &mapface = mapbrush->face(i);
const mtexinfo_t &texinfo = map.mtexinfos.at(mapface.texinfo); const mtexinfo_t &texinfo = map.mtexinfos.at(mapface.texinfo);
contentflags_t contents = options.target_game->face_get_contents(mapface.texname.data(), texinfo.flags, mapface.contents);
if (texinfo.flags.is_skip) { if (contents.is_empty(options.target_game)) {
continue; continue;
} }
contentflags_t contents = options.target_game->face_get_contents(mapface.texname.data(), texinfo.flags, mapface.contents);
// use the first non-skip as the base contents value // use the first non-empty as the base contents value
if (!base_contents_set) { if (!base_contents_set) {
base_contents_set = true; base_contents_set = true;
base_contents = contents; base_contents = contents;

View File

@ -439,6 +439,12 @@ void FinishBSPFile(void)
options.fVerbose = true; options.fVerbose = true;
LogPrint(LOG_PROGRESS, "---- {} ----\n", __func__); LogPrint(LOG_PROGRESS, "---- {} ----\n", __func__);
if (map.bsp.dvertexes.empty()) {
// First vertex must remain unused because edge references it
map.bsp.dvertexes.emplace_back();
Q_assert(map.bsp.dvertexes.size() == 1);
}
WriteExtendedTexinfoFlags(); WriteExtendedTexinfoFlags();
WriteBSPFile(); WriteBSPFile();