Conversation
|
Can you show a video how it looks before and after? I'd recommend replicating to Generals as the very last thing you do for any PR. It's easier for the PR creator and reviewer(s). |
|
I remember I worked on this before and it was difficult to get perfectly right and then paused this. I still have the WIP branch. I would be surprised if this change fixed it with no problems at all. For easy test, take a GLA Buggy and compare its physics with Retail at different FPS. If it is not matching, then there is work left to do. |
Oh that's right, I remember watching this, there's some buggy jank addressed is in episode 0844. I was just trying to apply changes similar to your decouple stealth fade one for remaining frame based logic, hadn't started testing yet. I'll convert to draft and assume there's more to do |
Can you push the latest to your WIP branch? |
2751da9 to
2bb1cb5
Compare
|
When I increase render FPS and update physics every render, the buggy doesn't wabble or wheelie as much. At higher render FPS we're getting effectively like a higher resolution of the damped spring math, so less overshoots, less wobble, but same total force is applied. Claude says it's called the Euler integration of a damped spring. I think it makes sense to only calculate it at logic frames, and we interpolate so it's smoother visually. Otherwise we're messing with the spring math to approximate the overshoots from before, and it's purely visual right? Anyway - I just tested, and it looks right to me. Note the other changes in this PR don't have this overshoot feedback kind of issue, so they all should work with calculations on render frames. Eg Linear fades like opacity I've implemented this approach and restored the Generals changes (can replicate once this is approved). |
2bb1cb5 to
77e6dad
Compare
Greptile SummaryThis PR adds render-frame interpolation to the drawable physics transform (vehicle tilt, suspension wobble, recoil) so that motion stays smooth at render rates above the 30 Hz logic rate, following the groundwork laid in #1528.
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Game Loop
participant WW3D as WW3D Timing
participant AP as applyPhysicsXform
participant Calc as calcPhysicsXform
Note over App,Calc: Logic Frame (Get_Sync_Frame_Time != 0)
App->>AP: render tick (logic frame)
AP->>AP: "save m_prev* = m_total*"
AP->>Calc: calcPhysicsXform()
Calc-->>AP: "new m_total* computed"
AP->>WW3D: Get_Fractional_Sync_Milliseconds() ≈ 0
WW3D-->>AP: t ≈ 0.0
AP->>AP: "interp = prev + 0*(current - prev) = prev"
Note right of AP: Renders previous frame values
Note over App,Calc: Render-only Frame (Get_Sync_Frame_Time == 0)
App->>AP: render tick (mid-frame)
Note right of AP: No prev save, no calcPhysicsXform
AP->>WW3D: Get_Fractional_Sync_Milliseconds() ≈ 16ms
WW3D-->>AP: t ≈ 0.5
AP->>AP: "interp = prev + 0.5*(current - prev)"
Note right of AP: Smoothly interpolated output
Note over App,Calc: Next Logic Frame
App->>AP: render tick (logic frame)
AP->>AP: "save m_prev* = m_total* (from prior logic frame)"
AP->>Calc: calcPhysicsXform()
Calc-->>AP: "new m_total*"
AP->>WW3D: Get_Fractional_Sync_Milliseconds() ≈ 0
WW3D-->>AP: t ≈ 0.0
Reviews (6): Last reviewed commit: "tweak(drawable): Replicate physics inter..." | Re-trigger Greptile |
|
@xezon are you ok with copying the zero hour changes to Generals here? Greptile is right that they used different approaches, and I don't see the benefit in keeping or trying to tweak the Generals' one vs using ZH's interpolation |
Both gone - the Zero Hour side no longer queries the ratio inside the physics functions at all (they run on logic frames now), and the Generals side will be replaced with the same approach once agreed. |
|
Found three problems while re-reviewing this, all fixed now:
With those fixed the spring math always steps at the logic rate with retail constants regardless of render fps, so the buggy behaves like retail at 30fps by construction — tested at [30 / 60 / uncapped]. One caveat: the rendered tilt lags the sim by one logic frame (~33ms) because it interpolates prev→current, so a frame-by-frame retail comparison will show that offset. I still want others' thoughts on copying this approach to Generals - the timeScale-at-call-site version there changes the spring dynamics with fps (step size alters the overshoot), which is exactly what your buggy test catches. |
Buggy movement at 30fps Buggy movement at 120fps |
04f1c20 to
d3c5b8d
Compare
|
Can this get some love? |
0451755 to
7be7c8f
Compare
|
Would you mind including larger videos with more detail? |
e7a1573 to
b90c640
Compare
Ok I swapped in the Rebel Ambush clip instead of another buggy one - since the other physics decoupling work was merged, this PR just handles the interpolation for physics like the buggy wobble and the fade effect timing - it's harder for me to see the smoother interpolated difference and particularly hard for me to record it on my old windows box because it'll struggle to both record and stay at high FPS lol. Anyway, the fade shows the bug plainly: at a 4:1 render/logic ratio an authored 3000 ms fade runs in 750 ms. Both halves of the PR are from the same issue, something that should advance per unit of time advancing once per render frame, so yeah, the fade is the better demo to share here (in the PR description). |
|
This Pull request has 2 changes. I suggest split them into 2 pulls. |
|
Yeah, makes sense. I’ll keep this one for the physics interpolation and move the fade timing changes into a separate PR. |
b90c640 to
e3606ef
Compare
|
Split now — this PR is physics interpolation only. The fade timing change moved to #3303. |
| @@ -1353,13 +1353,29 @@ void Drawable::applyPhysicsXform(Matrix3D* mtx) | |||
| // All calculations are originally catered to a 30 fps logic step. | |||
There was a problem hiding this comment.
The 30 fps part still applies to the physics state update, but yeah, “all calculations” is wrong now that interpolation runs every render frame. I updated the comment.
e3606ef to
32ad9ac
Compare
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Comment |
#1528 already made Drawable physics run on logic frames. At render rates above the logic rate, rendering still holds the last result until the next logic frame, so vehicle tilt, suspension, wobble, and recoil update at 30 Hz.
This saves the previous physics transform and interpolates between it and the current one using fractional sync time. The physics calculation itself is unchanged. The rendered transform trails the simulation by one logic frame (~33 ms).
Todo: