- Add fixedhoriz::Sgn().

This commit is contained in:
Mitchell Richters 2022-09-27 09:52:30 +10:00 committed by Christoph Oelckers
parent e4ae726015
commit fcdb360b92
2 changed files with 5 additions and 3 deletions

View file

@ -86,6 +86,8 @@ public:
constexpr fixed_t asq16() const { return value; }
double Degrees() const { return HorizToPitch(value); }
int Sgn() const { return ::Sgn(value); }
bool operator< (fixedhoriz other) const
{
return value < other.value;

View file

@ -58,10 +58,10 @@ inline static DAngle getscaledangle(const double value, const double scaleAdjust
inline static void scaletozero(fixedhoriz& object, const double value, const double scaleAdjust, const double push = DBL_MAX)
{
if (auto sgn = Sgn(object.asq16()))
if (auto sgn = object.Sgn())
{
object -= getscaledhoriz(value, scaleAdjust, object, push == DBL_MAX ? sgn * 2. / 9. : push);
if (sgn != Sgn(object.asq16())) object = q16horiz(0);
if (sgn != object.Sgn()) object = q16horiz(0);
}
}
@ -433,7 +433,7 @@ void PlayerHorizon::calcviewpitch(const DVector2& pos, DAngle const ang, bool co
else
{
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
scaletozero(horizoff, HORIZOFFSPEED, scaleAdjust, Sgn(horizoff.asq16()));
scaletozero(horizoff, HORIZOFFSPEED, scaleAdjust, horizoff.Sgn());
}
}
}