bevy_rapier2d/dynamics/
mod.rs

1pub use self::generic_joint::*;
2pub use self::joint::*;
3pub use self::rigid_body::*;
4
5pub use self::fixed_joint::*;
6pub use self::prismatic_joint::*;
7pub use self::revolute_joint::*;
8pub use self::rope_joint::*;
9pub use self::spring_joint::*;
10
11use bevy::reflect::Reflect;
12use rapier::dynamics::CoefficientCombineRule as RapierCoefficientCombineRule;
13
14#[cfg(feature = "dim3")]
15pub use self::spherical_joint::*;
16
17mod generic_joint;
18mod joint;
19mod rigid_body;
20
21mod fixed_joint;
22mod prismatic_joint;
23mod revolute_joint;
24mod rope_joint;
25
26#[cfg(feature = "dim3")]
27mod spherical_joint;
28mod spring_joint;
29
30/// Rules used to combine two coefficients.
31///
32/// This is used to determine the effective restitution and
33/// friction coefficients for a contact between two colliders.
34/// Each collider has its combination rule of type
35/// `CoefficientCombineRule`. And the rule
36/// actually used is given by `max(first_combine_rule as usize, second_combine_rule as usize)`.
37///
38/// This only affects entities with a [`RigidBody`] component.
39#[derive(Copy, Clone, Debug, PartialEq, Eq, Reflect, Default)]
40#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
41pub enum CoefficientCombineRule {
42    #[default]
43    /// The two coefficients are averaged.
44    Average = 0,
45    /// The smallest coefficient is chosen.
46    Min,
47    /// The two coefficients are multiplied.
48    Multiply,
49    /// The greatest coefficient is chosen.
50    Max,
51}
52
53impl From<CoefficientCombineRule> for RapierCoefficientCombineRule {
54    fn from(combine_rule: CoefficientCombineRule) -> RapierCoefficientCombineRule {
55        match combine_rule {
56            CoefficientCombineRule::Average => RapierCoefficientCombineRule::Average,
57            CoefficientCombineRule::Min => RapierCoefficientCombineRule::Min,
58            CoefficientCombineRule::Multiply => RapierCoefficientCombineRule::Multiply,
59            CoefficientCombineRule::Max => RapierCoefficientCombineRule::Max,
60        }
61    }
62}