- floatified aim and relAim

This commit is contained in:
Christoph Oelckers 2022-09-28 19:20:57 +02:00
parent a9095a5a1e
commit 312b96fedc
4 changed files with 15 additions and 33 deletions

View file

@ -503,10 +503,6 @@ struct VECTOR2D {
int dx, dy;
};
struct Aim {
int dx, dy, dz;
};
#pragma pack(pop)
inline int ClipLow(int a, int b)

View file

@ -835,9 +835,9 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->vodooVar2 = 0;
playerResetInertia(pPlayer);
pPlayer->zWeaponVel = 0;
pPlayer->_relAim.dx = 0x4000;
pPlayer->_relAim.dy = 0;
pPlayer->_relAim.dz = 0;
pPlayer->relAim.X = 1;
pPlayer->relAim.Y = 0;
pPlayer->relAim.Z = 0;
pPlayer->aimTarget = nullptr;
pPlayer->zViewVel = pPlayer->zWeaponVel;
if (!(gGameOptions.nGameType == 1 && gGameOptions.bKeepKeysOnRespawn && !bNewLevel))
@ -2385,18 +2385,6 @@ void PlayerKneelsOver(int, DBloodActor* actor)
//
//---------------------------------------------------------------------------
FSerializer& Serialize(FSerializer& arc, const char* keyname, Aim& w, Aim* def)
{
if (arc.BeginObject(keyname))
{
arc("x", w.dx)
("y", w.dx)
("z", w.dx)
.EndObject();
}
return arc;
}
FSerializer& Serialize(FSerializer& arc, const char* keyname, PACKINFO& w, PACKINFO* def)
{
if (arc.BeginObject(keyname))
@ -2483,8 +2471,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER*
("fusetime", w.fuseTime)
("throwtime", w.throwTime)
("throwpower", w.throwPower)
("aim", w._aim)
("relaim", w._relAim)
("aim", w.aim)
("relaim", w.relAim)
("aimtarget", w.aimTarget)
("aimtargetscount", w.aimTargetsCount)
.Array("aimtargets", w.aimTargets, countof(w.aimTargets))

View file

@ -136,12 +136,10 @@ struct PLAYER
int fuseTime;
int throwTime;
int throwPower;
Aim _aim; // world
Aim _relAim; // relative
Aim int_aim() const { return _aim; }
Aim int_relAim() const { return _relAim; }
DVector3 flt_aim() const { return { _aim.dx / 16384., _aim.dy / 16384.,_aim.dz / 16384. }; }
DVector3 flt_relAim() const { return { _relAim.dx / 16384., _relAim.dy / 16384.,_relAim.dz / 16384. }; }
DVector3 aim; // world
DVector3 relAim; // relative
DVector3 flt_aim() const { return aim; }
DVector3 flt_relAim() const { return relAim; }
TObjPtr<DBloodActor*> aimTarget; // aim target sprite
int aimTargetsCount;
TObjPtr<DBloodActor*> aimTargets[16];

View file

@ -535,12 +535,12 @@ void UpdateAimVector(PLAYER* pPlayer)
Aim2.XY() = Aim2.XY().Rotated(-plActor->spr.angle);
Aim2.Z -= pPlayer->slope;
pPlayer->_relAim.dx = interpolatedvalue(pPlayer->_relAim.dx, int(Aim2.X * 16384), FixedToFloat(pWeaponTrack->aimSpeedHorz));
pPlayer->_relAim.dy = interpolatedvalue(pPlayer->_relAim.dy, int(Aim2.Y * 16384), FixedToFloat(pWeaponTrack->aimSpeedHorz));
pPlayer->_relAim.dz = interpolatedvalue(pPlayer->_relAim.dz, int(Aim2.Z * 16384), FixedToFloat(pWeaponTrack->aimSpeedVert));
pPlayer->_aim = pPlayer->_relAim;
RotateVector((int*)&pPlayer->_aim.dx, (int*)&pPlayer->_aim.dy, plActor->int_ang());
pPlayer->_aim.dz += pPlayer->int_slope();
pPlayer->relAim.X = interpolatedvalue(pPlayer->relAim.X, Aim2.X, FixedToFloat(pWeaponTrack->aimSpeedHorz));
pPlayer->relAim.Y = interpolatedvalue(pPlayer->relAim.Y, Aim2.Y, FixedToFloat(pWeaponTrack->aimSpeedHorz));
pPlayer->relAim.Z = interpolatedvalue(pPlayer->relAim.Z, Aim2.Z, FixedToFloat(pWeaponTrack->aimSpeedVert));
pPlayer->aim = pPlayer->relAim;
pPlayer->aim.XY() = pPlayer->aim.XY().Rotated(plActor->spr.angle);
pPlayer->aim.Z += pPlayer->slope;
pPlayer->aimTarget = targetactor;
}