Repository navigation
Conversation
bobCycle is an integer and was advanced by (int)( old + bobmove * msec ), which drops the fraction on every pmove step: 0.3 * 6 msec = 1.8 became 1. The cycle therefore ran slow by an amount that depends on the frame time (running -6% at 125 fps, -17% at 144 fps; walking -17% at 125 fps, -44% at 144 fps; swimming and walking stop entirely below ~7 and ~4 msec per frame), so footstep cadence and view bob changed with the frame rate. Advance by floor( bobmove * time ) at the end of the step minus the same at its start instead. The rounding errors of consecutive steps cancel, so the cycle runs at the exact rate at any frame rate without adding state to playerState_t (which would change save games and the network format). Fixed in JK2 and JA SP. Measured in game (running, bobmove 0.4): 400.0 per second at 60, 144 and 200 fps. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PM_Footstepsadvances the integerbobCyclewitholdis an int, so the fraction ofbobmove * msecis dropped on every pmove step (0.3 * 6 msec = 1.8becomes1). The singleplayer player runs one pmove per rendered frame, so the bob cycle speed, and with it the footstep event cadence and the view/weapon bob, depends on the frame time:Swimming (0.15) stops advancing below 7 ms per frame, so
EV_SWIMis lost. Higher frame rate caps (high refresh rate displays) hit this directly.Fix
Advance by
floor( bobmove * time )at the end of the step minus the same expression at its start. The rounding errors of consecutive steps cancel, so for a constantbobmovethe cycle advances at exactly the intended rate at any frame rate, and the result does not drift. No state is added: a remainder field inplayerState_twould change the save game and network formats.Applied to both
codeJK2/game/bg_pmove.cppandcode/game/bg_pmove.cpp(the two call sites each: swimming and the general case).Behaviour change
At the default 125 fps running footsteps/bob get about 6% faster and walking about 20% faster, i.e. they now match the nominal
bobmoverates; at low frame rates the change is small (e.g. 30 fps: under 2%).Testing
bobmove * 1000per second.kejim_base, temporary counter that was removed again): running advances 400.0 bob units per moving second atcom_maxfps60, 144 and 200.🤖 Generated with Claude Code