- Eliminate BAngToDegree constant.

This commit is contained in:
Mitchell Richters 2022-12-11 12:09:19 +11:00 committed by Christoph Oelckers
parent 67b40ee1d5
commit de8353f085
6 changed files with 25 additions and 24 deletions

View file

@ -210,8 +210,6 @@ enum
};
constexpr double BAngRadian = pi::pi() * (1. / 1024.);
constexpr double BAngToDegree = 360. / 2048.;
constexpr DAngle DAngleBuildToDeg = DAngle::fromDeg(BAngToDegree);
//---------------------------------------------------------------------------
//

View file

@ -529,7 +529,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
PLAYER* pPlayer = &gPlayer[gViewIndex];
int nViewSprites = tsprites.Size();
// shift before interpolating to increase precision.
DAngle myclock = DAngle::fromDeg(((PlayClock << 3) + (4 << 3) * interpfrac) * BAngToDegree);
DAngle myclock = DAngle::fromBuild((PlayClock << 3) + (4 << 3) * interpfrac);
gCameraAng = cA;
for (int nTSprite = int(tsprites.Size()) - 1; nTSprite >= 0; nTSprite--)
{

View file

@ -87,15 +87,15 @@ void displaymasks_r(int snum, int p, double interpfrac)
//
//---------------------------------------------------------------------------
inline static void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, double a)
inline static void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, DAngle a)
{
hud_drawsprite(x, y, 34816, a * -BAngToDegree, tilenum, shade, p, 2 | orientation);
hud_drawsprite(x, y, 34816, a.Degrees(), tilenum, shade, p, 2 | orientation);
}
inline static void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, double a)
inline static void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, DAngle a)
{
hud_drawsprite(x, y, 66048, a * -BAngToDegree, tilenum, shade, p, 2 | orientation);
hud_drawsprite(x, y, 66048, a.Degrees(), tilenum, shade, p, 2 | orientation);
}
@ -150,6 +150,7 @@ void displayweapon_r(int snum, double interpfrac)
if (p->OnMotorcycle)
{
angle = DAngle::fromBuild(-TiltStatus);
int temp_kb;
if (numplayers == 1)
{
@ -198,11 +199,12 @@ void displayweapon_r(int snum, double interpfrac)
temp_kb = RTILE_MOTOHIT;
}
ShowMotorcycle(160 + offsets.X, 174, temp_kb, shade, 0, pal, TiltStatus*5);
ShowMotorcycle(160 + offsets.X, 174, temp_kb, shade, 0, pal, angle * 5);
return;
}
if (p->OnBoat)
{
angle = DAngle::fromBuild(-TiltStatus);
int temp2, temp_kb, temp3;
temp2 = 0;
if (TiltStatus > 0)
@ -265,7 +267,7 @@ void displayweapon_r(int snum, double interpfrac)
if (temp2)
shade = -96;
ShowBoat(160 + offsets.X, temp3, temp_kb, shade, 0, pal, TiltStatus);
ShowBoat(160 + offsets.X, temp3, temp_kb, shade, 0, pal, angle);
return;
}

View file

@ -555,7 +555,7 @@ static void processInputBits(player_struct *p, ControlInfo* const hidInput)
//
//---------------------------------------------------------------------------
static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor)
static FAngle motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor)
{
double turnvel = 0;
p->oTiltStatus = p->TiltStatus;
@ -636,7 +636,7 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool
if (fabs(p->TiltStatus) < factor)
p->TiltStatus = 0;
return turnvel * factor;
return FAngle::fromBuild(turnvel * factor);
}
//---------------------------------------------------------------------------
@ -645,7 +645,7 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool
//
//---------------------------------------------------------------------------
static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor)
static FAngle boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor)
{
double turnvel = 0;
p->oTiltStatus = p->TiltStatus;
@ -722,7 +722,7 @@ static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool
if (fabs(p->TiltStatus) < factor)
p->TiltStatus = 0;
return turnvel * factor;
return FAngle::fromBuild(turnvel * factor);
}
//---------------------------------------------------------------------------
@ -751,16 +751,15 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I
if (p->OnMotorcycle)
{
input.avel = (float)motoApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust);
input.avel = motoApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust).Degrees();
if (p->moto_underwater) p->MotoSpeed = 0;
}
else
{
input.avel = (float)boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust);
input.avel = boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust).Degrees();
}
loc.fvel = clamp<float>((float)p->MotoSpeed, -(MAXVELMOTO >> 3), MAXVELMOTO) * (1.f / 40.f);
input.avel *= BAngToDegree;
loc.avel += input.avel;
}

View file

@ -730,17 +730,19 @@ void player_struct::apply_seasick()
{
if (SeaSick < 250)
{
static constexpr DAngle adjustment = DAngle::fromDeg(4.21875);
if (SeaSick >= 180)
Angles.ViewAngles.Roll -= DAngle::fromDeg(24 * BAngToDegree);
Angles.ViewAngles.Roll -= adjustment;
else if (SeaSick >= 130)
Angles.ViewAngles.Roll += DAngle::fromDeg(24 * BAngToDegree);
Angles.ViewAngles.Roll += adjustment;
else if (SeaSick >= 70)
Angles.ViewAngles.Roll -= DAngle::fromDeg(24 * BAngToDegree);
Angles.ViewAngles.Roll -= adjustment;
else if (SeaSick >= 20)
Angles.ViewAngles.Roll += DAngle::fromDeg(24 * BAngToDegree);
Angles.ViewAngles.Roll += adjustment;
}
if (SeaSick < 250)
Angles.ViewAngles.Yaw = DAngle::fromDeg(((krand() & 255) - 128) * BAngToDegree);
Angles.ViewAngles.Yaw = DAngle::fromDeg(krandf(45) - 22.5);
}
}

View file

@ -967,7 +967,7 @@ void DrawWeapons(double interpfrac)
if (cl_hudinterpolation)
{
nBobAngle = interpolatedvalue<double>(obobangle, bobangle, interpfrac) * BAngToDegree;
nBobAngle = interpolatedvalue<double>(obobangle, bobangle, interpfrac);
nVal = interpolatedvalue<double>(PlayerList[nLocalPlayer].ototalvel, PlayerList[nLocalPlayer].totalvel, interpfrac);
}
else
@ -976,11 +976,11 @@ void DrawWeapons(double interpfrac)
nVal = PlayerList[nLocalPlayer].totalvel;
}
yOffset = nVal * fabs(g_sindeg(nBobAngle)) * (1. / 16.);
yOffset = nVal * fabs(BobVal(nBobAngle)) * (1. / 16.);
if (var_34 == 1)
{
xOffset = nVal * g_cosdeg(nBobAngle) * (1. / 8.);
xOffset = nVal * BobVal(nBobAngle + 512) * (1. / 8.);
}
}
else