From 0c092b679ea3e06e52fe7253218099a83d6ba6eb Mon Sep 17 00:00:00 2001 From: Chronos Ouroboros Date: Sat, 14 Nov 2020 14:34:09 -0300 Subject: [PATCH] Fixed weapon bob jittering. --- src/d_player.h | 1 + src/p_user.cpp | 3 +++ wadsrc/static/zscript/actors/player/player.zs | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 3dcfaafe8..2f2b1ca1f 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -310,6 +310,7 @@ public: double viewz = 0; // focal origin above r.z double viewheight = 0; // base height above floor for viewz double deltaviewheight = 0; // squat speed. + float prevbob = 0; // Previous value of "bob" double bob = 0; // bounded/scaled total velocity // killough 10/98: used for realistic bobbing (i.e. not simply overall speed) diff --git a/src/p_user.cpp b/src/p_user.cpp index 03b6fd038..d5f5d75c9 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -356,6 +356,7 @@ void player_t::CopyFrom(player_t &p, bool copyPSP) viewz = p.viewz; viewheight = p.viewheight; deltaviewheight = p.deltaviewheight; + prevbob = p.prevbob; bob = p.bob; Vel = p.Vel; centering = p.centering; @@ -1322,6 +1323,7 @@ void P_PlayerThink (player_t *player) player->original_cmd = cmd->ucmd; // Don't interpolate the view for more than one tic player->cheats &= ~CF_INTERPVIEW; + player->prevbob = player->bob; IFVIRTUALPTRNAME(player->mo, NAME_PlayerPawn, PlayerThink) { @@ -1793,6 +1795,7 @@ DEFINE_FIELD_X(PlayerInfo, player_t, FOV) DEFINE_FIELD_X(PlayerInfo, player_t, viewz) DEFINE_FIELD_X(PlayerInfo, player_t, viewheight) DEFINE_FIELD_X(PlayerInfo, player_t, deltaviewheight) +DEFINE_FIELD_X(PlayerInfo, player_t, prevbob) DEFINE_FIELD_X(PlayerInfo, player_t, bob) DEFINE_FIELD_X(PlayerInfo, player_t, Vel) DEFINE_FIELD_X(PlayerInfo, player_t, centering) diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index ed96c663d..970e60d5c 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -49,7 +49,6 @@ class PlayerPawn : Actor double ViewBob; // [SP] ViewBob Multiplier double FullHeight; double curBob; - float prevBob; meta Name HealingRadiusType; meta Name InvulMode; @@ -1587,7 +1586,6 @@ class PlayerPawn : Actor virtual void PlayerThink() { let player = self.player; - prevBob = player.bob; UserCmd cmd = player.cmd; CheckFOV(); @@ -2370,7 +2368,7 @@ class PlayerPawn : Actor double bobVal = player.bob; if (i == 0) { - bobVal = prevBob; + bobVal = player.prevBob; } //[SP] Added in decorate player.viewbob checks double bobx = (bobVal * BobIntensity * Rangex * ViewBob); @@ -2646,6 +2644,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native double viewz; native double viewheight; native double deltaviewheight; + native float prevbob; native double bob; native vector2 vel; native bool centering;