- 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:
MajorCooke 2015-02-19 23:19:24 -06:00
parent 045ab9fd5b
commit 0948b95e08
3 changed files with 19 additions and 19 deletions

View file

@ -154,7 +154,7 @@ void DEarthquake::Tick ()
//========================================================================== //==========================================================================
int DEarthquake::StaticGetQuakeIntensities(AActor *victim, 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)) if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP))
{ {
@ -191,15 +191,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim,
scaleDownStart = scaleDown = scaleUp = 1; scaleDownStart = scaleDown = scaleUp = 1;
if (quake->m_Flags & QF_SCALEDOWN) if (quake->m_Flags & QF_SCALEDOWN)
{ {
scaleDown = quake->m_Countdown; scaleDown = (double)quake->m_Countdown;
} }
else else
{ {
scaleDownStart = 0; scaleDownStart = 0.0;
scaleDown = 0; scaleDown = 0.0;
} }
if (quake->m_Flags & QF_SCALEUP) if (quake->m_Flags & QF_SCALEUP)
scaleUp = quake->m_Countup; scaleUp = (double)quake->m_Countup;
} }
} }
} }

View file

@ -156,7 +156,7 @@ public:
int m_Flags; int m_Flags;
int m_IntensityX, m_IntensityY, m_IntensityZ; 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: private:
DEarthquake (); DEarthquake ();

View file

@ -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; double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1));
//if (!scaleup) scaleup = 1;
//double sd = (scaledown / ((!scaledownstart) ? 1 : scaledownstart));
if (intensity == 0) if (intensity == 0)
{ {
return 0; return 0;
} }
else if (!scaleDownStart) else if (!scaleDownStart)
{ {
return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); return factor * ss;
} }
else 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) 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, if (DEarthquake::StaticGetQuakeIntensities(camera,
intensityX, intensityY, intensityZ, intensityX, intensityY, intensityZ,
relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0)
{ {
fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); double quakefactor = r_quakeintensity;
if (relIntensityX != 0) if (relIntensityX != 0)
{ {
int ang = (camera->angle) >> ANGLETOFINESHIFT; 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); viewx += FixedMul(finecosine[ang], power);
viewy += FixedMul(finesine[ang], power); viewy += FixedMul(finesine[ang], power);
} }
if (relIntensityY != 0) if (relIntensityY != 0)
{ {
int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; 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); viewx += FixedMul(finecosine[ang], power);
viewy += FixedMul(finesine[ang], power); viewy += FixedMul(finesine[ang], power);
} }
if (intensityX != 0) if (intensityX != 0)
{ {
viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp); viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp));
} }
if (intensityY != 0) if (intensityY != 0)
{ {
viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp); viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp));
} }
// FIXME: Relative Z is not relative // FIXME: Relative Z is not relative
intensityZ = MAX(intensityZ, relIntensityZ); intensityZ = MAX(intensityZ, relIntensityZ);
if (intensityZ != 0) if (intensityZ != 0)
{ {
viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp); viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp));
} }
} }
} }