diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 44a92b899..2242a8e6e 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -103,11 +103,6 @@ public: return interpolatedvalue(PrevAngles.Yaw, spr.Angles.Yaw, interpfrac); } - DRotator interpolatedangles(double const interpfrac) - { - return interpolatedvalue(PrevAngles, spr.Angles, interpfrac); - } - void backupz() { opos.Z = spr.pos.Z; diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index f3ae00708..152c6ae0e 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -242,7 +242,7 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const if (aimmode && canslopetilt) // If the floor is sloped { // Get a point, 512 (64 for Blood) units ahead of player's position - auto rotpt = pos + ang.ToVector() * (isBlood() ? 4 : 32); + auto rotpt = pos + ang.ToVector() * (!isBlood() ? 32 : 4); auto tempsect = cursectnum; updatesector(rotpt, &tempsect); diff --git a/source/core/gameinput.h b/source/core/gameinput.h index edc49194f..9973dab7d 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -28,7 +28,7 @@ struct PlayerAngles // General methods. void initialize(DCoreActor* const actor, const DAngle viewyaw = nullAngle) { - if ((pActor = actor)) RenderAngles = PrevLerpAngles = pActor->spr.Angles; + if (pActor = actor) RenderAngles = PrevLerpAngles = pActor->spr.Angles; PrevViewAngles.Yaw = ViewAngles.Yaw = viewyaw; } DAngle getPitchWithView() @@ -37,21 +37,17 @@ struct PlayerAngles } // Render angle functions. - DRotator lerpViewAngles(const double interpfrac) - { - return interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac); - } DRotator getRenderAngles(const double interpfrac) { // Get angles and return with clamped off pitch. - auto angles = RenderAngles + lerpViewAngles(interpfrac); + auto angles = RenderAngles + interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac); angles.Pitch = ClampViewPitch(angles.Pitch); return angles; } void updateRenderAngles(const double interpfrac) { // Apply the current interpolated angle state to the render angles. - const auto lerpAngles = pActor->interpolatedangles(interpfrac); + const auto lerpAngles = interpolatedvalue(pActor->PrevAngles, pActor->spr.Angles, interpfrac); RenderAngles += lerpAngles - PrevLerpAngles; PrevLerpAngles = lerpAngles; } @@ -66,14 +62,9 @@ struct PlayerAngles // Draw code helpers. auto getCrosshairOffsets(const double interpfrac) { - // Set up angles. - const auto viewAngles = lerpViewAngles(interpfrac); - const auto rotTangent = viewAngles.Roll.Tan(); - const auto yawTangent = clamp(viewAngles.Yaw, -DAngle90, DAngle90).Tan(); - const auto fovTangent = tan(r_fov * pi::pi() / 360.); - - // Return as pair with roll as the 2nd object since all callers inevitably need it. - return std::make_pair(DVector2(160, 120 * -rotTangent) * -yawTangent / fovTangent, viewAngles.Roll); + // Set up angles and return as pair with roll as the 2nd object since all callers inevitably need it. + const auto viewAngles = interpolatedvalue(PrevViewAngles, ViewAngles, interpfrac); + return std::make_pair(DVector2(160, 120 * -viewAngles.Roll.Tan()) * -viewAngles.Yaw.Tan() / tan(r_fov * pi::pi() / 360.), viewAngles.Roll); } auto getWeaponOffsets(const double interpfrac) { diff --git a/source/games/blood/src/controls.cpp b/source/games/blood/src/controls.cpp index a2be618d5..f28dfde8a 100644 --- a/source/games/blood/src/controls.cpp +++ b/source/games/blood/src/controls.cpp @@ -54,14 +54,11 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju ApplyGlobalInput(gInput, hidInput); processMovement(&input, &gInput, hidInput, scaleAdjust); - if (!SyncInput() && gamestate == GS_LEVEL) + // Perform unsynchronised angle/horizon if not dead. + if (!SyncInput() && gamestate == GS_LEVEL && pPlayer->actor->xspr.health != 0) { - // Perform unsynchronised angle/horizon if not dead. - if (pPlayer->actor->xspr.health != 0) - { - pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel); - pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz); - } + pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel); + pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz); } if (packet) diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 86161143e..a1194c1f5 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -489,7 +489,7 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DRotator& cAngles, sector { cPos.Z += bobHeight; } - cPos.Z -= interpolatedvalue(0., 10., cAngles.Pitch / DAngle90); + cPos.Z -= 10. * (cAngles.Pitch / DAngle90); } else { diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index ff374c813..7a58c1246 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -231,7 +231,7 @@ void displayweapon_d(int snum, double interpfrac) auto offpair = p->Angles.getWeaponOffsets(interpfrac); auto offsets = offpair.first; - auto pitchoffset = interpolatedvalue(0., 16., p->Angles.getRenderAngles(interpfrac).Pitch / DAngle90); + auto pitchoffset = 16. * (p->Angles.getRenderAngles(interpfrac).Pitch / DAngle90); auto yawinput = getavel(snum) * (1. / 16.); auto angle = offpair.second; auto weapon_xoffset = 160 - 90 - (BobVal(512 + weapon_sway * 0.5) * (16384. / 1536.)) - 58 - p->weapon_ang; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 3cddbcad3..0a177e00f 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -829,14 +829,10 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju FinalizeInput(p, input); - if (!SyncInput()) + if (!SyncInput() && p->GetActor()->spr.extra > 0) { - if (p->GetActor()->spr.extra > 0) - { - // Do these in the same order as the old code. - p->Angles.RenderAngles.Yaw += p->adjustavel(input.avel); - p->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz); - } + p->Angles.RenderAngles.Yaw += p->adjustavel(input.avel); + p->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz); } if (packet) diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 9366c933e..29ab58fcc 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -376,8 +376,6 @@ void GameInterface::Ticker() PlayerList[nLocalPlayer].Angles.resetRenderAngles(); UpdatePlayerSpriteAngle(&PlayerList[nLocalPlayer]); - inita = inita.Normalized360(); - // disable synchronised input if set by game. resetForcedSyncInput(); diff --git a/source/games/exhumed/src/input.cpp b/source/games/exhumed/src/input.cpp index d0ff2d946..3cfcc1c99 100644 --- a/source/games/exhumed/src/input.cpp +++ b/source/games/exhumed/src/input.cpp @@ -82,17 +82,14 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju sPlayerInput[nLocalPlayer].vel.Zero(); } - if (!SyncInput() && gamestate == GS_LEVEL) + if (!SyncInput() && gamestate == GS_LEVEL && !nFreeze) { - if (!nFreeze) - { - pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel); - pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz); + pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel); + pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz); - if (input.horz) - { - pPlayer->bPlayerPan = pPlayer->bLockPan = true; - } + if (input.horz) + { + pPlayer->bPlayerPan = pPlayer->bLockPan = true; } UpdatePlayerSpriteAngle(pPlayer); diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 89775176f..7a3a8115a 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -666,7 +666,7 @@ static void pickupMessage(int no) void UpdatePlayerSpriteAngle(Player* pPlayer) { - if (pPlayer->pActor) inita = pPlayer->pActor->spr.Angles.Yaw; + if (pPlayer->pActor) inita = pPlayer->pActor->spr.Angles.Yaw.Normalized360(); } //---------------------------------------------------------------------------