diff --git a/src/common/textures/skyboxtexture.cpp b/src/common/textures/skyboxtexture.cpp index b77a2ad3b..c5616643b 100644 --- a/src/common/textures/skyboxtexture.cpp +++ b/src/common/textures/skyboxtexture.cpp @@ -44,7 +44,6 @@ FSkyBox::FSkyBox(const char *name) } else previous = nullptr; faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5] = nullptr; - bSkybox = true; fliptop = false; } diff --git a/src/common/textures/skyboxtexture.h b/src/common/textures/skyboxtexture.h index 14ada8b4a..645e54b93 100644 --- a/src/common/textures/skyboxtexture.h +++ b/src/common/textures/skyboxtexture.h @@ -1,3 +1,42 @@ #pragma once #include "textures.h" + +//----------------------------------------------------------------------------- +// +// Todo: Get rid of this +// The faces can easily be stored in the material layer array +// +//----------------------------------------------------------------------------- + +class FSkyBox : public FImageTexture +{ +public: + + FGameTexture* previous; + FGameTexture* faces[6]; // the faces need to be full materials as they can have all supported effects. + bool fliptop; + + FSkyBox(const char* name); + void SetSize(); + + bool Is3Face() const + { + return faces[5] == nullptr; + } + + bool IsFlipped() const + { + return fliptop; + } + + FGameTexture* GetSkyFace(int num) const + { + return faces[num]; + } + + bool GetSkyFlip() const + { + return fliptop; + } +}; diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index d559c7131..2ffab8d1f 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -94,7 +94,6 @@ FTexture::FTexture (int lumpnum) bNoRemap0(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0) { - bSkybox = false; bNoCompress = false; bTranslucent = -1; } diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index d6872c697..a062cb643 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -258,7 +258,6 @@ protected: uint8_t bAlphaTexture : 1; // Texture is an alpha channel without color information uint8_t bHasCanvas : 1; // Texture is based off FCanvasTexture - uint8_t bSkybox : 1; // is a cubic skybox int8_t bTranslucent : 2; uint16_t Rotations; @@ -447,35 +446,6 @@ enum }; -//----------------------------------------------------------------------------- -// -// Todo: Get rid of this -// The faces can easily be stored in the material layer array -// -//----------------------------------------------------------------------------- - -class FSkyBox : public FImageTexture -{ -public: - - FGameTexture* previous; - FGameTexture* faces[6]; // the faces need to be full materials as they can have all supported effects. - bool fliptop; - - FSkyBox(const char* name); - void SetSize(); - - bool Is3Face() const - { - return faces[5] == nullptr; - } - - bool IsFlipped() const - { - return fliptop; - } -}; - enum EGameTexFlags { GTexf_NoDecals = 1, // Decals should not stick to texture @@ -644,7 +614,6 @@ public: bool isUserContent() const; int CheckRealHeight() { return xs_RoundToInt(Base->CheckRealHeight() / ScaleY); } - bool isSkybox() const { return Base->bSkybox; } void SetSize(int x, int y) { TexelWidth = x; @@ -684,13 +653,6 @@ public: return Base->GetTranslucency(); } - // Since these properties will later piggyback on existing members of FGameTexture, the accessors need to be here. - FGameTexture *GetSkyFace(int num) - { - return (isSkybox() ? static_cast(Base.get())->faces[num] : nullptr); - } - bool GetSkyFlip() { return isSkybox() ? static_cast(Base.get())->fliptop : false; } - int GetClampMode(int clampmode) { if (GetUseType() == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index fbd93e75e..c7ab8dfd4 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -78,6 +78,7 @@ #include "s_music.h" #include "animations.h" #include "texturemanager.h" +#include "p_lnspec.h" extern AActor *SpawnMapThing (int index, FMapThing *mthing, int position); @@ -188,9 +189,13 @@ static void PrecacheLevel(FLevelLocals *Level) for (i = Level->sides.Size() - 1; i >= 0; i--) { - AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::top), FTextureManager::HIT_Wall); - AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::mid), FTextureManager::HIT_Wall); - AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::bottom), FTextureManager::HIT_Wall); + auto &sd = Level->sides[i]; + int hitflag = FTextureManager::HIT_Wall; + // Only precache skyboxes when this is actually used as a sky transfer. + if (sd.linedef->sidedef[0] == &sd && sd.linedef->special == Static_Init && sd.linedef->args[1] == Init_TransferSky) hitflag |= FTextureManager::HIT_Sky; + AddToList(hitlist.Data(), sd.GetTexture(side_t::top), hitflag); + AddToList(hitlist.Data(), sd.GetTexture(side_t::mid), FTextureManager::HIT_Wall); + AddToList(hitlist.Data(), sd.GetTexture(side_t::bottom), hitflag); } diff --git a/src/rendering/hwrenderer/scene/hw_portal.h b/src/rendering/hwrenderer/scene/hw_portal.h index 10fd90d7d..88a920a2f 100644 --- a/src/rendering/hwrenderer/scene/hw_portal.h +++ b/src/rendering/hwrenderer/scene/hw_portal.h @@ -8,6 +8,7 @@ #include "hw_renderstate.h" #include "hw_material.h" +class FSkyBox; struct HWSkyInfo { @@ -358,7 +359,7 @@ struct HWSkyPortal : public HWPortal friend struct HWEEHorizonPortal; void RenderRow(HWDrawInfo *di, FRenderState &state, EDrawType prim, int row, bool apply = true); - void RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * gltex, float x_offset, bool sky2); + void RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FSkyBox * gltex, float x_offset, bool sky2); void RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture * tex, float x_offset, float y_offset, bool mirror, int mode); protected: diff --git a/src/rendering/hwrenderer/scene/hw_skyportal.cpp b/src/rendering/hwrenderer/scene/hw_skyportal.cpp index a41fff53e..cc945178d 100644 --- a/src/rendering/hwrenderer/scene/hw_skyportal.cpp +++ b/src/rendering/hwrenderer/scene/hw_skyportal.cpp @@ -93,12 +93,13 @@ void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture * // //----------------------------------------------------------------------------- -void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * tex, float x_offset, bool sky2) +void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FSkyBox * tex, float x_offset, bool sky2) { int faces; state.EnableModelMatrix(true); state.mModelMatrix.loadIdentity(); + state.mModelMatrix.scale(1, 1 / di->Level->info->pixelstretch, 1); // Undo the map's vertical scaling as skyboxes are true cubes. if (!sky2) state.mModelMatrix.rotate(-180.0f+x_offset, di->Level->info->skyrotatevector.X, di->Level->info->skyrotatevector.Z, di->Level->info->skyrotatevector.Y); @@ -171,9 +172,10 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state) di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); state.SetVertexBuffer(vertexBuffer); - if (origin->texture[0] && origin->texture[0]->isSkybox()) + auto skybox = origin->texture[0] ? dynamic_cast(origin->texture[0]->GetTexture()) : nullptr; + if (skybox) { - RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); + RenderBox(di, state, origin->skytexno1, skybox, origin->x_offset[0], origin->sky2); } else { diff --git a/src/rendering/hwrenderer/textures/hw_precache.cpp b/src/rendering/hwrenderer/textures/hw_precache.cpp index dd2932121..f3518bfb8 100644 --- a/src/rendering/hwrenderer/textures/hw_precache.cpp +++ b/src/rendering/hwrenderer/textures/hw_precache.cpp @@ -101,12 +101,12 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap &actorhitl for (int i = 0; iisSkybox()) + auto sb = dynamic_cast(tex->GetTexture()); + if (sb) { - FSkyBox *sb = static_cast(tex->GetTexture()); for (int i = 0; i<6; i++) { if (sb->faces[i])