mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 12:30:40 +00:00
- Exhumed: Add view bobbing, with defaults matching intensity of Powerslave Exhumed.
* `cl_viewbob` extended from bool to int, and allowing two modes: 1 == Powerslave Exhumed bobbing, 2 == Duke 3D-style bobbing. * Height and speed of bobbing customisable.
This commit is contained in:
parent
8283895828
commit
6799322544
5 changed files with 41 additions and 2 deletions
|
@ -69,7 +69,11 @@ CVARD(Bool, cl_idplayers, true, CVAR_ARCHIVE, "enable/disable name display when
|
|||
CVARD(Bool, cl_weaponsway, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable player weapon swaying")
|
||||
|
||||
// Todo: Consolidate these to be consistent across games?
|
||||
CVARD(Bool, cl_viewbob, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable player head bobbing")
|
||||
CUSTOM_CVARD(Int, cl_viewbob, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable player head bobbing")
|
||||
{
|
||||
if (self < 0) self = 0;
|
||||
else if (self > 2) self = 2;
|
||||
}
|
||||
CVARD(Bool, cl_viewhbob, true, CVAR_ARCHIVE, "enable/disable view horizontal bobbing") // Only implemented in Blood
|
||||
CVARD(Bool, cl_viewvbob, true, CVAR_ARCHIVE, "enable/disable view vertical bobbing") // Only implemented in Blood
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ EXTERN_CVAR(Bool, cl_autosavedeletion)
|
|||
EXTERN_CVAR(Int, cl_maxautosaves)
|
||||
EXTERN_CVAR(Bool, cl_obituaries)
|
||||
EXTERN_CVAR(Bool, cl_idplayers)
|
||||
EXTERN_CVAR(Bool, cl_viewbob)
|
||||
EXTERN_CVAR(Int, cl_viewbob)
|
||||
EXTERN_CVAR(Bool, cl_weaponsway)
|
||||
EXTERN_CVAR(Bool, cl_viewhbob)
|
||||
EXTERN_CVAR(Bool, cl_viewvbob)
|
||||
|
|
|
@ -43,6 +43,8 @@ CUSTOM_CVAR(Int, cl_exviewtilting, 0, CVAR_ARCHIVE)
|
|||
}
|
||||
CVAR(Float, cl_extiltscale, 1.f, CVAR_ARCHIVE);
|
||||
CVAR(Bool, cl_exjumprebound, false, CVAR_ARCHIVE);
|
||||
CVAR(Float, cl_exviewbobspeed, 4.f, CVAR_ARCHIVE);
|
||||
CVAR(Float, cl_exviewbobheight, 5.f, CVAR_ARCHIVE);
|
||||
|
||||
BEGIN_PS_NS
|
||||
|
||||
|
@ -1126,6 +1128,12 @@ static void updatePlayerVelocity(Player* const pPlayer)
|
|||
}
|
||||
}
|
||||
|
||||
if (pPlayer->vel.Length() < 0.09375 && !pPlayer->vel.isZero())
|
||||
{
|
||||
pPlayer->vel.Zero();
|
||||
pPlayer->nIdxBobZ = 0;
|
||||
}
|
||||
|
||||
pPlayerActor->vel.XY() = pPlayer->vel;
|
||||
}
|
||||
|
||||
|
@ -1580,6 +1588,26 @@ static void doPlayerCameraEffects(Player* const pPlayer, const double nDestVertP
|
|||
|
||||
// Always scale roll back to zero in case the functionality is disabled mid-roll.
|
||||
scaletozero(pPlayerActor->spr.Angles.Roll, rollreturnrate);
|
||||
|
||||
// Update Z bobbing.
|
||||
if (cl_viewbob)
|
||||
{
|
||||
// Increment index, attenuating by bob speed, type and whether we're underwater.
|
||||
const int nUnderwater = !!(pPlayerActor->sector()->Flag & kSectUnderwater);
|
||||
pPlayer->nPrevBobZ = pPlayer->nBobZ;
|
||||
pPlayer->nIdxBobZ += (2048. / 90.) * cl_exviewbobspeed / cl_viewbob / (nUnderwater + 1);
|
||||
pPlayer->nIdxBobZ *= !pPlayerActor->vel.Z;
|
||||
|
||||
// Increment bob value with index's sine, amplifed by player velocity, bob type and bob height CVAR.
|
||||
const auto nBobVel = (pPlayer->vel.Length() < 0.09375 && nUnderwater) ? (61. / 12.) : pPlayer->totalvel;
|
||||
const auto nBobAmp = nBobVel * 0.05 * cl_viewbob * cl_exviewbobheight;
|
||||
const auto newBobZ = BobVal(pPlayer->nIdxBobZ) * nBobAmp;
|
||||
pPlayer->nBobZ = (cl_viewbob == 2) ? (abs(newBobZ) - nBobAmp * 0.5 * !nUnderwater) : (newBobZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->nPrevBobZ = pPlayer->nBobZ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -99,6 +99,9 @@ struct Player
|
|||
PlayerSave sPlayerSave;
|
||||
double ototalvel;
|
||||
double totalvel;
|
||||
double nPrevBobZ;
|
||||
double nBobZ;
|
||||
double nIdxBobZ;
|
||||
bool crouch_toggle;
|
||||
bool bTouchFloor;
|
||||
bool bJumping;
|
||||
|
|
|
@ -145,6 +145,10 @@ void DrawView(double interpfrac, bool sceneonly)
|
|||
calcChaseCamPos(nCamerapos, pPlayerActor, &pSector, nCameraangles, interpfrac, 96.);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nCamerapos.Z += interpolatedvalue(pPlayer->nPrevBobZ, pPlayer->nBobZ, interpfrac);
|
||||
}
|
||||
}
|
||||
|
||||
if (pSector != nullptr)
|
||||
|
|
Loading…
Reference in a new issue