|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Classes | |
| struct | Particle |
| One simulated point of a chain. More... | |
| struct | StepParams |
| What shapes one step. More... | |
| struct | Collider |
| A collider in world space: a sphere when a == b, else a capsule from a to b. More... | |
| class | SpringBoneSystem |
Functions | |
| 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 after a teleport. | |
| 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. | |
| 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 chain, so the strand ripples instead of swaying as one. | |
| void | step (std::vector< Particle > &chain, const StepParams ¶ms, const std::vector< Collider > &colliders, f32 dt) |
| Advances the chain by dt seconds. | |
Variables | |
| constexpr f32 | kReferenceStep = 1.0f / 60.0f |
| The rate the integration is stepped at: the stiffness and drag are per frame of this. | |
| constexpr f32 | kMaxStep = 1.0f / 20.0f |
| Longest stretch of time one call integrates; a stall must not become a lurch. | |
The factor gusts put on the wind's strength for a particle at a moment: a travelling wave down the chain, so the strand ripples instead of swaying as one.
Definition at line 57 of file SpringBoneSolver.cpp.
Moves p out of c if it is inside (radius widened by extra), returning whether it moved.
Definition at line 34 of file SpringBoneSolver.cpp.
References esengine::springbone::Collider::a, esengine::springbone::Collider::b, and esengine::springbone::Collider::radius.
| void esengine::springbone::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 after a teleport.
Definition at line 10 of file SpringBoneSolver.cpp.
Referenced by esengine::springbone::SpringBoneSystem::update().
| glm::quat esengine::springbone::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.
Definition at line 17 of file SpringBoneSolver.cpp.
Referenced by esengine::springbone::SpringBoneSystem::update().
| void esengine::springbone::step | ( | std::vector< Particle > & | chain, |
| const StepParams & | params, | ||
| const std::vector< Collider > & | colliders, | ||
| f32 | dt ) |
Advances the chain by dt seconds.
The root is held at its target. Every other particle keeps its velocity less drag, falls with gravity, and is pulled toward its target; then each is put back at its rest length from its parent (parents first, so a bone cannot stretch) and pushed out of every collider. The time is split into steps of at most one 60 Hz frame, so the result does not depend on the frame rate much.
Definition at line 116 of file SpringBoneSolver.cpp.
References kMaxStep, kReferenceStep, and esengine::springbone::StepParams::time.
Referenced by esengine::springbone::SpringBoneSystem::update().
|
constexpr |
Longest stretch of time one call integrates; a stall must not become a lurch.
Definition at line 60 of file SpringBoneSolver.hpp.
Referenced by step(), and esengine::springbone::SpringBoneSystem::update().
|
constexpr |
The rate the integration is stepped at: the stiffness and drag are per frame of this.
Definition at line 57 of file SpringBoneSolver.hpp.
Referenced by step().