diff --git a/specs/udmf_zdoom.txt b/specs/udmf_zdoom.txt index 57b32f98bc..b3762cba78 100644 --- a/specs/udmf_zdoom.txt +++ b/specs/udmf_zdoom.txt @@ -365,6 +365,11 @@ Note: All fields default to false unless mentioned otherwise. friction = ; // sets the sector's friction factor. Must be between 0 and 1. movefactor = // sets the sector's movement acceleration factor. Must be > 0. + skyfloor = // defines lower sky for this sector. + skyceiling = // defines upper sky for this sector. + skyfloor2 = // defines secondary lower sky for this sector. (for lightning or transparent layers) + skyceiling2 = // defines secondary upper sky for this sector. + colormap = ; // only provided for backwards compatibility. Do not use in GZDoom projects. * Note about dropactors diff --git a/src/gamedata/r_defs.h b/src/gamedata/r_defs.h index 3b909ce282..d0b58ce9c0 100644 --- a/src/gamedata/r_defs.h +++ b/src/gamedata/r_defs.h @@ -667,6 +667,7 @@ struct sector_t float GlowHeight; FTextureID Texture; TextureManipulation TextureFx; + FTextureID skytexture[2]; }; @@ -690,7 +691,7 @@ struct sector_t int special; // map-defined sector special type - int sky; // MBF sky transfer info. + int skytransfer; // MBF sky transfer info. int validcount; // if == validcount, already checked uint32_t selfmap, bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps @@ -826,7 +827,6 @@ public: int CheckSpriteGlow(int lightlevel, const DVector3 &pos); bool GetWallGlow(float *topglowcolor, float *bottomglowcolor); - void SetXOffset(int pos, double o) { planes[pos].xform.xOffs = o; diff --git a/src/maploader/maploader.h b/src/maploader/maploader.h index 9848961bf8..432d75197d 100644 --- a/src/maploader/maploader.h +++ b/src/maploader/maploader.h @@ -197,7 +197,6 @@ private: void CreateScroller(EScroll type, double dx, double dy, sector_t *sect, side_t* side, int accel, EScrollPos scrollpos = EScrollPos::scw_all, int scrollmode = 15/*SCROLL_All*/); void SpawnScrollers(); void SpawnFriction(); - void SpawnUDMFFriction(double friction_factor, double move_factor, sector_t* sec); void SpawnPushers(); AActor *GetPushThing (int s); void SpawnPortal(line_t *line, int sectortag, int plane, int bytealpha, int linked); diff --git a/src/maploader/specials.cpp b/src/maploader/specials.cpp index 0c07539eed..c52b869a84 100644 --- a/src/maploader/specials.cpp +++ b/src/maploader/specials.cpp @@ -609,7 +609,7 @@ void MapLoader::InitSectorSpecial(sector_t *sector, int special) break; case Sky2: - sector->sky = PL_SKYFLAT; + sector->skytransfer = PL_SKYFLAT; break; default: @@ -872,7 +872,7 @@ void MapLoader::SpawnSpecials () { auto itr = Level->GetSectorTagIterator(line.args[0]); while ((s = itr.Next()) >= 0) - Level->sectors[s].sky = (line.Index() + 1) | PL_SKYFLAT; + Level->sectors[s].skytransfer = (line.Index() + 1) | PL_SKYFLAT; break; } } diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index 206b7b85fc..4f79115310 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -2124,6 +2124,22 @@ public: movefactor = CheckFloat(key); break; + case NAME_skyfloor: + sec->planes[sector_t::floor].skytexture[0] = TexMan.CheckForTexture(CheckString(key), ETextureType::Wall, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst); + break; + + case NAME_skyfloor2: + sec->planes[sector_t::floor].skytexture[1] = TexMan.CheckForTexture(CheckString(key), ETextureType::Wall, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst); + break; + + case NAME_skyceiling: + sec->planes[sector_t::ceiling].skytexture[0] = TexMan.CheckForTexture(CheckString(key), ETextureType::Wall, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst); + break; + + case NAME_skyceiling2: + sec->planes[sector_t::ceiling].skytexture[1] = TexMan.CheckForTexture(CheckString(key), ETextureType::Wall, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst); + break; + // These two are used by Eternity for something I do not understand. //case NAME_portal_ceil_useglobaltex: //case NAME_portal_floor_useglobaltex: diff --git a/src/namedef_custom.h b/src/namedef_custom.h index 9554d591e5..c66b3b3176 100644 --- a/src/namedef_custom.h +++ b/src/namedef_custom.h @@ -886,6 +886,8 @@ xx(thrustlocation) xx(colormap) xx(skyfloor) xx(skyceiling) +xx(skyfloor2) +xx(skyceiling2) xx(frictionfactor) xx(movefactor) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index de7f2a49d7..adcea8d903 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -308,7 +308,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t ("damageinterval", p.damageinterval, def->damageinterval) ("leakydamage", p.leakydamage, def->leakydamage) ("damagetype", p.damagetype, def->damagetype) - ("sky", p.sky, def->sky) + ("sky", p.skytransfer, def->skytransfer) ("moreflags", p.MoreFlags, def->MoreFlags) ("flags", p.Flags, def->Flags) .Array("portals", p.Portals, def->Portals, 2, true) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 2563e5a4fd..02f89c860d 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -186,6 +186,10 @@ static void PrecacheLevel(FLevelLocals *Level) { AddToList(hitlist.Data(), Level->sectors[i].GetTexture(sector_t::floor), FTextureManager::HIT_Flat); AddToList(hitlist.Data(), Level->sectors[i].GetTexture(sector_t::ceiling), FTextureManager::HIT_Flat); + AddToList(hitlist.Data(), Level->sectors[i].planes[0].skytexture[0], FTextureManager::HIT_Wall); + AddToList(hitlist.Data(), Level->sectors[i].planes[0].skytexture[1], FTextureManager::HIT_Wall); + AddToList(hitlist.Data(), Level->sectors[i].planes[1].skytexture[0], FTextureManager::HIT_Wall); + AddToList(hitlist.Data(), Level->sectors[i].planes[1].skytexture[1], FTextureManager::HIT_Wall); } for (i = Level->sides.Size() - 1; i >= 0; i--) diff --git a/src/playsim/p_sectors.cpp b/src/playsim/p_sectors.cpp index a194f177ad..a9014c2ce2 100644 --- a/src/playsim/p_sectors.cpp +++ b/src/playsim/p_sectors.cpp @@ -1637,3 +1637,4 @@ void vertex_t::RecalcVertexHeights() if (numheights <= 2) numheights = 0; // is not in need of any special attention dirty = false; } + diff --git a/src/rendering/hwrenderer/scene/hw_portal.cpp b/src/rendering/hwrenderer/scene/hw_portal.cpp index cb416995c0..565cf2794a 100644 --- a/src/rendering/hwrenderer/scene/hw_portal.cpp +++ b/src/rendering/hwrenderer/scene/hw_portal.cpp @@ -1029,7 +1029,7 @@ void HWEEHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state) sector->GetTexture(sector_t::ceiling) == skyflatnum) { HWSkyInfo skyinfo; - skyinfo.init(di, sector->sky, 0); + skyinfo.init(di, sector, sector_t::ceiling, sector->skytransfer, 0); HWSkyPortal sky(screen->mSkyData, mState, &skyinfo, true); sky.DrawContents(di, state); } diff --git a/src/rendering/hwrenderer/scene/hw_portal.h b/src/rendering/hwrenderer/scene/hw_portal.h index 3eebaee2d9..29481f9e32 100644 --- a/src/rendering/hwrenderer/scene/hw_portal.h +++ b/src/rendering/hwrenderer/scene/hw_portal.h @@ -30,7 +30,7 @@ struct HWSkyInfo { return !!memcmp(this, &inf, sizeof(*this)); } - void init(HWDrawInfo *di, int sky1, PalEntry fadecolor); + void init(HWDrawInfo *di, sector_t* sec, int skypos, int sky1, PalEntry fadecolor); }; struct HWHorizonInfo diff --git a/src/rendering/hwrenderer/scene/hw_sky.cpp b/src/rendering/hwrenderer/scene/hw_sky.cpp index 830bb7b9ce..dfa954530f 100644 --- a/src/rendering/hwrenderer/scene/hw_sky.cpp +++ b/src/rendering/hwrenderer/scene/hw_sky.cpp @@ -37,13 +37,26 @@ CVAR(Bool,gl_noskyboxes, false, 0) +//=========================================================================== +// +// +// +//=========================================================================== + +FTextureID GetSkyTexture(sector_t* sec, int plane, int second) +{ + auto tex = sec->planes[plane].skytexture[second]; + if (tex.isValid()) return tex; + return second ? sec->Level->skytexture2 : sec->Level->skytexture1; +} + //========================================================================== // // Set up the skyinfo struct // //========================================================================== -void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor) +void HWSkyInfo::init(HWDrawInfo *di, sector_t* sec, int skypos, int sky1, PalEntry FadeColor) { memset(this, 0, sizeof(*this)); if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT - 1))) @@ -73,25 +86,27 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor) else { normalsky: + auto skytex1 = GetSkyTexture(sec, skypos, false); + auto skytex2 = GetSkyTexture(sec, skypos, true); if (di->Level->flags&LEVEL_DOUBLESKY) { - auto tex1 = TexMan.GetGameTexture(di->Level->skytexture1, true); + auto tex1 = TexMan.GetGameTexture(skytex1); texture[1] = tex1; x_offset[1] = di->Level->hw_sky1pos; doublesky = true; } if ((di->Level->flags&LEVEL_SWAPSKIES || (sky1 == PL_SKYFLAT) || (di->Level->flags&LEVEL_DOUBLESKY)) && - di->Level->skytexture2 != di->Level->skytexture1) // If both skies are equal use the scroll offset of the first! + skytex2 != skytex1) // If both skies are equal use the scroll offset of the first! { - texture[0] = TexMan.GetGameTexture(di->Level->skytexture2, true); - skytexno1 = di->Level->skytexture2; + texture[0] = TexMan.GetGameTexture(skytex2, true); + skytexno1 = skytex2; sky2 = true; x_offset[0] = di->Level->hw_sky2pos; } else if (!doublesky) { - texture[0] = TexMan.GetGameTexture(di->Level->skytexture1, true); + texture[0] = TexMan.GetGameTexture(skytex1, true); skytexno1 = di->Level->skytexture1; x_offset[0] = di->Level->hw_sky1pos; } @@ -125,7 +140,7 @@ void HWWall::SkyPlane(HWWallDispatcher *di, sector_t *sector, int plane, bool al if (di->di) { HWSkyInfo skyinfo; - skyinfo.init(di->di, sector->sky, Colormap.FadeColor); + skyinfo.init(di->di, sector, plane, sector->skytransfer, Colormap.FadeColor); ptype = PORTALTYPE_SKY; sky = &skyinfo; } @@ -199,7 +214,7 @@ void HWWall::SkyLine(HWWallDispatcher *di, sector_t *fs, line_t *line) } else { - if (di->di) skyinfo.init(di->di, fs->sky, Colormap.FadeColor); + if (di->di) skyinfo.init(di->di, fs, sector_t::ceiling, fs->skytransfer, Colormap.FadeColor); ptype = PORTALTYPE_SKY; sky = &skyinfo; } diff --git a/src/rendering/swrenderer/scene/r_opaque_pass.cpp b/src/rendering/swrenderer/scene/r_opaque_pass.cpp index b688ef636e..17291bb494 100644 --- a/src/rendering/swrenderer/scene/r_opaque_pass.cpp +++ b/src/rendering/swrenderer/scene/r_opaque_pass.cpp @@ -555,7 +555,7 @@ namespace swrenderer frontsector->GetAlpha(sector_t::ceiling), !!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE), frontsector->planes[sector_t::ceiling].xform, - frontsector->sky, + frontsector->skytransfer, portal, basecolormap, Fake3DOpaque::Normal, @@ -595,7 +595,7 @@ namespace swrenderer frontsector->GetAlpha(sector_t::floor), !!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE), frontsector->planes[sector_t::floor].xform, - frontsector->sky, + frontsector->skytransfer, portal, basecolormap, Fake3DOpaque::Normal, @@ -732,7 +732,7 @@ namespace swrenderer tempsec.GetAlpha(sector_t::floor), !!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS), tempsec.planes[position].xform, - tempsec.sky, + tempsec.skytransfer, nullptr, basecolormap, Fake3DOpaque::FakeFloor, @@ -800,7 +800,7 @@ namespace swrenderer tempsec.GetAlpha(sector_t::ceiling), !!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS), tempsec.planes[position].xform, - tempsec.sky, + tempsec.skytransfer, nullptr, basecolormap, Fake3DOpaque::FakeCeiling, diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index 3b7a1898ed..ae191ecec7 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2861,7 +2861,7 @@ DEFINE_FIELD_X(Sector, sector_t, SoundTarget) DEFINE_FIELD_X(Sector, sector_t, special) DEFINE_FIELD_X(Sector, sector_t, lightlevel) DEFINE_FIELD_X(Sector, sector_t, seqType) -DEFINE_FIELD_X(Sector, sector_t, sky) +DEFINE_FIELD_NAMED_X(Sector, sector_t, skytransfer, sky) DEFINE_FIELD_X(Sector, sector_t, SeqName) DEFINE_FIELD_X(Sector, sector_t, centerspot) DEFINE_FIELD_X(Sector, sector_t, validcount)