Clean up decal behavior

Only update the mesh if a decal was truly created/destroyed
This commit is contained in:
Boondorl 2024-12-12 22:27:16 -05:00 committed by Nash Muhandes
commit 4d5bba8d02
4 changed files with 22 additions and 13 deletions

View file

@ -85,11 +85,14 @@ void CPUAccelStruct::FindFirstHit(const RayBBox& ray, int a, TraceHit* hit)
}
}
extern glcycle_t DynamicBLASTime;
void CPUAccelStruct::Update()
{
if (Mesh->UploadRanges.Index.Size() == 0)
return;
DynamicBLASTime.ResetAndClock();
InstanceCount = (Mesh->Mesh.IndexCount + IndexesPerBLAS - 1) / IndexesPerBLAS;
bool needsUpdate[32] = {};
@ -112,6 +115,7 @@ void CPUAccelStruct::Update()
DynamicBLAS[instance] = CreateBLAS(indexStart, indexEnd - indexStart);
}
}
DynamicBLASTime.Unclock();
CreateTLAS();
Upload();

View file

@ -986,6 +986,19 @@ void FDecalTemplate::ApplyToDecal (DBaseDecal *decal, side_t *wall) const
{
Animator->CreateThinker (decal, wall);
}
decal->Side = wall;
decal->WallPrev = wall->AttachedDecals;
while (decal->WallPrev != nullptr && decal->WallPrev->WallNext != nullptr)
{
decal->WallPrev = decal->WallPrev->WallNext;
}
if (decal->WallPrev != nullptr) decal->WallPrev->WallNext = decal;
else wall->AttachedDecals = decal;
decal->WallNext = nullptr;
LevelMeshUpdater->SideDecalsChanged(wall);
}
const FDecalTemplate *FDecalTemplate::GetDecal () const

View file

@ -255,19 +255,8 @@ void DBaseDecal::SetShade (int r, int g, int b)
FTextureID DBaseDecal::StickToWall (side_t *wall, double x, double y, F3DFloor *ffloor)
{
Side = wall;
WallPrev = wall->AttachedDecals;
while (WallPrev != nullptr && WallPrev->WallNext != nullptr)
{
WallPrev = WallPrev->WallNext;
}
if (WallPrev != nullptr) WallPrev->WallNext = this;
else wall->AttachedDecals = this;
WallNext = nullptr;
LevelMeshUpdater->SideDecalsChanged(wall);
Side = nullptr;
WallNext = WallPrev = nullptr;
sector_t *front, *back;
line_t *line;

View file

@ -55,6 +55,7 @@ static int InvalidateLightmap()
}
glcycle_t ProcessLevelMesh;
glcycle_t DynamicBLASTime;
ADD_STAT(lightmap)
{
@ -84,6 +85,7 @@ ADD_STAT(lightmap)
"Surface pixel area to update: %u\n"
"Surface pixel area: %u\nAtlas pixel area: %u\n"
"Atlas efficiency: %.4f%%\n"
"Dynamic BLAS time: %2.3f ms\n"
"Level mesh process time: %2.3f ms\n"
"Level mesh index buffer: %d K used (%d%%)",
stats.tiles.total, stats.tiles.dirty,
@ -91,6 +93,7 @@ ADD_STAT(lightmap)
stats.pixels.total,
atlasPixelCount,
float(stats.pixels.total) / float(atlasPixelCount) * 100.0f,
DynamicBLASTime.TimeMS(),
ProcessLevelMesh.TimeMS(),
indexBufferUsed / 1000,
indexBufferUsed * 100 / indexBufferTotal);