pub struct PhysicsWorld2D {
pub bodies: HashMap<BodyId, RigidBody2D>,
pub joints: Vec<Joint>,
pub gravity: Vec2,
pub substeps: u32,
pub last_contact_count: usize,
pub last_solve_time_us: u64,
pub allow_sleeping: bool,
/* private fields */
}Expand description
The main physics simulation world.
Fields§
§bodies: HashMap<BodyId, RigidBody2D>§joints: Vec<Joint>§gravity: Vec2§substeps: u32§last_contact_count: usize§last_solve_time_us: u64§allow_sleeping: boolImplementations§
Source§impl PhysicsWorld2D
impl PhysicsWorld2D
pub fn new() -> Self
pub fn zero_gravity() -> Self
pub fn add_body(&mut self, body: RigidBody2D) -> BodyId
pub fn remove_body(&mut self, id: BodyId)
pub fn add_joint(&mut self, joint: Joint) -> JointId
pub fn get_body(&self, id: BodyId) -> Option<&RigidBody2D>
pub fn get_body_mut(&mut self, id: BodyId) -> Option<&mut RigidBody2D>
Sourcepub fn raycast(&self, origin: Vec2, dir: Vec2, max_dist: f32) -> Vec<RayHit>
pub fn raycast(&self, origin: Vec2, dir: Vec2, max_dist: f32) -> Vec<RayHit>
Cast a ray through the world, returning all hits sorted by distance.
Sourcepub fn query_circle(&self, center: Vec2, radius: f32) -> Vec<BodyId>
pub fn query_circle(&self, center: Vec2, radius: f32) -> Vec<BodyId>
Query all bodies overlapping a circle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhysicsWorld2D
impl RefUnwindSafe for PhysicsWorld2D
impl Send for PhysicsWorld2D
impl Sync for PhysicsWorld2D
impl Unpin for PhysicsWorld2D
impl UnsafeUnpin for PhysicsWorld2D
impl UnwindSafe for PhysicsWorld2D
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> 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.