- floatifying player::slope, part 2

This commit is contained in:
Christoph Oelckers 2022-09-28 17:58:22 +02:00
parent 1a03c56eec
commit f286565abc
4 changed files with 11 additions and 12 deletions

View file

@ -820,7 +820,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE;
pPlayer->bloodlust = 0;
pPlayer->horizon.horiz = pPlayer->horizon.horizoff = nullAngle;
pPlayer->_slope = 0;
pPlayer->slope = 0;
pPlayer->fragger = nullptr;
pPlayer->underwaterTime = 1200;
pPlayer->bubbleTime = 0;
@ -1419,7 +1419,7 @@ int ActionScan(PLAYER* pPlayer, HitInfo* out)
{
auto plActor = pPlayer->actor;
*out = {};
auto pos = DVector3(plActor->spr.angle.ToVector(), pPlayer->flt_slope());
auto pos = DVector3(plActor->spr.angle.ToVector(), pPlayer->slope);
int hit = HitScan(pPlayer->actor, pPlayer->zView, pos, 0x10000040, 128);
double hitDist = (plActor->spr.pos.XY() - gHitInfo.hitpos.XY()).Length();
if (hitDist < 64)
@ -1731,7 +1731,7 @@ void ProcessInput(PLAYER* pPlayer)
pPlayer->angle.unlockinput();
pPlayer->horizon.unlockinput();
pPlayer->_slope = -pPlayer->horizon.horiz.Tan() * 16384.;
pPlayer->slope = -pPlayer->horizon.horiz.Tan();
if (pInput->actions & SB_INVPREV)
{
pInput->actions &= ~SB_INVPREV;
@ -2462,7 +2462,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER*
("zviewvel", w.zViewVel)
("zweapon", w.zWeapon)
("zweaponvel", w.zWeaponVel)
("slope", w._slope)
("slope", w.slope)
("underwater", w.isUnderwater)
.Array("haskey", w.hasKey, 8)
("hasflag", w.hasFlag)

View file

@ -113,9 +113,8 @@ struct PLAYER
double zWeapon;
double ozWeapon;
double zWeaponVel;
int _slope; // Q18.14, like dudeslope
int int_slope() const { return _slope; }
int flt_slope() const { return _slope / 16384.; }
double slope;
int int_slope() const { return slope * 16384; }
bool isUnderwater;
bool hasKey[8];
int8_t hasFlag;

View file

@ -424,7 +424,7 @@ void UpdateAimVector(PLAYER* pPlayer)
assert(pPlayer != NULL);
auto plActor = pPlayer->actor;
DVector3 pos(plActor->spr.pos.XY(), pPlayer->zWeapon);
DVector3 Aim(plActor->spr.angle.ToVector(), pPlayer->flt_slope());
DVector3 Aim(plActor->spr.angle.ToVector(), pPlayer->slope);
WEAPONTRACK* pWeaponTrack = &gWeaponTrack[pPlayer->curWeapon];
DBloodActor* targetactor = nullptr;
@ -455,7 +455,7 @@ void UpdateAimVector(PLAYER* pPlayer)
double t = nDist * 4096 / pWeaponTrack->seeker;
pos2 += actor->vel * t;
}
DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->flt_slope()) * nDist;
DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->slope) * nDist;
double zRange = nDist * (9460 / 16384.);
double top, bottom;
@ -502,7 +502,7 @@ void UpdateAimVector(PLAYER* pPlayer)
if (nDist == 0 || nDist > 3200)
continue;
DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->flt_slope()) * nDist;
DVector3 lpos = pos + DVector3(plActor->spr.angle.ToVector(), pPlayer->slope) * nDist;
double zRange = nDist * (9460 / 16384.);
double top, bottom;
@ -533,7 +533,7 @@ void UpdateAimVector(PLAYER* pPlayer)
}
DVector3 Aim2(Aim);
Aim2.XY() = Aim2.XY().Rotated(-plActor->spr.angle);
Aim2.Z -= pPlayer->flt_slope();
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));

View file

@ -77,7 +77,7 @@ struct BloodPlayer native
native double zViewVel;
native double zWeapon;
native double zWeaponVel;
native int slope;
native double slope;
native bool isUnderwater;
native bool hasKey[8];
native int8 hasFlag;