pub struct RigidBody {Show 18 fields
pub position: Vec3,
pub velocity: Vec3,
pub angular_vel: Vec3,
pub orientation: Quat,
pub mass: f32,
pub inv_mass: f32,
pub inv_inertia_local: Mat3,
pub force_accum: Vec3,
pub torque_accum: Vec3,
pub restitution: f32,
pub friction: f32,
pub linear_damping: f32,
pub angular_damping: f32,
pub sleep_state: SleepState,
pub collision_group: u32,
pub collision_mask: u32,
pub tag: u32,
pub shape: CollisionShape,
}Expand description
Full 3D rigid body.
Fields§
§position: Vec3World-space position.
velocity: Vec3Linear velocity.
angular_vel: Vec3Angular velocity (world space, in rad/s around each axis).
orientation: QuatOrientation quaternion.
mass: f32Total mass (kg). 0 = static.
inv_mass: f32Inverse mass (0 = static).
inv_inertia_local: Mat3Inverse inertia tensor in local body space.
force_accum: Vec3Accumulated forces this step (world space).
torque_accum: Vec3Accumulated torques this step (world space).
restitution: f32Coefficient of restitution.
friction: f32Friction coefficient.
linear_damping: f32Linear damping (0–1).
angular_damping: f32Angular damping (0–1).
sleep_state: SleepStateSleep / drowsy / awake state.
collision_group: u32Collision group mask.
collision_mask: u32Which groups this body collides with.
tag: u32User tag.
shape: CollisionShapeShape.
Implementations§
Source§impl RigidBody
impl RigidBody
Sourcepub fn dynamic(position: Vec3, mass: f32, shape: CollisionShape) -> Self
pub fn dynamic(position: Vec3, mass: f32, shape: CollisionShape) -> Self
Create a dynamic rigid body.
Sourcepub fn static_body(position: Vec3, shape: CollisionShape) -> Self
pub fn static_body(position: Vec3, shape: CollisionShape) -> Self
Create a static rigid body (inv_mass = 0, won’t move).
pub fn is_static(&self) -> bool
pub fn is_sleeping(&self) -> bool
Sourcepub fn apply_force(&mut self, force: Vec3)
pub fn apply_force(&mut self, force: Vec3)
Apply a force at center of mass.
Sourcepub fn apply_torque(&mut self, torque: Vec3)
pub fn apply_torque(&mut self, torque: Vec3)
Apply a torque.
Sourcepub fn apply_force_at_point(&mut self, force: Vec3, world_point: Vec3)
pub fn apply_force_at_point(&mut self, force: Vec3, world_point: Vec3)
Apply force at a world-space point (generates torque).
Sourcepub fn apply_linear_impulse(&mut self, impulse: Vec3)
pub fn apply_linear_impulse(&mut self, impulse: Vec3)
Apply an instantaneous linear impulse.
Sourcepub fn apply_angular_impulse(&mut self, impulse: Vec3)
pub fn apply_angular_impulse(&mut self, impulse: Vec3)
Apply an instantaneous angular impulse.
Sourcepub fn apply_impulse_at_point(&mut self, impulse: Vec3, world_point: Vec3)
pub fn apply_impulse_at_point(&mut self, impulse: Vec3, world_point: Vec3)
Apply an impulse at a world-space point.
Sourcepub fn clear_forces(&mut self)
pub fn clear_forces(&mut self)
Clear accumulated forces and torques.
Sourcepub fn inv_inertia_world(&self) -> Mat3
pub fn inv_inertia_world(&self) -> Mat3
Inverse inertia tensor in world space.
Sourcepub fn velocity_at_point(&self, world_point: Vec3) -> Vec3
pub fn velocity_at_point(&self, world_point: Vec3) -> Vec3
Velocity at a world-space point on the body.
Sourcepub fn kinetic_energy(&self) -> f32
pub fn kinetic_energy(&self) -> f32
Kinetic energy (linear + rotational).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RigidBody
impl RefUnwindSafe for RigidBody
impl Send for RigidBody
impl Sync for RigidBody
impl Unpin for RigidBody
impl UnsafeUnpin for RigidBody
impl UnwindSafe for RigidBody
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.