pub struct MaterialTable {
pub default_friction_combine: CombineRule,
pub default_restitution_combine: CombineRule,
/* private fields */
}Expand description
Material pair lookup table
Fields§
§default_friction_combine: CombineRuleGlobal friction combine rule (fallback)
default_restitution_combine: CombineRuleGlobal restitution combine rule (fallback)
Implementations§
Source§impl MaterialTable
impl MaterialTable
Sourcepub fn register(&mut self, material: PhysicsMaterial) -> MaterialId
pub fn register(&mut self, material: PhysicsMaterial) -> MaterialId
Register a material, returns its ID
The material’s id field is overwritten with the assigned ID.
§Panics
Panics when the table already holds u16::MAX as usize + 1 (65,536)
materials, i.e. every MaterialId is in use (the default material
created by MaterialTable::new occupies ID 0, so at most 65,535
materials can be added after construction). Use
MaterialTable::try_register to handle that case without panicking.
Sourcepub fn try_register(
&mut self,
material: PhysicsMaterial,
) -> Result<MaterialId, PhysicsError>
pub fn try_register( &mut self, material: PhysicsMaterial, ) -> Result<MaterialId, PhysicsError>
Register a material, returns its ID, or an error when every
MaterialId is already in use.
IDs are assigned in registration order, so a table can hold at most
u16::MAX as usize + 1 (65,536) materials, including the default
material at ID 0. A successful call never reuses or overwrites an
existing ID.
§Errors
Returns PhysicsError::CapacityExceeded with limit = 65_536 when
the table already holds 65,536 materials. The table is left unchanged.
Sourcepub fn get(&self, id: MaterialId) -> &PhysicsMaterial
pub fn get(&self, id: MaterialId) -> &PhysicsMaterial
Get material by ID
Sourcepub fn set_pair_override(
&mut self,
mat_a: MaterialId,
mat_b: MaterialId,
friction: Fix128,
restitution: Fix128,
)
pub fn set_pair_override( &mut self, mat_a: MaterialId, mat_b: MaterialId, friction: Fix128, restitution: Fix128, )
Set a pair-specific override
Sourcepub fn combine(&self, mat_a: MaterialId, mat_b: MaterialId) -> CombinedMaterial
pub fn combine(&self, mat_a: MaterialId, mat_b: MaterialId) -> CombinedMaterial
Combine materials for a contact pair
Sourcepub fn register_metal(&mut self) -> MaterialId
pub fn register_metal(&mut self) -> MaterialId
Register a “Metal” material
Sourcepub fn register_wood(&mut self) -> MaterialId
pub fn register_wood(&mut self) -> MaterialId
Register a “Wood” material
Sourcepub fn register_rubber(&mut self) -> MaterialId
pub fn register_rubber(&mut self) -> MaterialId
Register a “Rubber” material
Sourcepub fn register_ice(&mut self) -> MaterialId
pub fn register_ice(&mut self) -> MaterialId
Register an “Ice” material
Sourcepub fn register_concrete(&mut self) -> MaterialId
pub fn register_concrete(&mut self) -> MaterialId
Register a “Concrete” material
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MaterialTable
impl RefUnwindSafe for MaterialTable
impl Send for MaterialTable
impl Sync for MaterialTable
impl Unpin for MaterialTable
impl UnsafeUnpin for MaterialTable
impl UnwindSafe for MaterialTable
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> 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 more