Skip to content

tweak(drawable): Decouple police car light animation from render update#2829

Open
bobtista wants to merge 3 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/tweak/decouple-police-car-lights
Open

tweak(drawable): Decouple police car light animation from render update#2829
bobtista wants to merge 3 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/tweak/decouple-police-car-lights

Conversation

@bobtista

Copy link
Copy Markdown

Resolves #2828

The police car light bar animation and its blinking dynamic light are advanced by a fixed m_curFrame += 0.25 increment in W3DPoliceCarDraw::doDrawModule, which runs once per render frame. This makes the blink rate scale with render frame rate.

This change scales the per-frame increment by TheFramePacer->getActualLogicTimeScaleOverFpsRatio(), following the same pattern already applied to the stealth opacity fade, tint envelope, tree sway, and water movement. The animation now advances at the logic rate regardless of render frame rate.

This is a render-only change. m_curFrame is not part of crc()/xfer(), so there is no effect on logic, replays, or CRC determinism.

Testing:

[x]Police car light bar blinks at a consistent rate with various render FPS

@bobtista bobtista self-assigned this Jun 24, 2026
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR decouples the police car light bar animation from render frame rate by scaling the per-frame animAmt increment with TheFramePacer->getActualLogicTimeScaleOverFpsRatio(), matching the same technique already applied to stealth opacity, tree sway, and water movement.

  • animAmt is now 0.25f * TheFramePacer->getActualLogicTimeScaleOverFpsRatio() so the animation advances at the logic rate regardless of how many render frames occur per logic tick. The ratio is internally clamped to [0, 1.0], so the step never exceeds the original constant.
  • m_curFrame is not serialised in xfer() or hashed in crc(), so replay determinism and CRC checks are unaffected.

Confidence Score: 5/5

Safe to merge — the change is a one-line scaling of a render-only local constant, mirroring an established pattern used across W3DWater, W3DTreeBuffer, and Drawable.

The modification touches a single local constant in a render-only draw module. The ratio from getActualLogicTimeScaleOverFpsRatio is clamped to [0, 1.0] internally so the step never exceeds the original 0.25, m_curFrame is not serialised or CRC'd, and the identical pattern is already proven in several other render subsystems.

No files require special attention.

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp Adds FramePacer include and scales animAmt by getActualLogicTimeScaleOverFpsRatio(); one-line change, consistent with existing patterns in W3DWater, W3DTreeBuffer, and Drawable.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant RenderLoop
    participant W3DPoliceCarDraw
    participant FramePacer
    participant RenderObj

    RenderLoop->>W3DPoliceCarDraw: doDrawModule(transformMtx)
    W3DPoliceCarDraw->>FramePacer: getActualLogicTimeScaleOverFpsRatio()
    FramePacer-->>W3DPoliceCarDraw: "ratio = min(1.0, logicFPS / renderFPS)"
    W3DPoliceCarDraw->>W3DPoliceCarDraw: "animAmt = 0.25f * ratio"
    W3DPoliceCarDraw->>RenderObj: Peek_Animation()
    RenderObj-->>W3DPoliceCarDraw: anim
    W3DPoliceCarDraw->>W3DPoliceCarDraw: "m_curFrame += animAmt"
    W3DPoliceCarDraw->>RenderObj: Set_Animation(anim, m_curFrame)
    W3DPoliceCarDraw->>W3DPoliceCarDraw: compute light color from m_curFrame
    W3DPoliceCarDraw->>W3DPoliceCarDraw: "update dynamic light position & color"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant RenderLoop
    participant W3DPoliceCarDraw
    participant FramePacer
    participant RenderObj

    RenderLoop->>W3DPoliceCarDraw: doDrawModule(transformMtx)
    W3DPoliceCarDraw->>FramePacer: getActualLogicTimeScaleOverFpsRatio()
    FramePacer-->>W3DPoliceCarDraw: "ratio = min(1.0, logicFPS / renderFPS)"
    W3DPoliceCarDraw->>W3DPoliceCarDraw: "animAmt = 0.25f * ratio"
    W3DPoliceCarDraw->>RenderObj: Peek_Animation()
    RenderObj-->>W3DPoliceCarDraw: anim
    W3DPoliceCarDraw->>W3DPoliceCarDraw: "m_curFrame += animAmt"
    W3DPoliceCarDraw->>RenderObj: Set_Animation(anim, m_curFrame)
    W3DPoliceCarDraw->>W3DPoliceCarDraw: compute light color from m_curFrame
    W3DPoliceCarDraw->>W3DPoliceCarDraw: "update dynamic light position & color"
Loading

Reviews (3): Last reviewed commit: "style(drawable): Sort FramePacer include..." | Re-trigger Greptile

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct

@xezon xezon added this to the Decouple logic and rendering milestone Jun 26, 2026
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour Rendering Is Rendering related Fix Is fixing something, but is not user facing labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing Minor Severity: Minor < Major < Critical < Blocker Rendering Is Rendering related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Police car light bar animation speed changes with framerate

3 participants