pub struct PyRigidBody {Show 14 fields
pub id: u32,
pub mass: f64,
pub inertia: [f64; 3],
pub position: [f64; 3],
pub orientation: [f64; 4],
pub velocity: [f64; 3],
pub ang_vel: [f64; 3],
pub accumulated_force: [f64; 3],
pub accumulated_torque: [f64; 3],
pub sleeping: bool,
pub is_static: bool,
pub is_kinematic: bool,
pub linear_damping: f64,
pub angular_damping: f64,
}Expand description
A rigid body with full kinematic and dynamic state.
Positions and orientations are stored as plain arrays for easy FFI.
The orientation quaternion uses convention [x, y, z, w].
Fields§
§id: u32Unique handle for this body.
mass: f64Mass in kilograms. Zero means static.
inertia: [f64; 3]Diagonal inertia tensor [Ixx, Iyy, Izz].
position: [f64; 3]World-space position [x, y, z].
orientation: [f64; 4]Orientation quaternion [x, y, z, w].
velocity: [f64; 3]Linear velocity [vx, vy, vz].
ang_vel: [f64; 3]Angular velocity [wx, wy, wz].
accumulated_force: [f64; 3]Accumulated force buffer [fx, fy, fz].
accumulated_torque: [f64; 3]Accumulated torque buffer [tx, ty, tz].
sleeping: boolWhether the body is sleeping.
is_static: boolWhether the body is static (immovable).
is_kinematic: boolWhether the body is kinematic (user-controlled velocity).
linear_damping: f64Linear damping coefficient.
angular_damping: f64Angular damping coefficient.
Implementations§
Source§impl PyRigidBody
impl PyRigidBody
Sourcepub fn new_static(id: u32, position: [f64; 3]) -> Self
pub fn new_static(id: u32, position: [f64; 3]) -> Self
Create a static body (zero mass, immovable).
Sourcepub fn apply_force(&mut self, force: [f64; 3])
pub fn apply_force(&mut self, force: [f64; 3])
Apply a world-space force (accumulates until clear_forces is called).
Sourcepub fn apply_torque(&mut self, torque: [f64; 3])
pub fn apply_torque(&mut self, torque: [f64; 3])
Apply a torque about the body’s centre of mass.
Sourcepub fn apply_impulse(&mut self, impulse: [f64; 3])
pub fn apply_impulse(&mut self, impulse: [f64; 3])
Apply a linear impulse (instantaneous velocity change).
Sourcepub fn apply_angular_impulse(&mut self, ang_impulse: [f64; 3])
pub fn apply_angular_impulse(&mut self, ang_impulse: [f64; 3])
Apply an angular impulse (instantaneous angular velocity change).
Sourcepub fn clear_forces(&mut self)
pub fn clear_forces(&mut self)
Clear accumulated forces and torques.
Sourcepub fn integrate(&mut self, dt: f64, gravity: [f64; 3])
pub fn integrate(&mut self, dt: f64, gravity: [f64; 3])
Integrate the body forward by dt seconds (semi-implicit Euler).
Sourcepub fn kinetic_energy(&self) -> f64
pub fn kinetic_energy(&self) -> f64
Kinetic energy of this body.
Sourcepub fn linear_momentum(&self) -> [f64; 3]
pub fn linear_momentum(&self) -> [f64; 3]
Linear momentum [px, py, pz].
Trait Implementations§
Source§impl Clone for PyRigidBody
impl Clone for PyRigidBody
Source§fn clone(&self) -> PyRigidBody
fn clone(&self) -> PyRigidBody
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PyRigidBody
impl Debug for PyRigidBody
Source§impl<'de> Deserialize<'de> for PyRigidBody
impl<'de> Deserialize<'de> for PyRigidBody
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PyRigidBody
impl RefUnwindSafe for PyRigidBody
impl Send for PyRigidBody
impl Sync for PyRigidBody
impl Unpin for PyRigidBody
impl UnsafeUnpin for PyRigidBody
impl UnwindSafe for PyRigidBody
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.