mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- fixed: Random flicker lights must set up their size on the first tic they are run. If not they will keep the radius of the previous effect which may be too large.
This commit is contained in:
parent
d04c37101e
commit
c115c0a5b2
3 changed files with 24 additions and 17 deletions
|
@ -67,6 +67,7 @@
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "doomdata.h"
|
#include "doomdata.h"
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
|
#include "p_local.h"
|
||||||
#include "portal.h"
|
#include "portal.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
|
@ -192,6 +193,7 @@ void ADynamicLight::BeginPlay()
|
||||||
|
|
||||||
m_Radius[0] = args[LIGHT_INTENSITY];
|
m_Radius[0] = args[LIGHT_INTENSITY];
|
||||||
m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY];
|
m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY];
|
||||||
|
specialf1 = DAngle(double(SpawnAngle)).Normalized360().Degrees;
|
||||||
visibletoplayer = true;
|
visibletoplayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +230,7 @@ void ADynamicLight::Activate(AActor *activator)
|
||||||
|
|
||||||
if (lighttype == PulseLight)
|
if (lighttype == PulseLight)
|
||||||
{
|
{
|
||||||
float pulseTime = Angles.Yaw.Degrees / TICRATE;
|
float pulseTime = specialf1 / TICRATE;
|
||||||
|
|
||||||
m_lastUpdate = level.maptime;
|
m_lastUpdate = level.maptime;
|
||||||
m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime);
|
m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime);
|
||||||
|
@ -293,7 +295,7 @@ void ADynamicLight::Tick()
|
||||||
case FlickerLight:
|
case FlickerLight:
|
||||||
{
|
{
|
||||||
BYTE rnd = randLight();
|
BYTE rnd = randLight();
|
||||||
float pct = Angles.Yaw.Degrees / 360.f;
|
float pct = specialf1 / 360.f;
|
||||||
|
|
||||||
m_currentRadius = float(m_Radius[rnd >= pct * 255]);
|
m_currentRadius = float(m_Radius[rnd >= pct * 255]);
|
||||||
break;
|
break;
|
||||||
|
@ -304,12 +306,13 @@ void ADynamicLight::Tick()
|
||||||
int flickerRange = m_Radius[1] - m_Radius[0];
|
int flickerRange = m_Radius[1] - m_Radius[0];
|
||||||
float amt = randLight() / 255.f;
|
float amt = randLight() / 255.f;
|
||||||
|
|
||||||
m_tickCount++;
|
if (m_tickCount > specialf1)
|
||||||
|
{
|
||||||
if (m_tickCount > Angles.Yaw.Degrees)
|
m_tickCount = 0;
|
||||||
|
}
|
||||||
|
if (m_tickCount++ == 0 || m_currentRadius > m_Radius[1])
|
||||||
{
|
{
|
||||||
m_currentRadius = float(m_Radius[0] + (amt * flickerRange));
|
m_currentRadius = float(m_Radius[0] + (amt * flickerRange));
|
||||||
m_tickCount = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +322,7 @@ void ADynamicLight::Tick()
|
||||||
case ColorFlickerLight:
|
case ColorFlickerLight:
|
||||||
{
|
{
|
||||||
BYTE rnd = randLight();
|
BYTE rnd = randLight();
|
||||||
float pct = Angles.Yaw.Degrees/360.f;
|
float pct = specialf1/360.f;
|
||||||
|
|
||||||
m_currentRadius = m_Radius[rnd >= pct * 255];
|
m_currentRadius = m_Radius[rnd >= pct * 255];
|
||||||
break;
|
break;
|
||||||
|
@ -332,7 +335,7 @@ void ADynamicLight::Tick()
|
||||||
|
|
||||||
m_tickCount++;
|
m_tickCount++;
|
||||||
|
|
||||||
if (m_tickCount > Angles.Yaw.Degrees)
|
if (m_tickCount > specialf1)
|
||||||
{
|
{
|
||||||
m_currentRadius = m_Radius[0] + (amt * flickerRange);
|
m_currentRadius = m_Radius[0] + (amt * flickerRange);
|
||||||
m_tickCount = 0;
|
m_tickCount = 0;
|
||||||
|
@ -359,7 +362,6 @@ void ADynamicLight::Tick()
|
||||||
m_currentRadius = float(m_Radius[0]);
|
m_currentRadius = float(m_Radius[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLocation();
|
UpdateLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,6 +418,7 @@ void ADynamicLight::UpdateLocation()
|
||||||
intensity = m_currentRadius;
|
intensity = m_currentRadius;
|
||||||
}
|
}
|
||||||
radius = intensity * 2.0f;
|
radius = intensity * 2.0f;
|
||||||
|
assert(radius >= m_currentRadius * 2);
|
||||||
|
|
||||||
if (X() != oldx || Y() != oldy || radius != oldradius)
|
if (X() != oldx || Y() != oldy || radius != oldradius)
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,7 +164,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
|
||||||
void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
||||||
{
|
{
|
||||||
light->lighttype = m_type;
|
light->lighttype = m_type;
|
||||||
light->Angles.Yaw.Degrees = m_Param;
|
light->specialf1 = m_Param;
|
||||||
light->SetOffset(m_Pos);
|
light->SetOffset(m_Pos);
|
||||||
light->halo = m_halo;
|
light->halo = m_halo;
|
||||||
for (int a = 0; a < 3; a++) light->args[a] = clamp<int>((int)(m_Args[a]), 0, 255);
|
for (int a = 0; a < 3; a++) light->args[a] = clamp<int>((int)(m_Args[a]), 0, 255);
|
||||||
|
@ -174,6 +174,7 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
||||||
if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE;
|
if (m_subtractive) light->flags4 |= MF4_SUBTRACTIVE;
|
||||||
if (m_additive) light->flags4 |= MF4_ADDITIVE;
|
if (m_additive) light->flags4 |= MF4_ADDITIVE;
|
||||||
if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF;
|
if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF;
|
||||||
|
light->m_tickCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -431,6 +432,14 @@ void gl_ParsePulseLight(FScanner &sc)
|
||||||
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
sc.ScriptError("Unknown tag: %s\n", sc.String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (defaults->GetArg(LIGHT_INTENSITY) > defaults->GetArg(LIGHT_SECONDARY_INTENSITY))
|
||||||
|
{
|
||||||
|
auto i = defaults->GetArg(LIGHT_INTENSITY);
|
||||||
|
auto j = defaults->GetArg(LIGHT_SECONDARY_INTENSITY);
|
||||||
|
defaults->SetArg(LIGHT_INTENSITY, j);
|
||||||
|
defaults->SetArg(LIGHT_SECONDARY_INTENSITY, i);
|
||||||
|
}
|
||||||
|
|
||||||
gl_AddLightDefaults(defaults);
|
gl_AddLightDefaults(defaults);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1082,7 +1091,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig
|
||||||
light->target = actor;
|
light->target = actor;
|
||||||
light->owned = true;
|
light->owned = true;
|
||||||
light->ObjectFlags |= OF_Transient;
|
light->ObjectFlags |= OF_Transient;
|
||||||
light->flags4 |= MF4_ATTENUATE;
|
//light->flags4 |= MF4_ATTENUATE;
|
||||||
actor->dynamiclights.Push(light);
|
actor->dynamiclights.Push(light);
|
||||||
}
|
}
|
||||||
light->flags2&=~MF2_DORMANT;
|
light->flags2&=~MF2_DORMANT;
|
||||||
|
|
|
@ -128,12 +128,12 @@ private:
|
||||||
protected:
|
protected:
|
||||||
DVector3 m_off;
|
DVector3 m_off;
|
||||||
float m_currentRadius;
|
float m_currentRadius;
|
||||||
int m_tickCount;
|
|
||||||
unsigned int m_lastUpdate;
|
unsigned int m_lastUpdate;
|
||||||
FCycler m_cycler;
|
FCycler m_cycler;
|
||||||
subsector_t * subsector;
|
subsector_t * subsector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int m_tickCount;
|
||||||
int m_Radius[2];
|
int m_Radius[2];
|
||||||
BYTE lightflags;
|
BYTE lightflags;
|
||||||
BYTE lighttype;
|
BYTE lighttype;
|
||||||
|
@ -143,11 +143,6 @@ public:
|
||||||
bool visibletoplayer;
|
bool visibletoplayer;
|
||||||
int bufferindex;
|
int bufferindex;
|
||||||
|
|
||||||
// intermediate texture coordinate data
|
|
||||||
// this is stored in the light object to avoid recalculating it
|
|
||||||
// several times during rendering of a flat
|
|
||||||
Vector nearPt, up, right;
|
|
||||||
float scale;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue