WIP refactoring of surface gathering

This commit is contained in:
RaveYard 2023-09-09 17:42:57 +02:00 committed by Magnus Norddahl
commit 139ce34535
2 changed files with 52 additions and 23 deletions

View file

@ -97,6 +97,33 @@ void CollectLights(FLevelLocals* Level)
}
}
void UpdateLightmaps(DFrameBuffer* screen, FRenderState& RenderState)
{
// Lightmapping stuff
auto& list = RenderState.GetVisibleSurfaceList();
auto size = RenderState.GetVisibleSurfaceListCount();
list.Resize(min(list.Size(), unsigned(size)));
if (size < lm_background_updates)
{
int index = 0;
for (auto& e : level.levelMesh->Surfaces)
{
if (e.needsUpdate)
{
list.Push(index);
if (list.Size() >= lm_background_updates)
break;
}
++index;
}
}
screen->UpdateLightmaps(list);
}
//-----------------------------------------------------------------------------
//
@ -199,24 +226,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
screen->NextEye(eyeCount);
}
auto& list = RenderState.GetVisibleSurfaceList();
if (list.Size() < lm_background_updates)
{
int index = 0;
for (auto& e : level.levelMesh->Surfaces)
{
if (e.needsUpdate)
{
list.Push(index);
if(list.Size() >= lm_background_updates)
break;
}
++index;
}
}
screen->UpdateLightmaps(list);
UpdateLightmaps(screen, RenderState);
return mainvp.sector;
}