mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
Delay finding the light lists until after map has loaded
This commit is contained in:
parent
ab539d85d2
commit
8515661b1a
4 changed files with 25 additions and 6 deletions
|
@ -169,6 +169,8 @@ public:
|
|||
virtual LevelMeshSurface* GetSurface(int index) { return nullptr; }
|
||||
virtual int GetSurfaceCount() { return 0; }
|
||||
|
||||
virtual void UpdateLightLists() { }
|
||||
|
||||
TArray<LevelMeshSmoothingGroup> SmoothingGroups; // TODO fill
|
||||
TArray<LevelMeshPortal> Portals; // TODO fill
|
||||
|
||||
|
|
|
@ -540,6 +540,8 @@ void VulkanRenderDevice::SetLevelMesh(LevelMesh* mesh)
|
|||
{
|
||||
lastMesh = mesh;
|
||||
|
||||
mesh->UpdateLightLists();
|
||||
|
||||
GetTextureManager()->CreateLightmap(mesh->LMTextureSize, mesh->LMTextureCount);
|
||||
GetLightmap()->Raytrace(mesh);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,21 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals &doomMap)
|
|||
Collision = std::make_unique<TriangleMeshShape>(MeshVertices.Data(), MeshVertices.Size(), MeshElements.Data(), MeshElements.Size());
|
||||
}
|
||||
|
||||
void DoomLevelMesh::UpdateLightLists()
|
||||
{
|
||||
for (auto& surface : Surfaces)
|
||||
{
|
||||
if (surface.Type == ST_FLOOR || surface.Type == ST_CEILING)
|
||||
{
|
||||
CreateLightList(&surface, surface.Subsector->section->lighthead, surface.Subsector->sector->PortalGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateLightList(&surface, surface.Side->lighthead, surface.Side->sector->PortalGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoomLevelMesh::BindLightmapSurfacesToGeometry(FLevelLocals& doomMap)
|
||||
{
|
||||
// Allocate room for all surfaces
|
||||
|
@ -119,7 +134,6 @@ void DoomLevelMesh::BindLightmapSurfacesToGeometry(FLevelLocals& doomMap)
|
|||
}
|
||||
|
||||
// Copy and build properties
|
||||
size_t index = 0;
|
||||
for (auto& surface : Surfaces)
|
||||
{
|
||||
surface.TexCoords = (float*)&LightmapUvs[surface.startUvIndex];
|
||||
|
@ -160,8 +174,6 @@ void DoomLevelMesh::SetSubsectorLightmap(DoomLevelMeshSurface* surface)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
CreateLightList(surface, surface->Subsector->section->lighthead, surface->Subsector->sector->PortalGroup);
|
||||
}
|
||||
|
||||
void DoomLevelMesh::SetSideLightmap(DoomLevelMeshSurface* surface)
|
||||
|
@ -193,12 +205,13 @@ void DoomLevelMesh::SetSideLightmap(DoomLevelMeshSurface* surface)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
CreateLightList(surface, surface->Side->lighthead, surface->Side->sector->PortalGroup);
|
||||
}
|
||||
|
||||
void DoomLevelMesh::CreateLightList(DoomLevelMeshSurface* surface, FLightNode* node, int portalgroup)
|
||||
{
|
||||
surface->LightListBuffer.clear();
|
||||
surface->LightList.clear();
|
||||
|
||||
while (node)
|
||||
{
|
||||
FDynamicLight* light = node->lightsource;
|
||||
|
@ -206,7 +219,7 @@ void DoomLevelMesh::CreateLightList(DoomLevelMeshSurface* surface, FLightNode* n
|
|||
DVector3 pos = light->PosRelative(portalgroup);
|
||||
|
||||
LevelMeshLight meshlight;
|
||||
meshlight.Origin = { (float)pos.X, (float)pos.Z, (float)pos.Y };
|
||||
meshlight.Origin = { (float)pos.X, (float)pos.Y, (float)pos.Z };
|
||||
meshlight.RelativeOrigin = meshlight.Origin; // ?? what is the difference between this and Origin?
|
||||
meshlight.Radius = (float)light->GetRadius();
|
||||
meshlight.Intensity = 1.0f;
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
return Surfaces[surfaceIndex].bSky;
|
||||
}
|
||||
|
||||
void UpdateLightLists() override;
|
||||
|
||||
LevelMeshSurface* GetSurface(int index) override { return &Surfaces[index]; }
|
||||
int GetSurfaceCount() override { return Surfaces.Size(); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue