bugfix(smudge): Decouple smudge time step from render update#2484
bugfix(smudge): Decouple smudge time step from render update#2484xezon merged 7 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/GameClient/Smudge.h | Adds Identifier typedef (void*), m_draw flag to Smudge, STLPort hash specialization for Identifier, resetDraw()/findSmudge() helpers to SmudgeSet, removes setSmudgeCountLastFrame() setter from SmudgeManager, and updates removeSmudgeSet to take a reference-to-pointer for automatic nulling. |
| Core/GameEngine/Source/GameClient/System/Smudge.cpp | Implements new resetDraw(), findSmudge(), and addSmudgeToSet(identifier) methods; also adds m_usedSmudgeMap management across reset(), addSmudgeToSet, removeSmudgeFromSet, and adds hash-map-based identifier lookup. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp | Render function updated to skip smudges with m_draw == false, uses a local offset copy instead of mutating smudge->m_offset, moves m_smudgeCountLastFrame assignment into render(), and converts while loops to range-for style. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DSmudge.h | Marks W3DSmudgeManager as final, preventing unintended subclassing. Clean, minimal change. |
| Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | Adds the logic-side smudge update: on each logic frame, resets all smudges and rebuilds the SmudgeSet from current particles (with m_draw = false). This is the new owner of smudge state, decoupled from the render cycle. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp | Render-side smudge handling simplified: instead of creating smudges here, it now calls resetDraw() then sets m_draw = true on in-frustum particles via findSmudge(p). Removes stale visibleSmudgeCount tracking and setSmudgeCountLastFrame() call. |
Sequence Diagram
sequenceDiagram
participant LU as Logic Update<br/>(ParticleSys::update)
participant SM as SmudgeManager
participant RU as Render Update<br/>(W3DParticleSys::doParticles)
participant RN as Renderer<br/>(W3DSmudge::render)
note over LU,RN: Each Logic Frame (pauses when game is paused)
LU->>SM: reset() — clears all SmudgeSets & smudges
LU->>SM: addSmudgeSet()
loop For each smudge particle
LU->>SM: addSmudgeToSet(particle*)<br/>sets pos, offset (random), size, opacity<br/>m_draw = false
end
note over LU,RN: Each Render Frame (runs even when paused)
RU->>SM: resetDraw() — sets all m_draw = false
loop For each in-frustum smudge particle
RU->>SM: findSmudge(particle*)
SM-->>RU: Smudge*
RU->>SM: smudge->m_draw = true
end
RU->>RN: render(rinfo)
note over RN: Pass 1: count visible (m_draw==true),<br/>compute view-space verts & UVs<br/>using local offset copy
note over RN: Pass 2: upload vertex data to GPU<br/>in batches of ≤SMUDGE_DRAW_SIZE,<br/>skip m_draw==false smudges
RN->>SM: m_smudgeCountLastFrame = count
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/GameClient/System/ParticleSys.cpp
Line: 3034-3039
Comment:
**`m_draw` initialization belongs inside `addSmudgeToSet`**
`m_draw = false` is always assigned by every call-site right after `addSmudgeToSet` returns. Smudges recycled from the free pool carry whatever `m_draw` value they had when they were last removed, so if a future call-site forgets to reinitialise the field the render pass could spuriously draw a stale smudge.
Consider initialising `m_draw` inside `addSmudgeToSet` (in `Smudge.cpp`) so correctness is self-contained:
```cpp
// In SmudgeSet::addSmudgeToSet, after smudge->m_identifier = identifier:
smudge->m_draw = false;
```
That would also let you drop the explicit `smudge->m_draw = false;` from every call-site.
How can I resolve this? If you propose a fix, please make it concise.Reviews (7): Last reviewed commit: "Fix offset Y" | Re-trigger Greptile
1c343f0 to
eb58201
Compare
12d14aa to
60e3af8
Compare
|
Rebased and Y offset adjusted. |
This change decouples the smudge time step from the render update. Smudge refers to the heat haze of the USA Microwave Tank. When the game is paused, the heat effect will now pause as well.
TODO