- Flip svel around in the input code so we can use proper anti-clockwise vector math.

This commit is contained in:
Mitchell Richters 2022-09-20 09:15:26 +10:00 committed by Christoph Oelckers
parent 1eaab2f531
commit def2b9d483
6 changed files with 18 additions and 17 deletions

View file

@ -162,7 +162,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
if (!strafing)
currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed));
else
currInput->svel -= int16_t(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale);
currInput->svel += int16_t(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale);
if (!(inputBuffer->actions & SB_AIMMODE))
currInput->horz -= hidInput->mouseturny;
@ -171,7 +171,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
// process remaining controller input.
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed);
currInput->svel += int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale);
currInput->svel -= int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale);
currInput->fvel += int16_t(scaleAdjust * hidInput->dz * keymove * hidprescale);
// process keyboard turning keys.
@ -201,18 +201,18 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
else
{
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
currInput->svel += keymove;
currInput->svel -= keymove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
currInput->svel -= keymove;
currInput->svel += keymove;
}
// process keyboard side velocity keys.
if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && allowstrafe)
currInput->svel += keymove;
currInput->svel -= keymove;
if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && allowstrafe)
currInput->svel -= keymove;
currInput->svel += keymove;
// process keyboard forward velocity keys.
if (!(isRR() && drink_amt >= 66 && drink_amt <= 87))
@ -228,13 +228,13 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
{
currInput->fvel += keymove;
currInput->svel += drink_amt & 1 ? keymove : -keymove;
currInput->svel -= drink_amt & 1 ? keymove : -keymove;
}
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
{
currInput->fvel -= keymove;
currInput->svel -= drink_amt & 1 ? keymove : -keymove;
currInput->svel += drink_amt & 1 ? keymove : -keymove;
}
}

View file

@ -4393,8 +4393,8 @@ bool condCheckPlayer(DBloodActor* aCond, int cmpOp, bool PUSH)
switch (arg1) {
case 1: return (pPlayer->input.fvel > 0); // forward
case 2: return (pPlayer->input.fvel < 0); // backward
case 3: return (pPlayer->input.svel > 0); // left
case 4: return (pPlayer->input.svel < 0); // right
case 3: return (pPlayer->input.svel < 0); // left
case 4: return (pPlayer->input.svel > 0); // right
case 5: return !!(pPlayer->input.actions & SB_JUMP); // jump
case 6: return !!(pPlayer->input.actions & SB_CROUCH); // crouch
case 7: return !!(pPlayer->input.actions & SB_FIRE); // normal fire weapon

View file

@ -1596,7 +1596,7 @@ void ProcessInput(PLAYER* pPlayer)
const double speed = 1. - (actor->xspr.height < 256 ? actor->xspr.height * (1. / 256.) : 0);
const double& fvAccel = pInput->fvel > 0 ? pPosture->frontAccel : pPosture->backAccel;
const double& svAccel = pPosture->sideAccel;
actor->vel.XY() += DVector2(pInput->fvel * fvAccel, -pInput->svel * svAccel).Rotated(actor->spr.angle) * speed;
actor->vel.XY() += DVector2(pInput->fvel * fvAccel, pInput->svel * svAccel).Rotated(actor->spr.angle) * speed;
}
if (SyncInput())

View file

@ -852,8 +852,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (packet)
{
*packet = loc;
packet->fvel = MulScale(loc.fvel, p->angle.ang.Cos() * (1 << 14), 9) + MulScale(loc.svel, p->angle.ang.Sin() * (1 << 14), 9) + p->fric.X;
packet->svel = MulScale(loc.fvel, p->angle.ang.Sin() * (1 << 14), 9) - MulScale(loc.svel, p->angle.ang.Cos() * (1 << 14), 9) + p->fric.Y;
packet->fvel = MulScale(loc.fvel, p->angle.ang.Cos() * (1 << 14), 9) - MulScale(loc.svel, p->angle.ang.Sin() * (1 << 14), 9) + p->fric.X;
packet->svel = MulScale(loc.fvel, p->angle.ang.Sin() * (1 << 14), 9) + MulScale(loc.svel, p->angle.ang.Cos() * (1 << 14), 9) + p->fric.Y;
loc = {};
}
}

View file

@ -373,11 +373,12 @@ void GameInterface::Ticker()
auto& lPlayerVel = sPlayerInput[nLocalPlayer].vel;
auto inputvect = DVector2(localInput.fvel, localInput.svel).Rotated(inita) * (1. / 16.);
for (int i = 0; i < 4; i++)
{
// Velocities are stored as Q14.18
lPlayerVel.X += (localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) / 16.;
lPlayerVel.Y += (localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) / 16.;
lPlayerVel += inputvect;
lPlayerVel *= 0.953125;
}
UpdateInterpolations();

View file

@ -207,8 +207,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (packet)
{
*packet = loc;
packet->fvel = MulScale(loc.fvel, pp->angle.ang.Cos() * (1 << 14), 9) + MulScale(loc.svel, pp->angle.ang.Sin() * (1 << 14), 9);
packet->svel = MulScale(loc.fvel, pp->angle.ang.Sin() * (1 << 14), 9) - MulScale(loc.svel, pp->angle.ang.Cos() * (1 << 14), 9);
packet->fvel = MulScale(loc.fvel, pp->angle.ang.Cos() * (1 << 14), 9) - MulScale(loc.svel, pp->angle.ang.Sin() * (1 << 14), 9);
packet->svel = MulScale(loc.fvel, pp->angle.ang.Sin() * (1 << 14), 9) + MulScale(loc.svel, pp->angle.ang.Cos() * (1 << 14), 9);
loc = {};
}
}