C-Compliant clipmap trigger conversion
This commit is contained in:
parent
f851a0a3a9
commit
d610e85176
@ -887,13 +887,18 @@ namespace Assets
|
||||
|
||||
// add triggers to mapEnts
|
||||
|
||||
std::vector<Game::TriggerSlab> slabs;
|
||||
std::vector<Game::TriggerHull> hulls;
|
||||
std::vector<Game::TriggerModel> models;
|
||||
|
||||
|
||||
clipMap->mapEnts->trigger.count = clipMap->numSubModels;
|
||||
clipMap->mapEnts->trigger.hullCount = clipMap->numSubModels;
|
||||
clipMap->mapEnts->trigger.slabCount = 0;
|
||||
clipMap->mapEnts->trigger.slabCount = clipMap->numSubModels * 1000;
|
||||
|
||||
Game::TriggerHull* hulls = builder->getAllocator()->allocateArray<Game::TriggerHull>(clipMap->mapEnts->trigger.hullCount * sizeof(Game::TriggerHull));
|
||||
Game::TriggerModel* models = builder->getAllocator()->allocateArray<Game::TriggerModel>(clipMap->mapEnts->trigger.count * sizeof(Game::TriggerModel));
|
||||
Game::TriggerSlab* slabs = builder->getAllocator()->allocateArray<Game::TriggerSlab>(clipMap->mapEnts->trigger.slabCount * sizeof(Game::TriggerSlab));
|
||||
|
||||
int hullCountSoFar = 0;
|
||||
int slabCountSoFar = 0;
|
||||
|
||||
for (int i = 0; i < clipMap->numSubModels; ++i)
|
||||
{
|
||||
@ -910,12 +915,12 @@ namespace Assets
|
||||
|
||||
if (!node->leafBrushCount) continue; // skip empty brushes
|
||||
|
||||
int baseHull = hulls.size();
|
||||
int baseHull = hullCountSoFar;
|
||||
for (int j = 0; j < node->leafBrushCount; ++j)
|
||||
{
|
||||
auto* brush = &clipMap->brushes[node->data.leaf.brushes[j]];
|
||||
|
||||
auto baseSlab = slabs.size();
|
||||
auto baseSlab = slabCountSoFar;
|
||||
for (int k = 0; k < brush->numsides; ++k)
|
||||
{
|
||||
Game::TriggerSlab curSlab;
|
||||
@ -925,23 +930,23 @@ namespace Assets
|
||||
curSlab.halfSize = brush->sides[k].plane->dist;
|
||||
curSlab.midPoint = 0.0f; // ??
|
||||
|
||||
slabs.emplace_back(curSlab);
|
||||
clipMap->mapEnts->trigger.slabCount++;
|
||||
slabs[slabCountSoFar] = curSlab;
|
||||
slabCountSoFar++;
|
||||
}
|
||||
|
||||
trigHull.firstSlab = baseSlab;
|
||||
trigHull.slabCount = slabs.size() - baseSlab;
|
||||
trigHull.slabCount = slabCountSoFar - baseSlab;
|
||||
}
|
||||
|
||||
models.emplace_back(trigMod);
|
||||
hulls.emplace_back(trigHull);
|
||||
models[i] = trigMod;
|
||||
hulls[i] = trigHull;
|
||||
hullCountSoFar++;
|
||||
}
|
||||
|
||||
clipMap->mapEnts->trigger.models = &models[0];
|
||||
clipMap->mapEnts->trigger.models = &models[0];;
|
||||
clipMap->mapEnts->trigger.hulls = &hulls[0];
|
||||
clipMap->mapEnts->trigger.slabs = &slabs[0];
|
||||
|
||||
|
||||
// This mustn't be null and has to have at least 1 'valid' entry.
|
||||
if (!clipMap->smodelNodeCount || !clipMap->smodelNodes)
|
||||
{
|
||||
|
@ -1071,7 +1071,7 @@ namespace Components
|
||||
|
||||
if(ent->r.isInUse)
|
||||
{
|
||||
auto b = ent->r.box;
|
||||
Game::Bounds b = ent->r.box;
|
||||
b.midPoint[0] += ent->r.currentOrigin[0];
|
||||
b.midPoint[1] += ent->r.currentOrigin[1];
|
||||
b.midPoint[2] += ent->r.currentOrigin[2];
|
||||
@ -1098,6 +1098,13 @@ namespace Components
|
||||
break;
|
||||
|
||||
default:
|
||||
float rv = std::min((float)ent->handler, (float)5) / 5;
|
||||
float gv = std::clamp((float)ent->handler-5, (float)0, (float)5) / 5;
|
||||
float bv = std::clamp((float)ent->handler - 10, (float)0, (float)5) / 5;
|
||||
|
||||
float color[4] = { rv, gv, bv, 1.0f };
|
||||
|
||||
Game::R_AddDebugBounds(color, &b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user