mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- Changed QuakePower to take doubles on everything but intensity. This lets the camera shake until it truly reaches 0 as the limitations of integers were actually cutting it short.
This commit is contained in:
parent
045ab9fd5b
commit
0948b95e08
3 changed files with 19 additions and 19 deletions
|
@ -154,7 +154,7 @@ void DEarthquake::Tick ()
|
|||
//==========================================================================
|
||||
|
||||
int DEarthquake::StaticGetQuakeIntensities(AActor *victim,
|
||||
int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp)
|
||||
int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp)
|
||||
{
|
||||
if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP))
|
||||
{
|
||||
|
@ -191,15 +191,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim,
|
|||
scaleDownStart = scaleDown = scaleUp = 1;
|
||||
if (quake->m_Flags & QF_SCALEDOWN)
|
||||
{
|
||||
scaleDown = quake->m_Countdown;
|
||||
scaleDown = (double)quake->m_Countdown;
|
||||
}
|
||||
else
|
||||
{
|
||||
scaleDownStart = 0;
|
||||
scaleDown = 0;
|
||||
scaleDownStart = 0.0;
|
||||
scaleDown = 0.0;
|
||||
}
|
||||
if (quake->m_Flags & QF_SCALEUP)
|
||||
scaleUp = quake->m_Countup;
|
||||
scaleUp = (double)quake->m_Countup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
int m_Flags;
|
||||
int m_IntensityX, m_IntensityY, m_IntensityZ;
|
||||
|
||||
static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp);
|
||||
static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp);
|
||||
|
||||
private:
|
||||
DEarthquake ();
|
||||
|
|
|
@ -770,22 +770,20 @@ bool R_GetViewInterpolationStatus()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static fixed_t QuakePower(fixed_t factor, int intensity, int scaleDown, int scaleDownStart, int scaleUp)
|
||||
static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart, double scaleUp)
|
||||
{
|
||||
//if (!scaledown) scaledown = 1;
|
||||
//if (!scaleup) scaleup = 1;
|
||||
//double sd = (scaledown / ((!scaledownstart) ? 1 : scaledownstart));
|
||||
double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1));
|
||||
if (intensity == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (!scaleDownStart)
|
||||
{
|
||||
return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1));
|
||||
return factor * ss;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)) * ((scaleDown / scaleDownStart) >> 3));
|
||||
return ((factor * ss) * ((scaleDown / scaleDownStart) / 256.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -899,40 +897,42 @@ void R_SetupFrame (AActor *actor)
|
|||
|
||||
if (!paused)
|
||||
{
|
||||
int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp;
|
||||
int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ;
|
||||
double scaleDown, scaleDownStart, scaleUp;
|
||||
//double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart;
|
||||
if (DEarthquake::StaticGetQuakeIntensities(camera,
|
||||
intensityX, intensityY, intensityZ,
|
||||
relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0)
|
||||
{
|
||||
fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity);
|
||||
double quakefactor = r_quakeintensity;
|
||||
|
||||
if (relIntensityX != 0)
|
||||
{
|
||||
int ang = (camera->angle) >> ANGLETOFINESHIFT;
|
||||
fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp);
|
||||
fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp));
|
||||
viewx += FixedMul(finecosine[ang], power);
|
||||
viewy += FixedMul(finesine[ang], power);
|
||||
}
|
||||
if (relIntensityY != 0)
|
||||
{
|
||||
int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT;
|
||||
fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp);
|
||||
fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp));
|
||||
viewx += FixedMul(finecosine[ang], power);
|
||||
viewy += FixedMul(finesine[ang], power);
|
||||
}
|
||||
if (intensityX != 0)
|
||||
{
|
||||
viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp);
|
||||
viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp));
|
||||
}
|
||||
if (intensityY != 0)
|
||||
{
|
||||
viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp);
|
||||
viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp));
|
||||
}
|
||||
// FIXME: Relative Z is not relative
|
||||
intensityZ = MAX(intensityZ, relIntensityZ);
|
||||
if (intensityZ != 0)
|
||||
{
|
||||
viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp);
|
||||
viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue