From 6629944d39f210d65a85a9f930b4871e4358d0d2 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 2 Dec 2022 22:24:21 +1100 Subject: [PATCH] - Make the new scaled angle changes at frame rate opt-in behind new flag `SPF_SCALEDNOLERP`. * This will still test whether the game needs to lerp and will force `SPF_INTERPOLATE` if needed. --- src/playsim/d_player.h | 3 +- src/playsim/p_local.h | 1 + src/playsim/p_mobj.cpp | 78 +++++++++++++++++------------- src/playsim/p_user.cpp | 1 + src/rendering/r_utility.cpp | 7 ++- wadsrc/static/zscript/constants.zs | 4 +- 6 files changed, 57 insertions(+), 37 deletions(-) diff --git a/src/playsim/d_player.h b/src/playsim/d_player.h index efaabdb9e..549748070 100644 --- a/src/playsim/d_player.h +++ b/src/playsim/d_player.h @@ -122,7 +122,8 @@ typedef enum CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted CF_INTERPVIEW = 1 << 14, // [RH] view was changed outside of input, so interpolate one frame - CF_INTERPVIEWANGLES = 1 << 15, // [RH] flag for interpolating view angles without interpolating the entire frame + CF_INTERPVIEWANGLES = 1 << 15, // [MR] flag for interpolating view angles without interpolating the entire frame + CF_SCALEDNOLERP = 1 << 15, // [MR] flag for applying angles changes in the ticrate without interpolating the frame CF_EXTREMELYDEAD = 1 << 22, // [RH] Reliably let the status bar know about extreme deaths. CF_BUDDHA2 = 1 << 24, // [MC] Absolute buddha. No voodoo can kill it either. CF_GODMODE2 = 1 << 25, // [MC] Absolute godmode. No voodoo can kill it either. diff --git a/src/playsim/p_local.h b/src/playsim/p_local.h index 9ea6202ce..e1fae8d62 100644 --- a/src/playsim/p_local.h +++ b/src/playsim/p_local.h @@ -218,6 +218,7 @@ enum SPF { SPF_FORCECLAMP = 1, // players always clamp SPF_INTERPOLATE = 2, + SPF_SCALEDNOLERP = 4, }; enum PCM diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 1a4c65211..bcc825e0d 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -3429,18 +3429,22 @@ void AActor::SetPitch(DAngle p, int fflags) { if (player != nullptr) { - if (fflags & SPF_INTERPOLATE) + const bool mustLerp = !P_NoInterpolation(player, this); + + if ((fflags & SPF_INTERPOLATE) || ((fflags & SPF_SCALEDNOLERP) && mustLerp)) { - if (P_NoInterpolation(player, this)) - { - player->angleTargets.Pitch = deltaangle(Angles.Pitch, p); - player->angleAppliedAmounts.Pitch = nullAngle; - } - else - { - Angles.Pitch = p; - player->cheats |= CF_INTERPVIEW; - } + Angles.Pitch = p; + player->cheats |= CF_INTERPVIEW; + } + else if ((fflags & SPF_SCALEDNOLERP) && !mustLerp) + { + player->angleTargets.Pitch = deltaangle(Angles.Pitch, p); + player->angleAppliedAmounts.Pitch = nullAngle; + player->cheats |= CF_SCALEDNOLERP; + } + else + { + Angles.Pitch = p; } } else @@ -3457,18 +3461,22 @@ void AActor::SetAngle(DAngle ang, int fflags) { if (player != nullptr) { - if (fflags & SPF_INTERPOLATE) + const bool mustLerp = !P_NoInterpolation(player, this); + + if ((fflags & SPF_INTERPOLATE) || ((fflags & SPF_SCALEDNOLERP) && mustLerp)) { - if (P_NoInterpolation(player, this)) - { - player->angleTargets.Yaw = deltaangle(Angles.Yaw, ang); - player->angleAppliedAmounts.Yaw = nullAngle; - } - else - { - Angles.Yaw = ang; - player->cheats |= CF_INTERPVIEW; - } + Angles.Yaw = ang; + player->cheats |= CF_INTERPVIEW; + } + else if ((fflags & SPF_SCALEDNOLERP) && !mustLerp) + { + player->angleTargets.Yaw = deltaangle(Angles.Yaw, ang); + player->angleAppliedAmounts.Yaw = nullAngle; + player->cheats |= CF_SCALEDNOLERP; + } + else + { + Angles.Yaw = ang; } } else @@ -3485,18 +3493,22 @@ void AActor::SetRoll(DAngle r, int fflags) { if (player != nullptr) { - if (fflags & SPF_INTERPOLATE) + const bool mustLerp = !P_NoInterpolation(player, this); + + if ((fflags & SPF_INTERPOLATE) || ((fflags & SPF_SCALEDNOLERP) && mustLerp)) { - if (P_NoInterpolation(player, this)) - { - player->angleTargets.Roll = deltaangle(Angles.Roll, r); - player->angleAppliedAmounts.Roll = nullAngle; - } - else - { - Angles.Roll = r; - player->cheats |= CF_INTERPVIEW; - } + Angles.Roll = r; + player->cheats |= CF_INTERPVIEW; + } + else if ((fflags & SPF_SCALEDNOLERP) && !mustLerp) + { + player->angleTargets.Roll = deltaangle(Angles.Roll, r); + player->angleAppliedAmounts.Roll = nullAngle; + player->cheats |= CF_SCALEDNOLERP; + } + else + { + Angles.Roll = r; } } else diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index a1dfb35c2..0fa33a90e 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -1259,6 +1259,7 @@ void P_PlayerThink (player_t *player) // Don't interpolate the view for more than one tic player->cheats &= ~CF_INTERPVIEW; player->cheats &= ~CF_INTERPVIEWANGLES; + player->cheats &= ~CF_SCALEDNOLERP; player->mo->FloatVar("prevBob") = player->bob; IFVIRTUALPTRNAME(player->mo, NAME_PlayerPawn, PlayerThink) diff --git a/src/rendering/r_utility.cpp b/src/rendering/r_utility.cpp index 1af920a7f..1fe4aa1da 100644 --- a/src/rendering/r_utility.cpp +++ b/src/rendering/r_utility.cpp @@ -828,10 +828,13 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor I_Error ("You lost your body. Bad dehacked work is likely to blame."); } + // [MR] Get the input fraction, even if we don't need it this frame. Must run every frame. + const auto scaleAdjust = I_GetInputFrac(false); + // [MR] Process player angle changes if permitted to do so. - if (player && P_NoInterpolation(player, viewpoint.camera)) + if (player && (player->cheats & CF_SCALEDNOLERP) && P_NoInterpolation(player, viewpoint.camera)) { - R_DoActorTickerAngleChanges(player, viewpoint.camera, I_GetInputFrac(false)); + R_DoActorTickerAngleChanges(player, viewpoint.camera, scaleAdjust); } iview = FindPastViewer (viewpoint.camera); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index d5ed7c4cd..fac6619af 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -524,6 +524,7 @@ enum EAngleFlags { SPF_FORCECLAMP = 1, SPF_INTERPOLATE = 2, + SPF_SCALEDNOLERP = 4, }; // flags for A_CheckLOF @@ -1137,7 +1138,8 @@ enum EPlayerCheats CF_TOTALLYFROZEN = 1 << 12, // [RH] All players can do is press +use CF_PREDICTING = 1 << 13, // [RH] Player movement is being predicted CF_INTERPVIEW = 1 << 14, // [RH] view was changed outside of input, so interpolate one frame - CF_INTERPVIEWANGLES = 1 << 15, // [RH] flag for interpolating view angles without interpolating the entire frame + CF_INTERPVIEWANGLES = 1 << 15, // [MR] flag for interpolating view angles without interpolating the entire frame + CF_SCALEDNOLERP = 1 << 15, // [MR] flag for applying angles changes in the ticrate without interpolating the frame CF_EXTREMELYDEAD = 1 << 22, // [RH] Reliably let the status bar know about extreme deaths.