OwnedBody

Struct OwnedBody 

Source
pub struct OwnedBody { /* private fields */ }
Expand description

A RAII-owned body that is destroyed on drop.

This handle is not Send so it cannot be dropped on another thread. It keeps the underlying world alive via an internal reference-counted core.

Implementations§

Source§

impl OwnedBody

Source

pub fn id(&self) -> BodyId

Source

pub fn world_id(&self) -> b2WorldId

Source

pub fn try_world_id(&self) -> ApiResult<b2WorldId>

Source

pub fn is_valid(&self) -> bool

Source

pub fn try_is_valid(&self) -> ApiResult<bool>

Source

pub fn position(&self) -> Vec2

Source

pub fn try_position(&self) -> ApiResult<Vec2>

Source

pub fn linear_velocity(&self) -> Vec2

Source

pub fn try_linear_velocity(&self) -> ApiResult<Vec2>

Source

pub fn angular_velocity(&self) -> f32

Source

pub fn try_angular_velocity(&self) -> ApiResult<f32>

Source

pub fn transform(&self) -> b2Transform

Source

pub fn try_transform(&self) -> ApiResult<b2Transform>

Source

pub fn transform_ex(&self) -> Transform

Source

pub fn local_point<V: Into<Vec2>>(&self, world_point: V) -> Vec2

Source

pub fn try_local_point<V: Into<Vec2>>(&self, world_point: V) -> ApiResult<Vec2>

Source

pub fn world_point<V: Into<Vec2>>(&self, local_point: V) -> Vec2

Source

pub fn try_world_point<V: Into<Vec2>>(&self, local_point: V) -> ApiResult<Vec2>

Source

pub fn local_vector<V: Into<Vec2>>(&self, world_vector: V) -> Vec2

Source

pub fn try_local_vector<V: Into<Vec2>>( &self, world_vector: V, ) -> ApiResult<Vec2>

Source

pub fn world_vector<V: Into<Vec2>>(&self, local_vector: V) -> Vec2

Source

pub fn try_world_vector<V: Into<Vec2>>( &self, local_vector: V, ) -> ApiResult<Vec2>

Source

pub fn local_point_velocity<V: Into<Vec2>>(&self, local_point: V) -> Vec2

Source

pub fn try_local_point_velocity<V: Into<Vec2>>( &self, local_point: V, ) -> ApiResult<Vec2>

Source

pub fn world_point_velocity<V: Into<Vec2>>(&self, world_point: V) -> Vec2

Source

pub fn try_world_point_velocity<V: Into<Vec2>>( &self, world_point: V, ) -> ApiResult<Vec2>

Source

pub fn set_position_and_rotation<V: Into<Vec2>>( &mut self, p: V, angle_radians: f32, )

Source

pub fn try_set_position_and_rotation<V: Into<Vec2>>( &mut self, p: V, angle_radians: f32, ) -> ApiResult<()>

Source

pub fn set_linear_velocity<V: Into<Vec2>>(&mut self, v: V)

Source

pub fn try_set_linear_velocity<V: Into<Vec2>>(&mut self, v: V) -> ApiResult<()>

Source

pub fn set_angular_velocity(&mut self, w: f32)

Source

pub fn try_set_angular_velocity(&mut self, w: f32) -> ApiResult<()>

Source

pub fn set_target_transform( &mut self, target: Transform, time_step: f32, wake: bool, )

Source

pub fn try_set_target_transform( &mut self, target: Transform, time_step: f32, wake: bool, ) -> ApiResult<()>

Source

pub fn apply_force_to_center<V: Into<Vec2>>(&mut self, force: V, wake: bool)

Source

pub fn try_apply_force_to_center<V: Into<Vec2>>( &mut self, force: V, wake: bool, ) -> ApiResult<()>

Source

pub fn apply_force<F: Into<Vec2>, P: Into<Vec2>>( &mut self, force: F, point: P, wake: bool, )

Source

pub fn try_apply_force<F: Into<Vec2>, P: Into<Vec2>>( &mut self, force: F, point: P, wake: bool, ) -> ApiResult<()>

Source

pub fn apply_torque(&mut self, torque: f32, wake: bool)

Source

pub fn try_apply_torque(&mut self, torque: f32, wake: bool) -> ApiResult<()>

Source

pub fn clear_forces(&mut self)

Source

pub fn try_clear_forces(&mut self) -> ApiResult<()>

Source

pub fn apply_linear_impulse_to_center<V: Into<Vec2>>( &mut self, impulse: V, wake: bool, )

Source

pub fn try_apply_linear_impulse_to_center<V: Into<Vec2>>( &mut self, impulse: V, wake: bool, ) -> ApiResult<()>

Source

pub fn apply_linear_impulse<F: Into<Vec2>, P: Into<Vec2>>( &mut self, impulse: F, point: P, wake: bool, )

Source

pub fn apply_angular_impulse(&mut self, impulse: f32, wake: bool)

Source

pub fn try_apply_linear_impulse<F: Into<Vec2>, P: Into<Vec2>>( &mut self, impulse: F, point: P, wake: bool, ) -> ApiResult<()>

Source

pub fn try_apply_angular_impulse( &mut self, impulse: f32, wake: bool, ) -> ApiResult<()>

Source

pub fn mass(&self) -> f32

Source

pub fn try_mass(&self) -> ApiResult<f32>

Source

pub fn rotational_inertia(&self) -> f32

Source

pub fn try_rotational_inertia(&self) -> ApiResult<f32>

Source

pub fn local_center_of_mass(&self) -> Vec2

Source

pub fn try_local_center_of_mass(&self) -> ApiResult<Vec2>

Source

pub fn world_center_of_mass(&self) -> Vec2

Source

pub fn try_world_center_of_mass(&self) -> ApiResult<Vec2>

Source

pub fn mass_data(&self) -> MassData

Source

pub fn try_mass_data(&self) -> ApiResult<MassData>

Source

pub fn set_mass_data(&mut self, mass_data: MassData)

Source

pub fn try_set_mass_data(&mut self, mass_data: MassData) -> ApiResult<()>

Source

pub fn apply_mass_from_shapes(&mut self)

Source

pub fn try_apply_mass_from_shapes(&mut self) -> ApiResult<()>

Source

pub fn body_type(&self) -> BodyType

Source

pub fn try_body_type(&self) -> ApiResult<BodyType>

Source

pub fn set_body_type(&mut self, t: BodyType)

Source

pub fn try_set_body_type(&mut self, t: BodyType) -> ApiResult<()>

Source

pub fn gravity_scale(&self) -> f32

Source

pub fn try_gravity_scale(&self) -> ApiResult<f32>

Source

pub fn set_gravity_scale(&mut self, v: f32)

Source

pub fn try_set_gravity_scale(&mut self, v: f32) -> ApiResult<()>

Source

pub fn linear_damping(&self) -> f32

Source

pub fn try_linear_damping(&self) -> ApiResult<f32>

Source

pub fn set_linear_damping(&mut self, v: f32)

Source

pub fn try_set_linear_damping(&mut self, v: f32) -> ApiResult<()>

Source

pub fn angular_damping(&self) -> f32

Source

pub fn try_angular_damping(&self) -> ApiResult<f32>

Source

pub fn set_angular_damping(&mut self, v: f32)

Source

pub fn try_set_angular_damping(&mut self, v: f32) -> ApiResult<()>

Source

pub fn is_awake(&self) -> bool

Source

pub fn try_is_awake(&self) -> ApiResult<bool>

Source

pub fn set_awake(&mut self, awake: bool)

Source

pub fn try_set_awake(&mut self, awake: bool) -> ApiResult<()>

Source

pub fn is_enabled(&self) -> bool

Source

pub fn try_is_enabled(&self) -> ApiResult<bool>

Source

pub fn enable(&mut self)

Source

pub fn try_enable(&mut self) -> ApiResult<()>

Source

pub fn disable(&mut self)

Source

pub fn try_disable(&mut self) -> ApiResult<()>

Source

pub fn is_bullet(&self) -> bool

Source

pub fn try_is_bullet(&self) -> ApiResult<bool>

Source

pub fn set_bullet(&mut self, flag: bool)

Source

pub fn try_set_bullet(&mut self, flag: bool) -> ApiResult<()>

Source

pub fn set_name(&mut self, name: &str)

Source

pub fn try_set_name(&mut self, name: &str) -> ApiResult<()>

Source

pub fn name(&self) -> Option<String>

Source

pub fn try_name(&self) -> ApiResult<Option<String>>

Source

pub fn contact_data(&self) -> Vec<b2ContactData>

Source

pub fn try_contact_data(&self) -> ApiResult<Vec<b2ContactData>>

Source

pub fn as_id(&self) -> BodyId

Borrow the raw id for ID-style APIs.

Source

pub unsafe fn set_user_data_ptr(&mut self, p: *mut c_void)

Set an opaque user data pointer on this body.

§Safety

The caller must ensure that p is either null or points to a valid object for the entire time the body may access it, and that any lifetimes/aliasing rules are upheld. Box2D treats this as an opaque pointer and may store/use it across steps.

If typed user data was previously set via set_user_data, it will be cleared and dropped.

Source

pub unsafe fn try_set_user_data_ptr(&mut self, p: *mut c_void) -> ApiResult<()>

Set an opaque user data pointer on this body.

§Safety

Same safety contract as set_user_data_ptr.

If typed user data was previously set via set_user_data, it will be cleared and dropped.

Source

pub fn user_data_ptr(&self) -> *mut c_void

Source

pub fn try_user_data_ptr(&self) -> ApiResult<*mut c_void>

Source

pub fn set_user_data<T: 'static>(&mut self, value: T)

Set typed user data on this body.

This stores a Box<T> internally and sets Box2D’s user data pointer to it. The allocation is automatically freed when cleared or when the body is destroyed.

Source

pub fn try_set_user_data<T: 'static>(&mut self, value: T) -> ApiResult<()>

Source

pub fn clear_user_data(&mut self) -> bool

Clear typed user data on this body. Returns whether any typed data was present.

Source

pub fn try_clear_user_data(&mut self) -> ApiResult<bool>

Source

pub fn with_user_data<T: 'static, R>( &self, f: impl FnOnce(&T) -> R, ) -> Option<R>

Source

pub fn try_with_user_data<T: 'static, R>( &self, f: impl FnOnce(&T) -> R, ) -> ApiResult<Option<R>>

Source

pub fn with_user_data_mut<T: 'static, R>( &mut self, f: impl FnOnce(&mut T) -> R, ) -> Option<R>

Source

pub fn try_with_user_data_mut<T: 'static, R>( &mut self, f: impl FnOnce(&mut T) -> R, ) -> ApiResult<Option<R>>

Source

pub fn take_user_data<T: 'static>(&mut self) -> Option<T>

Source

pub fn try_take_user_data<T: 'static>(&mut self) -> ApiResult<Option<T>>

Source

pub fn into_id(self) -> BodyId

Disarm RAII and return the raw id for manual lifetime management.

Source

pub fn destroy(self)

Destroy the body immediately and disarm drop.

Trait Implementations§

Source§

impl Drop for OwnedBody

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.