- fixed some issues with dynamic lights caused by the floatification changes

This commit is contained in:
Christoph Oelckers 2016-03-24 13:38:37 +01:00
parent 609defe078
commit 379d5bc0c5
5 changed files with 32 additions and 36 deletions

View file

@ -285,7 +285,7 @@ void ADynamicLight::Tick()
case ColorFlickerLight:
{
BYTE rnd = randLight();
float pct = ANGLE2FLOAT(angle)/360.f;
float pct = Angles.Yaw.Degrees/360.f;
m_currentIntensity = m_intensity[rnd >= pct * 255];
break;
@ -298,7 +298,7 @@ void ADynamicLight::Tick()
m_tickCount++;
if (m_tickCount > ANGLE2FLOAT(angle))
if (m_tickCount > Angles.Yaw.Degrees)
{
m_currentIntensity = m_intensity[0] + (amt * flickerRange);
m_tickCount = 0;
@ -348,16 +348,16 @@ void ADynamicLight::UpdateLocation()
{
if (target)
{
angle_t angle = target->_f_angle() >> ANGLETOFINESHIFT;
fixedvec3 pos = target->Vec3Offset(
FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]),
FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]),
m_offY + target->GetBobOffset());
DAngle angle = target->Angles.Yaw;
double s = angle.Sin();
double c = angle.Cos();
DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset());
SetXYZ(pos); // attached lights do not need to go into the regular blockmap
PrevX = pos.x;
PrevY = pos.y;
PrevZ = pos.z;
subsector = R_PointInSubsector(pos.x, pos.y);
PrevX = target->_f_X();
PrevY = target->_f_Y();
PrevZ = target->_f_Z();
subsector = R_PointInSubsector(target->_f_X(), target->_f_Y());
Sector = subsector->sector;
}
@ -402,11 +402,9 @@ void ADynamicLight::SetOrigin(fixed_t x, fixed_t y, fixed_t z, bool moving)
//
//==========================================================================
void ADynamicLight::SetOffset(fixed_t x, fixed_t y, fixed_t z)
void ADynamicLight::SetOffset(const DVector3 &pos)
{
m_offX = x;
m_offY = y;
m_offZ = z;
m_off = pos;
UpdateLocation();
}

View file

@ -129,10 +129,10 @@ public:
void ApplyProperties(ADynamicLight * light) const;
FName GetName() const { return m_Name; }
void SetAngle(angle_t angle) { m_Angle = angle; }
void SetParameter(double p) { m_Param = p; }
void SetArg(int arg, BYTE val) { m_Args[arg] = val; }
BYTE GetArg(int arg) { return m_Args[arg]; }
void SetOffset(float* ft) { m_X = FLOAT2FIXED(ft[0]); m_Y = FLOAT2FIXED(ft[1]); m_Z = FLOAT2FIXED(ft[2]); }
void SetOffset(float* ft) { m_Pos.X = ft[0]; m_Pos.Z = ft[1]; m_Pos.Y = ft[2]; }
void SetSubtractive(bool subtract) { m_subtractive = subtract; }
void SetAdditive(bool add) { m_additive = add; }
void SetDontLightSelf(bool add) { m_dontlightself = add; }
@ -140,8 +140,8 @@ public:
protected:
FName m_Name;
unsigned char m_Args[5];
angle_t m_Angle;
fixed_t m_X, m_Y, m_Z;
double m_Param;
DVector3 m_Pos;
ELightType m_type;
bool m_subtractive, m_additive, m_halo, m_dontlightself;
};
@ -159,8 +159,9 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
m_Name = name;
m_type = type;
m_X = m_Y = m_Z = 0;
m_Pos.Zero();
memset(m_Args, 0, 5);
m_Param = 0;
m_subtractive = false;
m_additive = false;
@ -171,16 +172,16 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
void FLightDefaults::ApplyProperties(ADynamicLight * light) const
{
light->lighttype = m_type;
light->Angles.Yaw = ANGLE2DBL(m_Angle);
light->SetOffset(m_X, m_Y, m_Z);
light->Angles.Yaw.Degrees = m_Param;
light->SetOffset(m_Pos);
light->halo = m_halo;
for (int a = 0; a < 3; a++) light->args[a] = clamp<int>((int)(m_Args[a] * gl_lights_intensity), 0, 255);
light->m_intensity[0] = int(m_Args[LIGHT_INTENSITY]);
light->m_intensity[1] = int(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;
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;
}
@ -423,7 +424,7 @@ void gl_ParsePulseLight(FScanner &sc)
break;
case LIGHTTAG_INTERVAL:
floatVal = gl_ParseFloat(sc);
defaults->SetAngle(FLOAT2ANGLE(floatVal * TICRATE));
defaults->SetParameter(floatVal * TICRATE);
break;
case LIGHTTAG_SUBTRACTIVE:
defaults->SetSubtractive(gl_ParseInt(sc) != 0);
@ -502,7 +503,7 @@ void gl_ParseFlickerLight(FScanner &sc)
break;
case LIGHTTAG_CHANCE:
floatVal = gl_ParseFloat(sc);
defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX));
defaults->SetParameter(floatVal*360.);
break;
case LIGHTTAG_SUBTRACTIVE:
defaults->SetSubtractive(gl_ParseInt(sc) != 0);
@ -581,7 +582,7 @@ void gl_ParseFlickerLight2(FScanner &sc)
break;
case LIGHTTAG_INTERVAL:
floatVal = gl_ParseFloat(sc);
defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX));
defaults->SetParameter(floatVal * 360.);
break;
case LIGHTTAG_SUBTRACTIVE:
defaults->SetSubtractive(gl_ParseInt(sc) != 0);

View file

@ -87,7 +87,7 @@ public:
void Destroy();
void Activate(AActor *activator);
void Deactivate(AActor *activator);
void SetOffset(fixed_t x, fixed_t y, fixed_t z);
void SetOffset(const DVector3 &pos);
void UpdateLocation();
bool IsOwned() const { return owned; }
bool IsActive() const { return !(flags2&MF2_DORMANT); }
@ -103,7 +103,7 @@ private:
void CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius);
protected:
fixed_t m_offX, m_offY, m_offZ;
DVector3 m_off;
float m_currentIntensity;
int m_tickCount;
unsigned int m_lastUpdate;

View file

@ -202,10 +202,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
(r_deathcamera && camera->health <= 0))
return;
fixed_t ox, oy;
P_BobWeapon (player, &player->psprites[ps_weapon], &ox, &oy);
ofsx = FIXED2FLOAT(ox);
ofsy = FIXED2FLOAT(oy);
P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy);
// check for fullbright
if (player->fixedcolormap==NOFIXEDCOLORMAP)

View file

@ -1469,7 +1469,7 @@ void P_SpawnSpecials (void)
else if (lines[i].args[1] == 3 || lines[i].args[1] == 4)
{
line_t *line = &lines[i];
ASkyViewpoint *origin = Spawn<ASkyViewpoint>(0, 0, 0, NO_REPLACE);
ASkyViewpoint *origin = Spawn<ASkyViewpoint>();
origin->Sector = line->frontsector;
origin->special1 = line->args[1] == 3? SKYBOX_PLANE:SKYBOX_HORIZON;