Skip to main content

RigidBody3D

Struct RigidBody3D 

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

A 3D rigid body participating in the physics simulation.

Implementations§

Source§

impl RigidBody3D

Implements body creation and force management for RigidBody3D.

Source

pub fn new_dynamic(id: u64, position: Vector3D) -> RigidBody3D

Creates a new dynamic 3D rigid body with default mass and the given position.

§Arguments
  • u64 - The unique ID.
  • Vector3D - The initial position.
§Returns
  • RigidBody3D - The new body.
Source

pub fn new_static(id: u64, position: Vector3D) -> RigidBody3D

Creates a new static 3D rigid body at the given position with infinite mass.

§Arguments
  • u64 - The unique ID.
  • Vector3D - The position.
§Returns
  • RigidBody3D - The new static body.
Source

pub fn apply_force(&mut self, force: Vector3D)

Applies a force to the body’s force accumulator.

§Arguments
  • Vector3D - The force vector.
Source

pub fn apply_torque(&mut self, torque: Vector3D)

Applies a torque to the body’s torque accumulator.

§Arguments
  • Vector3D - The torque vector.
Source

pub fn apply_impulse(&mut self, impulse: Vector3D)

Applies an instantaneous impulse, directly changing velocity.

§Arguments
  • Vector3D - The impulse vector.
Source

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

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

pub fn update_collider(&mut self, collider: BodyCollider3D)

Attaches a 3D collider shape to this body.

§Arguments
  • BodyCollider3D - The collider to attach.
Source

pub fn bounding_box(&self) -> Option<AABB3D>

Returns the world-space 3D bounding box of the attached collider, if any.

§Returns
  • Option<AABB3D> - The bounding box, or None if no collider is attached.
Source§

impl RigidBody3D

Source

pub fn get_id(&self) -> u64

Source

pub fn get_mut_id(&mut self) -> &mut u64

Source

pub fn set_id(&mut self, val: u64) -> &mut Self

Source

pub fn get_position(&self) -> Vector3D

Source

pub fn set_position(&mut self, val: Vector3D) -> &mut Self

Source

pub fn get_velocity(&self) -> Vector3D

Source

pub fn set_velocity(&mut self, val: Vector3D) -> &mut Self

Source

pub fn get_rotation(&self) -> Quaternion

Source

pub fn set_rotation(&mut self, val: Quaternion) -> &mut Self

Source

pub fn get_angular_velocity(&self) -> Vector3D

Source

pub fn set_angular_velocity(&mut self, val: Vector3D) -> &mut Self

Source

pub fn get_mass(&self) -> f64

Source

pub fn set_mass(&mut self, val: f64) -> &mut Self

Source

pub fn get_restitution(&self) -> f64

Source

pub fn get_mut_restitution(&mut self) -> &mut f64

Source

pub fn set_restitution(&mut self, val: f64) -> &mut Self

Source

pub fn get_friction(&self) -> f64

Source

pub fn get_mut_friction(&mut self) -> &mut f64

Source

pub fn set_friction(&mut self, val: f64) -> &mut Self

Source

pub fn get_body_type(&self) -> BodyType

Source

pub fn get_mut_body_type(&mut self) -> &mut BodyType

Source

pub fn set_body_type(&mut self, val: BodyType) -> &mut Self

Source

pub fn get_collider(&self) -> Option<BodyCollider3D>

Source

pub fn try_get_collider(&self) -> Option<BodyCollider3D>

Source

pub fn get_mut_collider(&mut self) -> &mut Option<BodyCollider3D>

Source

pub fn set_collider(&mut self, val: Option<BodyCollider3D>) -> &mut Self

Source§

impl RigidBody3D

Source

pub fn new( id: u64, position: Vector3D, mass: f64, inverse_mass: f64, restitution: f64, friction: f64, body_type: BodyType, ) -> Self

Trait Implementations§

Source§

impl Clone for RigidBody3D

Source§

fn clone(&self) -> RigidBody3D

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 Debug for RigidBody3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RigidBody3D

Source§

fn eq(&self, other: &RigidBody3D) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RigidBody3D

Auto Trait Implementations§

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more