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

Manages oriented-capsule tracers for fast-bullet projectile entities. More...

#include <TracerEffect.hpp>

Collaboration diagram for TracerEffect:
[legend]

Classes

struct  RuntimeState

Public Member Functions

void update (float dt, Registry &registry)
 Update all live tracers.
void attach (entt::entity e, Registry &registry)
 Attach a new tracer to a projectile entity.
void detach (entt::entity e)
 Detach the tracer from an entity (entity dying); tracer fades out.
void spawnRifleTracer (glm::vec3 origin, glm::vec3 dir, float range)
 Spawn a visual-only rifle bullet that travels along a hitscan path.
const TracerParticledata () const
uint32_t count () const

Private Types

enum class  RuntimeKind : uint8_t { None , Entity , RifleProjectile }

Private Member Functions

void killTracer (uint32_t idx)
void updateRifleTracer (uint32_t idx, float dt)

Private Attributes

ParticlePool< TracerParticle, k_maxTracerspool_
std::array< RuntimeState, k_maxTracersruntime_ {}
std::unordered_map< uint32_t, uint32_t > entityToIdx_

Static Private Attributes

static constexpr uint32_t k_maxTracers = 512
static constexpr float k_streakLength = 200.f
 Visual streak length in world units.
static constexpr float k_fadeTime = 0.15f
 Seconds to fade after entity death.
static constexpr float k_rifleVisualSpeed = 8000.f
static constexpr float k_rifleTrailLength = 140.f
static constexpr float k_rifleSpawnLead = 75.f
static constexpr float k_rifleRadius = 2.35f

Detailed Description

Manages oriented-capsule tracers for fast-bullet projectile entities.

Each frame, update() polls registry entities with TracerEmitter components and updates the tip/tail of their associated TracerParticle.

Member Enumeration Documentation

◆ RuntimeKind

enum class TracerEffect::RuntimeKind : uint8_t
strongprivate
Enumerator
None 
Entity 
RifleProjectile 

Member Function Documentation

◆ attach()

void TracerEffect::attach ( entt::entity e,
Registry & registry )

Attach a new tracer to a projectile entity.

Parameters
eEntity handle of the projectile.
registryECS registry to read Position and TracerEmitter from.
Here is the caller graph for this function:

◆ count()

uint32_t TracerEffect::count ( ) const
inlinenodiscard

◆ data()

const TracerParticle * TracerEffect::data ( ) const
inlinenodiscard

◆ detach()

void TracerEffect::detach ( entt::entity e)

Detach the tracer from an entity (entity dying); tracer fades out.

Parameters
eEntity handle being destroyed.

◆ killTracer()

void TracerEffect::killTracer ( uint32_t idx)
private
Here is the caller graph for this function:

◆ spawnRifleTracer()

void TracerEffect::spawnRifleTracer ( glm::vec3 origin,
glm::vec3 dir,
float range )

Spawn a visual-only rifle bullet that travels along a hitscan path.

Parameters
originMuzzle world position.
dirNormalized or normalizable fire direction.
rangeVisual travel distance in world units.

◆ update()

void TracerEffect::update ( float dt,
Registry & registry )

Update all live tracers.

Registry is used to read projectile positions.

Parameters
dtFrame delta time in seconds.
registryECS registry containing TracerEmitter entities.
Here is the call graph for this function:

◆ updateRifleTracer()

void TracerEffect::updateRifleTracer ( uint32_t idx,
float dt )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ entityToIdx_

std::unordered_map<uint32_t, uint32_t> TracerEffect::entityToIdx_
private

◆ k_fadeTime

float TracerEffect::k_fadeTime = 0.15f
staticconstexprprivate

Seconds to fade after entity death.

◆ k_maxTracers

uint32_t TracerEffect::k_maxTracers = 512
staticconstexprprivate

◆ k_rifleRadius

float TracerEffect::k_rifleRadius = 2.35f
staticconstexprprivate

◆ k_rifleSpawnLead

float TracerEffect::k_rifleSpawnLead = 75.f
staticconstexprprivate

◆ k_rifleTrailLength

float TracerEffect::k_rifleTrailLength = 140.f
staticconstexprprivate

◆ k_rifleVisualSpeed

float TracerEffect::k_rifleVisualSpeed = 8000.f
staticconstexprprivate

◆ k_streakLength

float TracerEffect::k_streakLength = 200.f
staticconstexprprivate

Visual streak length in world units.

◆ pool_

ParticlePool<TracerParticle, k_maxTracers> TracerEffect::pool_
private

◆ runtime_

std::array<RuntimeState, k_maxTracers> TracerEffect::runtime_ {}
private

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