pub struct PhysicsObject {
pub position: Vec3,
pub velocity: Vec3,
pub angular_velocity: f32,
pub mass: f32,
pub restitution: f32,
pub friction: f32,
pub shape: CollisionShape,
pub is_static: bool,
pub is_trigger: bool,
pub collision_layer: u32,
/* private fields */
}Expand description
A physics object within the arena world.
Fields§
§position: Vec3§velocity: Vec3§angular_velocity: f32§mass: f32§restitution: f32§friction: f32§shape: CollisionShape§is_static: bool§is_trigger: bool§collision_layer: u32Implementations§
Source§impl PhysicsObject
impl PhysicsObject
Sourcepub fn new(position: Vec3, mass: f32, shape: CollisionShape) -> Self
pub fn new(position: Vec3, mass: f32, shape: CollisionShape) -> Self
Create a new dynamic physics object.
Sourcepub fn new_static(position: Vec3, shape: CollisionShape) -> Self
pub fn new_static(position: Vec3, shape: CollisionShape) -> Self
Create a static physics object (infinite mass, no movement).
Sourcepub fn new_trigger(position: Vec3, shape: CollisionShape) -> Self
pub fn new_trigger(position: Vec3, shape: CollisionShape) -> Self
Create a trigger volume (no collision response, fires events).
Sourcepub fn world_aabb(&self) -> AABB
pub fn world_aabb(&self) -> AABB
Compute world-space AABB.
Sourcepub fn apply_force(&mut self, force: Vec2)
pub fn apply_force(&mut self, force: Vec2)
Apply a force (accumulated, applied during integration).
Sourcepub fn apply_torque(&mut self, torque: f32)
pub fn apply_torque(&mut self, torque: f32)
Apply a torque.
Sourcepub fn apply_impulse(&mut self, impulse: Vec2)
pub fn apply_impulse(&mut self, impulse: Vec2)
Apply an impulse at the center of mass.
Sourcepub fn apply_impulse_at(&mut self, impulse: Vec2, contact_offset: Vec2)
pub fn apply_impulse_at(&mut self, impulse: Vec2, contact_offset: Vec2)
Apply an impulse at a contact point.
Trait Implementations§
Source§impl Clone for PhysicsObject
impl Clone for PhysicsObject
Source§fn clone(&self) -> PhysicsObject
fn clone(&self) -> PhysicsObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PhysicsObject
impl RefUnwindSafe for PhysicsObject
impl Send for PhysicsObject
impl Sync for PhysicsObject
impl Unpin for PhysicsObject
impl UnsafeUnpin for PhysicsObject
impl UnwindSafe for PhysicsObject
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.