Fixed clipmap trigger brushmodel conversion (correct indexing)

This commit is contained in:
rackover 2021-04-05 14:49:30 +02:00
parent 9b86825713
commit 529e44ac51

View File

@ -887,8 +887,6 @@ namespace Assets
// add triggers to mapEnts // add triggers to mapEnts
clipMap->mapEnts->trigger.count = clipMap->numSubModels; clipMap->mapEnts->trigger.count = clipMap->numSubModels;
clipMap->mapEnts->trigger.hullCount = clipMap->numSubModels; clipMap->mapEnts->trigger.hullCount = clipMap->numSubModels;
clipMap->mapEnts->trigger.slabCount = clipMap->numSubModels * 1000; clipMap->mapEnts->trigger.slabCount = clipMap->numSubModels * 1000;
@ -899,6 +897,11 @@ namespace Assets
int hullCountSoFar = 0; int hullCountSoFar = 0;
int slabCountSoFar = 0; int slabCountSoFar = 0;
//int skipped = 0;
Utils::Entities memEnts(clipMap->mapEnts->entityString);
std::vector<int> radioTriggers = memEnts.getRadioTriggerModels();
for (int i = 0; i < clipMap->numSubModels; ++i) for (int i = 0; i < clipMap->numSubModels; ++i)
{ {
@ -908,12 +911,14 @@ namespace Assets
Game::TriggerModel trigMod = {}; Game::TriggerModel trigMod = {};
trigMod.hullCount = 1; trigMod.hullCount = 1;
trigMod.firstHull = 0; trigMod.firstHull = i /*- skipped*/;
trigMod.contents = clipMap->cmodels[i].leaf.brushContents | clipMap->cmodels[i].leaf.terrainContents;; trigMod.contents = clipMap->cmodels[i].leaf.brushContents | clipMap->cmodels[i].leaf.terrainContents;;
auto* node = &clipMap->leafbrushNodes[clipMap->cmodels[i].leaf.leafBrushNode]; auto* node = &clipMap->leafbrushNodes[clipMap->cmodels[i].leaf.leafBrushNode];
if (!node->leafBrushCount) continue; // skip empty brushes if (node->leafBrushCount) {
////skipped++;
//continue; // skip empty brushes
int baseHull = hullCountSoFar; int baseHull = hullCountSoFar;
for (int j = 0; j < node->leafBrushCount; ++j) for (int j = 0; j < node->leafBrushCount; ++j)
@ -937,13 +942,14 @@ namespace Assets
trigHull.firstSlab = baseSlab; trigHull.firstSlab = baseSlab;
trigHull.slabCount = slabCountSoFar - baseSlab; trigHull.slabCount = slabCountSoFar - baseSlab;
} }
}
models[i] = trigMod; models[i/* - skipped*/] = trigMod;
hulls[i] = trigHull; hulls[i/* - skipped*/] = trigHull;
hullCountSoFar++; hullCountSoFar++;
} }
clipMap->mapEnts->trigger.models = &models[0];; clipMap->mapEnts->trigger.models = &models[0];
clipMap->mapEnts->trigger.hulls = &hulls[0]; clipMap->mapEnts->trigger.hulls = &hulls[0];
clipMap->mapEnts->trigger.slabs = &slabs[0]; clipMap->mapEnts->trigger.slabs = &slabs[0];