Skip to content

bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam to restore correct position and fix quiet beam audio#2415

Open
githubawn wants to merge 1 commit intoTheSuperHackers:mainfrom
githubawn:fix/particle-cannon-audio-volume
Open

bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam to restore correct position and fix quiet beam audio#2415
githubawn wants to merge 1 commit intoTheSuperHackers:mainfrom
githubawn:fix/particle-cannon-audio-volume

Conversation

@githubawn
Copy link

@githubawn githubawn commented Mar 7, 2026

@greptile-apps
Copy link

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a regression introduced in #2220 where the Particle Cannon's positional audio became quieter because the audio source was being implicitly anchored to the visual beam drawable's transform (which points from orbit down to the ground, placing the audio source far from the player's camera). The fix explicitly calls beam->setPosition() with a Coord3D 500 units above the ground-impact target in both the per-frame update() path and the one-time createOrbitToTargetLaser() initialization path, decoupling the audio spawn point from the visual laser endpoints managed by LaserUpdate::initLaser.

Changes are applied symmetrically to both Generals/ (vanilla) and GeneralsMD/ (Zero Hour) builds with correct product name headers and GPL licenses. The fix is applied at two call sites per file: update() (runs every frame, follows m_currentTargetPosition as the beam sweeps) and createOrbitToTargetLaser() (initial beam creation, uses m_initialTargetPosition). Both are necessary for correct audio positioning throughout the weapon's lifetime.

LaserUpdate::initLaser uses explicit world-space endpoint coordinates independent of the drawable's own transform, so calling setPosition afterward does not affect the visual rendering — only the audio source location.

Confidence Score: 4/5

  • Safe to merge; the fix is targeted, logically sound, and carries no risk of visual or gameplay regression.
  • The change is minimal (4 lines × 2 sites × 2 files), follows established patterns in the codebase, and correctly targets only the drawable position used by the audio system without disturbing LaserUpdate's world-space visual endpoints. No correctness or safety issues identified.
  • No files require special attention.

Sequence Diagram

sequenceDiagram
    participant Logic as ParticleUplinkCannonUpdate
    participant GC as TheGameClient
    participant Beam as Drawable (beam)
    participant LU as LaserUpdate
    participant Audio as TheAudio

    Note over Logic: createOrbitToTargetLaser()
    Logic->>GC: newDrawable(thingTemplate)
    GC-->>Beam: beam created
    Logic->>Beam: findClientUpdateModule("LaserUpdate")
    Beam-->>LU: update module
    Logic->>LU: initLaser(orbitPosition → initialTargetPosition)
    Note over LU: Sets visual endpoints (world-space absolute)
    Logic->>Beam: setPosition(initialTargetPosition + z500)
    Note over Beam: Audio anchor = ground target + 500 units
    Logic->>Audio: addAudioEvent(annihilationSound @ drawableID)

    Note over Logic: update() — every frame
    Logic->>GC: findDrawableByID(m_orbitToTargetBeamID)
    GC-->>Beam: existing beam
    Logic->>LU: initLaser(orbitPosition → currentTargetPosition)
    Note over LU: Updates visual endpoints each frame
    Logic->>Beam: setPosition(currentTargetPosition + z500)
    Note over Beam: Audio follows swept target position
Loading

Last reviewed commit: 05fd43e

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Looks good. Can be polished a bit.

}
// TheSuperHackers @fix anchor positional audio 500 units above the ground target
Coord3D audioPos = m_initialTargetPosition;
audioPos.z += 500.0f;
Copy link

Choose a reason for hiding this comment

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

I suggest put this near ORBITAL_BEAM_Z_OFFSET as

// TheSuperHackers @fix The positional audio is now decoupled from the beam origin.
// 500 units represent the height of the original audio emitter.
constexpr const Real ORBITAL_BEAM_AUDIO_Z_OFFSET = 500.0f;

@xezon xezon added Audio Is audio related Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project labels Mar 7, 2026
@xezon xezon changed the title fix(audio): Decouple Particle Cannon audio spawn point from visual beam bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam Mar 7, 2026
@xezon xezon changed the title bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam to restore correct position and fix quiet beam audio Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Audio Is audio related Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Particle Beam audio is very quiet

2 participants