Allow lm_dynamic to be able to set level-wide in ZDRayInfo

This commit is contained in:
nashmuhandes 2025-06-11 15:24:38 +08:00 committed by Nash Muhandes
commit c40a36ea7c
7 changed files with 33 additions and 2 deletions

View file

@ -22,6 +22,7 @@
#include "vm.h"
#include "p_setup.h"
static void UpdateLightmapTiles();
static int InvalidateLightmap();
static void InvalidateActorLightTraceCache();
@ -74,6 +75,16 @@ static bool RequireLightmap()
return false;
}
// Forces lightmap tiles update
static void UpdateLightmapTiles()
{
for (auto& tile : level.levelMesh->Lightmap.Tiles)
{
if (!tile.NeedsInitialBake)
tile.ReceivedNewLight = true;
}
}
static int InvalidateLightmap()
{
int count = 0;
@ -251,6 +262,7 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals& doomMap)
Lightmap.SampleDistance = doomMap.LightmapSampleDistance;
LightBounce = doomMap.LightBounce;
AmbientOcclusion = doomMap.AmbientOcclusion;
LevelWideLMDynamic = doomMap.LevelWideLMDynamic;
// HWWall and HWFlat still looks at r_viewpoint when doing calculations,
// but we aren't rendering a specific viewpoint when this function gets called
@ -2717,6 +2729,14 @@ static void InvalidateActorLightTraceCache()
}
}
DEFINE_ACTION_FUNCTION(_Lightmap, Update)
{
PARAM_PROLOGUE;
UpdateLightmapTiles();
InvalidateActorLightTraceCache();
return 0;
}
DEFINE_ACTION_FUNCTION(_Lightmap, Invalidate)
{
PARAM_PROLOGUE;