- Adjust PlayerHorizon and PlayerAngle struct member scaletozero() to consistently return to zero at the same speed for synchronised and unsynchronised input at any framerate from 60 fps to at least 1000 fps.

This commit is contained in:
Mitch Richters 2021-11-13 21:14:37 +11:00 committed by Christoph Oelckers
parent 4231119717
commit 1906de5d0c

View file

@ -75,12 +75,12 @@ struct PlayerHorizon
{
return buildfhoriz(scaleAdjust * (((object ? object->asbuildf() : 1.) * getTicrateScale(value)) + push));
}
void scaletozero(fixedhoriz& object, double const value, double const scaleAdjust, double const push = 0.)
void scaletozero(fixedhoriz& object, double const value, double const scaleAdjust, double const push = DBL_MAX)
{
if (object.asq16())
{
auto sgn = Sgn(object.asq16());
object -= getscaledhoriz(value, scaleAdjust, &object, push == 0 ? sgn * (1. / 3.) : push);
object -= getscaledhoriz(value, scaleAdjust, &object, push == DBL_MAX ? sgn * (2. / 9.) * (scaleAdjust < 1. ? (1. - scaleAdjust * 0.5) * 1.5 : 1.) : push);
if (sgn != Sgn(object.asq16())) object = q16horiz(0);
}
}
@ -195,12 +195,12 @@ struct PlayerAngle
{
return buildfang(scaleAdjust * (((object ? object->signedbuildf() : 1.) * getTicrateScale(value)) + push));
}
void scaletozero(binangle& object, double const value, double const scaleAdjust, double const push = 0.)
void scaletozero(binangle& object, double const value, double const scaleAdjust, double const push = DBL_MAX)
{
if (object.asbam())
{
auto sgn = Sgn(object.signedbam());
object -= getscaledangle(value, scaleAdjust, &object, push == 0 ? sgn * (1. / 3.) : push);
object -= getscaledangle(value, scaleAdjust, &object, push == DBL_MAX ? sgn * (2. / 9.) * (scaleAdjust < 1. ? (1. - scaleAdjust * 0.5) * 1.5 : 1.) : push);
if (sgn != Sgn(object.signedbam())) object = bamang(0);
}
}