mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
- gameinput.cpp/h: Internalise if statements used before calling PlayerHorizon
and PlayerAngle
class method scaletozero()
into method itself.
This commit is contained in:
parent
72531e61db
commit
b27f5e3be0
2 changed files with 16 additions and 10 deletions
|
@ -318,7 +318,7 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons
|
|||
}
|
||||
|
||||
// return to center if conditions met.
|
||||
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)) && horiz.asq16())
|
||||
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||
{
|
||||
scaletozero(horiz, CNTRSPEED, scaleAdjust);
|
||||
if (!horiz.asq16()) *actions &= ~SB_CENTERVIEW;
|
||||
|
@ -369,8 +369,8 @@ enum
|
|||
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const scaleAdjust)
|
||||
{
|
||||
// Process angle return to zeros.
|
||||
if (rotscrnang.asbam()) scaletozero(rotscrnang, LOOKROTRETBASE, scaleAdjust);
|
||||
if (look_ang.asbam()) scaletozero(look_ang, +LOOKROTRETBASE * 0.5, scaleAdjust);
|
||||
scaletozero(rotscrnang, LOOKROTRETBASE, scaleAdjust);
|
||||
scaletozero(look_ang, +LOOKROTRETBASE * 0.5, scaleAdjust);
|
||||
|
||||
// Process keyboard input.
|
||||
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
|
||||
|
@ -489,7 +489,7 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
|
|||
horizoff += getscaledhoriz(4.375, scaleAdjust, &temphorizoff, 1.);
|
||||
}
|
||||
}
|
||||
else if (horizoff.asq16())
|
||||
else
|
||||
{
|
||||
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
||||
scaletozero(horizoff, 4.375, scaleAdjust, Sgn(horizoff.asq16()));
|
||||
|
|
|
@ -77,9 +77,12 @@ struct PlayerHorizon
|
|||
}
|
||||
void scaletozero(fixedhoriz& object, double const value, double const scaleAdjust, double const push = 0.)
|
||||
{
|
||||
auto sgn = Sgn(object.asq16());
|
||||
object -= getscaledhoriz(value, scaleAdjust, &object, push == 0 ? sgn * (1. / 3.) : push);
|
||||
if (sgn != Sgn(object.asq16())) object = q16horiz(0);
|
||||
if (object.asq16())
|
||||
{
|
||||
auto sgn = Sgn(object.asq16());
|
||||
object -= getscaledhoriz(value, scaleAdjust, &object, push == 0 ? sgn * (1. / 3.) : push);
|
||||
if (sgn != Sgn(object.asq16())) object = q16horiz(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Ticrate playsim adjustment processor.
|
||||
|
@ -194,9 +197,12 @@ struct PlayerAngle
|
|||
}
|
||||
void scaletozero(binangle& object, double const value, double const scaleAdjust, double const push = 0.)
|
||||
{
|
||||
auto sgn = Sgn(object.signedbam());
|
||||
object -= getscaledangle(value, scaleAdjust, &object, push == 0 ? sgn * (1. / 3.) : push);
|
||||
if (sgn != Sgn(object.signedbam())) object = bamang(0);
|
||||
if (object.asbam())
|
||||
{
|
||||
auto sgn = Sgn(object.signedbam());
|
||||
object -= getscaledangle(value, scaleAdjust, &object, push == 0 ? sgn * (1. / 3.) : push);
|
||||
if (sgn != Sgn(object.signedbam())) object = bamang(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Ticrate playsim adjustment processor.
|
||||
|
|
Loading…
Reference in a new issue