pub struct BodyState {
pub position: Vec2,
pub velocity: Vec2,
pub angle: f32,
pub angular_velocity: f32,
pub inv_mass: f32,
pub inv_inertia: f32,
pub impulse_accum: Vec2,
pub torque_accum: f32,
}Expand description
Minimal state the solver needs from a rigid body.
Fields§
§position: Vec2§velocity: Vec2§angle: f32§angular_velocity: f32§inv_mass: f32Inverse mass (0.0 for static bodies).
inv_inertia: f32Inverse moment of inertia (0.0 for static).
impulse_accum: Vec2Accumulated corrective impulse from constraints.
torque_accum: f32Implementations§
Source§impl BodyState
impl BodyState
pub fn new(position: Vec2, mass: f32, inertia: f32) -> Self
pub fn static_body(position: Vec2) -> Self
pub fn apply_impulse(&mut self, impulse: Vec2, contact_arm: Vec2)
pub fn apply_angular_impulse(&mut self, ang_impulse: f32)
pub fn is_static(&self) -> bool
pub fn kinetic_energy(&self) -> f32
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BodyState
impl RefUnwindSafe for BodyState
impl Send for BodyState
impl Sync for BodyState
impl Unpin for BodyState
impl UnsafeUnpin for BodyState
impl UnwindSafe for BodyState
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
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.