|
group2 0.1.0
CSE 125 Group 2
|
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 ®) |
| Attach an oriented-capsule tracer to a fast-bullet projectile entity. | |
| void | spawnRibbonTrail (entt::entity e, Registry ®) |
| 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 ®) |
| 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 |
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()
|
inline |
|
inline |
| void ParticleSystem::drawScreenText | ( | glm::vec2 | pixelPos, |
| std::string_view | text, | ||
| glm::vec4 | color, | ||
| float | pixelHeight | ||
| ) |
Queue screen-space HUD SDF text for this frame.
| pixelPos | Screen position in pixels (top-left origin). |
| text | UTF-8 string to render. |
| color | RGBA text colour. |
| pixelHeight | Glyph height in pixels. |
| void ParticleSystem::drawWorldText | ( | glm::vec3 | worldPos, |
| std::string_view | text, | ||
| glm::vec4 | color, | ||
| float | worldHeight | ||
| ) |
Queue world-space SDF text for this frame.
| worldPos | World-space anchor position. |
| text | UTF-8 string to render. |
| color | RGBA text colour. |
| worldHeight | Glyph height in world units. |
|
inline |
|
inline |
| bool ParticleSystem::init | ( | SDL_GPUDevice * | dev, |
| SDL_GPUTextureFormat | colorFmt, | ||
| SDL_GPUShaderFormat | shaderFmt | ||
| ) |
Initialise all effect sub-systems and the GPU renderer.
| dev | The SDL GPU device. |
| colorFmt | Swapchain colour format. |
| shaderFmt | Shader binary format (SPIRV or MSL). |
| void ParticleSystem::onExplosion | ( | const ExplosionEvent & | e | ) |
Handle an explosion event (spawns explosion and smoke).
| void ParticleSystem::onImpact | ( | const ProjectileImpactEvent & | e | ) |
Handle a projectile impact event (spawns sparks and decal).
| void ParticleSystem::onWeaponFired | ( | const WeaponFiredEvent & | e | ) |
Handle a weapon-fired event (spawns hitscan beam if applicable).
| void ParticleSystem::quit | ( | ) |
Tear down all GPU resources and effect sub-systems.
| void ParticleSystem::render | ( | SDL_GPURenderPass * | pass, |
| SDL_GPUCommandBuffer * | cmd | ||
| ) |
Issue all particle draw calls. Must be called INSIDE a render pass.
|
inline |
|
inline |
|
inline |
Set screen dimensions for HUD rendering. Call before render().
|
inline |
| void ParticleSystem::spawnBulletHole | ( | glm::vec3 | pos, |
| glm::vec3 | normal, | ||
| WeaponType | wt | ||
| ) |
Place a bullet-hole decal on a surface.
| void ParticleSystem::spawnBulletTracer | ( | glm::vec3 | origin, |
| glm::vec3 | dir, | ||
| float | range = 500.f |
||
| ) |
Spawn a one-shot bullet-tracer streak (no ECS entity needed).
| origin | Muzzle world position (e.g. hip-fire offset from eye). |
| dir | Normalised fire direction. |
| range | Streak length in world units. |
| void ParticleSystem::spawnExplosion | ( | glm::vec3 | pos, |
| float | blastRadius | ||
| ) |
Spawn rocket explosion at pos.
| void ParticleSystem::spawnHitscanBeam | ( | glm::vec3 | origin, |
| glm::vec3 | hitPos, | ||
| WeaponType | wt | ||
| ) |
Spawn an instant energy beam from origin to hitPos.
| void ParticleSystem::spawnImpactEffect | ( | glm::vec3 | pos, |
| glm::vec3 | normal, | ||
| SurfaceType | surf, | ||
| WeaponType | wt | ||
| ) |
Spawn spark burst + impact flash + bullet hole decal.
| void ParticleSystem::spawnProjectileTracer | ( | entt::entity | e, |
| Registry & | reg | ||
| ) |
Attach an oriented-capsule tracer to a fast-bullet projectile entity.
| void ParticleSystem::spawnRibbonTrail | ( | entt::entity | e, |
| Registry & | reg | ||
| ) |
Attach a ribbon trail to a slow/arcing projectile entity (rocket).
| void ParticleSystem::spawnSmoke | ( | glm::vec3 | pos, |
| float | radius | ||
| ) |
Spawn a smoke cloud at pos.
|
inline |
Simulate all effects. Called once per render frame (not per physics tick).
| void ParticleSystem::uploadToGpu | ( | SDL_GPUCommandBuffer * | cmd | ) |
Upload all particle data to GPU. Must be called BEFORE render pass.