-
Notifications
You must be signed in to change notification settings - Fork 149
unity(particlesys): Merge Particle System code #2153
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?
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/GameClient/ParticleSys.h | added PARTICLE_USE_XY_ROTATION macro to conditionally compile out unused X/Y rotation, added SMUDGE particle type, added setSkipParentXfrm method |
| Generals/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp | optimized particle updates (alpha only for non-additive, wind motion guarded), changed angle calculation to use angleBetween function, removed drawable management code, added PARTICLE_USE_XY_ROTATION conditionals, minor performance improvement opportunity in angleBetween |
| Generals/Code/Tools/ParticleEditor/Resource.h | added GPL header with incorrect game title and copyright year |
| GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h | added PARTICLE_USE_XY_ROTATION macro, fixed indentation for setSkipParentXfrm and m_skipParentXfrm, made update/isInvisible non-inline |
| GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp | fixed particle visibility thresholds in isInvisible (0.06f->0.01f for additive, 0.02f->0.01f for alpha, 0.95f->0.99f for subtract), added PARTICLE_USE_XY_ROTATION conditionals, fixed indentation, minor performance improvement opportunity in angleBetween |
Sequence Diagram
sequenceDiagram
participant PST as ParticleSystemTemplate
participant PS as ParticleSystem
participant P as Particle
participant PI as ParticleInfo
Note over PST,P: Particle System Initialization
PST->>PS: Constructor(template)
PS->>PS: Initialize m_skipParentXfrm = false
Note over PS: Set angle/angularRate from template<br/>(conditionally for XY if PARTICLE_USE_XY_ROTATION)
Note over PST,P: Particle Creation
PS->>PS: generateParticleInfo()
PS->>PI: Create ParticleInfo
Note over PI: Copy angle/angularRate values<br/>(conditionally for XY if PARTICLE_USE_XY_ROTATION)
PI-->>PS: Return info
PS->>P: Particle(system, info)
Note over P: Initialize angles and rates<br/>(conditionally for XY if PARTICLE_USE_XY_ROTATION)
Note over PST,P: Particle Update Loop
PS->>PS: update()
PS->>PS: Check if windMotion != NOT_USED
alt Parent has transform
PS->>PS: Apply parent transform<br/>(unless m_skipParentXfrm)
end
PS->>P: update()
P->>P: Update position & velocity
alt Wind motion enabled
P->>P: doWindMotion()
end
P->>P: Update angleZ & angularRateZ<br/>(XY angles compiled out)
alt particleUpTowardsEmitter
P->>P: Calculate emitterDir
P->>P: angleZ = angleBetween(upVec, emitterDir) + PI
end
P->>P: Update size & sizeRate
alt Shader != ADDITIVE
P->>P: Update alpha & alphaRate
end
P->>P: Update color via keyframes
P->>P: isInvisible() check<br/>(fixed thresholds in ZH)
alt Particle invisible or lifetime expired
P-->>PS: Return false (dead)
else
P-->>PS: Return true (alive)
end
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.
Additional Comments (2)
-
Generals/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp, line 217-220 (link)logic: The null check calls
length()twice per vector unnecessarily, then calls it again below. Sincelength()involves a square root calculation (sqrt(x*x + y*y)), this is wasteful. Calculate once and check for zero length: -
GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp, line 217-220 (link)logic: The null check calls
length()twice per vector unnecessarily, then calls it again below. Sincelength()involves a square root calculation (sqrt(x*x + y*y)), this is wasteful. Calculate once and check for zero length:
14 files reviewed, 2 comments
|
Very fair comment, but this is EA code and outside the scope of this change. Edit: I have prepared an optimization for later. |
…n Generals (#2153)
…article::isInvisible for Zero Hour (#2153)
…d in Generals (#2153)
… emitter direction in Generals (#2153)
ff4e1b2 to
df1cc68
Compare
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.
Additional Comments (1)
-
GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp, line 3457-3459 (link)style: inefficient to compute
vecA->length()andvecB->length()twice each - the guard condition calls.length(), then it's called again belowNote: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
14 files reviewed, 4 comments
Merge with Rebase
This change merges all Particle System related code, including Particle Editor code. All individual changes are split into separate commits for best visibility.
Zero Hour gets
Particle::isInvisible. This is the code fix for what this data fix attempted to workaround: Fix: Missing particle effects GeneralsGamePatch#809Generals gets
TODO