group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
ParticleSystem Class Reference

Top-level particle system orchestrator. More...

#include <ParticleSystem.hpp>

Public Member Functions

bool init (SDL_GPUDevice *dev, SDL_GPUTextureFormat colorFmt, SDL_GPUShaderFormat shaderFmt)
 Initialise all effect sub-systems and the GPU renderer.
 
void quit ()
 Tear down all GPU resources and effect sub-systems.
 
void spawnProjectileTracer (entt::entity e, Registry &reg)
 Attach an oriented-capsule tracer to a fast-bullet projectile entity.
 
void spawnRibbonTrail (entt::entity e, Registry &reg)
 Attach a ribbon trail to a slow/arcing projectile entity (rocket).
 
void spawnBulletTracer (glm::vec3 origin, glm::vec3 dir, float range=500.f)
 Spawn a one-shot bullet-tracer streak (no ECS entity needed).
 
void spawnHitscanBeam (glm::vec3 origin, glm::vec3 hitPos, WeaponType wt)
 Spawn an instant energy beam from origin to hitPos.
 
void spawnImpactEffect (glm::vec3 pos, glm::vec3 normal, SurfaceType surf, WeaponType wt)
 Spawn spark burst + impact flash + bullet hole decal.
 
void spawnBulletHole (glm::vec3 pos, glm::vec3 normal, WeaponType wt)
 Place a bullet-hole decal on a surface.
 
void spawnSmoke (glm::vec3 pos, float radius)
 Spawn a smoke cloud at pos.
 
void spawnExplosion (glm::vec3 pos, float blastRadius)
 Spawn rocket explosion at pos.
 
void drawWorldText (glm::vec3 worldPos, std::string_view text, glm::vec4 color, float worldHeight)
 Queue world-space SDF text for this frame.
 
void drawScreenText (glm::vec2 pixelPos, std::string_view text, glm::vec4 color, float pixelHeight)
 Queue screen-space HUD SDF text for this frame.
 
void setScreenSize (float w, float h)
 Set screen dimensions for HUD rendering. Call before render().
 
void update (float dt, const Camera &cam, Registry &reg)
 Simulate all effects. Called once per render frame (not per physics tick).
 
void uploadToGpu (SDL_GPUCommandBuffer *cmd)
 Upload all particle data to GPU. Must be called BEFORE render pass.
 
void render (SDL_GPURenderPass *pass, SDL_GPUCommandBuffer *cmd)
 Issue all particle draw calls. Must be called INSIDE a render pass.
 
void onWeaponFired (const WeaponFiredEvent &e)
 Handle a weapon-fired event (spawns hitscan beam if applicable).
 
void onImpact (const ProjectileImpactEvent &e)
 Handle a projectile impact event (spawns sparks and decal).
 
void onExplosion (const ExplosionEvent &e)
 Handle an explosion event (spawns explosion and smoke).
 
uint32_t impactCount () const
 
uint32_t tracerCount () const
 
uint32_t ribbonVertexCount () const
 
uint32_t hitscanBeamCount () const
 
uint32_t arcVertexCount () const
 
uint32_t smokeCount () const
 
uint32_t decalCount () const
 
bool sdfReady () const
 

Detailed Description

Top-level particle system orchestrator.

Owns all effect sub-systems and the ParticleRenderer. Lifecycle: Game::init() → particleSystem.init() Game::iterate() → particleSystem.update(dt, cam) Renderer::drawFrame() calls internally: particleSystem.uploadToGpu(cmd) [before render pass] particleSystem.render(pass, cmd) [inside render pass] Game::quit() → particleSystem.quit()

Member Function Documentation

◆ arcVertexCount()

uint32_t ParticleSystem::arcVertexCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decalCount()

uint32_t ParticleSystem::decalCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawScreenText()

void ParticleSystem::drawScreenText ( glm::vec2  pixelPos,
std::string_view  text,
glm::vec4  color,
float  pixelHeight 
)

Queue screen-space HUD SDF text for this frame.

Parameters
pixelPosScreen position in pixels (top-left origin).
textUTF-8 string to render.
colorRGBA text colour.
pixelHeightGlyph height in pixels.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawWorldText()

void ParticleSystem::drawWorldText ( glm::vec3  worldPos,
std::string_view  text,
glm::vec4  color,
float  worldHeight 
)

Queue world-space SDF text for this frame.

Parameters
worldPosWorld-space anchor position.
textUTF-8 string to render.
colorRGBA text colour.
worldHeightGlyph height in world units.
Here is the call graph for this function:

◆ hitscanBeamCount()

uint32_t ParticleSystem::hitscanBeamCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ impactCount()

uint32_t ParticleSystem::impactCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool ParticleSystem::init ( SDL_GPUDevice *  dev,
SDL_GPUTextureFormat  colorFmt,
SDL_GPUShaderFormat  shaderFmt 
)

Initialise all effect sub-systems and the GPU renderer.

Parameters
devThe SDL GPU device.
colorFmtSwapchain colour format.
shaderFmtShader binary format (SPIRV or MSL).
Returns
True on success.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onExplosion()

void ParticleSystem::onExplosion ( const ExplosionEvent e)

Handle an explosion event (spawns explosion and smoke).

Here is the call graph for this function:

◆ onImpact()

void ParticleSystem::onImpact ( const ProjectileImpactEvent e)

Handle a projectile impact event (spawns sparks and decal).

Here is the call graph for this function:

◆ onWeaponFired()

void ParticleSystem::onWeaponFired ( const WeaponFiredEvent e)

Handle a weapon-fired event (spawns hitscan beam if applicable).

Here is the call graph for this function:

◆ quit()

void ParticleSystem::quit ( )

Tear down all GPU resources and effect sub-systems.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render()

void ParticleSystem::render ( SDL_GPURenderPass *  pass,
SDL_GPUCommandBuffer *  cmd 
)

Issue all particle draw calls. Must be called INSIDE a render pass.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ribbonVertexCount()

uint32_t ParticleSystem::ribbonVertexCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdfReady()

bool ParticleSystem::sdfReady ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setScreenSize()

void ParticleSystem::setScreenSize ( float  w,
float  h 
)
inline

Set screen dimensions for HUD rendering. Call before render().

Here is the caller graph for this function:

◆ smokeCount()

uint32_t ParticleSystem::smokeCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ spawnBulletHole()

void ParticleSystem::spawnBulletHole ( glm::vec3  pos,
glm::vec3  normal,
WeaponType  wt 
)

Place a bullet-hole decal on a surface.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spawnBulletTracer()

void ParticleSystem::spawnBulletTracer ( glm::vec3  origin,
glm::vec3  dir,
float  range = 500.f 
)

Spawn a one-shot bullet-tracer streak (no ECS entity needed).

Parameters
originMuzzle world position (e.g. hip-fire offset from eye).
dirNormalised fire direction.
rangeStreak length in world units.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ spawnExplosion()

void ParticleSystem::spawnExplosion ( glm::vec3  pos,
float  blastRadius 
)

Spawn rocket explosion at pos.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spawnHitscanBeam()

void ParticleSystem::spawnHitscanBeam ( glm::vec3  origin,
glm::vec3  hitPos,
WeaponType  wt 
)

Spawn an instant energy beam from origin to hitPos.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spawnImpactEffect()

void ParticleSystem::spawnImpactEffect ( glm::vec3  pos,
glm::vec3  normal,
SurfaceType  surf,
WeaponType  wt 
)

Spawn spark burst + impact flash + bullet hole decal.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spawnProjectileTracer()

void ParticleSystem::spawnProjectileTracer ( entt::entity  e,
Registry reg 
)

Attach an oriented-capsule tracer to a fast-bullet projectile entity.

Here is the call graph for this function:

◆ spawnRibbonTrail()

void ParticleSystem::spawnRibbonTrail ( entt::entity  e,
Registry reg 
)

Attach a ribbon trail to a slow/arcing projectile entity (rocket).

◆ spawnSmoke()

void ParticleSystem::spawnSmoke ( glm::vec3  pos,
float  radius 
)

Spawn a smoke cloud at pos.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tracerCount()

uint32_t ParticleSystem::tracerCount ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void ParticleSystem::update ( float  dt,
const Camera cam,
Registry reg 
)

Simulate all effects. Called once per render frame (not per physics tick).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uploadToGpu()

void ParticleSystem::uploadToGpu ( SDL_GPUCommandBuffer *  cmd)

Upload all particle data to GPU. Must be called BEFORE render pass.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: