Skip to content

Commit

Permalink
ensure non-dynamic tiles are baked first
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 authored and nashmuhandes committed Dec 13, 2024
1 parent 36d74cf commit c290140
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/rendering/hwrenderer/scene/hw_drawinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,31 @@ void HWDrawInfo::UpdateLightmaps()
{
if (!outer && VisibleTiles.Size() < unsigned(lm_background_updates))
{
int unbaked = 0;
int dynamic = 0;

for (auto& e : level.levelMesh->Lightmap.Tiles)
{
if (e.NeedsUpdate)
{
if(e.AlwaysUpdate == 0) unbaked++;
if(e.AlwaysUpdate != 0) dynamic++;

VisibleTiles.Push(&e);

if (VisibleTiles.Size() >= unsigned(lm_background_updates))
break;
if((!dynamic && (VisibleTiles.Size() >= unsigned(lm_background_updates))) || unbaked >= unsigned(lm_background_updates)) break;
}
}

if(unbaked && dynamic)
{
std::sort(VisibleTiles.begin(), VisibleTiles.end(), [](LightmapTile *a, LightmapTile *b){return (!!a->AlwaysUpdate) < (!!b->AlwaysUpdate);});
}

if(VisibleTiles.Size() > unsigned(lm_background_updates))
{
VisibleTiles.Resize(lm_background_updates);
}
}
screen->UpdateLightmaps(VisibleTiles);
}
Expand Down

0 comments on commit c290140

Please sign in to comment.