Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Jan 19, 2026

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

Generals gets

  • Removal of unused Drawable Particle Attachments
  • Addition of ParticleSystem::setSkipParentXfrm
  • Compile out of superfluous X and Y particle angles
  • Addition of SMUDGE particle type (used for Microwave Tank effect)
  • Optimization for particle update
  • Optimization for wind motion particle update when disabled
  • Change of math for aligning particle Z rotation with emitter direction

TODO

  • Add pull id to commits
  • Test all commits compile individually

@xezon xezon added this to the Code foundation build up milestone Jan 19, 2026
@xezon xezon added Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels Jan 19, 2026
@greptile-apps
Copy link

greptile-apps bot commented Jan 19, 2026

Greptile Overview

Greptile Summary

This PR unifies particle system code between Generals and Zero Hour by merging implementations and applying optimizations in both directions.

Key Changes:

  • Compiles out unused X/Y particle rotation (PARTICLE_USE_XY_ROTATION=0) since particles only support Z-axis rotation due to billboard and ground-aligned rendering modes
  • Removes drawable particle attachment system (unused feature) from Generals codebase
  • Optimizes alpha updates by skipping calculations for ADDITIVE shader type
  • Optimizes wind motion by checking if enabled before processing
  • Fixes visibility threshold calculations in Particle::isInvisible (from 0.02f/0.06f to 0.01f and component checks)
  • Adds SMUDGE particle type (used for Microwave Tank effect)
  • Adds ParticleSystem::setSkipParentXfrm() method to disable parent transform application
  • Refactors angleBetween function for cleaner implementation with pointer parameters
  • Updates particle editor UI to respect PARTICLE_USE_XY_ROTATION macro

The changes are well-structured with individual commits for each logical change, making the merge history clear and reviewable.

Confidence Score: 4/5

  • Safe to merge with minor performance optimization noted for follow-up
  • Well-tested changes with clear commit history and logical separation of concerns. The only issue (redundant length calculations in angleBetween) is already acknowledged with a planned follow-up fix.
  • No files require special attention - the redundant length calculation in Generals/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp:3457 is already tracked for follow-up

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp Compiles out X/Y rotation support, optimizes alpha/wind updates, fixes visibility thresholds, adds SMUDGE type, refactors angleBetween function
GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp Adds X/Y rotation guards, fixes visibility thresholds, improves formatting consistency
Generals/Code/GameEngine/Include/GameClient/ParticleSys.h Adds PARTICLE_USE_XY_ROTATION macro, guards X/Y angle fields, adds SMUDGE type and setSkipParentXfrm method
GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h Adds PARTICLE_USE_XY_ROTATION macro and guards X/Y angle fields for consistency with Generals

Sequence Diagram

sequenceDiagram
    participant PS as ParticleSystem
    participant P as Particle
    participant D as Drawable (removed)
    
    Note over PS,D: Particle System Update Flow
    
    PS->>PS: update()
    PS->>PS: updateWindMotion() [if enabled]
    PS->>PS: generateParticleInfo()
    PS->>P: new Particle(info)
    
    Note over P: Particle Update (per frame)
    P->>P: update()
    P->>P: Update position with velocity
    P->>P: doWindMotion() [if enabled]
    P->>P: Update orientation (Z-axis only)
    
    alt particleUpTowardsEmitter
        P->>P: angleBetween(&upVec, &emitterDir)
        P->>P: Set m_angleZ
    end
    
    alt Shader != ADDITIVE
        P->>P: Update alpha with keyframes
    end
    
    P->>P: Update size and color
    P->>P: isInvisible() check
    
    Note over D: Drawable particles removed
    Note over P: No m_drawable member
    Note over P: No X/Y rotation (PARTICLE_USE_XY_ROTATION=0)
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (2)

  1. 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. Since length() involves a square root calculation (sqrt(x*x + y*y)), this is wasteful. Calculate once and check for zero length:

  2. 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. Since length() 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

Edit Code Review Agent Settings | Greptile

@xezon
Copy link
Author

xezon commented Jan 19, 2026

Very fair comment, but this is EA code and outside the scope of this change.

Edit: I have prepared an optimization for later.

@xezon xezon force-pushed the xezon/unify-particlesystem-code branch from ff4e1b2 to df1cc68 Compare January 20, 2026 17:11
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp, line 3457-3459 (link)

    style: inefficient to compute vecA->length() and vecB->length() twice each - the guard condition calls .length(), then it's called again below

    Note: 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

Edit Code Review Agent Settings | Greptile

Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

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

Ok

xezon added 9 commits January 28, 2026 18:57
…holds in Particle::isInvisible from Generals (#2153)

This merge fixes 13 broken particle effects in Zero Hour:

airCarrierExplosion2
airCarrierHotPillarArms
airCarrierJet01Explosion
airCarrierJetExplosion1
airCarrierJetExplosion2
airCarrierJetExplosion3
ArmExplosionSmall01
BarrelExplosion
BuggyNewExplosionArms
FireBaseHowitzerPillarArms
HotPillarArms
MammothTankExplosionArms
SpectreHotPillarArms
…ation with emitter direction from Zero Hour (#2153)
@xezon xezon force-pushed the xezon/unify-particlesystem-code branch from df1cc68 to e39583d Compare January 28, 2026 18:01
@xezon xezon merged commit 5c4df79 into TheSuperHackers:main Jan 28, 2026
24 checks passed
xezon added a commit that referenced this pull request Jan 28, 2026
xezon added a commit that referenced this pull request Jan 28, 2026
xezon added a commit that referenced this pull request Jan 28, 2026
xezon added a commit that referenced this pull request Jan 28, 2026
xezon added a commit that referenced this pull request Jan 28, 2026
…holds in Particle::isInvisible from Generals (#2153)

This merge fixes 13 broken particle effects in Zero Hour:

airCarrierExplosion2
airCarrierHotPillarArms
airCarrierJet01Explosion
airCarrierJetExplosion1
airCarrierJetExplosion2
airCarrierJetExplosion3
ArmExplosionSmall01
BarrelExplosion
BuggyNewExplosionArms
FireBaseHowitzerPillarArms
HotPillarArms
MammothTankExplosionArms
SpectreHotPillarArms
xezon added a commit that referenced this pull request Jan 28, 2026
xezon added a commit that referenced this pull request Jan 28, 2026
@xezon xezon deleted the xezon/unify-particlesystem-code branch January 28, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants