- Move input vector rotation for Duke and SW into the playsim.

* The next commit needs this to ensure the vector is rotated using the most current angle.
This commit is contained in:
Mitchell Richters 2022-12-06 19:09:24 +11:00 committed by Christoph Oelckers
parent 15b101870d
commit 9437ea9622
5 changed files with 14 additions and 6 deletions

View file

@ -88,6 +88,7 @@ void GameInterface::Ticker()
p->pals.a--;
hud_input(i);
processinputvel(i);
fi.processinput(i);
fi.checksectors(i);
}

View file

@ -352,4 +352,12 @@ inline int monsterCheatCheck(DDukeActor* self)
return false;
}
inline void processinputvel(int snum)
{
const auto p = &ps[snum];
const auto velvect = DVector2(p->sync.fvel, p->sync.svel).Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric;
p->sync.fvel = (float)velvect.X;
p->sync.svel = (float)velvect.Y;
}
END_DUKE_NS

View file

@ -843,9 +843,6 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (packet)
{
*packet = loc;
auto velvect = DVector2(loc.fvel, loc.svel).Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric;
packet->fvel = (float)velvect.X;
packet->svel = (float)velvect.Y;
loc = {};
}
}

View file

@ -204,9 +204,6 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (packet)
{
*packet = loc;
auto velvect = DVector2(loc.fvel, loc.svel).Rotated(pp->actor->spr.Angles.Yaw);
packet->fvel = (float)velvect.X;
packet->svel = (float)velvect.Y;
loc = {};
}
}

View file

@ -6996,6 +6996,11 @@ void domovethings(void)
// disable synchronised input if set by game.
resetForcedSyncInput();
// convert fvel/svel into a vector before performing actions.
const auto velvect = DVector2(pp->input.fvel, pp->input.svel).Rotated(pp->actor->spr.Angles.Yaw);
pp->input.fvel = (float)velvect.X;
pp->input.svel = (float)velvect.Y;
if (pp->DoPlayerAction) pp->DoPlayerAction(pp);
UpdatePlayerSprite(pp);