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
impl OwnedBody
pub fn id(&self) -> BodyId
pub fn world_id(&self) -> b2WorldId
pub fn try_world_id(&self) -> ApiResult<b2WorldId>
pub fn is_valid(&self) -> bool
pub fn try_is_valid(&self) -> ApiResult<bool>
pub fn position(&self) -> Vec2
pub fn try_position(&self) -> ApiResult<Vec2>
pub fn linear_velocity(&self) -> Vec2
pub fn try_linear_velocity(&self) -> ApiResult<Vec2>
pub fn angular_velocity(&self) -> f32
pub fn try_angular_velocity(&self) -> ApiResult<f32>
pub fn transform(&self) -> b2Transform
pub fn try_transform(&self) -> ApiResult<b2Transform>
pub fn transform_ex(&self) -> Transform
pub fn local_point<V: Into<Vec2>>(&self, world_point: V) -> Vec2
pub fn try_local_point<V: Into<Vec2>>(&self, world_point: V) -> ApiResult<Vec2>
pub fn world_point<V: Into<Vec2>>(&self, local_point: V) -> Vec2
pub fn try_world_point<V: Into<Vec2>>(&self, local_point: V) -> ApiResult<Vec2>
pub fn local_vector<V: Into<Vec2>>(&self, world_vector: V) -> Vec2
pub fn try_local_vector<V: Into<Vec2>>( &self, world_vector: V, ) -> ApiResult<Vec2>
pub fn world_vector<V: Into<Vec2>>(&self, local_vector: V) -> Vec2
pub fn try_world_vector<V: Into<Vec2>>( &self, local_vector: V, ) -> ApiResult<Vec2>
pub fn local_point_velocity<V: Into<Vec2>>(&self, local_point: V) -> Vec2
pub fn try_local_point_velocity<V: Into<Vec2>>( &self, local_point: V, ) -> ApiResult<Vec2>
pub fn world_point_velocity<V: Into<Vec2>>(&self, world_point: V) -> Vec2
pub fn try_world_point_velocity<V: Into<Vec2>>( &self, world_point: V, ) -> ApiResult<Vec2>
pub fn set_position_and_rotation<V: Into<Vec2>>( &mut self, p: V, angle_radians: f32, )
pub fn try_set_position_and_rotation<V: Into<Vec2>>( &mut self, p: V, angle_radians: f32, ) -> ApiResult<()>
pub fn set_linear_velocity<V: Into<Vec2>>(&mut self, v: V)
pub fn try_set_linear_velocity<V: Into<Vec2>>(&mut self, v: V) -> ApiResult<()>
pub fn set_angular_velocity(&mut self, w: f32)
pub fn try_set_angular_velocity(&mut self, w: f32) -> ApiResult<()>
pub fn set_target_transform( &mut self, target: Transform, time_step: f32, wake: bool, )
pub fn try_set_target_transform( &mut self, target: Transform, time_step: f32, wake: bool, ) -> ApiResult<()>
pub fn apply_force_to_center<V: Into<Vec2>>(&mut self, force: V, wake: bool)
pub fn try_apply_force_to_center<V: Into<Vec2>>( &mut self, force: V, wake: bool, ) -> ApiResult<()>
pub fn apply_force<F: Into<Vec2>, P: Into<Vec2>>( &mut self, force: F, point: P, wake: bool, )
pub fn try_apply_force<F: Into<Vec2>, P: Into<Vec2>>( &mut self, force: F, point: P, wake: bool, ) -> ApiResult<()>
pub fn apply_torque(&mut self, torque: f32, wake: bool)
pub fn try_apply_torque(&mut self, torque: f32, wake: bool) -> ApiResult<()>
pub fn clear_forces(&mut self)
pub fn try_clear_forces(&mut self) -> ApiResult<()>
pub fn apply_linear_impulse_to_center<V: Into<Vec2>>( &mut self, impulse: V, wake: bool, )
pub fn try_apply_linear_impulse_to_center<V: Into<Vec2>>( &mut self, impulse: V, wake: bool, ) -> ApiResult<()>
pub fn apply_linear_impulse<F: Into<Vec2>, P: Into<Vec2>>( &mut self, impulse: F, point: P, wake: bool, )
pub fn apply_angular_impulse(&mut self, impulse: f32, wake: bool)
pub fn try_apply_linear_impulse<F: Into<Vec2>, P: Into<Vec2>>( &mut self, impulse: F, point: P, wake: bool, ) -> ApiResult<()>
pub fn try_apply_angular_impulse( &mut self, impulse: f32, wake: bool, ) -> ApiResult<()>
pub fn mass(&self) -> f32
pub fn try_mass(&self) -> ApiResult<f32>
pub fn rotational_inertia(&self) -> f32
pub fn try_rotational_inertia(&self) -> ApiResult<f32>
pub fn local_center_of_mass(&self) -> Vec2
pub fn try_local_center_of_mass(&self) -> ApiResult<Vec2>
pub fn world_center_of_mass(&self) -> Vec2
pub fn try_world_center_of_mass(&self) -> ApiResult<Vec2>
pub fn mass_data(&self) -> MassData
pub fn try_mass_data(&self) -> ApiResult<MassData>
pub fn set_mass_data(&mut self, mass_data: MassData)
pub fn try_set_mass_data(&mut self, mass_data: MassData) -> ApiResult<()>
pub fn apply_mass_from_shapes(&mut self)
pub fn try_apply_mass_from_shapes(&mut self) -> ApiResult<()>
pub fn body_type(&self) -> BodyType
pub fn try_body_type(&self) -> ApiResult<BodyType>
pub fn set_body_type(&mut self, t: BodyType)
pub fn try_set_body_type(&mut self, t: BodyType) -> ApiResult<()>
pub fn gravity_scale(&self) -> f32
pub fn try_gravity_scale(&self) -> ApiResult<f32>
pub fn set_gravity_scale(&mut self, v: f32)
pub fn try_set_gravity_scale(&mut self, v: f32) -> ApiResult<()>
pub fn linear_damping(&self) -> f32
pub fn try_linear_damping(&self) -> ApiResult<f32>
pub fn set_linear_damping(&mut self, v: f32)
pub fn try_set_linear_damping(&mut self, v: f32) -> ApiResult<()>
pub fn angular_damping(&self) -> f32
pub fn try_angular_damping(&self) -> ApiResult<f32>
pub fn set_angular_damping(&mut self, v: f32)
pub fn try_set_angular_damping(&mut self, v: f32) -> ApiResult<()>
pub fn is_awake(&self) -> bool
pub fn try_is_awake(&self) -> ApiResult<bool>
pub fn set_awake(&mut self, awake: bool)
pub fn try_set_awake(&mut self, awake: bool) -> ApiResult<()>
pub fn is_enabled(&self) -> bool
pub fn try_is_enabled(&self) -> ApiResult<bool>
pub fn enable(&mut self)
pub fn try_enable(&mut self) -> ApiResult<()>
pub fn disable(&mut self)
pub fn try_disable(&mut self) -> ApiResult<()>
pub fn is_bullet(&self) -> bool
pub fn try_is_bullet(&self) -> ApiResult<bool>
pub fn set_bullet(&mut self, flag: bool)
pub fn try_set_bullet(&mut self, flag: bool) -> ApiResult<()>
pub fn set_name(&mut self, name: &str)
pub fn try_set_name(&mut self, name: &str) -> ApiResult<()>
pub fn name(&self) -> Option<String>
pub fn try_name(&self) -> ApiResult<Option<String>>
pub fn contact_data(&self) -> Vec<b2ContactData>
pub fn try_contact_data(&self) -> ApiResult<Vec<b2ContactData>>
Sourcepub unsafe fn set_user_data_ptr(&mut self, p: *mut c_void)
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.
Sourcepub unsafe fn try_set_user_data_ptr(&mut self, p: *mut c_void) -> ApiResult<()>
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.
pub fn user_data_ptr(&self) -> *mut c_void
pub fn try_user_data_ptr(&self) -> ApiResult<*mut c_void>
Sourcepub fn set_user_data<T: 'static>(&mut self, value: T)
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.
pub fn try_set_user_data<T: 'static>(&mut self, value: T) -> ApiResult<()>
Sourcepub fn clear_user_data(&mut self) -> bool
pub fn clear_user_data(&mut self) -> bool
Clear typed user data on this body. Returns whether any typed data was present.