From 867af9edcc55f59cde333806d5589ea629dcf3c3 Mon Sep 17 00:00:00 2001 From: RaveYard Date: Fri, 24 Jun 2022 14:53:13 +0200 Subject: [PATCH] Update CheckSkySectors to consider floors --- src/level/doomdata.h | 15 ++++++++++++++- src/level/level_light.cpp | 28 +++++++++++++--------------- src/lightmap/levelmesh.cpp | 18 +++++++++++++++--- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/level/doomdata.h b/src/level/doomdata.h index 8b14f7c..a1adc19 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -120,6 +120,12 @@ struct MapSector short tag; }; +enum SecPlaneType +{ + PLANE_FLOOR, + PLANE_CEILING, +}; + struct IntSector { // none of the sector properties are used by the node builder @@ -140,7 +146,14 @@ struct IntSector bool controlsector; TArray x3dfloors; - bool skySector; + + union + { + bool skyPlanes[2]; + struct { bool skyFloor, skyCeiling; }; + }; + + inline const char* GetTextureName(int plane) const { return plane != PLANE_FLOOR ? data.ceilingpic : data.floorpic; } TArray props; diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index 5fc57fd..ac1d18a 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -124,23 +124,21 @@ void FLevel::SetupLights() void FLevel::CheckSkySectors() { - char name[65]; - - for (int i = 0; i < (int)Sectors.Size(); ++i) + for (auto& sector : Sectors) { - //if (mapDef && mapDef->sunIgnoreTag != 0 && Sectors[i].data.tag == mapDef->sunIgnoreTag) - // continue; - - strncpy(name, Sectors[i].data.ceilingpic, 64); - name[64] = 0; - - if (!strncmp(name, "F_SKY001", 64) || !strncmp(name, "F_SKY1", 64) || !strncmp(name, "F_SKY", 64)) + for (int i = 0; i < 2; ++i) { - Sectors[i].skySector = true; - } - else - { - Sectors[i].skySector = false; + sector.skyPlanes[i] = false; + + //if (mapDef && mapDef->sunIgnoreTag != 0 && sector.data.tag == mapDef->sunIgnoreTag) + // continue; + + const auto name = sector.GetTextureName(i); + + if (!strncmp(name, "F_SKY001", 64) || !strncmp(name, "F_SKY1", 64) || !strncmp(name, "F_SKY", 64)) + { + sector.skyPlanes[i] = true; + } } } } diff --git a/src/lightmap/levelmesh.cpp b/src/lightmap/levelmesh.cpp index 2107317..8f2dcb6 100644 --- a/src/lightmap/levelmesh.cpp +++ b/src/lightmap/levelmesh.cpp @@ -570,7 +570,17 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) // bottom seg if (v1Bottom < v1BottomBack || v2Bottom < v2BottomBack) { - if (side->bottomtexture[0] != '-') + bool bSky = false; + + if (front->skyFloor && back->skyFloor) + { + if (front->data.floorheight != back->data.floorheight && side->bottomtexture[0] == '-') + { + bSky = true; + } + } + + if (side->bottomtexture[0] != '-' || bSky) { float texWidth = 128.0f; float texHeight = 128.0f; @@ -593,6 +603,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) surf->plane.SetDistance(surf->verts[0]); surf->type = ST_LOWERSIDE; surf->typeIndex = typeIndex; + surf->bSky = bSky; surf->controlSector = nullptr; surf->sampleDimension = (surf->sampleDimension = side->GetSampleDistanceBottom()) ? surf->sampleDimension : defaultSamples; @@ -620,7 +631,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) { bool bSky = false; - if (front->skySector && back->skySector) + if (front->skyCeiling && back->skyCeiling) { if (front->data.ceilingheight != back->data.ceilingheight && side->toptexture[0] == '-') { @@ -726,6 +737,7 @@ void LevelMesh::CreateFloorSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSect surf->numVerts = sub->numlines; surf->verts.resize(surf->numVerts); surf->uvs.resize(surf->numVerts); + surf->bSky = sector->skyFloor; if (!is3DFloor) { @@ -764,7 +776,7 @@ void LevelMesh::CreateCeilingSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSe surf->numVerts = sub->numlines; surf->verts.resize(surf->numVerts); surf->uvs.resize(surf->numVerts); - surf->bSky = sector->skySector; + surf->bSky = sector->skyCeiling; if (!is3DFloor) {