pub struct ContactCache { /* private fields */ }Expand description
Per-step contact impulses, keyed by feature, for warm starting.
Usage is two calls per step around the solve: ContactCache::warm_start
before it to build the seed vector, ContactCache::store after it to
record the result. store replaces the whole table rather than merging, so
contacts that ended are dropped and the cache cannot grow without bound.
Implementations§
Source§impl ContactCache
impl ContactCache
Sourcepub const DEFAULT_CELL: f64 = 2e-3
pub const DEFAULT_CELL: f64 = 2e-3
Default quantization cell, in metres.
Coarse enough to absorb the sub-millimetre wander of a narrow-phase contact point on a resting face, fine enough to keep the corners of a centimetre-scale box distinct.
Sourcepub fn key(&self, state: &State, c: &Collision) -> ContactKey
pub fn key(&self, state: &State, c: &Collision) -> ContactKey
The feature key for one contact at the current state.
Sourcepub fn warm_start(&mut self, state: &State, contacts: &[Collision]) -> Vec<Vec3> ⓘ
pub fn warm_start(&mut self, state: &State, contacts: &[Collision]) -> Vec<Vec3> ⓘ
Seed impulses for contacts, in the same order, from the previous step.
Contacts with no cached match seed at zero, which is exactly the cold
start. The returned vector is what crate::solve_contacts_warm takes.
Sourcepub fn store(
&mut self,
state: &State,
contacts: &[Collision],
impulses: &[Vec3],
)
pub fn store( &mut self, state: &State, contacts: &[Collision], impulses: &[Vec3], )
Record the solved impulses for the next step’s warm start.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Forget every cached contact. Call after teleporting or resetting a state, where last step’s impulses are not a guess about this step.
Sourcepub fn stats(&self) -> (usize, usize)
pub fn stats(&self) -> (usize, usize)
(hits, misses) since construction or the last Self::clear.
A persistently low hit rate on a body that is visibly resting means the key is not identifying the feature — the cell size is likely wrong for the scale of the model.
Trait Implementations§
Source§impl Clone for ContactCache
impl Clone for ContactCache
Source§fn clone(&self) -> ContactCache
fn clone(&self) -> ContactCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more