Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::particle Namespace Reference

Namespaces

namespace  noise

Classes

struct  Particle
class  ParticlePool
struct  ScheduledBurst
 One burst of a schedule: count particles at time seconds after the emitter starts emitting. More...
struct  EmitterFrame
struct  SpawnSample
struct  StretchedQuad
 How a stretched particle's quad is laid along its velocity. More...
struct  ForceFieldInstance
struct  SdfColliderInstance
struct  CollisionQuery
struct  CollisionReply
struct  CollisionEvent
struct  CollisionStats
struct  GpuStep
 What one frame asks of a GPU-simulated emitter: how long to advance, how many to spawn and where in the ring they go. More...
struct  EmitterState
class  ParticleSystem

Typedefs

using EasingType = ecs::ParticleEasing
using RandomRange = std::function<f32(f32, f32)>
using ColorLut = std::array<glm::vec4, kColorLutSize>
using SizeLut = std::array<f32, kColorLutSize>

Functions

f32 unitHash (u32 v)
u32 burstsDue (const std::vector< ScheduledBurst > &schedule, f32 prev, f32 cur, f32 duration, bool looping)
 How many particles the schedule releases while the emitter's clock goes from prev to cur.
f32 applyEasing (EasingType type, f32 t)
glm::vec3 worldPointOf (const glm::vec3 &local, const EmitterFrame &f)
glm::vec3 worldDirOf (const glm::vec3 &local, const EmitterFrame &f)
 A local direction placed in the world — rotation ALONE.
glm::vec3 coneDirection (f32 halfAngle, const RandomRange &rand)
 A direction inside the cap of half-angle halfAngle about local +Y.
SpawnSample sampleShape (const ecs::ParticleEmitter &emitter, const RandomRange &rand)
glm::vec3 limitedVelocity (glm::vec3 velocity, f32 limit, f32 dampen, f32 dt)
 A particle's velocity after its speed limit has pulled it back.
glm::vec2 velocityOnScreen (const glm::vec3 &velocity, const glm::vec3 &towardViewer)
StretchedQuad stretchedQuad (glm::vec2 velocity, f32 rotation, f32 size, f32 lengthScale, f32 velocityScale)
static glm::vec4 sampleColorLut (const ColorLut &lut, f32 t)
static f32 sampleSizeLut (const SizeLut &lut, f32 t)
static void applyForceField (const ForceFieldInstance &ff, Particle &p, f32 dt)
f32 sdfDistance (const SdfColliderInstance &c, const glm::vec3 &point)
 How far a world point is outside a collider, negative inside; what the kernel's sdfOne answers.

Variables

constexpr int kColorLutSize = 32
constexpr int kMaxTrailPoints = 12

Typedef Documentation

◆ ColorLut

using esengine::particle::ColorLut = std::array<glm::vec4, kColorLutSize>

Definition at line 33 of file ParticleSystem.hpp.

◆ EasingType

◆ RandomRange

using esengine::particle::RandomRange = std::function<f32(f32, f32)>

A uniform draw in [a, b). Injected so a test can be deterministic.

Definition at line 28 of file ParticleShapes.hpp.

◆ SizeLut

Definition at line 35 of file ParticleSystem.hpp.

Function Documentation

◆ applyEasing()

◆ applyForceField()

◆ burstsDue()

u32 esengine::particle::burstsDue ( const std::vector< ScheduledBurst > & schedule,
f32 prev,
f32 cur,
f32 duration,
bool looping )
inline

How many particles the schedule releases while the emitter's clock goes from prev to cur.

A burst fires once per pass over its time: prev < time <= cur. A looping emitter repeats its schedule every duration, so each cycle the clock crossed in this step is checked. prev starts below zero, so a burst at 0 fires on the first step.

Definition at line 23 of file ParticleBursts.hpp.

Referenced by esengine::particle::ParticleSystem::update().

◆ coneDirection()

glm::vec3 esengine::particle::coneDirection ( f32 halfAngle,
const RandomRange & rand )
inline

A direction inside the cap of half-angle halfAngle about local +Y.

cos(theta) is what must be uniform, not theta: sampling the angle crowds the axis, the same mistake latitude/longitude makes at a sphere's poles. PI/2 is the +Y hemisphere and PI the whole sphere, so one function is Cone, Hemisphere and Sphere.

Definition at line 65 of file ParticleShapes.hpp.

References esengine::math::TWO_PI.

Referenced by sampleShape().

◆ limitedVelocity()

glm::vec3 esengine::particle::limitedVelocity ( glm::vec3 velocity,
f32 limit,
f32 dampen,
f32 dt )
inline

A particle's velocity after its speed limit has pulled it back.

The excess over the limit shrinks by dampen for every 1/60 s that passes, so the braking does not change with the frame rate: 1 removes the whole excess at once, a small value eases a fast particle down over several frames. A particle within the limit is left as it is.

Definition at line 20 of file ParticleSpeedLimit.hpp.

◆ sampleColorLut()

glm::vec4 esengine::particle::sampleColorLut ( const ColorLut & lut,
f32 t )
static

Definition at line 608 of file ParticleSystem.cpp.

References kColorLutSize, and esengine::math::lerp().

◆ sampleShape()

◆ sampleSizeLut()

f32 esengine::particle::sampleSizeLut ( const SizeLut & lut,
f32 t )
static

Definition at line 615 of file ParticleSystem.cpp.

References kColorLutSize, and esengine::math::lerp().

◆ sdfDistance()

f32 esengine::particle::sdfDistance ( const SdfColliderInstance & c,
const glm::vec3 & point )

◆ stretchedQuad()

StretchedQuad esengine::particle::stretchedQuad ( glm::vec2 velocity,
f32 rotation,
f32 size,
f32 lengthScale,
f32 velocityScale )
inline

Definition at line 34 of file ParticleStretch.hpp.

Referenced by esengine::ParticlePlugin::collect().

◆ unitHash()

f32 esengine::particle::unitHash ( u32 v)
inline

Definition at line 32 of file Particle.hpp.

Referenced by esengine::ParticlePlugin::collect().

◆ velocityOnScreen()

glm::vec2 esengine::particle::velocityOnScreen ( const glm::vec3 & velocity,
const glm::vec3 & towardViewer )
inline

Definition at line 24 of file ParticleStretch.hpp.

References esengine::towardViewer().

Referenced by esengine::ParticlePlugin::collect().

◆ worldDirOf()

glm::vec3 esengine::particle::worldDirOf ( const glm::vec3 & local,
const EmitterFrame & f )
inline

A local direction placed in the world — rotation ALONE.

Scaling an aim would skew a cone's half-angle and translating one would make it depend on where the emitter stands.

Definition at line 48 of file ParticleShapes.hpp.

References esengine::particle::EmitterFrame::rotation.

◆ worldPointOf()

glm::vec3 esengine::particle::worldPointOf ( const glm::vec3 & local,
const EmitterFrame & f )
inline

A local point placed in the world: scale sizes the shape, rotation aims it.

Definition at line 39 of file ParticleShapes.hpp.

References esengine::particle::EmitterFrame::position, esengine::particle::EmitterFrame::rotation, and esengine::particle::EmitterFrame::scale.

Variable Documentation

◆ kColorLutSize

◆ kMaxTrailPoints