- calcviewpitch

This commit is contained in:
Christoph Oelckers 2021-11-24 02:03:53 +01:00
parent 879407538e
commit 41506f35db
5 changed files with 11 additions and 11 deletions

View file

@ -445,9 +445,9 @@ enum
BLOODVIEWPITCH = (0x4000 >> SINSHIFTDELTA) - (DEFVIEWPITCH << (SINSHIFTDELTA - 1)), // 1408.
};
void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust, bool const climbing)
void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust, bool const climbing)
{
if (cl_slopetilting && cursectnum >= 0)
if (cl_slopetilting && cursectnum != nullptr)
{
if (aimmode && canslopetilt) // If the floor is sloped
{
@ -455,22 +455,22 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
int const shift = -(isBlood() ? BLOODSINSHIFT : DEFSINSHIFT);
int const x = pos.x + ang.bcos(shift);
int const y = pos.y + ang.bsin(shift);
int tempsect = cursectnum;
auto tempsect = cursectnum;
updatesector(x, y, &tempsect);
if (tempsect >= 0) // If the new point is inside a valid sector...
if (tempsect != nullptr) // If the new point is inside a valid sector...
{
// Get the floorz as if the new (x,y) point was still in
// your sector
int const j = getflorzofslope(cursectnum, pos.x, pos.y);
int const k = getflorzofslope(tempsect, x, y);
int const j = getflorzofslopeptr(cursectnum, pos.x, pos.y);
int const k = getflorzofslopeptr(tempsect, x, y);
// If extended point is in same sector as you or the slopes
// of the sector of the extended point and your sector match
// closely (to avoid accidently looking straight out when
// you're at the edge of a sector line) then adjust horizon
// accordingly
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, x, y) - k) <= (4 << 8)))
{
horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
}

View file

@ -35,7 +35,7 @@ struct PlayerHorizon
// Prototypes for functions in gameinput.cpp.
void applyinput(float const horz, ESyncBits* actions, double const scaleAdjust = 1);
void calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
void calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
// Interpolation helpers.
void backup()

View file

@ -1339,7 +1339,7 @@ void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1)
auto* const pXSprite = pPlayer->pXSprite;
int const florhit = pPlayer->actor->hit.florhit.type;
bool const va = pXSprite->height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0;
pPlayer->horizon.calcviewpitch(pSprite->pos.vec2, buildang(pSprite->ang), va, pSprite->sector()->floorstat & 2, pSprite->sectnum, scaleAdjust);
pPlayer->horizon.calcviewpitch(pSprite->pos.vec2, buildang(pSprite->ang), va, pSprite->sector()->floorstat & 2, pSprite->sector(), scaleAdjust);
}
void ProcessInput(PLAYER *pPlayer)

View file

@ -190,7 +190,7 @@ inline bool playrunning()
inline void doslopetilting(player_struct* p, double const scaleAdjust = 1)
{
bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & 2);
p->horizon.calcviewpitch(p->pos.vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, sectnum(p->cursector), scaleAdjust);
p->horizon.calcviewpitch(p->pos.vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust);
}
//---------------------------------------------------------------------------

View file

@ -1618,7 +1618,7 @@ void SlipSlope(PLAYERp pp)
void DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust)
{
bool const canslopetilt = !TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING) && TEST(pp->cursector()->floorstat, FLOOR_STAT_SLOPE);
pp->horizon.calcviewpitch(pp->pos.vec2, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursectnum, scaleAdjust, TEST(pp->Flags, PF_CLIMBING));
pp->horizon.calcviewpitch(pp->pos.vec2, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, &sector[pp->cursectnum], scaleAdjust, TEST(pp->Flags, PF_CLIMBING));
pp->horizon.applyinput(horz, &pp->input.actions, scaleAdjust);
}