group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
TracerEffect.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
9
10#include <glm/glm.hpp>
11#include <unordered_map>
12
18{
19public:
23 void update(float dt, Registry& registry);
24
28 void attach(entt::entity e, Registry& registry);
29
32 void detach(entt::entity e);
33
38 void spawnFree(glm::vec3 tip, glm::vec3 tail, float lifetime = 0.12f);
39
40 [[nodiscard]] const TracerParticle* data() const { return pool_.rawData(); }
41 [[nodiscard]] uint32_t count() const { return pool_.liveCount(); }
42
43private:
45
46 // Maps entity -> index into pool (for fast detach / per-entity update)
47 std::unordered_map<uint32_t, uint32_t> entityToIdx_;
48
49 static constexpr float k_streakLength = 200.f;
50 static constexpr float k_fadeTime = 0.15f;
51};
Fixed-capacity particle pool with O(1) swap-remove.
GPU-uploadable particle structs for all effect categories.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
Manages oriented-capsule tracers for fast-bullet projectile entities.
Definition TracerEffect.hpp:18
const TracerParticle * data() const
Definition TracerEffect.hpp:40
void update(float dt, Registry &registry)
Update all live tracers.
Definition TracerEffect.cpp:64
void spawnFree(glm::vec3 tip, glm::vec3 tail, float lifetime=0.12f)
Spawn a standalone one-shot tracer streak not tied to any ECS entity.
Definition TracerEffect.cpp:36
void attach(entt::entity e, Registry &registry)
Attach a new tracer to a projectile entity.
Definition TracerEffect.cpp:10
void detach(entt::entity e)
Detach the tracer from an entity (entity dying); tracer fades out.
Definition TracerEffect.cpp:51
uint32_t count() const
Definition TracerEffect.hpp:41
Fixed-capacity particle pool with O(1) swap-remove.
Definition ParticlePool.hpp:22
const T * rawData() const
Pointer to the contiguous live data for GPU upload.
Definition ParticlePool.hpp:48
uint32_t liveCount() const
Definition ParticlePool.hpp:49
Oriented capsule streak for fast-bullet tracers (R301 style).
Definition ParticleTypes.hpp:23