mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-13 04:24:39 +00:00
- Rework PlayerAngles::doViewPitch()
to apply at ticrate like PlayerAngles::doViewYaw()
.
This commit is contained in:
parent
fdcf8bbe2f
commit
abdeeac205
14 changed files with 40 additions and 32 deletions
|
@ -267,7 +267,7 @@ void PlayerAngles::applyYaw(float const avel, ESyncBits* actions, double const s
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust, bool const climbing)
|
void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, bool const climbing)
|
||||||
{
|
{
|
||||||
if (cl_slopetilting && cursectnum != nullptr)
|
if (cl_slopetilting && cursectnum != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +292,7 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const
|
||||||
// accordingly
|
// accordingly
|
||||||
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4))
|
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4))
|
||||||
{
|
{
|
||||||
ViewAngles.Pitch -= maphoriz(scaleAdjust * ((j - k) * (!isBlood() ? 0.625 : 5.5)));
|
ViewAngles.Pitch -= maphoriz((j - k) * (!isBlood() ? 0.625 : 5.5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,12 +300,12 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const
|
||||||
if (climbing)
|
if (climbing)
|
||||||
{
|
{
|
||||||
// tilt when climbing but you can't even really tell it.
|
// tilt when climbing but you can't even really tell it.
|
||||||
if (ViewAngles.Pitch > PITCH_HORIZOFFCLIMB) ViewAngles.Pitch += getscaledangle(PITCH_HORIZOFFSPEED, deltaangle(ViewAngles.Pitch, PITCH_HORIZOFFCLIMB), PITCH_HORIZOFFPUSH, scaleAdjust);
|
if (ViewAngles.Pitch > PITCH_HORIZOFFCLIMB) ViewAngles.Pitch += getscaledangle(PITCH_HORIZOFFSPEED, deltaangle(ViewAngles.Pitch, PITCH_HORIZOFFCLIMB), PITCH_HORIZOFFPUSH);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
||||||
scaletozero(ViewAngles.Pitch, PITCH_HORIZOFFSPEED, scaleAdjust, PITCH_HORIZOFFPUSH);
|
scaletozero(ViewAngles.Pitch, PITCH_HORIZOFFSPEED, 1, PITCH_HORIZOFFPUSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clamp off against the maximum allowed pitch.
|
// Clamp off against the maximum allowed pitch.
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct PlayerAngles
|
||||||
void applyYaw(float const avel, ESyncBits* actions, double const scaleAdjust = 1);
|
void applyYaw(float const avel, ESyncBits* actions, double const scaleAdjust = 1);
|
||||||
|
|
||||||
// Prototypes for applying view.
|
// Prototypes for applying view.
|
||||||
void doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
|
void doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, bool const climbing = false);
|
||||||
void doViewYaw(const ESyncBits actions);
|
void doViewYaw(const ESyncBits actions);
|
||||||
|
|
||||||
// General methods.
|
// General methods.
|
||||||
|
@ -101,9 +101,8 @@ struct PlayerAngles
|
||||||
|
|
||||||
|
|
||||||
// Legacy, to be removed.
|
// Legacy, to be removed.
|
||||||
DAngle horizOLDSUM() { return ZzOLDHORIZON() + PrevViewAngles.Pitch; }
|
DAngle horizSUM(const double interpfrac = 1) { return ZzHORIZON() + interpolatedvalue(PrevViewAngles.Pitch, ViewAngles.Pitch, interpfrac); }
|
||||||
DAngle horizSUM() { return ZzHORIZON() + ViewAngles.Pitch; }
|
DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDHORIZON() + PrevViewAngles.Pitch, ZzHORIZON() + ViewAngles.Pitch, interpfrac); }
|
||||||
DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(horizOLDSUM(), horizSUM(), interpfrac); }
|
|
||||||
DAngle angSUM(const double interpfrac) { return ZzANGLE() + angLERPLOOKANG(interpfrac); }
|
DAngle angSUM(const double interpfrac) { return ZzANGLE() + angLERPLOOKANG(interpfrac); }
|
||||||
DAngle angLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE() + PrevViewAngles.Yaw, ZzANGLE() + ViewAngles.Yaw, interpfrac); }
|
DAngle angLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE() + PrevViewAngles.Yaw, ZzANGLE() + ViewAngles.Yaw, interpfrac); }
|
||||||
DAngle angLERPANG(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE(), ZzANGLE(), interpfrac); }
|
DAngle angLERPANG(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE(), ZzANGLE(), interpfrac); }
|
||||||
|
|
|
@ -34,8 +34,6 @@ BEGIN_BLD_NS
|
||||||
|
|
||||||
static InputPacket gInput;
|
static InputPacket gInput;
|
||||||
|
|
||||||
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust);
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -63,7 +61,6 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
|
||||||
{
|
{
|
||||||
pPlayer->Angles.applyYaw(input.avel, &pPlayer->input.actions, scaleAdjust);
|
pPlayer->Angles.applyYaw(input.avel, &pPlayer->input.actions, scaleAdjust);
|
||||||
pPlayer->Angles.applyPitch(input.horz, &pPlayer->input.actions, scaleAdjust);
|
pPlayer->Angles.applyPitch(input.horz, &pPlayer->input.actions, scaleAdjust);
|
||||||
doslopetilting(pPlayer, scaleAdjust);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pPlayer->Angles.applyScaledAdjustments(scaleAdjust);
|
pPlayer->Angles.applyScaledAdjustments(scaleAdjust);
|
||||||
|
|
|
@ -1498,12 +1498,12 @@ int ActionScan(PLAYER* pPlayer, HitInfo* out)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1)
|
void doslopetilting(PLAYER* pPlayer)
|
||||||
{
|
{
|
||||||
auto plActor = pPlayer->actor;
|
auto plActor = pPlayer->actor;
|
||||||
int const florhit = pPlayer->actor->hit.florhit.type;
|
int const florhit = pPlayer->actor->hit.florhit.type;
|
||||||
bool const va = plActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0;
|
bool const va = plActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0;
|
||||||
pPlayer->Angles.doViewPitch(plActor->spr.pos.XY(), plActor->spr.Angles.Yaw, va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector(), scaleAdjust);
|
pPlayer->Angles.doViewPitch(plActor->spr.pos.XY(), plActor->spr.Angles.Yaw, va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -1715,9 +1715,10 @@ void ProcessInput(PLAYER* pPlayer)
|
||||||
if (SyncInput())
|
if (SyncInput())
|
||||||
{
|
{
|
||||||
pPlayer->Angles.applyPitch(pInput->horz, &pInput->actions);
|
pPlayer->Angles.applyPitch(pInput->horz, &pInput->actions);
|
||||||
doslopetilting(pPlayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doslopetilting(pPlayer);
|
||||||
|
|
||||||
pPlayer->Angles.unlockYaw();
|
pPlayer->Angles.unlockYaw();
|
||||||
pPlayer->Angles.unlockPitch();
|
pPlayer->Angles.unlockPitch();
|
||||||
|
|
||||||
|
|
|
@ -502,7 +502,7 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, s
|
||||||
if (!SyncInput())
|
if (!SyncInput())
|
||||||
{
|
{
|
||||||
cA = pPlayer->Angles.angSUM(interpfrac);
|
cA = pPlayer->Angles.angSUM(interpfrac);
|
||||||
cH = pPlayer->Angles.horizSUM();
|
cH = pPlayer->Angles.horizSUM(interpfrac);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -229,7 +229,7 @@ void displayweapon_d(int snum, double interpfrac)
|
||||||
gun_pos -= fabs(p->GetActor()->spr.scale.X < 0.5 ? BobVal(weapon_sway * 4.) * 32 : BobVal(weapon_sway * 0.5) * 16) + hard_landing;
|
gun_pos -= fabs(p->GetActor()->spr.scale.X < 0.5 ? BobVal(weapon_sway * 4.) * 32 : BobVal(weapon_sway * 0.5) * 16) + hard_landing;
|
||||||
|
|
||||||
auto offsets = p->Angles.angWEAPONOFFSETS(interpfrac);
|
auto offsets = p->Angles.angWEAPONOFFSETS(interpfrac);
|
||||||
auto horiz = !SyncInput() ? p->Angles.horizSUM() : p->Angles.horizLERPSUM(interpfrac);
|
auto horiz = !SyncInput() ? p->Angles.horizSUM(interpfrac) : p->Angles.horizLERPSUM(interpfrac);
|
||||||
auto pitchoffset = interpolatedvalue(0., 16., horiz / DAngle90);
|
auto pitchoffset = interpolatedvalue(0., 16., horiz / DAngle90);
|
||||||
auto yawinput = getavel(snum) * (1. / 16.);
|
auto yawinput = getavel(snum) * (1. / 16.);
|
||||||
auto angle = -p->Angles.angLERPROTSCRN(interpfrac);
|
auto angle = -p->Angles.angLERPROTSCRN(interpfrac);
|
||||||
|
|
|
@ -208,10 +208,10 @@ inline bool playrunning()
|
||||||
return (paused == 0 || (paused == 1 && (ud.recstat == 2 || ud.multimode > 1)));
|
return (paused == 0 || (paused == 1 && (ud.recstat == 2 || ud.multimode > 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void doslopetilting(player_struct* p, double const scaleAdjust = 1)
|
inline void doslopetilting(player_struct* p)
|
||||||
{
|
{
|
||||||
bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE);
|
bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE);
|
||||||
p->Angles.doViewPitch(p->GetActor()->spr.pos.XY(), p->Angles.ZzANGLE(), p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust);
|
p->Angles.doViewPitch(p->GetActor()->spr.pos.XY(), p->Angles.ZzANGLE(), p->aim_mode == 0, canslopetilt, p->cursector);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -835,7 +835,6 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
|
||||||
if (p->GetActor()->spr.extra > 0)
|
if (p->GetActor()->spr.extra > 0)
|
||||||
{
|
{
|
||||||
// Do these in the same order as the old code.
|
// Do these in the same order as the old code.
|
||||||
doslopetilting(p, scaleAdjust);
|
|
||||||
p->Angles.applyYaw(p->adjustavel(input.avel), &p->sync.actions, scaleAdjust);
|
p->Angles.applyYaw(p->adjustavel(input.avel), &p->sync.actions, scaleAdjust);
|
||||||
p->Angles.applyPitch(input.horz, &p->sync.actions, scaleAdjust);
|
p->Angles.applyPitch(input.horz, &p->sync.actions, scaleAdjust);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2761,10 +2761,7 @@ void processinput_d(int snum)
|
||||||
pact->floorz = floorz;
|
pact->floorz = floorz;
|
||||||
pact->ceilingz = ceilingz;
|
pact->ceilingz = ceilingz;
|
||||||
|
|
||||||
if (SyncInput())
|
doslopetilting(p);
|
||||||
{
|
|
||||||
doslopetilting(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chz.type == kHitSprite)
|
if (chz.type == kHitSprite)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3347,10 +3347,7 @@ void processinput_r(int snum)
|
||||||
pact->floorz = floorz;
|
pact->floorz = floorz;
|
||||||
pact->ceilingz = ceilingz;
|
pact->ceilingz = ceilingz;
|
||||||
|
|
||||||
if (SyncInput())
|
doslopetilting(p);
|
||||||
{
|
|
||||||
doslopetilting(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chz.type == kHitSprite)
|
if (chz.type == kHitSprite)
|
||||||
{
|
{
|
||||||
|
|
|
@ -305,7 +305,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly)
|
||||||
{
|
{
|
||||||
// This is for real time updating of the view direction.
|
// This is for real time updating of the view direction.
|
||||||
cang = p->Angles.angSUM(interpfrac);
|
cang = p->Angles.angSUM(interpfrac);
|
||||||
choriz = p->Angles.horizSUM();
|
choriz = p->Angles.horizSUM(interpfrac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ void DrawView(double interpfrac, bool sceneonly)
|
||||||
|
|
||||||
if (!SyncInput())
|
if (!SyncInput())
|
||||||
{
|
{
|
||||||
nCamerapan = PlayerList[nLocalPlayer].Angles.horizSUM();
|
nCamerapan = PlayerList[nLocalPlayer].Angles.horizSUM(interpfrac);
|
||||||
nCameraang = PlayerList[nLocalPlayer].Angles.angSUM(interpfrac);
|
nCameraang = PlayerList[nLocalPlayer].Angles.angSUM(interpfrac);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1250,7 +1250,7 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tang = pp->Angles.angSUM(interpfrac);
|
tang = pp->Angles.angSUM(interpfrac);
|
||||||
thoriz = pp->Angles.horizSUM();
|
thoriz = pp->Angles.horizSUM(interpfrac);
|
||||||
}
|
}
|
||||||
trotscrnang = camerapp->Angles.angLERPROTSCRN(interpfrac);
|
trotscrnang = camerapp->Angles.angLERPROTSCRN(interpfrac);
|
||||||
tsect = camerapp->cursector;
|
tsect = camerapp->cursector;
|
||||||
|
|
|
@ -1667,10 +1667,20 @@ void SlipSlope(PLAYER* pp)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust)
|
void DoPlayerSlopeTilting(PLAYER* pp)
|
||||||
{
|
{
|
||||||
bool const canslopetilt = !(pp->Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) && pp->cursector && (pp->cursector->floorstat & CSTAT_SECTOR_SLOPE);
|
bool const canslopetilt = !(pp->Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) && pp->cursector && (pp->cursector->floorstat & CSTAT_SECTOR_SLOPE);
|
||||||
pp->Angles.doViewPitch(pp->actor->spr.pos.XY(), pp->Angles.ZzANGLE(), pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING));
|
pp->Angles.doViewPitch(pp->actor->spr.pos.XY(), pp->Angles.ZzANGLE(), pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, (pp->Flags & PF_CLIMBING));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust)
|
||||||
|
{
|
||||||
pp->Angles.applyPitch(horz, &pp->input.actions, scaleAdjust);
|
pp->Angles.applyPitch(horz, &pp->input.actions, scaleAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2202,6 +2212,8 @@ void DoPlayerMove(PLAYER* pp)
|
||||||
DoPlayerHorizon(pp, pp->input.horz, 1);
|
DoPlayerHorizon(pp, pp->input.horz, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoPlayerSlopeTilting(pp);
|
||||||
|
|
||||||
if (pp->insector() && (pp->cursector->extra & SECTFX_DYNAMIC_AREA))
|
if (pp->insector() && (pp->cursector->extra & SECTFX_DYNAMIC_AREA))
|
||||||
{
|
{
|
||||||
if (pp->Flags & (PF_FLYING|PF_JUMPING|PF_FALLING))
|
if (pp->Flags & (PF_FLYING|PF_JUMPING|PF_FALLING))
|
||||||
|
@ -2776,6 +2788,8 @@ void DoPlayerMoveVehicle(PLAYER* pp)
|
||||||
DoPlayerHorizon(pp, pp->input.horz, 1);
|
DoPlayerHorizon(pp, pp->input.horz, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoPlayerSlopeTilting(pp);
|
||||||
|
|
||||||
DoTankTreads(pp);
|
DoTankTreads(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2817,6 +2831,8 @@ void DoPlayerMoveTurret(PLAYER* pp)
|
||||||
{
|
{
|
||||||
DoPlayerHorizon(pp, pp->input.horz, 1);
|
DoPlayerHorizon(pp, pp->input.horz, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoPlayerSlopeTilting(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -3380,6 +3396,8 @@ void DoPlayerClimb(PLAYER* pp)
|
||||||
DoPlayerHorizon(pp, pp->input.horz, 1);
|
DoPlayerHorizon(pp, pp->input.horz, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoPlayerSlopeTilting(pp);
|
||||||
|
|
||||||
if (FAF_ConnectArea(pp->cursector))
|
if (FAF_ConnectArea(pp->cursector))
|
||||||
{
|
{
|
||||||
updatesectorz(pp->actor->getPosWithOffsetZ(), &pp->cursector);
|
updatesectorz(pp->actor->getPosWithOffsetZ(), &pp->cursector);
|
||||||
|
|
Loading…
Reference in a new issue