Skip to content

Commit

Permalink
- Convert all remaining angle internals of PlayerAngle into `DAngle…
Browse files Browse the repository at this point in the history
…` units.

* With the old setup, we needed to use primitives to get the desired outcome, but since DAngle stores a proper angle in true degrees, we can use it all the way.
  • Loading branch information
mjr4077au authored and coelckers committed Jul 25, 2023
1 parent eefaf1b commit 3c68028
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions source/core/gamefuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ enum

constexpr double BAngRadian = pi::pi() * (1. / 1024.);
constexpr double BAngToDegree = 360. / 2048.;
constexpr DAngle DAngleBuildToDeg = DAngle::fromDeg(BAngToDegree);

extern int sintable[2048];

Expand Down
21 changes: 10 additions & 11 deletions source/core/gameinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ struct PlayerAngle
DAngle interpolatedrotscrn(double const smoothratio) { return interpolatedangle(orotscrnang, rotscrnang, smoothratio); }

// Ticrate playsim adjustment helpers.
void resetadjustment() { adjustment = 0; }
bool targetset() { return target.BAMs(); }
void resetadjustment() { adjustment = nullAngle; }
bool targetset() { return target.Sgn(); }

// Input locking helpers.
void lockinput() { inputdisabled = true; }
Expand All @@ -162,7 +162,7 @@ struct PlayerAngle
{
if (!SyncInput())
{
adjustment += value.Normalized180().Degrees();
adjustment += value.Normalized180();
}
else
{
Expand All @@ -174,7 +174,7 @@ struct PlayerAngle
{
if (!SyncInput() && !backup)
{
target = value.BAMs() ? value : DAngle::fromBam(1);
target = value.Sgn() ? value : DAngle::fromBam(1);
}
else
{
Expand All @@ -187,27 +187,26 @@ struct PlayerAngle
{
if (targetset())
{
auto delta = deltaangle(ang, target).Degrees();
auto delta = deltaangle(ang, target);

if (abs(delta) > BAngToDegree)
if (abs(delta) > DAngleBuildToDeg)
{
ang += DAngle::fromDeg(scaleAdjust * delta);
ang += delta * scaleAdjust;
}
else
{
ang = target;
target = nullAngle;
}
}
else if (adjustment)
else if (adjustment.Sgn())
{
ang += DAngle::fromDeg(scaleAdjust * adjustment);
ang += adjustment * scaleAdjust;
}
}

private:
DAngle target;
double adjustment;
DAngle target, adjustment;
bool inputdisabled;
};

Expand Down

0 comments on commit 3c68028

Please sign in to comment.