63void reset(std::vector<Particle>& chain);
71void step(std::vector<Particle>& chain,
const StepParams& params,
const std::vector<Collider>& colliders,
f32 dt);
74glm::quat
shortestArc(
const glm::vec3& from,
const glm::vec3& to);
Math utilities and GLM configuration for ESEngine.
Core type definitions and utilities for ESEngine.
constexpr f32 kReferenceStep
The rate the integration is stepped at: the stiffness and drag are per frame of this.
bool pushOut(glm::vec3 &p, const Collider &c, f32 extra)
Moves p out of c if it is inside (radius widened by extra), returning whether it moved.
f32 gustFactor(f32 time, f32 frequency, f32 gust, i32 index)
The factor gusts put on the wind's strength for a particle at a moment: a travelling wave down the ch...
constexpr f32 kMaxStep
Longest stretch of time one call integrates; a stall must not become a lurch.
glm::quat shortestArc(const glm::vec3 &from, const glm::vec3 &to)
The shortest rotation that turns direction from onto direction to; identity when either has no length...
void step(std::vector< Particle > &chain, const StepParams ¶ms, const std::vector< Collider > &colliders, f32 dt)
Advances the chain by dt seconds.
void reset(std::vector< Particle > &chain)
Sets every particle to rest at its target: the state a chain starts in and the one it is put back in ...
std::int32_t i32
Signed 32-bit integer.
float f32
32-bit floating point
A collider in world space: a sphere when a == b, else a capsule from a to b.
One simulated point of a chain.
i32 parent
Index of the parent particle, -1 for the root, which the animation drives.
glm::vec3 position
Simulated world position, and where it was a step ago (Verlet's velocity).
f32 restLength
Its distance from its parent, which the chain keeps.
glm::vec3 target
Where the animation puts it this frame.
f32 time
Seconds on the chain's own clock at the start of the call; gusts are a function of it,...
glm::vec3 wind
Steady wind acceleration, world units a second squared.
f32 radius
The strand's own thickness, kept clear of colliders.
f32 windFrequency
Gusts a second.
f32 stiffness
Pull toward the animated pose per 60 Hz frame, 0 to 1.
f32 windGust
How far gusts swing the wind's strength, 0 to 1: 0.5 takes it between half and one and a half times w...
f32 drag
Share of speed lost per 60 Hz frame, 0 to 1.