mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
Wave quakes now stack.
This commit is contained in:
parent
ce13b5c6e1
commit
043ada24da
3 changed files with 47 additions and 43 deletions
|
@ -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);
|
assert(m_CountdownStart >= m_Countdown);
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ double DEarthquake::GetModIntensity(double intensity) const
|
||||||
}
|
}
|
||||||
scalar = (scalar > divider) ? divider : scalar;
|
scalar = (scalar > divider) ? divider : scalar;
|
||||||
|
|
||||||
if (m_Flags & QF_FULLINTENSITY)
|
if (!fake && (m_Flags & QF_FULLINTENSITY))
|
||||||
{
|
{
|
||||||
scalar *= 2;
|
scalar *= 2;
|
||||||
}
|
}
|
||||||
|
@ -273,64 +273,69 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
|
||||||
DEarthquake *quake;
|
DEarthquake *quake;
|
||||||
int count = 0;
|
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)
|
if (dist < quake->m_TremorRadius)
|
||||||
{
|
{
|
||||||
const double falloff = quake->GetFalloff(dist);
|
|
||||||
const double rfalloff = (quake->m_RollIntensity != 0) ? falloff : 0.;
|
|
||||||
++count;
|
++count;
|
||||||
double x = quake->GetModIntensity(quake->m_Intensity.X);
|
const double falloff = quake->GetFalloff(dist);
|
||||||
double y = quake->GetModIntensity(quake->m_Intensity.Y);
|
const double r = quake->GetModIntensity(quake->m_RollIntensity);
|
||||||
double z = quake->GetModIntensity(quake->m_Intensity.Z);
|
const double strength = quake->GetModIntensity(1.0, true);
|
||||||
double r = quake->GetModIntensity(quake->m_RollIntensity);
|
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))
|
if (!(quake->m_Flags & QF_WAVE))
|
||||||
{
|
{
|
||||||
jiggers.Falloff = MAX(falloff, jiggers.Falloff);
|
jiggers.Falloff = MAX(falloff, jiggers.Falloff);
|
||||||
jiggers.RFalloff = MAX(rfalloff, jiggers.RFalloff);
|
jiggers.RollIntensity = MAX(r, jiggers.RollIntensity) * jiggers.Falloff;
|
||||||
jiggers.RollIntensity = MAX(r, jiggers.RollIntensity);
|
|
||||||
|
intensity *= jiggers.Falloff;
|
||||||
if (quake->m_Flags & QF_RELATIVE)
|
if (quake->m_Flags & QF_RELATIVE)
|
||||||
{
|
{
|
||||||
jiggers.RelIntensity.X = MAX(x, jiggers.RelIntensity.X);
|
jiggers.RelIntensity.X = MAX(intensity.X, jiggers.RelIntensity.X);
|
||||||
jiggers.RelIntensity.Y = MAX(y, jiggers.RelIntensity.Y);
|
jiggers.RelIntensity.Y = MAX(intensity.Y, jiggers.RelIntensity.Y);
|
||||||
jiggers.RelIntensity.Z = MAX(z, jiggers.RelIntensity.Z);
|
jiggers.RelIntensity.Z = MAX(intensity.Z, jiggers.RelIntensity.Z);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jiggers.Intensity.X = MAX(x, jiggers.Intensity.X);
|
jiggers.Intensity.X = MAX(intensity.X, jiggers.Intensity.X);
|
||||||
jiggers.Intensity.Y = MAX(y, jiggers.Intensity.Y);
|
jiggers.Intensity.Y = MAX(intensity.Y, jiggers.Intensity.Y);
|
||||||
jiggers.Intensity.Z = MAX(z, jiggers.Intensity.Z);
|
jiggers.Intensity.Z = MAX(intensity.Z, jiggers.Intensity.Z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jiggers.WFalloff = MAX(falloff, jiggers.WFalloff);
|
jiggers.Falloff = MAX(falloff, jiggers.Falloff);
|
||||||
jiggers.RWFalloff = MAX(rfalloff, jiggers.RWFalloff);
|
jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave) * jiggers.Falloff * strength;
|
||||||
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);
|
intensity.X *= quake->GetModWave(quake->m_WaveSpeed.X);
|
||||||
double mz = z * quake->GetModWave(quake->m_WaveSpeed.Z);
|
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
|
// [RH] This only gives effect to the last sine quake. I would
|
||||||
// prefer if some way was found to make multiples coexist
|
// prefer if some way was found to make multiples coexist
|
||||||
// peacefully, but just summing them together is undesirable
|
// peacefully, but just summing them together is undesirable
|
||||||
// because they could cancel each other out depending on their
|
// because they could cancel each other out depending on their
|
||||||
// relative phases.
|
// 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)
|
if (quake->m_Flags & QF_RELATIVE)
|
||||||
{
|
{
|
||||||
jiggers.RelOffset.X = mx;
|
jiggers.RelOffset += intensity;
|
||||||
jiggers.RelOffset.Y = my;
|
|
||||||
jiggers.RelOffset.Z = mz;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jiggers.Offset.X = mx;
|
jiggers.Offset += intensity;
|
||||||
jiggers.Offset.Y = my;
|
|
||||||
jiggers.Offset.Z = mz;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ struct FQuakeJiggers
|
||||||
DVector3 RelIntensity;
|
DVector3 RelIntensity;
|
||||||
DVector3 Offset;
|
DVector3 Offset;
|
||||||
DVector3 RelOffset;
|
DVector3 RelOffset;
|
||||||
double Falloff, WFalloff, RFalloff, RWFalloff;
|
double Falloff;
|
||||||
double RollIntensity, RollWave;
|
double RollIntensity, RollWave;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -180,8 +180,7 @@ public:
|
||||||
int m_Highpoint, m_MiniCount;
|
int m_Highpoint, m_MiniCount;
|
||||||
double m_RollIntensity, m_RollWave;
|
double m_RollIntensity, m_RollWave;
|
||||||
|
|
||||||
|
double GetModIntensity(double intensity, bool fake = false) const;
|
||||||
double GetModIntensity(double intensity) const;
|
|
||||||
double GetModWave(double waveMultiplier) const;
|
double GetModWave(double waveMultiplier) const;
|
||||||
double GetFalloff(double dist) const;
|
double GetFalloff(double dist) const;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
double randumb;
|
||||||
if (intensity == 0)
|
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;
|
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)
|
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)
|
if (jiggers.RelIntensity.X != 0 || jiggers.RelOffset.X != 0)
|
||||||
{
|
{
|
||||||
an = camera->Angles.Yaw;
|
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);
|
ViewPos += an.ToVector(power);
|
||||||
}
|
}
|
||||||
if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0)
|
if (jiggers.RelIntensity.Y != 0 || jiggers.RelOffset.Y != 0)
|
||||||
{
|
{
|
||||||
an = camera->Angles.Yaw + 90;
|
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);
|
ViewPos += an.ToVector(power);
|
||||||
}
|
}
|
||||||
// FIXME: Relative Z is not relative
|
// FIXME: Relative Z is not relative
|
||||||
if (jiggers.RelIntensity.Z != 0 || jiggers.RelOffset.Z != 0)
|
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)
|
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)
|
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)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue