pub struct RigidBody2D { /* private fields */ }Expand description
A 2D rigid body participating in the physics simulation.
Implementations§
Source§impl RigidBody2D
Implements body creation and force management for RigidBody2D.
impl RigidBody2D
Implements body creation and force management for RigidBody2D.
Sourcepub fn new_dynamic(id: u64, position: Vector2D) -> RigidBody2D
pub fn new_dynamic(id: u64, position: Vector2D) -> RigidBody2D
Sourcepub fn new_static(id: u64, position: Vector2D) -> RigidBody2D
pub fn new_static(id: u64, position: Vector2D) -> RigidBody2D
Sourcepub fn apply_force(&mut self, force: Vector2D)
pub fn apply_force(&mut self, force: Vector2D)
Sourcepub fn apply_impulse(&mut self, impulse: Vector2D)
pub fn apply_impulse(&mut self, impulse: Vector2D)
Applies an instantaneous impulse, directly changing velocity.
§Arguments
Vector2D- The impulse vector.
Sourcepub fn update_mass(&mut self, mass: f64)
pub fn update_mass(&mut self, mass: f64)
Sets the mass of the body, updating the inverse mass. A mass of 0 makes the body static (infinite mass).
§Arguments
f64- The new mass.
Sourcepub fn is_dynamic(&self) -> bool
pub fn is_dynamic(&self) -> bool
Returns true if this body is affected by forces and collisions.
§Returns
bool- True if the body is dynamic.
Sourcepub fn update_collider(&mut self, collider: BodyCollider)
pub fn update_collider(&mut self, collider: BodyCollider)
Sourcepub fn bounding_box(&self) -> Option<Rect>
pub fn bounding_box(&self) -> Option<Rect>
Returns the world-space bounding box of the attached collider, if any.
§Returns
Option<Rect>- The bounding box, orNoneif no collider is attached.
Source§impl RigidBody2D
impl RigidBody2D
pub fn get_id(&self) -> u64
pub fn get_mut_id(&mut self) -> &mut u64
pub fn set_id(&mut self, val: u64) -> &mut Self
pub fn get_position(&self) -> Vector2D
pub fn set_position(&mut self, val: Vector2D) -> &mut Self
pub fn get_velocity(&self) -> Vector2D
pub fn set_velocity(&mut self, val: Vector2D) -> &mut Self
pub fn get_rotation(&self) -> f64
pub fn set_rotation(&mut self, val: f64) -> &mut Self
pub fn get_angular_velocity(&self) -> f64
pub fn set_angular_velocity(&mut self, val: f64) -> &mut Self
pub fn get_mass(&self) -> f64
pub fn set_mass(&mut self, val: f64) -> &mut Self
pub fn get_restitution(&self) -> f64
pub fn get_mut_restitution(&mut self) -> &mut f64
pub fn set_restitution(&mut self, val: f64) -> &mut Self
pub fn get_friction(&self) -> f64
pub fn get_mut_friction(&mut self) -> &mut f64
pub fn set_friction(&mut self, val: f64) -> &mut Self
pub fn get_body_type(&self) -> BodyType
pub fn get_mut_body_type(&mut self) -> &mut BodyType
pub fn set_body_type(&mut self, val: BodyType) -> &mut Self
pub fn get_collider(&self) -> Option<BodyCollider>
pub fn try_get_collider(&self) -> Option<BodyCollider>
pub fn get_mut_collider(&mut self) -> &mut Option<BodyCollider>
pub fn set_collider(&mut self, val: Option<BodyCollider>) -> &mut Self
Trait Implementations§
Source§impl Clone for RigidBody2D
impl Clone for RigidBody2D
Source§fn clone(&self) -> RigidBody2D
fn clone(&self) -> RigidBody2D
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RigidBody2D
impl Debug for RigidBody2D
Source§impl PartialEq for RigidBody2D
impl PartialEq for RigidBody2D
Source§fn eq(&self, other: &RigidBody2D) -> bool
fn eq(&self, other: &RigidBody2D) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for RigidBody2D
Auto Trait Implementations§
impl Freeze for RigidBody2D
impl RefUnwindSafe for RigidBody2D
impl Send for RigidBody2D
impl Sync for RigidBody2D
impl Unpin for RigidBody2D
impl UnsafeUnpin for RigidBody2D
impl UnwindSafe for RigidBody2D
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
Mutably borrows from an owned value. Read more