- SW: New implementation of playerSetAngle() that works better for intended purpose. This corrects the issues with angle not being quite right when getting onto a ladder.

This commit is contained in:
Mitchell Richters 2020-09-09 21:29:03 +10:00
parent ee5689b07e
commit b832442e31
3 changed files with 36 additions and 3 deletions

View file

@ -1009,6 +1009,7 @@ struct PLAYERstruct
// Input helper variables and setters.
double horizAdjust, angAdjust, pitchAdjust;
fixed_t angTarget;
void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; }
void setang(int v) { q16ang = IntToFixed(v); }
void addhoriz(int v) { q16horiz += (IntToFixed(v)); }

View file

@ -280,22 +280,45 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
if (!cl_syncinput)
{
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
{
DoPlayerHorizon(pp, q16horz, scaleAdjust);
}
if (pp->horizAdjust)
{
pp->q16horiz += FloatToFixed(scaleAdjust * pp->horizAdjust);
}
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL))
{
DoPlayerTurn(pp, q16avel, scaleAdjust);
}
if (pp->angAdjust)
if (pp->angTarget)
{
fixed_t angDelta = GetDeltaQ16Angle(pp->angTarget, pp->q16ang);
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * angDelta));
if (pp->q16ang >= pp->angTarget)
{
pp->q16ang = pp->angTarget;
pp->angTarget = 0;
}
}
else if (pp->angAdjust)
{
pp->q16ang = (pp->q16ang + FloatToFixed(scaleAdjust * pp->angAdjust)) & 0x7FFFFFF;
}
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_VEHICLE))
{
DoPlayerTurnVehicle(pp, q16avel, pp->posz + Z(10), labs(pp->posz + Z(10) - pp->sop->floor_loz));
}
if (TEST(pp->Flags2, PF2_INPUT_CAN_MOVE_TURRET))
{
DoPlayerMoveTurret(pp, q16avel, q16horz, scaleAdjust);
}
}
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);

View file

@ -4258,7 +4258,7 @@ PlayerOnLadder(PLAYERp pp)
pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5;
playerAddAngle(pp, FixedToFloat(GetDeltaQ16Angle(IntToFixed(pp->LadderAngle), pp->q16ang)));
playerSetAngle(pp, pp->LadderAngle);
return TRUE;
}
@ -7801,7 +7801,16 @@ void playerSetAngle(PLAYERp pp, double ang)
{
if (!cl_syncinput)
{
pp->angAdjust += -1. * ((pp->q16ang / 65536.) - ang);
// Cancel out any angle adjustments as we're setting angle now.
pp->angAdjust = 0;
// Add slight offset if input angle is coming in as absolute 0.
if (ang == 0)
{
ang += 0.1;
}
pp->angTarget = pp->q16ang + GetDeltaQ16Angle(ang, pp->q16ang);
}
else
{