- Remove the whole angle locking concept, we can just force synchronised input instead which is cleaner.

This commit is contained in:
Mitchell Richters 2022-12-01 07:59:13 +11:00 committed by Christoph Oelckers
parent 6c0493868e
commit bb1113c251
4 changed files with 50 additions and 80 deletions

View file

@ -174,9 +174,6 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
//---------------------------------------------------------------------------
void PlayerAngles::applyPitch(float const horz, ESyncBits* actions, double const scaleAdjust)
{
// Process only if movement isn't locked.
if (!lockedPitch())
{
// Process mouse input.
if (horz)
@ -209,11 +206,6 @@ void PlayerAngles::applyPitch(float const horz, ESyncBits* actions, double const
// clamp before we finish, even if it's clamped in the drawer.
pActor->spr.Angles.Pitch = ClampViewPitch(pActor->spr.Angles.Pitch);
}
else
{
*actions &= ~SB_CENTERVIEW;
}
}
//---------------------------------------------------------------------------
@ -223,9 +215,6 @@ void PlayerAngles::applyPitch(float const horz, ESyncBits* actions, double const
//---------------------------------------------------------------------------
void PlayerAngles::applyYaw(float const avel, ESyncBits* actions, double const scaleAdjust)
{
// Process only if movement isn't locked.
if (!lockedYaw())
{
// add player's input
pActor->spr.Angles.Yaw += DAngle::fromDeg(avel);
@ -254,11 +243,6 @@ void PlayerAngles::applyYaw(float const avel, ESyncBits* actions, double const s
pActor->spr.Angles.Yaw += add;
}
}
else
{
YawSpin = nullAngle;
}
}
//---------------------------------------------------------------------------
@ -348,7 +332,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P
arc("viewangles", w.ViewAngles)
("spin", w.YawSpin)
("actor", w.pActor)
("anglelocks", w.AngleLocks)
.EndObject();
if (arc.isReading())

View file

@ -62,23 +62,14 @@ struct PlayerAngles
}
// Pitch methods.
void lockPitch() { AngleLocks.Set(PITCH); }
void unlockPitch() { AngleLocks.Clear(PITCH); }
bool lockedPitch() { return AngleLocks[PITCH]; }
void addPitch(const DAngle value) { updateAngle(PITCH, ClampViewPitch(pActor->spr.Angles.Pitch + value)); }
void setPitch(const DAngle value, const bool backup = false) { updateAngle(PITCH, ClampViewPitch(value), backup); }
// Yaw methods.
void lockYaw() { AngleLocks.Set(YAW); }
void unlockYaw() { AngleLocks.Clear(YAW); }
bool lockedYaw() { return AngleLocks[YAW]; }
void addYaw(const DAngle value) { updateAngle(YAW, pActor->spr.Angles.Yaw + value); }
void setYaw(const DAngle value, const bool backup = false) { updateAngle(YAW, value, backup); }
// Roll methods.
void lockRoll() { AngleLocks.Set(ROLL); }
void unlockRoll() { AngleLocks.Clear(ROLL); }
bool lockedRoll() { return AngleLocks[ROLL]; }
void addRoll(const DAngle value) { updateAngle(ROLL, pActor->spr.Angles.Roll + value); }
void setRoll(const DAngle value, const bool backup = false) { updateAngle(ROLL, value, backup); }
@ -118,7 +109,6 @@ private:
// Private data which should never be accessed publically.
DRotator Targets, AppliedAmounts;
FixedBitArray<MAXANGLES> AngleLocks;
DCoreActor* pActor;
// Internal angle updater to reduce boilerplate from the public setters.

View file

@ -2186,8 +2186,8 @@ void trPlayerCtrlSetLookAngle(int value, PLAYER* pPlayer)
if (const double adjustment = clamp(value * 0.125 * (value > 0 ? lookStepUp : lookStepDown), downAngle, upAngle))
{
setForcedSyncInput();
pPlayer->Angles.setPitch(maphoriz(-100. * tan(adjustment * pi::pi() * (1. / 1024.))));
pPlayer->Angles.lockPitch();
}
}
@ -6050,13 +6050,13 @@ bool modernTypeOperateSprite(DBloodActor* actor, EVENT& event)
if (actor->xspr.data4 != 0) break;
else if (actor->spr.flags & kModernTypeFlag1)
{
setForcedSyncInput();
pPlayer->Angles.setYaw(actor->spr.Angles.Yaw);
pPlayer->Angles.lockYaw();
}
else if (valueIsBetween(actor->xspr.data2, -kAng360, kAng360))
{
setForcedSyncInput();
pPlayer->Angles.setYaw(mapangle(actor->xspr.data2));
pPlayer->Angles.lockYaw();
}
break;
case 10: // 74 (de)activate powerup

View file

@ -1718,9 +1718,6 @@ void ProcessInput(PLAYER* pPlayer)
doslopetilting(pPlayer);
pPlayer->Angles.unlockYaw();
pPlayer->Angles.unlockPitch();
pPlayer->slope = pPlayer->actor->spr.Angles.Pitch.Tan();
if (pInput->actions & SB_INVPREV)
{