- 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) if (!strafing)
currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed)); currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed));
else 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)) if (!(inputBuffer->actions & SB_AIMMODE))
currInput->horz -= hidInput->mouseturny; currInput->horz -= hidInput->mouseturny;
@ -171,7 +171,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
// process remaining controller input. // process remaining controller input.
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed); 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); currInput->fvel += int16_t(scaleAdjust * hidInput->dz * keymove * hidprescale);
// process keyboard turning keys. // process keyboard turning keys.
@ -201,18 +201,18 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
else else
{ {
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
currInput->svel += keymove; currInput->svel -= keymove;
if (buttonMap.ButtonDown(gamefunc_Turn_Right)) if (buttonMap.ButtonDown(gamefunc_Turn_Right))
currInput->svel -= keymove; currInput->svel += keymove;
} }
// process keyboard side velocity keys. // process keyboard side velocity keys.
if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && allowstrafe) if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && allowstrafe)
currInput->svel += keymove; currInput->svel -= keymove;
if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && allowstrafe) if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && allowstrafe)
currInput->svel -= keymove; currInput->svel += keymove;
// process keyboard forward velocity keys. // process keyboard forward velocity keys.
if (!(isRR() && drink_amt >= 66 && drink_amt <= 87)) 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)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
{ {
currInput->fvel += keymove; currInput->fvel += keymove;
currInput->svel += drink_amt & 1 ? keymove : -keymove; currInput->svel -= drink_amt & 1 ? keymove : -keymove;
} }
if (buttonMap.ButtonDown(gamefunc_Move_Backward)) if (buttonMap.ButtonDown(gamefunc_Move_Backward))
{ {
currInput->fvel -= keymove; 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) { switch (arg1) {
case 1: return (pPlayer->input.fvel > 0); // forward case 1: return (pPlayer->input.fvel > 0); // forward
case 2: return (pPlayer->input.fvel < 0); // backward case 2: return (pPlayer->input.fvel < 0); // backward
case 3: return (pPlayer->input.svel > 0); // left case 3: return (pPlayer->input.svel < 0); // left
case 4: return (pPlayer->input.svel < 0); // right case 4: return (pPlayer->input.svel > 0); // right
case 5: return !!(pPlayer->input.actions & SB_JUMP); // jump case 5: return !!(pPlayer->input.actions & SB_JUMP); // jump
case 6: return !!(pPlayer->input.actions & SB_CROUCH); // crouch case 6: return !!(pPlayer->input.actions & SB_CROUCH); // crouch
case 7: return !!(pPlayer->input.actions & SB_FIRE); // normal fire weapon 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 speed = 1. - (actor->xspr.height < 256 ? actor->xspr.height * (1. / 256.) : 0);
const double& fvAccel = pInput->fvel > 0 ? pPosture->frontAccel : pPosture->backAccel; const double& fvAccel = pInput->fvel > 0 ? pPosture->frontAccel : pPosture->backAccel;
const double& svAccel = pPosture->sideAccel; 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()) if (SyncInput())

View file

@ -852,8 +852,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (packet) if (packet)
{ {
*packet = loc; *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->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->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 = {}; loc = {};
} }
} }

View file

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

View file

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