- floatified player input velocity.

This commit is contained in:
Christoph Oelckers 2022-09-11 13:01:13 +02:00
parent b14ab1bde3
commit f16f9b302f
6 changed files with 15 additions and 27 deletions

View file

@ -374,10 +374,9 @@ void GameInterface::Ticker()
for (int i = 0; i < 4; i++)
{
// Velocities are stored as Q14.18
lPlayerXVel += int((localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) * 16384);
lPlayerYVel += int((localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) * 16384);
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
lPlayerVel.X += (localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) / 16.;
lPlayerVel.Y += (localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) / 16.;
lPlayerVel *= 0.953125;
}
UpdateInterpolations();
@ -473,8 +472,7 @@ void GameInterface::Ticker()
sPlayerInput[nLocalPlayer].actions = localInput.actions;
if (oldactions & SB_CENTERVIEW) sPlayerInput[nLocalPlayer].actions |= SB_CENTERVIEW;
sPlayerInput[nLocalPlayer].xVel = lPlayerXVel;
sPlayerInput[nLocalPlayer].yVel = lPlayerYVel;
sPlayerInput[nLocalPlayer].vel = lPlayerVel;
sPlayerInput[nLocalPlayer].buttons = lLocalCodes;
sPlayerInput[nLocalPlayer].pTarget = bestTarget;
sPlayerInput[nLocalPlayer].nAngle = localInput.avel;

View file

@ -191,8 +191,7 @@ void InitLevel(MapRecord* map)
ResetEngine();
totalmoves = 0;
GrabPalette();
lPlayerXVel = 0;
lPlayerYVel = 0;
lPlayerVel.Zero();
if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->music, true); // Allow non-CD music if defined for the current level
playCDtrack(map->cdSongId, true);

View file

@ -79,8 +79,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
}
else
{
lPlayerYVel = 0;
lPlayerXVel = 0;
lPlayerVel.Zero();
}
if (!SyncInput())

View file

@ -33,8 +33,7 @@ enum {
struct PlayerInput
{
TObjPtr<DExhumedActor*> pTarget;
int xVel;
int yVel;
DVector2 vel;
uint16_t buttons;
float nAngle;
float pan;

View file

@ -42,8 +42,7 @@ BEGIN_PS_NS
extern int nStatusSeqOffset;
int lPlayerXVel = 0;
int lPlayerYVel = 0;
DVector2 lPlayerVel;
int obobangle = 0, bobangle = 0;
static actionSeq PlayerSeq[] = {
@ -858,7 +857,7 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort
{
PlayerList[nPlayer].pPlayerPushSect = sect;
DVector2 vel(FixedToFloat<18>(sPlayerInput[nPlayer].xVel), FixedToFloat<18>(sPlayerInput[nPlayer].yVel));
DVector2 vel = sPlayerInput[nPlayer].vel;
auto nMyAngle = VecToAngle(vel).Normalized360();
setsectinterpolate(sect);
@ -915,8 +914,7 @@ void AIPlayer::Tick(RunListEvent* ev)
PlayerList[nPlayer].horizon.resetadjustment();
PlayerList[nPlayer].oeyelevel = PlayerList[nPlayer].eyelevel;
pPlayerActor->vel.X = FixedToFloat<18>(sPlayerInput[nPlayer].xVel);
pPlayerActor->vel.Y = FixedToFloat<18>(sPlayerInput[nPlayer].yVel);
pPlayerActor->vel.XY() = sPlayerInput[nPlayer].vel;
if (sPlayerInput[nPlayer].nItem > -1)
{
@ -1013,7 +1011,7 @@ void AIPlayer::Tick(RunListEvent* ev)
auto playerPos = pPlayerActor->spr.pos.XY();
DVector2 vect(FixedToFloat<18>(sPlayerInput[nPlayer].xVel), FixedToFloat<18>(sPlayerInput[nPlayer].yVel));
DVector2 vect = sPlayerInput[nPlayer].vel;
double zz = pPlayerActor->vel.Z;
if (pPlayerActor->vel.Z > 32)
@ -1084,12 +1082,9 @@ void AIPlayer::Tick(RunListEvent* ev)
PlayerList[nPlayer].horizon.settarget(buildhoriz(0), true);
lPlayerXVel = 0;
lPlayerYVel = 0;
lPlayerVel.Zero();
pPlayerActor->vel.X = 0;
pPlayerActor->vel.Y = 0;
pPlayerActor->vel.Z = 0;
pPlayerActor->vel.Zero();
if (nFreeze < 1)
{
@ -2753,8 +2748,7 @@ void SerializePlayer(FSerializer& arc)
{
if (arc.BeginObject("player"))
{
arc("lxvel", lPlayerXVel)
("lyvel", lPlayerYVel)
arc("lvel", lPlayerVel)
("bobangle", bobangle)
("standheight", nStandHeight)
("playercount", PlayerCount)

View file

@ -40,8 +40,7 @@ enum
extern int nLocalPlayer;
extern int lPlayerXVel;
extern int lPlayerYVel;
extern DVector2 lPlayerVel;
struct PlayerSave
{