diff --git a/src/framework/textureid.h b/src/framework/textureid.h index d2306d2..d3c9cd1 100644 --- a/src/framework/textureid.h +++ b/src/framework/textureid.h @@ -3,6 +3,8 @@ #include "framework/tarray.h" #include "framework/templates.h" #include "framework/zstring.h" +#include +#include class FGameTexture; @@ -87,12 +89,37 @@ public: extern FFileSystem fileSystem; +class FGameTexture +{ +public: + bool isValid() const { return Valid; } + float GetDisplayWidth() const { return 64.0f; } + float GetDisplayHeight() const { return 64.0f; } + float GetScaleY() const { return 1.0f; } + +private: + FString Name; + bool Valid = true; + + friend class FTextureManager; +}; + class FTextureManager { public: + FTextureManager() + { + Textures.Push(std::make_unique()); + Textures.Last()->Name = "-"; + Textures.Last()->Valid = false; + } + FGameTexture* GetGameTexture(FTextureID texnum, bool animate = false) { - return nullptr; + if (!texnum.isValid() || texnum.isNull()) + return Textures[0].get(); + + return Textures[texnum.GetIndex()].get(); } enum @@ -125,19 +152,20 @@ public: if (name[0] == '-' && name[1] == '\0') return FTextureID(0); - // To do: actually build up a list of texture ids - return FTextureID(1); + auto it = NameToID.find(name); + if (it != NameToID.end()) + return FTextureID(it->second); + + int id = Textures.Size(); + Textures.Push(std::make_unique()); + Textures.Last()->Name = name; + NameToID[name] = id; + + return FTextureID(id); } - + std::map NameToID; + TArray> Textures; }; extern FTextureManager TexMan; - -class FGameTexture -{ -public: - bool isValid() const { return false; } - float GetDisplayWidth() const { return 64.0f; } - float GetDisplayHeight() const { return 64.0f; } -}; diff --git a/src/level/doomdata.h b/src/level/doomdata.h index c2cc904..c5e7559 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -190,6 +190,9 @@ struct IntSector Plane ceilingplane; Plane floorplane; + double floorTexZ; + double ceilingTexZ; + int sampleDistanceCeiling; int sampleDistanceFloor; diff --git a/src/level/level_udmf.cpp b/src/level/level_udmf.cpp index 3efc27b..3ad9850 100644 --- a/src/level/level_udmf.cpp +++ b/src/level/level_udmf.cpp @@ -450,6 +450,8 @@ void FProcessor::ParseSector(IntSector *sec) sec->sampleDistanceFloor = 0; int ceilingplane = 0, floorplane = 0; + bool floorTexZSet = false; + bool ceilingTexZSet = false; SC_MustGetStringName("{"); while (!SC_CheckString("}")) @@ -457,6 +459,16 @@ void FProcessor::ParseSector(IntSector *sec) const char *value; const char *key = ParseKey(value); + if (stricmp(key, "heightfloor") == 0) + { + sec->floorTexZ = CheckFloat(key); + floorTexZSet = true; + } + else if (stricmp(key, "heightceiling") == 0) + { + sec->ceilingTexZ = CheckFloat(key); + ceilingTexZSet = true; + } if (stricmp(key, "textureceiling") == 0) { CopyUDMFString(sec->data.ceilingpic, 64, value); @@ -468,10 +480,14 @@ void FProcessor::ParseSector(IntSector *sec) else if (stricmp(key, "heightceiling") == 0) { sec->data.ceilingheight = CheckFloat(key); + if (!ceilingTexZSet) + sec->ceilingTexZ = sec->data.ceilingheight; } else if (stricmp(key, "heightfloor") == 0) { sec->data.floorheight = CheckFloat(key); + if (!floorTexZSet) + sec->floorTexZ = sec->data.floorheight; } else if (stricmp(key, "lightlevel") == 0) { diff --git a/src/lightmapper/doom_levelmesh.cpp b/src/lightmapper/doom_levelmesh.cpp index e97f846..bd099ef 100644 --- a/src/lightmapper/doom_levelmesh.cpp +++ b/src/lightmapper/doom_levelmesh.cpp @@ -224,11 +224,7 @@ void DoomLevelMesh::CreateSideSurfaces(FLevel& doomMap, IntSideDef* side) float v2Top = (float)front->ceilingplane.ZatPoint(v2); float v2Bottom = (float)front->floorplane.ZatPoint(v2); - /*if (side->line->getPortal() && side->line->frontsector == front) - { - CreateLinePortalSurface(doomMap, side); - } - else*/ if (side->line->special == Line_Horizon && front != back) + if (side->line->special == Line_Horizon && front != back) { CreateLineHorizonSurface(doomMap, side); } @@ -382,14 +378,14 @@ void DoomLevelMesh::CreateMidWallSurface(FLevel& doomMap, IntSideDef* side) const auto& texture = side->GetTexture(WallPart::MIDDLE); - //if ((side->Flags & WALLF_WRAP_MIDTEX) || (side->line->flags & WALLF_WRAP_MIDTEX)) + if (/*(side->flags & ML_3DMIDTEX) ||*/ (side->line->flags & ML_3DMIDTEX)) { verts[0].z = v1Bottom; verts[1].z = v2Bottom; verts[2].z = v1Top; verts[3].z = v2Top; } - /*else + else { int offset = 0; @@ -404,18 +400,18 @@ void DoomLevelMesh::CreateMidWallSurface(FLevel& doomMap, IntSideDef* side) if (side->line->flags & ML_DONTPEGBOTTOM) { - yTextureOffset += (float)side->sectordef->planes[PLANE_FLOOR].TexZ; + yTextureOffset += (float)side->sectordef->floorTexZ; } else { - yTextureOffset += (float)(side->sectordef->planes[PLANE_CEILING].TexZ - gameTexture->GetDisplayHeight() / side->GetTextureYScale(WallPart::MIDDLE)); + yTextureOffset += (float)(side->sectordef->ceilingTexZ - gameTexture->GetDisplayHeight() / side->GetTextureYScale(WallPart::MIDDLE)); } verts[0].z = std::min(std::max(yTextureOffset + mid1Bottom, v1Bottom), v1Top); verts[1].z = std::min(std::max(yTextureOffset + mid2Bottom, v2Bottom), v2Top); verts[2].z = std::max(std::min(yTextureOffset + mid1Top, v1Top), v1Bottom); verts[3].z = std::max(std::min(yTextureOffset + mid2Top, v2Top), v2Bottom); - }*/ + } // mid texture DoomLevelMeshSurface surf; @@ -775,16 +771,14 @@ bool DoomLevelMesh::IsTopSideSky(IntSector* frontsector, IntSector* backsector, bool DoomLevelMesh::IsTopSideVisible(IntSideDef* side) { - //auto tex = TexMan.GetGameTexture(side->GetTexture(WallPart::TOP), true); - //return tex && tex->isValid(); - return true; + auto tex = TexMan.GetGameTexture(side->GetTexture(WallPart::TOP), true); + return tex && tex->isValid(); } bool DoomLevelMesh::IsBottomSideVisible(IntSideDef* side) { - //auto tex = TexMan.GetGameTexture(side->GetTexture(WallPart::BOTTOM), true); - //return tex && tex->isValid(); - return true; + auto tex = TexMan.GetGameTexture(side->GetTexture(WallPart::BOTTOM), true); + return tex && tex->isValid(); } bool DoomLevelMesh::IsSkySector(IntSector* sector, SecPlaneType plane)