mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-04-21 10:20:46 +00:00
Minor refactor and fix 3d floors not being detected for lightmap updates
This commit is contained in:
parent
934ba83503
commit
2bdb495498
4 changed files with 32 additions and 9 deletions
|
@ -735,7 +735,7 @@ public:
|
|||
|
||||
inline void PushVisibleSurface(int surfaceIndex, LevelMeshSurface* surface)
|
||||
{
|
||||
if(surface->needsUpdate && mActiveLightmapSurfaces.Size() < lm_max_updates && mActiveLightmapSurfaces.Find(surfaceIndex) >= mActiveLightmapSurfaces.Size()) // yikes, how awful
|
||||
if(surface->needsUpdate && mActiveLightmapSurfaces.Size() < unsigned(lm_max_updates) && mActiveLightmapSurfaces.Find(surfaceIndex) >= mActiveLightmapSurfaces.Size()) // yikes, how awful
|
||||
mActiveLightmapSurfaces.Push(surfaceIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,15 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals &doomMap)
|
|||
BindLightmapSurfacesToGeometry(doomMap);
|
||||
|
||||
Collision = std::make_unique<TriangleMeshShape>(MeshVertices.Data(), MeshVertices.Size(), MeshElements.Data(), MeshElements.Size());
|
||||
|
||||
// Runtime stuff
|
||||
for (auto& surface : Surfaces)
|
||||
{
|
||||
if ((surface.Type == ST_FLOOR || surface.Type == ST_CEILING) && surface.ControlSector)
|
||||
{
|
||||
XFloorToSurface[surface.ControlSector].Push(&surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoomLevelMesh::CreatePortals()
|
||||
|
|
|
@ -27,6 +27,9 @@ class DoomLevelMesh : public LevelMesh
|
|||
{
|
||||
public:
|
||||
DoomLevelMesh(FLevelLocals &doomMap);
|
||||
|
||||
void CreatePortals();
|
||||
void DumpMesh(const FString& objFilename, const FString& mtlFilename) const;
|
||||
|
||||
bool TraceSky(const FVector3& start, FVector3 direction, float dist)
|
||||
{
|
||||
|
@ -40,17 +43,15 @@ public:
|
|||
LevelMeshSurface* GetSurface(int index) override { return &Surfaces[index]; }
|
||||
int GetSurfaceCount() override { return Surfaces.Size(); }
|
||||
|
||||
|
||||
TArray<DoomLevelMeshSurface> Surfaces;
|
||||
std::vector<std::unique_ptr<LevelMeshLight>> Lights;
|
||||
TArray<FVector2> LightmapUvs;
|
||||
|
||||
static_assert(alignof(FVector2) == alignof(float[2]) && sizeof(FVector2) == sizeof(float) * 2);
|
||||
|
||||
void DumpMesh(const FString& objFilename, const FString& mtlFilename) const;
|
||||
// runtime utility variables
|
||||
TMap<sector_t*, TArray<DoomLevelMeshSurface*>> XFloorToSurface;
|
||||
|
||||
void SetupLightmapUvs();
|
||||
|
||||
void CreatePortals();
|
||||
private:
|
||||
void CreateSubsectorSurfaces(FLevelLocals &doomMap);
|
||||
void CreateCeilingSurface(FLevelLocals &doomMap, subsector_t *sub, sector_t *sector, int typeIndex, bool is3DFloor);
|
||||
|
@ -61,6 +62,7 @@ private:
|
|||
void SetSubsectorLightmap(DoomLevelMeshSurface* surface);
|
||||
void SetSideLightmap(DoomLevelMeshSurface* surface);
|
||||
|
||||
void SetupLightmapUvs();
|
||||
void PropagateLight(const LevelMeshLight* light, std::set<LevelMeshPortal, RecursivePortalComparator>& touchedPortals, int lightPropagationRecursiveDepth);
|
||||
void CreateLightList();
|
||||
|
||||
|
|
|
@ -192,12 +192,24 @@ void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
|
|||
}
|
||||
state.SetLightIndex(dynlightindex);
|
||||
|
||||
const auto* lm = §or->Level->levelMesh->Surfaces[0]; // temporay hack on top of a temporary hack
|
||||
|
||||
for (auto& subsector : section->subsectors)
|
||||
{
|
||||
auto lightmap = subsector->lightmap[ceiling ? 1 : 0][0];
|
||||
if (lightmap)
|
||||
if (auto lightmap = subsector->lightmap[ceiling ? 1 : 0][0])
|
||||
{
|
||||
state.PushVisibleSurface(lightmap - &subsector->sector->Level->levelMesh->Surfaces[0], lightmap);
|
||||
state.PushVisibleSurface(lightmap - lm, lightmap);
|
||||
}
|
||||
}
|
||||
|
||||
if (auto subsectors = sector->Level->levelMesh->XFloorToSurface.CheckKey(sector))
|
||||
{
|
||||
for (auto* surface : *subsectors)
|
||||
{
|
||||
if (surface)
|
||||
{
|
||||
state.PushVisibleSurface(surface - lm, surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue