Wave quakes now stack.

This commit is contained in:
Major Cooke 2016-09-04 16:49:57 -05:00 committed by Christoph Oelckers
parent ce13b5c6e1
commit 043ada24da
3 changed files with 47 additions and 43 deletions

View file

@ -161,7 +161,7 @@ double DEarthquake::GetModWave(double waveMultiplier) const
//
//==========================================================================
double DEarthquake::GetModIntensity(double intensity) const
double DEarthquake::GetModIntensity(double intensity, bool fake) const
{
assert(m_CountdownStart >= m_Countdown);
@ -195,7 +195,7 @@ double DEarthquake::GetModIntensity(double intensity) const
}
scalar = (scalar > divider) ? divider : scalar;
if (m_Flags & QF_FULLINTENSITY)
if (!fake && (m_Flags & QF_FULLINTENSITY))
{
scalar *= 2;
}
@ -273,64 +273,69 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
DEarthquake *quake;
int count = 0;
while ( (quake = iterator.Next()) != NULL)
while ( (quake = iterator.Next()) != nullptr)
{
if (quake->m_Spot != NULL)
if (quake->m_Spot != nullptr)
{
double dist = quake->m_Spot->Distance2D (victim, true);
const double dist = quake->m_Spot->Distance2D(victim, true);
if (dist < quake->m_TremorRadius)
{
const double falloff = quake->GetFalloff(dist);
const double rfalloff = (quake->m_RollIntensity != 0) ? falloff : 0.;
++count;
double x = quake->GetModIntensity(quake->m_Intensity.X);
double y = quake->GetModIntensity(quake->m_Intensity.Y);
double z = quake->GetModIntensity(quake->m_Intensity.Z);
double r = quake->GetModIntensity(quake->m_RollIntensity);
const double falloff = quake->GetFalloff(dist);
const double r = quake->GetModIntensity(quake->m_RollIntensity);
const double strength = quake->GetModIntensity(1.0, true);
DVector3 intensity;
intensity.X = quake->GetModIntensity(quake->m_Intensity.X);
intensity.Y = quake->GetModIntensity(quake->m_Intensity.Y);
intensity.Z = quake->GetModIntensity(quake->m_Intensity.Z);
if (!(quake->m_Flags & QF_WAVE))
{
jiggers.Falloff = MAX(falloff, jiggers.Falloff);
jiggers.RFalloff = MAX(rfalloff, jiggers.RFalloff);
jiggers.RollIntensity = MAX(r, jiggers.RollIntensity);
jiggers.RollIntensity = MAX(r, jiggers.RollIntensity) * jiggers.Falloff;
intensity *= jiggers.Falloff;
if (quake->m_Flags & QF_RELATIVE)
{
jiggers.RelIntensity.X = MAX(x, jiggers.RelIntensity.X);
jiggers.RelIntensity.Y = MAX(y, jiggers.RelIntensity.Y);
jiggers.RelIntensity.Z = MAX(z, jiggers.RelIntensity.Z);
jiggers.RelIntensity.X = MAX(intensity.X, jiggers.RelIntensity.X);
jiggers.RelIntensity.Y = MAX(intensity.Y, jiggers.RelIntensity.Y);
jiggers.RelIntensity.Z = MAX(intensity.Z, jiggers.RelIntensity.Z);
}
else
{
jiggers.Intensity.X = MAX(x, jiggers.Intensity.X);
jiggers.Intensity.Y = MAX(y, jiggers.Intensity.Y);
jiggers.Intensity.Z = MAX(z, jiggers.Intensity.Z);
jiggers.Intensity.X = MAX(intensity.X, jiggers.Intensity.X);
jiggers.Intensity.Y = MAX(intensity.Y, jiggers.Intensity.Y);
jiggers.Intensity.Z = MAX(intensity.Z, jiggers.Intensity.Z);
}
}
else
{
jiggers.WFalloff = MAX(falloff, jiggers.WFalloff);
jiggers.RWFalloff = MAX(rfalloff, jiggers.RWFalloff);
jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave);
double mx = x * quake->GetModWave(quake->m_WaveSpeed.X);
double my = y * quake->GetModWave(quake->m_WaveSpeed.Y);
double mz = z * quake->GetModWave(quake->m_WaveSpeed.Z);
jiggers.Falloff = MAX(falloff, jiggers.Falloff);
jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave) * jiggers.Falloff * strength;
intensity.X *= quake->GetModWave(quake->m_WaveSpeed.X);
intensity.Y *= quake->GetModWave(quake->m_WaveSpeed.Y);
intensity.Z *= quake->GetModWave(quake->m_WaveSpeed.Z);
intensity *= strength * jiggers.Falloff;
// [RH] This only gives effect to the last sine quake. I would
// prefer if some way was found to make multiples coexist
// peacefully, but just summing them together is undesirable
// because they could cancel each other out depending on their
// relative phases.
// [MC] Now does so. And they stack rather well. I'm a little
// surprised at how easy it was.
if (quake->m_Flags & QF_RELATIVE)
{
jiggers.RelOffset.X = mx;
jiggers.RelOffset.Y = my;
jiggers.RelOffset.Z = mz;
jiggers.RelOffset += intensity;
}
else
{
jiggers.Offset.X = mx;
jiggers.Offset.Y = my;
jiggers.Offset.Z = mz;
jiggers.Offset += intensity;
}
}
}

View file

@ -153,7 +153,7 @@ struct FQuakeJiggers
DVector3 RelIntensity;
DVector3 Offset;
DVector3 RelOffset;
double Falloff, WFalloff, RFalloff, RWFalloff;
double Falloff;
double RollIntensity, RollWave;
};
@ -180,8 +180,7 @@ public:
int m_Highpoint, m_MiniCount;
double m_RollIntensity, m_RollWave;
double GetModIntensity(double intensity) const;
double GetModIntensity(double intensity, bool fake = false) const;
double GetModWave(double waveMultiplier) const;
double GetFalloff(double dist) const;

View file

@ -656,7 +656,7 @@ void R_AddInterpolationPoint(const DVector3a &vec)
//
//==========================================================================
static double QuakePower(double factor, double intensity, double offset, double falloff, double wfalloff)
static double QuakePower(double factor, double intensity, double offset)
{
double randumb;
if (intensity == 0)
@ -667,7 +667,7 @@ static double QuakePower(double factor, double intensity, double offset, double
{
randumb = pr_torchflicker.GenRand_Real2() * (intensity * 2) - intensity;
}
return factor * (wfalloff * offset + falloff * randumb);
return factor * (offset + randumb);
}
//==========================================================================
@ -797,36 +797,36 @@ void R_SetupFrame (AActor *actor)
if (jiggers.RollIntensity != 0 || jiggers.RollWave != 0)
{
ViewRoll += QuakePower(quakefactor, jiggers.RollIntensity, jiggers.RollWave, jiggers.RFalloff, jiggers.RWFalloff);
ViewRoll += QuakePower(quakefactor, jiggers.RollIntensity, jiggers.RollWave);
}
if (jiggers.RelIntensity.X != 0 || jiggers.RelOffset.X != 0)
{
an = camera->Angles.Yaw;
double power = QuakePower(quakefactor, jiggers.RelIntensity.X, jiggers.RelOffset.X, jiggers.Falloff, jiggers.WFalloff);
double power = QuakePower(quakefactor, jiggers.RelIntensity.X, jiggers.RelOffset.X);
ViewPos += an.ToVector(power);
}
if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0)
{
an = camera->Angles.Yaw + 90;
double power = QuakePower(quakefactor, jiggers.RelIntensity.Y, jiggers.RelOffset.Y, jiggers.Falloff, jiggers.WFalloff);
double power = QuakePower(quakefactor, jiggers.RelIntensity.Y, jiggers.RelOffset.Y);
ViewPos += an.ToVector(power);
}
// FIXME: Relative Z is not relative
if (jiggers.RelIntensity.Z != 0 || jiggers.RelOffset.Z != 0)
{
ViewPos.Z += QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z, jiggers.Falloff, jiggers.WFalloff);
ViewPos.Z += QuakePower(quakefactor, jiggers.RelIntensity.Z, jiggers.RelOffset.Z);
}
if (jiggers.Intensity.X != 0 || jiggers.Offset.X != 0)
{
ViewPos.X += QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X, jiggers.Falloff, jiggers.WFalloff);
ViewPos.X += QuakePower(quakefactor, jiggers.Intensity.X, jiggers.Offset.X);
}
if (jiggers.Intensity.Y != 0 || jiggers.Offset.Y != 0)
{
ViewPos.Y += QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y, jiggers.Falloff, jiggers.WFalloff);
ViewPos.Y += QuakePower(quakefactor, jiggers.Intensity.Y, jiggers.Offset.Y);
}
if (jiggers.Intensity.Z != 0 || jiggers.Offset.Z != 0)
{
ViewPos.Z += QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z, jiggers.Falloff, jiggers.WFalloff);
ViewPos.Z += QuakePower(quakefactor, jiggers.Intensity.Z, jiggers.Offset.Z);
}
}
}