mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
This commit is contained in:
commit
fa622710f1
5 changed files with 32 additions and 8 deletions
|
@ -235,7 +235,7 @@ void ADynamicLight::Activate(AActor *activator)
|
|||
m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime);
|
||||
m_cycler.ShouldCycle(true);
|
||||
m_cycler.SetCycleType(CYCLE_Sin);
|
||||
m_currentRadius = (BYTE)m_cycler.GetVal();
|
||||
m_currentRadius = m_cycler.GetVal();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,8 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
|
|||
|
||||
void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
||||
{
|
||||
auto oldtype = light->lighttype;
|
||||
|
||||
light->lighttype = m_type;
|
||||
light->specialf1 = m_Param;
|
||||
light->SetOffset(m_Pos);
|
||||
|
@ -179,6 +181,17 @@ void FLightDefaults::ApplyProperties(ADynamicLight * light) const
|
|||
if (m_additive) light->flags4 |= MF4_ADDITIVE;
|
||||
if (m_dontlightself) light->flags4 |= MF4_DONTLIGHTSELF;
|
||||
light->m_tickCount = 0;
|
||||
if (m_type == PulseLight)
|
||||
{
|
||||
float pulseTime = float(m_Param / TICRATE);
|
||||
|
||||
light->m_lastUpdate = level.maptime;
|
||||
light->m_cycler.SetParams(float(light->m_Radius[1]), float(light->m_Radius[0]), pulseTime, oldtype == PulseLight);
|
||||
light->m_cycler.ShouldCycle(true);
|
||||
light->m_cycler.SetCycleType(CYCLE_Sin);
|
||||
light->m_currentRadius = light->m_cycler.GetVal();
|
||||
}
|
||||
|
||||
switch (m_attenuate)
|
||||
{
|
||||
case 0: light->flags4 &= ~MF4_ATTENUATE; break;
|
||||
|
|
|
@ -33,7 +33,7 @@ EXTERN_CVAR(Bool, gl_attachedlights)
|
|||
|
||||
class ADynamicLight;
|
||||
class FSerializer;
|
||||
|
||||
class FLightDefaults;
|
||||
|
||||
|
||||
enum
|
||||
|
@ -91,6 +91,7 @@ struct FLightNode
|
|||
|
||||
class ADynamicLight : public AActor
|
||||
{
|
||||
friend class FLightDefaults;
|
||||
DECLARE_CLASS (ADynamicLight, AActor)
|
||||
public:
|
||||
virtual void Tick();
|
||||
|
|
|
@ -83,13 +83,23 @@ FCycler::FCycler()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCycler::SetParams(float start, float end, float cycle)
|
||||
void FCycler::SetParams(float start, float end, float cycle, bool update)
|
||||
{
|
||||
if (!update || cycle != m_cycle)
|
||||
{
|
||||
m_cycle = cycle;
|
||||
m_time = 0.f;
|
||||
m_start = m_current = start;
|
||||
m_end = end;
|
||||
m_increment = true;
|
||||
m_current = start;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When updating and keeping the same cycle, scale the current light size to the new dimensions.
|
||||
float fact = (m_current - m_start) / (m_end - m_start);
|
||||
m_current = start + fact *(end - start);
|
||||
}
|
||||
m_start = start;
|
||||
m_end = end;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class FCycler
|
|||
public:
|
||||
FCycler();
|
||||
void Update(float diff);
|
||||
void SetParams(float start, float end, float cycle);
|
||||
void SetParams(float start, float end, float cycle, bool update = false);
|
||||
void ShouldCycle(bool sc) { m_shouldCycle = sc; }
|
||||
void SetCycleType(CycleType ct) { m_cycleType = ct; }
|
||||
float GetVal() { return m_current; }
|
||||
|
|
Loading…
Reference in a new issue