bugfix(smudge): Decouple smudge time step from render update#2484
bugfix(smudge): Decouple smudge time step from render update#2484xezon wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/GameClient/Smudge.h | Adds Identifier typedef (void *) and m_draw flag to Smudge; introduces a std::hash_map-backed index on SmudgeSet for O(1) particle lookup; updates SmudgeManager API to null-invalidate removed sets and exposes resetDraw/findSmudge. |
| Core/GameEngine/Source/GameClient/System/Smudge.cpp | Implements the new hash-map-backed addSmudgeToSet, findSmudge, and resetDraw. Also fixes a pre-existing omission: SmudgeSet::reset() now correctly clears m_usedSmudgeMap and resets m_usedSmudgeCount. |
| Core/GameEngine/Source/GameClient/System/ParticleSys.cpp | Adds smudge rebuilding to ParticleSystemManager::update() (logic-rate), decoupling it from the render path. Each update resets the smudge manager and repopulates it from current live particles, freezing the effect when the game is paused. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DSmudge.h | Marks W3DSmudgeManager as final, a safe and correct addition with no functional change. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp | Render loop now checks smudge->m_draw and skips invisible smudges; uses a local offset copy instead of mutating smudge->m_offset (good fix for data stability across frames); moves m_smudgeCountLastFrame assignment into render() instead of relying on the removed setSmudgeCountLastFrame setter. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp | Render path simplified: instead of creating smudge data, it now only calls resetDraw() then marks frustum-culled smudges as drawable via findSmudge(p). Smudge manager reset and cleanup calls correctly removed since they moved to the logic layer. |
Sequence Diagram
sequenceDiagram
participant Logic as ParticleSystemManager<br/>(update, logic-rate)
participant SM as SmudgeManager
participant SS as SmudgeSet
participant Render as W3DParticleSystemManager<br/>(doParticles, render-rate)
participant W3DSM as W3DSmudgeManager<br/>(render)
Note over Logic,W3DSM: Each game logic tick (paused = skipped)
Logic->>SM: reset()
SM->>SS: reset() [clears map + list]
Logic->>SM: addSmudgeSet()
SM-->>Logic: SmudgeSet*
loop For each smudge particle
Logic->>SS: addSmudgeToSet(particle*)
SS-->>Logic: Smudge* (m_draw=false)
Logic->>Logic: set pos/offset/size/opacity
end
Note over Logic,W3DSM: Each render frame (always runs, even when paused)
Render->>SM: resetDraw()
SM->>SS: resetDraw() [all m_draw = false]
loop For each smudge particle in frustum
Render->>SM: findSmudge(particle*)
SM->>SS: findSmudge via hash_map
SS-->>SM: Smudge*
SM-->>Render: Smudge*
Render->>Render: smudge->m_draw = true
end
Render->>W3DSM: render(rinfo)
loop For each smudge where m_draw==true
W3DSM->>W3DSM: compute UV coords (local offset copy)
W3DSM->>W3DSM: count++
end
W3DSM->>W3DSM: m_smudgeCountLastFrame = count
W3DSM->>W3DSM: draw batches via DX8 vertex buffer
Reviews (6): Last reviewed commit: "Add assert to SmudgeSet::addSmudgeToSet" | Re-trigger Greptile
1c343f0 to
eb58201
Compare
| const Coord3D *pos = p->getPosition(); | ||
| Smudge *smudge = set->addSmudgeToSet(p); | ||
| smudge->m_pos.Set(pos->x, pos->y, pos->z); | ||
| smudge->m_offset.Set(GameClientRandomValueReal(-0.06f,0.06f), GameClientRandomValueReal(-0.03f,0.03f)); |
There was a problem hiding this comment.
It is strange that the Y component has a different value range. This needs some investigation.
There was a problem hiding this comment.
There was a problem hiding this comment.
Looks how i imagine the GAP generator in red alert would distort someone's view of an area.
|
|
||
| struct SmudgeSet : public DLNodeClass<SmudgeSet> | ||
| #ifdef USING_STLPORT | ||
| namespace std |
There was a problem hiding this comment.
I would remove the namespace usage considering this is within the header.
you also call std:: directly further down.
There was a problem hiding this comment.
It needs to be in the std namespace for the hash map to automatically pick up without being an explicit template argument. Modern STL already provides it, but STLPort did not which is why it is written like this.
There was a problem hiding this comment.
Oh wait i see it now, yeah this is fine, i for some reason read it as though it was a using namespace directive.

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.