Fix lightmapper still using hacks to detect levelmesh changes

This commit is contained in:
RaveYard 2023-09-11 15:27:24 +02:00 committed by Christoph Oelckers
parent 776b615e10
commit 2c795a5a8b
3 changed files with 13 additions and 18 deletions

View file

@ -46,18 +46,17 @@ VkLightmap::~VkLightmap()
lights.Buffer->Unmap();
}
void VkLightmap::Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& surfaces)
void VkLightmap::SetLevelMesh(LevelMesh* level)
{
bool newLevel = (mesh != level);
mesh = level;
if (newLevel)
{
UpdateAccelStructDescriptors();
UpdateAccelStructDescriptors();
lightmapRaytrace.Reset();
lightmapRaytraceLast.Reset();
}
lightmapRaytrace.Reset();
lightmapRaytraceLast.Reset();
}
void VkLightmap::Raytrace(const TArray<LevelMeshSurface*>& surfaces)
{
if (surfaces.Size())
{
lightmapRaytrace.active = true;

View file

@ -90,8 +90,8 @@ public:
VkLightmap(VulkanRenderDevice* fb);
~VkLightmap();
void Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& surfaces);
void Raytrace(const TArray<LevelMeshSurface*>& surfaces);
void SetLevelMesh(LevelMesh* level);
private:
void UpdateAccelStructDescriptors();

View file

@ -475,6 +475,7 @@ void VulkanRenderDevice::BeginFrame()
{
levelMesh->UpdateLightLists();
GetTextureManager()->CreateLightmap(levelMesh->LMTextureSize, levelMesh->LMTextureCount);
GetLightmap()->SetLevelMesh(levelMesh);
#if 0 // full lightmap generation
TArray<LevelMeshSurface*> surfaces;
@ -484,9 +485,7 @@ void VulkanRenderDevice::BeginFrame()
surfaces[i] = mesh->GetSurface(i);
}
GetLightmap()->Raytrace(mesh, surfaces);
#else
GetLightmap()->Raytrace(levelMesh, {});
GetLightmap()->Raytrace(surfaces);
#endif
}
}
@ -564,12 +563,9 @@ void VulkanRenderDevice::SetLevelMesh(LevelMesh* mesh)
void VulkanRenderDevice::UpdateLightmaps(const TArray<LevelMeshSurface*>& surfaces)
{
if (surfaces.Size() > 0)
if (surfaces.Size() > 0 && levelMesh)
{
if (levelMesh)
{
GetLightmap()->Raytrace(levelMesh, surfaces);
}
GetLightmap()->Raytrace(surfaces);
}
}