pub struct Body {Show 15 fields
pub transform: Transform,
pub prev_transform: Transform,
pub velocity: BodyVelocity,
pub force: [Real; 3],
pub torque: [Real; 3],
pub mass: Real,
pub inv_mass: Real,
pub inertia: Real,
pub linear_damping: Real,
pub angular_damping: Real,
pub restitution: Real,
pub mode: BodyMode,
pub active: bool,
pub sleep_timer: Real,
pub generation: u32,
}Expand description
All simulation state for a single rigid body.
Fields§
§transform: TransformCurrent world-space transform.
prev_transform: TransformPrevious-frame transform (for CCD and interpolation).
velocity: BodyVelocityCurrent velocities.
force: [Real; 3]Accumulated force for this step (Newtons).
torque: [Real; 3]Accumulated torque for this step (N·m).
mass: RealBody mass (kg). 0 means static.
inv_mass: RealInverse mass. 0 means static/kinematic.
inertia: RealIsotropic moment of inertia scalar.
linear_damping: RealLinear damping coefficient.
angular_damping: RealAngular damping coefficient.
restitution: RealRestitution coefficient (bounciness).
mode: BodyModeSimulation mode.
active: boolWhether the body is currently active (participating in simulation).
sleep_timer: RealHow many consecutive steps the body has been below sleep thresholds.
generation: u32Generation counter (for handle validation).
Implementations§
Source§impl Body
impl Body
Sourcepub fn new_dynamic(position: [Real; 3], mass: Real) -> Self
pub fn new_dynamic(position: [Real; 3], mass: Real) -> Self
Create a dynamic body at the given position with given mass.
Sourcepub fn new_static(position: [Real; 3]) -> Self
pub fn new_static(position: [Real; 3]) -> Self
Create a static body at the given position.
Sourcepub fn apply_force(&mut self, force: [Real; 3])
pub fn apply_force(&mut self, force: [Real; 3])
Apply a force to the body (accumulates until cleared).
Sourcepub fn apply_torque(&mut self, torque: [Real; 3])
pub fn apply_torque(&mut self, torque: [Real; 3])
Apply a torque to the body.
Sourcepub fn apply_impulse_at(&mut self, impulse: [Real; 3], offset: [Real; 3])
pub fn apply_impulse_at(&mut self, impulse: [Real; 3], offset: [Real; 3])
Apply an impulse at a world-space offset (cross-product contributes to angular).
Sourcepub fn clear_forces(&mut self)
pub fn clear_forces(&mut self)
Clear accumulated forces and torques.
Sourcepub fn integrate_velocities(&mut self, gravity: [Real; 3], dt: Real)
pub fn integrate_velocities(&mut self, gravity: [Real; 3], dt: Real)
Integrate velocities from forces over dt (semi-implicit Euler).
Sourcepub fn integrate_positions(&mut self, dt: Real)
pub fn integrate_positions(&mut self, dt: Real)
Integrate positions from velocities over dt.
Sourcepub fn interpolated_transform(&self, alpha: Real) -> Transform
pub fn interpolated_transform(&self, alpha: Real) -> Transform
Return an interpolated transform at sub-step fraction α ∈ [0,1].
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
impl UnwindSafe for Body
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.