Skip to main content

B2fixture

Struct B2fixture 

Source
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>

Source

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.

Source

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.

Source

pub fn set_sensor(&mut self, sensor: bool)

Set if this fixture is a sensor.

Source

pub fn is_sensor(&self) -> bool

Is this fixture a sensor (non-solid)?

@return the true if the shape is a sensor.

Source

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.

Source

pub fn get_filter_data(&self) -> B2filter

Get the contact filtering data.

Source

pub fn refilter(&mut self)

Call this if you want to establish collision that was previously disabled by B2contactFilter::should_collide.

Source

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.

Source

pub fn get_next(&self) -> Option<FixturePtr<D>>

Get the next fixture in the parent body’s fixture list.

@return the next shape.

Source

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.

Source

pub fn set_user_data(&mut self, data: &D::Fixture)

Set the user data. Use this to store your application specific data.

Source

pub fn test_point(&self, p: B2vec2) -> bool

Test a point for containment in this fixture.

  • p - a point in world coordinates.
Source

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)
Source

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.

Source

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.

Source

pub fn get_density(&self) -> f32

Get the density of this fixture.

Source

pub fn get_friction(&self) -> f32

Get the coefficient of friction.

Source

pub fn set_friction(&mut self, friction: f32)

Set the coefficient of friction. This will not change the friction of existing contacts.

Source

pub fn get_restitution(&self) -> f32

Get the coefficient of restitution.

Source

pub fn set_restitution(&mut self, restitution: f32)

Set the coefficient of restitution. This will not change the restitution of existing contacts.

Source

pub fn get_restitution_threshold(&self) -> f32

Get the restitution velocity threshold.

Source

pub fn set_restitution_threshold(&mut self, threshold: f32)

Set the restitution threshold. This will not change the restitution threshold of existing contacts.

Source

pub fn get_aabb(&self, child_index: i32) -> B2AABB

Get the fixture’s AABB. This AABB may be enlarge and/or stale. If you need a more accurate AABB, compute it using the shape and the body transform.

Trait Implementations§

Source§

impl<D: Clone + UserDataType> Clone for B2fixture<D>
where D::Fixture: Clone,

Source§

fn clone(&self) -> B2fixture<D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Default + UserDataType> Default for B2fixture<D>
where D::Fixture: Default,

Source§

fn default() -> B2fixture<D>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<D> Freeze for B2fixture<D>
where <D as UserDataType>::Fixture: Freeze,

§

impl<D> !RefUnwindSafe for B2fixture<D>

§

impl<D> !Send for B2fixture<D>

§

impl<D> !Sync for B2fixture<D>

§

impl<D> Unpin for B2fixture<D>
where <D as UserDataType>::Fixture: Unpin,

§

impl<D> UnsafeUnpin for B2fixture<D>

§

impl<D> !UnwindSafe for B2fixture<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.