-
Notifications
You must be signed in to change notification settings - Fork 176
bugfix(smudge): Decouple smudge time step from render update #2484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e8e6564
8f8b5de
519a386
ac54675
eb58201
12d14aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,39 +28,59 @@ | |
|
|
||
| struct Smudge : public DLNodeClass<Smudge> | ||
| { | ||
| typedef void *Identifier; | ||
|
|
||
| W3DMPO_GLUE(Smudge) | ||
|
|
||
| Identifier m_identifier; //a number or pointer to identify this smudge | ||
| Vector3 m_pos; //position of smudge center | ||
| Vector2 m_offset; // difference in position between "texture" extraction and re-insertion for center vertex | ||
| Real m_size; //size of smudge in world space. | ||
| Real m_opacity; //alpha of center vertex, corners are assumed at 0 | ||
| Bool m_draw; //whether this smudge needs to be drawn | ||
|
|
||
| struct smudgeVertex | ||
| { Vector3 pos; //world-space position of vertex | ||
| { | ||
| Vector3 pos; //world-space position of vertex | ||
| Vector2 uv; //uv coordinates of vertex | ||
| }; | ||
| smudgeVertex m_verts[5]; //5 vertices of this smudge (in counter-clockwise order, starting at top-left, ending in center.) | ||
| }; | ||
|
|
||
| struct SmudgeSet : public DLNodeClass<SmudgeSet> | ||
| #ifdef USING_STLPORT | ||
| namespace std | ||
| { | ||
| W3DMPO_GLUE(SmudgeSet) | ||
|
|
||
| public: | ||
| template<> struct hash<Smudge::Identifier> | ||
| { | ||
| size_t operator()(Smudge::Identifier id) const { return reinterpret_cast<size_t>(id); } | ||
| }; | ||
| } | ||
| #endif // USING_STLPORT | ||
|
|
||
| struct SmudgeSet : public DLNodeClass<SmudgeSet> | ||
| { | ||
| friend class SmudgeManager; | ||
|
|
||
| W3DMPO_GLUE(SmudgeSet) | ||
|
|
||
| SmudgeSet(); | ||
| virtual ~SmudgeSet() override; | ||
|
|
||
| void reset(); | ||
| void resetDraw(); | ||
|
|
||
| Smudge *addSmudgeToSet(Smudge::Identifier identifier); ///< add and return a smudge to the set with the given identifier | ||
| void removeSmudgeFromSet(Smudge *&smudge); ///< remove and invalidate the given smudge | ||
| Smudge *findSmudge(Smudge::Identifier identifier); ///< find the smudge that belongs to this identifier | ||
|
|
||
| Smudge *addSmudgeToSet(); | ||
| void removeSmudgeFromSet ( Smudge &mySmudge); | ||
| DLListClass<Smudge> &getUsedSmudgeList() { return m_usedSmudgeList;} | ||
| Int getUsedSmudgeCount() { return m_usedSmudgeCount; } ///<active smudges that need rendering. | ||
|
|
||
| private: | ||
| typedef std::hash_map<Smudge::Identifier, Smudge *> SmudgeIdToPtrMap; | ||
|
|
||
| DLListClass<Smudge> m_usedSmudgeList; ///<list of smudges in this set. | ||
| SmudgeIdToPtrMap m_usedSmudgeMap; | ||
| static DLListClass<Smudge> m_freeSmudgeList; ///<list of unused smudges for use by SmudgeSets. | ||
| Int m_usedSmudgeCount; | ||
| }; | ||
|
|
@@ -76,10 +96,12 @@ class SmudgeManager | |
| virtual void ReleaseResources() {} | ||
| virtual void ReAcquireResources() {} | ||
|
|
||
| SmudgeSet *addSmudgeSet(); | ||
| void removeSmudgeSet(SmudgeSet &mySmudge); | ||
| void resetDraw(); ///< reset whether all smudges need to be drawn | ||
|
|
||
| SmudgeSet *addSmudgeSet(); ///< add and return a new smudge set | ||
| void removeSmudgeSet(SmudgeSet *&smudgeSet); ///< remove and invalidate the given smudge set | ||
| Smudge *findSmudge(Smudge::Identifier identifier); ///< find the smudge from any smudge set | ||
| Int getSmudgeCountLastFrame() {return m_smudgeCountLastFrame;} ///<return number of smudges submitted last frame. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used by anything so could be removed. |
||
| void setSmudgeCountLastFrame(Int count) { m_smudgeCountLastFrame = count;} | ||
| Bool getHardwareSupport() { return m_hardwareSupportStatus != SMUDGE_SUPPORT_NO;} | ||
|
|
||
| protected: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| #include "GameClient/GameClient.h" | ||
| #include "GameClient/InGameUI.h" | ||
| #include "GameClient/ParticleSys.h" | ||
| #include "GameClient/Smudge.h" | ||
|
|
||
| #include "GameLogic/GameLogic.h" | ||
| #include "GameLogic/Object.h" | ||
|
|
@@ -3003,6 +3004,43 @@ void ParticleSystemManager::update() | |
| deleteInstance(sys); | ||
| } | ||
| } | ||
|
|
||
| const Bool drawSmudge = TheSmudgeManager && TheSmudgeManager->getHardwareSupport() && TheGlobalData->m_useHeatEffects; | ||
|
|
||
| if (drawSmudge) | ||
| { | ||
| // TheSuperHackers @bugfix The smudge time step is now decoupled from the render update. | ||
| // This clears all prior smudges and recreates them for all current smudge particles. | ||
|
|
||
| TheSmudgeManager->reset(); | ||
| SmudgeSet *set = TheSmudgeManager->addSmudgeSet(); //global smudge set through which all smudges are rendered. | ||
|
|
||
| for (ParticleSystemManager::ParticleSystemListIt it = m_allParticleSystemList.begin(); it != m_allParticleSystemList.end(); ++it) | ||
| { | ||
| ParticleSystem *sys = (*it); | ||
| if (!sys) | ||
| continue; | ||
|
|
||
| // only look at particle/point style systems | ||
| if (sys->isUsingDrawables()) | ||
| continue; | ||
|
|
||
| // temporary hack that checks if texture name starts with "SMUD" - if so, we can assume it's a smudge type | ||
| if (/*sys->isUsingSmudge()*/ *((DWORD *)sys->getParticleTypeName().str()) == 0x44554D53) | ||
| { | ||
| for (Particle *p = sys->getFirstParticle(); p; p = p->m_systemNext) | ||
| { | ||
| 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)); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is strange that the Y component has a different value range. This needs some investigation.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks how i imagine the GAP generator in red alert would distort someone's view of an area. |
||
| smudge->m_size = p->getSize(); | ||
| smudge->m_opacity = p->getAlpha(); | ||
| smudge->m_draw = false; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait i see it now, yeah this is fine, i for some reason read it as though it was a
using namespacedirective.