diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 679074254..6915679ec 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -448,16 +448,16 @@ enum BLOODVIEWPITCH = (0x4000 >> SINSHIFTDELTA) - (DEFVIEWPITCH << (SINSHIFTDELTA - 1)), // 1408. }; -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) +void PlayerHorizon::calcviewpitch(vec2_t const pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust, bool const climbing) { if (cl_slopetilting && cursectnum != nullptr) { if (aimmode && canslopetilt) // If the floor is sloped { // Get a point, 512 (64 for Blood) units ahead of player's position - int const shift = -(isBlood() ? BLOODSINSHIFT : DEFSINSHIFT); - int const x = pos.X + ang.bcos(shift); - int const y = pos.Y + ang.bsin(shift); + int const shift = isBlood() ? BLOODSINSHIFT : DEFSINSHIFT; + int const x = pos.X + int(ang.Cos() * (1 << (BUILDSINBITS - shift))); + int const y = pos.Y + int(ang.Sin() * (1 << (BUILDSINBITS - shift))); auto tempsect = cursectnum; updatesector(x, y, &tempsect); diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 9633fa60d..1ebb35247 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -24,13 +24,13 @@ 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, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false); - void calcviewpitch(const DVector2& pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false) + void calcviewpitch(vec2_t const pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false); + void calcviewpitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false) { vec2_t ps = { int(pos.X * worldtoint), int(pos.Y * worldtoint) }; calcviewpitch(ps, ang, aimmode, canslopetilt, cursectnum, scaleAdjust, climbing); } - void calcviewpitch(const DVector3& pos, binangle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false) + void calcviewpitch(const DVector3& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false) { vec2_t ps = { int(pos.X * worldtoint), int(pos.Y * worldtoint) }; calcviewpitch(ps, ang, aimmode, canslopetilt, cursectnum, scaleAdjust, climbing); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index b5d6c0902..7cd7b55fc 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1518,7 +1518,7 @@ void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1) auto plActor = pPlayer->actor; int const florhit = pPlayer->actor->hit.florhit.type; bool const va = plActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0; - pPlayer->horizon.calcviewpitch(plActor->int_pos().vec2, buildang(plActor->int_ang()), va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector(), scaleAdjust); + pPlayer->horizon.calcviewpitch(plActor->int_pos().vec2, DAngle::fromBuild(plActor->int_ang()), va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector(), scaleAdjust); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 304510fa1..bc010d9e3 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -208,7 +208,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 & CSTAT_SECTOR_SLOPE); - p->horizon.calcviewpitch(p->pos, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); + p->horizon.calcviewpitch(p->pos.XY(), DAngle::fromBam(p->angle.ang.asbam()), p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); } //--------------------------------------------------------------------------- diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 8097dcfc6..2352ddd80 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1592,7 +1592,7 @@ void SlipSlope(PLAYER* pp) void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust) { bool const canslopetilt = !(pp->Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) && pp->cursector && (pp->cursector->floorstat & CSTAT_SECTOR_SLOPE); - pp->horizon.calcviewpitch(pp->pos.vec2, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING)); + pp->horizon.calcviewpitch(pp->pos.vec2, DAngle::fromBam(pp->angle.ang.asbam()), pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING)); pp->horizon.applyinput(horz, &pp->input.actions, scaleAdjust); }