Update CheckSkySectors to consider floors

This commit is contained in:
RaveYard 2022-06-24 14:53:13 +02:00
parent 3e701313dc
commit 867af9edcc
3 changed files with 42 additions and 19 deletions

View file

@ -120,6 +120,12 @@ struct MapSector
short tag; short tag;
}; };
enum SecPlaneType
{
PLANE_FLOOR,
PLANE_CEILING,
};
struct IntSector struct IntSector
{ {
// none of the sector properties are used by the node builder // none of the sector properties are used by the node builder
@ -140,7 +146,14 @@ struct IntSector
bool controlsector; bool controlsector;
TArray<IntSector*> x3dfloors; TArray<IntSector*> 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<UDMFKey> props; TArray<UDMFKey> props;

View file

@ -124,23 +124,21 @@ void FLevel::SetupLights()
void FLevel::CheckSkySectors() void FLevel::CheckSkySectors()
{ {
char name[65]; for (auto& sector : Sectors)
for (int i = 0; i < (int)Sectors.Size(); ++i)
{ {
//if (mapDef && mapDef->sunIgnoreTag != 0 && Sectors[i].data.tag == mapDef->sunIgnoreTag) for (int i = 0; i < 2; ++i)
{
sector.skyPlanes[i] = false;
//if (mapDef && mapDef->sunIgnoreTag != 0 && sector.data.tag == mapDef->sunIgnoreTag)
// continue; // continue;
strncpy(name, Sectors[i].data.ceilingpic, 64); const auto name = sector.GetTextureName(i);
name[64] = 0;
if (!strncmp(name, "F_SKY001", 64) || !strncmp(name, "F_SKY1", 64) || !strncmp(name, "F_SKY", 64)) if (!strncmp(name, "F_SKY001", 64) || !strncmp(name, "F_SKY1", 64) || !strncmp(name, "F_SKY", 64))
{ {
Sectors[i].skySector = true; sector.skyPlanes[i] = true;
} }
else
{
Sectors[i].skySector = false;
} }
} }
} }

View file

@ -570,7 +570,17 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
// bottom seg // bottom seg
if (v1Bottom < v1BottomBack || v2Bottom < v2BottomBack) 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 texWidth = 128.0f;
float texHeight = 128.0f; float texHeight = 128.0f;
@ -593,6 +603,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
surf->plane.SetDistance(surf->verts[0]); surf->plane.SetDistance(surf->verts[0]);
surf->type = ST_LOWERSIDE; surf->type = ST_LOWERSIDE;
surf->typeIndex = typeIndex; surf->typeIndex = typeIndex;
surf->bSky = bSky;
surf->controlSector = nullptr; surf->controlSector = nullptr;
surf->sampleDimension = (surf->sampleDimension = side->GetSampleDistanceBottom()) ? surf->sampleDimension : defaultSamples; surf->sampleDimension = (surf->sampleDimension = side->GetSampleDistanceBottom()) ? surf->sampleDimension : defaultSamples;
@ -620,7 +631,7 @@ void LevelMesh::CreateSideSurfaces(FLevel &doomMap, IntSideDef *side)
{ {
bool bSky = false; bool bSky = false;
if (front->skySector && back->skySector) if (front->skyCeiling && back->skyCeiling)
{ {
if (front->data.ceilingheight != back->data.ceilingheight && side->toptexture[0] == '-') 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->numVerts = sub->numlines;
surf->verts.resize(surf->numVerts); surf->verts.resize(surf->numVerts);
surf->uvs.resize(surf->numVerts); surf->uvs.resize(surf->numVerts);
surf->bSky = sector->skyFloor;
if (!is3DFloor) if (!is3DFloor)
{ {
@ -764,7 +776,7 @@ void LevelMesh::CreateCeilingSurface(FLevel &doomMap, MapSubsectorEx *sub, IntSe
surf->numVerts = sub->numlines; surf->numVerts = sub->numlines;
surf->verts.resize(surf->numVerts); surf->verts.resize(surf->numVerts);
surf->uvs.resize(surf->numVerts); surf->uvs.resize(surf->numVerts);
surf->bSky = sector->skySector; surf->bSky = sector->skyCeiling;
if (!is3DFloor) if (!is3DFloor)
{ {