pub struct B2fixture<D: UserDataType> { /* private fields */ }Expand description
A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via b2_body::create_fixture.
Warning: you cannot reuse fixtures.
Implementations§
Source§impl<D: UserDataType> B2fixture<D>
impl<D: UserDataType> B2fixture<D>
Sourcepub fn get_type(&self) -> B2ShapeType
pub fn get_type(&self) -> B2ShapeType
Get the type of the child shape. You can use this to down cast to the concrete shape.
@return the shape type.
Sourcepub fn get_shape(&self) -> Rc<dyn B2shapeDynTrait>
pub fn get_shape(&self) -> Rc<dyn B2shapeDynTrait>
Get the child shape. You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms. Manipulating the shape may lead to non-physical behavior.
Sourcepub fn set_sensor(&mut self, sensor: bool)
pub fn set_sensor(&mut self, sensor: bool)
Set if this fixture is a sensor.
Sourcepub fn is_sensor(&self) -> bool
pub fn is_sensor(&self) -> bool
Is this fixture a sensor (non-solid)?
@return the true if the shape is a sensor.
Sourcepub fn set_filter_data(&mut self, filter: B2filter)
pub fn set_filter_data(&mut self, filter: B2filter)
Set the contact filtering data. This will not update contacts until the next time step when either parent body is active and awake. This automatically calls refilter.
Sourcepub fn get_filter_data(&self) -> B2filter
pub fn get_filter_data(&self) -> B2filter
Get the contact filtering data.
Sourcepub fn refilter(&mut self)
pub fn refilter(&mut self)
Call this if you want to establish collision that was previously disabled by B2contactFilter::should_collide.
Sourcepub fn get_body(&self) -> BodyPtr<D>
pub fn get_body(&self) -> BodyPtr<D>
Get the parent body of this fixture. This is None if the fixture is not attached.
@return the parent body.
Sourcepub fn get_next(&self) -> Option<FixturePtr<D>>
pub fn get_next(&self) -> Option<FixturePtr<D>>
Get the next fixture in the parent body’s fixture list.
@return the next shape.
Sourcepub fn get_user_data(&self) -> Option<D::Fixture>
pub fn get_user_data(&self) -> Option<D::Fixture>
Get the user data that was assigned in the fixture definition. Use this to store your application specific data.
Sourcepub fn set_user_data(&mut self, data: &D::Fixture)
pub fn set_user_data(&mut self, data: &D::Fixture)
Set the user data. Use this to store your application specific data.
Sourcepub fn test_point(&self, p: B2vec2) -> bool
pub fn test_point(&self, p: B2vec2) -> bool
Test a point for containment in this fixture.
p- a point in world coordinates.
Sourcepub fn ray_cast(
&self,
output: &mut B2rayCastOutput,
input: &B2rayCastInput,
child_index: i32,
) -> bool
pub fn ray_cast( &self, output: &mut B2rayCastOutput, input: &B2rayCastInput, child_index: i32, ) -> bool
Cast a ray against this shape.
output- the ray-cast results.input- the ray-cast input parameters.child_index- the child shape index (e.g. edge index)
Sourcepub fn get_mass_data(&self, mass_data: &mut B2massData)
pub fn get_mass_data(&self, mass_data: &mut B2massData)
Get the mass data for this fixture. The mass data is based on the density and the shape. The rotational inertia is about the shape’s origin. This operation may be expensive.
Sourcepub fn set_density(&mut self, density: f32)
pub fn set_density(&mut self, density: f32)
Set the density of this fixture. This will not automatically adjust the mass of the body. You must call b2_body::reset_mass_data to update the body’s mass.
Sourcepub fn get_density(&self) -> f32
pub fn get_density(&self) -> f32
Get the density of this fixture.
Sourcepub fn get_friction(&self) -> f32
pub fn get_friction(&self) -> f32
Get the coefficient of friction.
Sourcepub fn set_friction(&mut self, friction: f32)
pub fn set_friction(&mut self, friction: f32)
Set the coefficient of friction. This will not change the friction of existing contacts.
Sourcepub fn get_restitution(&self) -> f32
pub fn get_restitution(&self) -> f32
Get the coefficient of restitution.
Sourcepub fn set_restitution(&mut self, restitution: f32)
pub fn set_restitution(&mut self, restitution: f32)
Set the coefficient of restitution. This will not change the restitution of existing contacts.
Sourcepub fn get_restitution_threshold(&self) -> f32
pub fn get_restitution_threshold(&self) -> f32
Get the restitution velocity threshold.
Sourcepub fn set_restitution_threshold(&mut self, threshold: f32)
pub fn set_restitution_threshold(&mut self, threshold: f32)
Set the restitution threshold. This will not change the restitution threshold of existing contacts.