pub enum CoefficientCombineRule {
Average = 0,
Min = 1,
Multiply = 2,
Max = 3,
ClampedSum = 4,
GeometricMean = 5,
}Expand description
How to combine friction/restitution values when two colliders touch.
When two colliders with different friction (or restitution) values collide, Rapier needs to decide what the effective friction/restitution should be. Each collider has a combine rule, and the “stronger” rule wins (GeometricMean > ClampedSum > Max > Multiply > Min > Average).
§Combine Rules
Most games use Average (the default) and never change this.
- Average (default):
(friction1 + friction2) / 2- Balanced, intuitive - Min:
min(friction1, friction2).abs()- “Slippery wins” (ice on any surface = ice) - Multiply:
friction1 × friction2- Both must be high for high friction - Max:
max(friction1, friction2)- “Sticky wins” (rubber on any surface = rubber) - ClampedSum:
sum(friction1, friction2).clamp(0, 1)- Sum of both frictions, clamped to range 0, 1. - GeometricMean:
sqrt(friction1 × friction2)- Between Multiply and Average; zero if either is zero.
§Example
// Ice collider that makes everything slippery
let ice = ColliderBuilder::cuboid(10.0, 0.1, 10.0)
.friction(0.0)
.friction_combine_rule(CoefficientCombineRule::Min) // Ice wins!
.build();§Priority System
If colliders disagree on rules, the “higher” one wins: GeometricMean > ClampedSum > Max > Multiply > Min > Average
Variants§
Average = 0
Average the two values (default, most common).
Min = 1
Use the smaller value (“slippery/soft wins”).
Multiply = 2
Multiply the two values (both must be high).
Max = 3
Use the larger value (“sticky/bouncy wins”).
ClampedSum = 4
The clamped sum of the two coefficients.
GeometricMean = 5
The square root of the product of the two values.
A common convention in other engines (e.g. Bullet, PhysX): stricter than Average (either value being zero results in zero) but less aggressive than Multiply for values below 1.
Trait Implementations§
Source§impl Clone for CoefficientCombineRule
impl Clone for CoefficientCombineRule
Source§fn clone(&self) -> CoefficientCombineRule
fn clone(&self) -> CoefficientCombineRule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CoefficientCombineRule
Source§impl Debug for CoefficientCombineRule
impl Debug for CoefficientCombineRule
Source§impl Default for CoefficientCombineRule
impl Default for CoefficientCombineRule
Source§fn default() -> CoefficientCombineRule
fn default() -> CoefficientCombineRule
impl Eq for CoefficientCombineRule
Source§impl Ord for CoefficientCombineRule
impl Ord for CoefficientCombineRule
Source§fn cmp(&self, other: &CoefficientCombineRule) -> Ordering
fn cmp(&self, other: &CoefficientCombineRule) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for CoefficientCombineRule
impl PartialEq for CoefficientCombineRule
Source§fn eq(&self, other: &CoefficientCombineRule) -> bool
fn eq(&self, other: &CoefficientCombineRule) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for CoefficientCombineRule
impl PartialOrd for CoefficientCombineRule
impl StructuralPartialEq for CoefficientCombineRule
Auto Trait Implementations§
impl Freeze for CoefficientCombineRule
impl RefUnwindSafe for CoefficientCombineRule
impl Send for CoefficientCombineRule
impl Sync for CoefficientCombineRule
impl Unpin for CoefficientCombineRule
impl UnsafeUnpin for CoefficientCombineRule
impl UnwindSafe for CoefficientCombineRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSync for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.