mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- moved the static sky variables into FLevelLocals and removed the redundant ones for the texture ID.
This commit is contained in:
parent
06e5dd1d86
commit
3c565c9e86
13 changed files with 89 additions and 91 deletions
|
@ -1055,21 +1055,21 @@ CCMD(changesky)
|
|||
|
||||
if (netgame || argv.argc()<2) return;
|
||||
|
||||
// This only alters the primary level's sky setting. For testing out a sky that is sufficient.
|
||||
sky1name = argv[1];
|
||||
if (sky1name[0] != 0)
|
||||
{
|
||||
FTextureID newsky = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
if (newsky.Exists())
|
||||
{
|
||||
// This only alters the primary level's sky setting.
|
||||
sky1texture = currentUILevel->skytexture1 = newsky;
|
||||
currentUILevel->skytexture1 = newsky;
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("changesky: Texture '%s' not found\n", sky1name);
|
||||
}
|
||||
}
|
||||
R_InitSkyMap ();
|
||||
InitSkyMap (currentUILevel);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -390,8 +390,7 @@ CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO)
|
|||
{
|
||||
// In case DF_NO_FREELOOK was changed, reinitialize the sky
|
||||
// map. (If no freelook, then no need to stretch the sky.)
|
||||
if (sky1texture.isValid())
|
||||
R_InitSkyMap ();
|
||||
R_InitSkyMap ();
|
||||
|
||||
if (self & DF_NO_FREELOOK)
|
||||
{
|
||||
|
|
|
@ -143,8 +143,8 @@ void FScriptLoader::ParseInfoCmd(char *line, FString &scriptsrc)
|
|||
sc.MustGetStringName("=");
|
||||
sc.MustGetString();
|
||||
|
||||
sky2texture = sky1texture = Level->skytexture1 = Level->skytexture2 = TexMan.GetTextureID (sc.String, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
R_InitSkyMap ();
|
||||
Level->skytexture1 = Level->skytexture2 = TexMan.GetTextureID (sc.String, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
InitSkyMap (Level);
|
||||
}
|
||||
else if (sc.Compare("interpic"))
|
||||
{
|
||||
|
|
|
@ -1001,14 +1001,8 @@ void G_DoLoadLevel (const FString &nextmapname, int position, bool autosave, boo
|
|||
// setting one.
|
||||
skyflatnum = TexMan.GetTextureID (gameinfo.SkyFlatName, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
// DOOM determines the sky texture to be used
|
||||
// depending on the current episode and the game version.
|
||||
// [RH] Fetch sky parameters from FLevelLocals.
|
||||
sky1texture = level.skytexture1;
|
||||
sky2texture = level.skytexture2;
|
||||
|
||||
// [RH] Set up details about sky rendering
|
||||
R_InitSkyMap ();
|
||||
InitSkyMap (&level);
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
|
@ -2162,9 +2156,9 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, ChangeSky)
|
|||
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
||||
PARAM_INT(sky1);
|
||||
PARAM_INT(sky2);
|
||||
sky1texture = self->skytexture1 = FSetTextureID(sky1);
|
||||
sky2texture = self->skytexture2 = FSetTextureID(sky2);
|
||||
R_InitSkyMap();
|
||||
self->skytexture1 = FSetTextureID(sky1);
|
||||
self->skytexture2 = FSetTextureID(sky2);
|
||||
InitSkyMap(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -492,6 +492,10 @@ public:
|
|||
float skyspeed1; // Scrolling speed of sky textures, in pixels per ms
|
||||
float skyspeed2;
|
||||
|
||||
double sky1pos, sky2pos;
|
||||
float hw_sky1pos, hw_sky2pos;
|
||||
bool skystretch;
|
||||
|
||||
int total_secrets;
|
||||
int found_secrets;
|
||||
|
||||
|
|
|
@ -72,24 +72,24 @@ void GLSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
|
|||
normalsky:
|
||||
if (di->Level->flags&LEVEL_DOUBLESKY)
|
||||
{
|
||||
texture[1] = FMaterial::ValidateTexture(sky1texture, false, true);
|
||||
x_offset[1] = hw_sky1pos;
|
||||
texture[1] = FMaterial::ValidateTexture(di->Level->skytexture1, false, true);
|
||||
x_offset[1] = di->Level->hw_sky1pos;
|
||||
doublesky = true;
|
||||
}
|
||||
|
||||
if ((di->Level->flags&LEVEL_SWAPSKIES || (sky1 == PL_SKYFLAT) || (di->Level->flags&LEVEL_DOUBLESKY)) &&
|
||||
sky2texture != sky1texture) // If both skies are equal use the scroll offset of the first!
|
||||
di->Level->skytexture2 != di->Level->skytexture1) // If both skies are equal use the scroll offset of the first!
|
||||
{
|
||||
texture[0] = FMaterial::ValidateTexture(sky2texture, false, true);
|
||||
skytexno1 = sky2texture;
|
||||
texture[0] = FMaterial::ValidateTexture(di->Level->skytexture2, false, true);
|
||||
skytexno1 = di->Level->skytexture2;
|
||||
sky2 = true;
|
||||
x_offset[0] = hw_sky2pos;
|
||||
x_offset[0] = di->Level->hw_sky2pos;
|
||||
}
|
||||
else if (!doublesky)
|
||||
{
|
||||
texture[0] = FMaterial::ValidateTexture(sky1texture, false, true);
|
||||
skytexno1 = sky1texture;
|
||||
x_offset[0] = hw_sky1pos;
|
||||
texture[0] = FMaterial::ValidateTexture(di->Level->skytexture1, false, true);
|
||||
skytexno1 = di->Level->skytexture1;
|
||||
x_offset[0] = di->Level->hw_sky1pos;
|
||||
}
|
||||
}
|
||||
if (di->Level->skyfog > 0)
|
||||
|
|
|
@ -9762,13 +9762,13 @@ scriptwait:
|
|||
sky2name = Level->Behaviors.LookupString (STACK(1));
|
||||
if (sky1name[0] != 0)
|
||||
{
|
||||
sky1texture = Level->skytexture1 = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
Level->skytexture1 = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
}
|
||||
if (sky2name[0] != 0)
|
||||
{
|
||||
sky2texture = Level->skytexture2 = TexMan.GetTextureID(sky2name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
Level->skytexture2 = TexMan.GetTextureID(sky2name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
}
|
||||
R_InitSkyMap ();
|
||||
InitSkyMap (Level);
|
||||
sp -= 2;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "events.h"
|
||||
#include "p_destructible.h"
|
||||
#include "r_sky.h"
|
||||
#include "fragglescript/t_script.h"
|
||||
|
||||
//==========================================================================
|
||||
|
@ -976,9 +977,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
|
|||
|
||||
if (arc.isReading())
|
||||
{
|
||||
sky1texture = skytexture1;
|
||||
sky2texture = skytexture2;
|
||||
R_InitSkyMap();
|
||||
InitSkyMap(this);
|
||||
AirControlChanged();
|
||||
bglobal.freeze = !!(frozenstate & 2);
|
||||
}
|
||||
|
|
|
@ -175,20 +175,14 @@ static void PrecacheLevel(FLevelLocals *Level)
|
|||
AddToList(hitlist.Data(), Level->sides[i].GetTexture(side_t::bottom), FTextureManager::HIT_Wall);
|
||||
}
|
||||
|
||||
// Sky texture is always present.
|
||||
// Note that F_SKY1 is the name used to
|
||||
// indicate a sky floor/ceiling as a flat,
|
||||
// while the sky texture is stored like
|
||||
// a wall texture, with an episode dependant
|
||||
// name.
|
||||
|
||||
if (sky1texture.isValid())
|
||||
if (Level->skytexture1.isValid())
|
||||
{
|
||||
AddToList(hitlist.Data(), sky1texture, FTextureManager::HIT_Sky);
|
||||
AddToList(hitlist.Data(), Level->skytexture1, FTextureManager::HIT_Sky);
|
||||
}
|
||||
if (sky2texture.isValid())
|
||||
if (Level->skytexture2.isValid())
|
||||
{
|
||||
AddToList(hitlist.Data(), sky2texture, FTextureManager::HIT_Sky);
|
||||
AddToList(hitlist.Data(), Level->skytexture2, FTextureManager::HIT_Sky);
|
||||
}
|
||||
|
||||
for (auto n : gameinfo.PrecachedTextures)
|
||||
|
|
|
@ -291,9 +291,10 @@ void PolySkySetup::Update()
|
|||
double skyscale = 0.0;
|
||||
float skyiscale = 0.0f;
|
||||
fixed_t sky1cyl = 0, sky2cyl = 0;
|
||||
auto Level = PolyRenderer::Instance()->Level;
|
||||
|
||||
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
|
||||
auto skytex1 = TexMan.GetPalettedTexture(Level->skytexture1, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(Level->skytexture2, true);
|
||||
|
||||
if (skytex1)
|
||||
{
|
||||
|
@ -307,7 +308,7 @@ void PolySkySetup::Update()
|
|||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(PolyRenderer::Instance()->Level->flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(Level->flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
|
@ -319,7 +320,7 @@ void PolySkySetup::Update()
|
|||
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
if (Level->skystretch)
|
||||
{
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
|
@ -339,13 +340,13 @@ void PolySkySetup::Update()
|
|||
|
||||
if ((PolyRenderer::Instance()->Level->flags & LEVEL_SWAPSKIES) && !(PolyRenderer::Instance()->Level->flags & LEVEL_DOUBLESKY))
|
||||
{
|
||||
sky1tex = sky2texture;
|
||||
sky1tex = Level->skytexture2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sky1tex = sky1texture;
|
||||
sky1tex = Level->skytexture1;
|
||||
}
|
||||
sky2tex = sky2texture;
|
||||
sky2tex = Level->skytexture2;
|
||||
skymid = skytexturemid;
|
||||
skyangle = 0;
|
||||
|
||||
|
@ -360,8 +361,8 @@ void PolySkySetup::Update()
|
|||
else
|
||||
backskytex = nullptr;
|
||||
skyflip = false;
|
||||
frontdpos = sky1pos;
|
||||
backdpos = sky2pos;
|
||||
frontdpos = Level->sky1pos;
|
||||
backdpos = Level->sky2pos;
|
||||
frontcyl = sky1cyl;
|
||||
backcyl = sky2cyl;
|
||||
}
|
||||
|
@ -371,7 +372,7 @@ void PolySkySetup::Update()
|
|||
backskytex = nullptr;
|
||||
frontcyl = sky2cyl;
|
||||
skyflip = false;
|
||||
frontdpos = sky2pos;
|
||||
frontdpos = Level->sky2pos;
|
||||
}
|
||||
else
|
||||
{ // MBF's linedef-controlled skies
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
// sky mapping
|
||||
//
|
||||
FTextureID skyflatnum;
|
||||
FTextureID sky1texture, sky2texture;
|
||||
double sky1pos, sky2pos;
|
||||
float hw_sky1pos, hw_sky2pos;
|
||||
bool skystretch;
|
||||
|
||||
// [RH] Stretch sky texture if not taller than 128 pixels?
|
||||
// Also now controls capped skies. 0 = normal, 1 = stretched, 2 = capped
|
||||
|
@ -65,31 +61,32 @@ CVAR(Float, skyoffset, 0, 0) // for testing
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_InitSkyMap()
|
||||
void InitSkyMap(FLevelLocals *Level)
|
||||
{
|
||||
int skyheight;
|
||||
FTexture *skytex1, *skytex2;
|
||||
|
||||
// Do not allow the null texture which has no bitmap and will crash.
|
||||
if (sky1texture.isNull())
|
||||
if (Level->skytexture1.isNull())
|
||||
{
|
||||
sky1texture = TexMan.CheckForTexture("-noflat-", ETextureType::Any);
|
||||
Level->skytexture1 = TexMan.CheckForTexture("-noflat-", ETextureType::Any);
|
||||
}
|
||||
if (sky2texture.isNull())
|
||||
if (Level->skytexture2.isNull())
|
||||
{
|
||||
sky2texture = TexMan.CheckForTexture("-noflat-", ETextureType::Any);
|
||||
Level->skytexture2 = TexMan.CheckForTexture("-noflat-", ETextureType::Any);
|
||||
}
|
||||
|
||||
skytex1 = TexMan.GetTexture(sky1texture, false);
|
||||
skytex2 = TexMan.GetTexture(sky2texture, false);
|
||||
skytex1 = TexMan.GetTexture(Level->skytexture1, false);
|
||||
skytex2 = TexMan.GetTexture(Level->skytexture2, false);
|
||||
|
||||
if (skytex1 == nullptr)
|
||||
return;
|
||||
|
||||
if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetDisplayHeight() != skytex2->GetDisplayHeight())
|
||||
if ((Level->flags & LEVEL_DOUBLESKY) && skytex1->GetDisplayHeight() != skytex2->GetDisplayHeight())
|
||||
{
|
||||
Printf(TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n");
|
||||
sky2texture = sky1texture;
|
||||
Level->flags &= ~LEVEL_DOUBLESKY;
|
||||
Level->skytexture1 = Level->skytexture2;
|
||||
}
|
||||
|
||||
// There are various combinations for sky rendering depending on how tall the sky is:
|
||||
|
@ -109,14 +106,23 @@ void R_InitSkyMap()
|
|||
|
||||
if (skyheight >= 128 && skyheight < 200)
|
||||
{
|
||||
skystretch = (r_skymode == 1
|
||||
Level->skystretch = (r_skymode == 1
|
||||
&& skyheight >= 128
|
||||
&& level.IsFreelookAllowed()
|
||||
&& !(level.flags & LEVEL_FORCETILEDSKY)) ? 1 : 0;
|
||||
&& Level->IsFreelookAllowed()
|
||||
&& !(Level->flags & LEVEL_FORCETILEDSKY)) ? 1 : 0;
|
||||
}
|
||||
else skystretch = false;
|
||||
else Level->skystretch = false;
|
||||
}
|
||||
|
||||
void R_InitSkyMap()
|
||||
{
|
||||
for(auto Level : AllLevels())
|
||||
{
|
||||
InitSkyMap(Level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_UpdateSky
|
||||
|
@ -127,14 +133,16 @@ void R_InitSkyMap()
|
|||
|
||||
void R_UpdateSky (uint64_t mstime)
|
||||
{
|
||||
// Scroll the sky
|
||||
double ms = (double)mstime * FRACUNIT;
|
||||
sky1pos = ms * level.skyspeed1;
|
||||
sky2pos = ms * level.skyspeed2;
|
||||
|
||||
// The hardware renderer uses a different value range and clamps it to a single rotation
|
||||
hw_sky1pos = (float)(fmod((double(mstime) * level.skyspeed1), 1024.) * (90. / 256.));
|
||||
hw_sky2pos = (float)(fmod((double(mstime) * level.skyspeed2), 1024.) * (90. / 256.));
|
||||
for(auto Level : AllLevels())
|
||||
{
|
||||
// Scroll the sky
|
||||
Level->sky1pos = ms * level.skyspeed1;
|
||||
Level->sky2pos = ms * level.skyspeed2;
|
||||
|
||||
// The hardware renderer uses a different value range and clamps it to a single rotation
|
||||
Level->hw_sky1pos = (float)(fmod((double(mstime) * level.skyspeed1), 1024.) * (90. / 256.));
|
||||
Level->hw_sky2pos = (float)(fmod((double(mstime) * level.skyspeed2), 1024.) * (90. / 256.));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,17 +30,16 @@
|
|||
|
||||
#include "textures/textures.h"
|
||||
|
||||
struct FLevelLocals;
|
||||
|
||||
extern FTextureID skyflatnum;
|
||||
extern FTextureID sky1texture, sky2texture;
|
||||
extern double sky1pos, sky2pos;
|
||||
extern float hw_sky1pos, hw_sky2pos;
|
||||
extern bool skystretch;
|
||||
extern int freelookviewheight;
|
||||
|
||||
#define SKYSTRETCH_HEIGHT 228
|
||||
|
||||
// Called whenever the sky changes.
|
||||
void R_InitSkyMap ();
|
||||
void InitSkyMap(FLevelLocals *Level);
|
||||
void R_InitSkyMap();
|
||||
void R_UpdateSky (uint64_t mstime);
|
||||
|
||||
// 57 world units roughly represent one sky texel for the glTranslate call.
|
||||
|
|
|
@ -72,8 +72,8 @@ namespace swrenderer
|
|||
Thread = thread;
|
||||
auto Level = Thread->Viewport->Level();
|
||||
|
||||
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
|
||||
auto skytex1 = TexMan.GetPalettedTexture(Level->skytexture1, true);
|
||||
auto skytex2 = TexMan.GetPalettedTexture(Level->skytexture2, true);
|
||||
|
||||
if (skytex1 == nullptr)
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ namespace swrenderer
|
|||
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
if (Level->skystretch)
|
||||
{
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
|
@ -123,13 +123,13 @@ namespace swrenderer
|
|||
|
||||
if ((Level->flags & LEVEL_SWAPSKIES) && !(Level->flags & LEVEL_DOUBLESKY))
|
||||
{
|
||||
sky1tex = sky2texture;
|
||||
sky1tex = Level->skytexture2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sky1tex = sky1texture;
|
||||
sky1tex = Level->skytexture1;
|
||||
}
|
||||
sky2tex = sky2texture;
|
||||
sky2tex = Level->skytexture2;
|
||||
skymid = skytexturemid;
|
||||
skyangle = Thread->Viewport->viewpoint.Angles.Yaw.BAMs();
|
||||
|
||||
|
@ -144,8 +144,8 @@ namespace swrenderer
|
|||
else
|
||||
backskytex = NULL;
|
||||
skyflip = 0;
|
||||
frontdpos = sky1pos;
|
||||
backdpos = sky2pos;
|
||||
frontdpos = Level->sky1pos;
|
||||
backdpos = Level->sky2pos;
|
||||
frontcyl = sky1cyl;
|
||||
backcyl = sky2cyl;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ namespace swrenderer
|
|||
backskytex = NULL;
|
||||
frontcyl = sky2cyl;
|
||||
skyflip = 0;
|
||||
frontdpos = sky2pos;
|
||||
frontdpos = Level->sky2pos;
|
||||
}
|
||||
else
|
||||
{ // MBF's linedef-controlled skies
|
||||
|
@ -202,7 +202,7 @@ namespace swrenderer
|
|||
|
||||
int frontxscale = int(frontskytex->GetScale().X * 1024);
|
||||
frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
|
||||
if (skystretch)
|
||||
if (Level->skystretch)
|
||||
{
|
||||
skymid = skymid * frontskytex->GetScaledHeightDouble() / SKYSTRETCH_HEIGHT;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue