mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- use a dedicated flag word for the dynamic light flags instead of piggybacking on some flags4 bits.
This commit is contained in:
parent
cf1d94c9bb
commit
3b024c347b
11 changed files with 72 additions and 53 deletions
|
@ -139,6 +139,19 @@ void ADynamicLight::Serialize(FSerializer &arc)
|
|||
if (lighttype == PulseLight)
|
||||
arc("lastupdate", m_lastUpdate, def->m_lastUpdate)
|
||||
("cycler", m_cycler, def->m_cycler);
|
||||
|
||||
// Remap the old flags.
|
||||
if (SaveVersion < 4552)
|
||||
{
|
||||
lightflags = 0;
|
||||
if (flags4 & MF4_MISSILEEVENMORE) lightflags |= LF_SUBTRACTIVE;
|
||||
if (flags4 & MF4_MISSILEMORE) lightflags |= LF_ADDITIVE;
|
||||
if (flags4 & MF4_SEESDAGGERS) lightflags |= LF_DONTLIGHTSELF;
|
||||
if (flags4 & MF4_INCOMBAT) lightflags |= LF_ATTENUATE;
|
||||
if (flags4 & MF4_STANDSTILL) lightflags |= LF_NOSHADOWMAP;
|
||||
if (flags4 & MF4_EXTREMEDEATH) lightflags |= LF_DONTLIGHTACTORS;
|
||||
flags4 &= ~(MF4_SEESDAGGERS); // this flag is dangerous and must be cleared. The others do not matter.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,7 +177,7 @@ void ADynamicLight::BeginPlay()
|
|||
specialf1 = DAngle(double(SpawnAngle)).Normalized360().Degrees;
|
||||
visibletoplayer = true;
|
||||
|
||||
if (currentrenderer == 1 && gl.legacyMode && (flags4 & MF4_ATTENUATE))
|
||||
if (currentrenderer == 1 && gl.legacyMode && (lightflags & LF_ATTENUATE))
|
||||
{
|
||||
args[LIGHT_INTENSITY] = args[LIGHT_INTENSITY] * 2 / 3;
|
||||
args[LIGHT_SECONDARY_INTENSITY] = args[LIGHT_SECONDARY_INTENSITY] * 2 / 3;
|
||||
|
@ -663,7 +676,7 @@ void ADynamicLight::CollectWithinRadius(const DVector3 &opos, subsector_t *subSe
|
|||
}
|
||||
}
|
||||
}
|
||||
shadowmapped = hitonesidedback && !(flags4 & MF4_NOSHADOWMAP);
|
||||
shadowmapped = hitonesidedback && !(lightflags & LF_NOSHADOWMAP);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -791,7 +804,7 @@ CCMD(listlights)
|
|||
Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f %s %s",
|
||||
dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(),
|
||||
dl->X(), dl->Y(), dl->Z(), dl->args[LIGHT_RED],
|
||||
dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], dl->radius, (dl->flags4 & MF4_ATTENUATE)? "attenuated" : "", dl->shadowmapped? "shadowmapped" : "");
|
||||
dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], dl->radius, (dl->lightflags & LF_ATTENUATE)? "attenuated" : "", dl->shadowmapped? "shadowmapped" : "");
|
||||
i++;
|
||||
shadowcount += dl->shadowmapped;
|
||||
|
||||
|
|
|
@ -21,13 +21,19 @@ enum
|
|||
LIGHT_SCALE = 3,
|
||||
};
|
||||
|
||||
// This is as good as something new
|
||||
#define MF4_SUBTRACTIVE MF4_MISSILEEVENMORE
|
||||
#define MF4_ADDITIVE MF4_MISSILEMORE
|
||||
#define MF4_DONTLIGHTSELF MF4_SEESDAGGERS
|
||||
#define MF4_ATTENUATE MF4_INCOMBAT
|
||||
#define MF4_NOSHADOWMAP MF4_STANDSTILL
|
||||
#define MF4_DONTLIGHTACTORS MF4_EXTREMEDEATH
|
||||
enum LightFlag
|
||||
{
|
||||
LF_SUBTRACTIVE = 1,
|
||||
LF_ADDITIVE = 2,
|
||||
LF_DONTLIGHTSELF = 4,
|
||||
LF_ATTENUATE = 8,
|
||||
LF_NOSHADOWMAP = 16,
|
||||
LF_DONTLIGHTACTORS = 32
|
||||
};
|
||||
|
||||
typedef TFlags<LightFlag> LightFlags;
|
||||
DEFINE_TFLAGS_OPERATORS(LightFlags)
|
||||
|
||||
|
||||
enum ELightType
|
||||
{
|
||||
|
@ -92,8 +98,8 @@ public:
|
|||
void UpdateLocation();
|
||||
bool IsOwned() const { return owned; }
|
||||
bool IsActive() const { return !(flags2&MF2_DORMANT); }
|
||||
bool IsSubtractive() { return !!(flags4&MF4_SUBTRACTIVE); }
|
||||
bool IsAdditive() { return !!(flags4&MF4_ADDITIVE); }
|
||||
bool IsSubtractive() { return !!(lightflags & LF_SUBTRACTIVE); }
|
||||
bool IsAdditive() { return !!(lightflags & LF_ADDITIVE); }
|
||||
FState *targetState;
|
||||
FLightNode * touching_sides;
|
||||
FLightNode * touching_subsectors;
|
||||
|
@ -112,7 +118,6 @@ protected:
|
|||
|
||||
public:
|
||||
int m_tickCount;
|
||||
uint8_t lightflags;
|
||||
uint8_t lighttype;
|
||||
bool owned;
|
||||
bool halo;
|
||||
|
@ -121,6 +126,7 @@ public:
|
|||
bool swapped;
|
||||
bool shadowmapped;
|
||||
int bufferindex;
|
||||
LightFlags lightflags;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -178,11 +178,11 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
|||
for (int a = 0; a < 3; a++) light->args[a] = clamp<int>((int)(m_Args[a]), 0, 255);
|
||||
light->args[LIGHT_INTENSITY] = m_Args[LIGHT_INTENSITY];
|
||||
light->args[LIGHT_SECONDARY_INTENSITY] = m_Args[LIGHT_SECONDARY_INTENSITY];
|
||||
light->flags4 &= ~(MF4_ADDITIVE | MF4_SUBTRACTIVE | MF4_DONTLIGHTSELF);
|
||||
if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE;
|
||||
if (m_additive) light->flags4 |= MF4_ADDITIVE;
|
||||
if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF;
|
||||
if (m_dontlightactors) light->flags4 |= MF4_DONTLIGHTACTORS;
|
||||
light->lightflags &= ~(LF_ADDITIVE | LF_SUBTRACTIVE | LF_DONTLIGHTSELF);
|
||||
if (m_subtractive) light->lightflags |= LF_SUBTRACTIVE;
|
||||
if (m_additive) light->lightflags |= LF_ADDITIVE;
|
||||
if (m_dontlightself) light->lightflags |= LF_DONTLIGHTSELF;
|
||||
if (m_dontlightactors) light->lightflags |= LF_DONTLIGHTACTORS;
|
||||
light->m_tickCount = 0;
|
||||
if (m_type == PulseLight)
|
||||
{
|
||||
|
@ -200,9 +200,9 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
|||
|
||||
switch (m_attenuate)
|
||||
{
|
||||
case 0: light->flags4 &= ~MF4_ATTENUATE; break;
|
||||
case 1: light->flags4 |= MF4_ATTENUATE; break;
|
||||
default: if (level.flags3 & LEVEL3_ATTENUATE) light->flags4 |= MF4_ATTENUATE; else light->flags4 &= ~MF4_ATTENUATE; break;
|
||||
case 0: light->lightflags &= ~LF_ATTENUATE; break;
|
||||
case 1: light->lightflags |= LF_ATTENUATE; break;
|
||||
default: if (level.flags3 & LEVEL3_ATTENUATE) light->lightflags |= LF_ATTENUATE; else light->lightflags &= ~LF_ATTENUATE; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ void AActor::AttachLight(unsigned int count, const FLightDefaults *lightdef)
|
|||
light->target = this;
|
||||
light->owned = true;
|
||||
light->ObjectFlags |= OF_Transient;
|
||||
//light->flags4 |= MF4_ATTENUATE;
|
||||
//light->lightflags |= LF_ATTENUATE;
|
||||
AttachedLights.Push(light);
|
||||
}
|
||||
light->flags2&=~MF2_DORMANT;
|
||||
|
|
|
@ -110,7 +110,7 @@ bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FD
|
|||
float shadowIndex = GLRenderer->mShadowMap.ShadowMapIndex(light) + 1.0f;
|
||||
bool attenuate;
|
||||
|
||||
if (gl_attenuate == -1) attenuate = !!(light->flags4 & MF4_ATTENUATE);
|
||||
if (gl_attenuate == -1) attenuate = !!(light->lightflags & LF_ATTENUATE);
|
||||
else attenuate = !!gl_attenuate;
|
||||
|
||||
if (attenuate) shadowIndex = -shadowIndex;
|
||||
|
|
|
@ -62,7 +62,7 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
|
|||
while (node)
|
||||
{
|
||||
light=node->lightsource;
|
||||
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self) && !(light->flags4&MF4_DONTLIGHTACTORS))
|
||||
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->lightflags&LF_DONTLIGHTSELF) || light->target != self) && !(light->lightflags&LF_DONTLIGHTACTORS))
|
||||
{
|
||||
float dist;
|
||||
|
||||
|
|
|
@ -488,12 +488,12 @@ static FFlagDef PlayerPawnFlagDefs[] =
|
|||
static FFlagDef DynLightFlagDefs[] =
|
||||
{
|
||||
// PlayerPawn flags
|
||||
DEFINE_FLAG(MF4, SUBTRACTIVE, ADynamicLight, flags4),
|
||||
DEFINE_FLAG(MF4, ADDITIVE, ADynamicLight, flags4),
|
||||
DEFINE_FLAG(MF4, DONTLIGHTSELF, ADynamicLight, flags4),
|
||||
DEFINE_FLAG(MF4, ATTENUATE, ADynamicLight, flags4),
|
||||
DEFINE_FLAG(MF4, NOSHADOWMAP, ADynamicLight, flags4),
|
||||
DEFINE_FLAG(MF4, DONTLIGHTACTORS, ADynamicLight, flags4),
|
||||
DEFINE_FLAG(LF, SUBTRACTIVE, ADynamicLight, lightflags),
|
||||
DEFINE_FLAG(LF, ADDITIVE, ADynamicLight, lightflags),
|
||||
DEFINE_FLAG(LF, DONTLIGHTSELF, ADynamicLight, lightflags),
|
||||
DEFINE_FLAG(LF, ATTENUATE, ADynamicLight, lightflags),
|
||||
DEFINE_FLAG(LF, NOSHADOWMAP, ADynamicLight, lightflags),
|
||||
DEFINE_FLAG(LF, DONTLIGHTACTORS, ADynamicLight, lightflags),
|
||||
};
|
||||
|
||||
static FFlagDef PowerSpeedFlagDefs[] =
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace swrenderer
|
|||
float lz = (float)lightZ;
|
||||
|
||||
// Precalculate the constant part of the dot here so the drawer doesn't have to.
|
||||
bool is_point_light = (cur_node->lightsource->flags4 & MF4_ATTENUATE) != 0;
|
||||
bool is_point_light = (cur_node->lightsource->lightflags & LF_ATTENUATE) != 0;
|
||||
float lconstant = lx * lx + ly * ly;
|
||||
float nlconstant = is_point_light ? lx * drawerargs.dc_normal.X + ly * drawerargs.dc_normal.Y : 0.0f;
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ namespace swrenderer
|
|||
float lz = (float)lightZ - drawerargs.dc_viewpos.Z;
|
||||
|
||||
// Precalculate the constant part of the dot here so the drawer doesn't have to.
|
||||
bool is_point_light = (cur_node->lightsource->flags4 & MF4_ATTENUATE) != 0;
|
||||
bool is_point_light = (cur_node->lightsource->lightflags & LF_ATTENUATE) != 0;
|
||||
float lconstant = ly * ly + lz * lz;
|
||||
float nlconstant = is_point_light ? lz * drawerargs.dc_normal.Z : 0.0f;
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ namespace swrenderer
|
|||
while (node != nullptr)
|
||||
{
|
||||
ADynamicLight *light = node->lightsource;
|
||||
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != thing) && !(light->flags4&MF4_DONTLIGHTACTORS))
|
||||
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->lightflags&LF_DONTLIGHTSELF) || light->target != thing) && !(light->lightflags&LF_DONTLIGHTACTORS))
|
||||
{
|
||||
float lx = (float)(light->X() - thing->X());
|
||||
float ly = (float)(light->Y() - thing->Y());
|
||||
|
|
|
@ -91,7 +91,7 @@ const char *GetVersionString();
|
|||
|
||||
// Use 4500 as the base git save version, since it's higher than the
|
||||
// SVN revision ever got.
|
||||
#define SAVEVER 4551
|
||||
#define SAVEVER 4552
|
||||
|
||||
// This is so that derivates can use the same savegame versions without worrying about engine compatibility
|
||||
#define GAMESIG "GZDOOM"
|
||||
|
|
|
@ -77,13 +77,13 @@ class PointLightFlickerRandom : PointLight
|
|||
}
|
||||
}
|
||||
|
||||
// MISSILEMORE and MISSILEEVENMORE are used by the lights for additive and subtractive lights
|
||||
// DYNAMICLIGHT.ADDITIVE and DYNAMICLIGHT.SUBTRACTIVE are used by the lights for additive and subtractive lights
|
||||
|
||||
class PointLightAdditive : PointLight
|
||||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEMORE
|
||||
+DYNAMICLIGHT.ADDITIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ class PointLightPulseAdditive : PointLightPulse
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEMORE
|
||||
+DYNAMICLIGHT.ADDITIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class PointLightFlickerAdditive : PointLightFlicker
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEMORE
|
||||
+DYNAMICLIGHT.ADDITIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ class SectorPointLightAdditive : SectorPointLight
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEMORE
|
||||
+DYNAMICLIGHT.ADDITIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class PointLightFlickerRandomAdditive :PointLightFlickerRandom
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEMORE
|
||||
+DYNAMICLIGHT.ADDITIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ class PointLightSubtractive : PointLight
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEEVENMORE
|
||||
+DYNAMICLIGHT.SUBTRACTIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ class PointLightPulseSubtractive : PointLightPulse
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEEVENMORE
|
||||
+DYNAMICLIGHT.SUBTRACTIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class PointLightFlickerSubtractive : PointLightFlicker
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEEVENMORE
|
||||
+DYNAMICLIGHT.SUBTRACTIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ class SectorPointLightSubtractive : SectorPointLight
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEEVENMORE
|
||||
+DYNAMICLIGHT.SUBTRACTIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ class PointLightFlickerRandomSubtractive : PointLightFlickerRandom
|
|||
{
|
||||
Default
|
||||
{
|
||||
+MISSILEEVENMORE
|
||||
+DYNAMICLIGHT.SUBTRACTIVE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ class PointLightAttenuated : PointLight
|
|||
{
|
||||
Default
|
||||
{
|
||||
+INCOMBAT
|
||||
+DYNAMICLIGHT.ATTENUATE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ class PointLightPulseAttenuated : PointLightPulse
|
|||
{
|
||||
Default
|
||||
{
|
||||
+INCOMBAT
|
||||
+DYNAMICLIGHT.ATTENUATE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class PointLightFlickerAttenuated : PointLightFlicker
|
|||
{
|
||||
Default
|
||||
{
|
||||
+INCOMBAT
|
||||
+DYNAMICLIGHT.ATTENUATE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ class SectorPointLightAttenuated : SectorPointLight
|
|||
{
|
||||
Default
|
||||
{
|
||||
+INCOMBAT
|
||||
+DYNAMICLIGHT.ATTENUATE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ class PointLightFlickerRandomAttenuated :PointLightFlickerRandom
|
|||
{
|
||||
Default
|
||||
{
|
||||
+INCOMBAT
|
||||
+DYNAMICLIGHT.ATTENUATE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue