PhysicsProvider

Trait PhysicsProvider 

Source
pub trait PhysicsProvider: Send + Sync {
Show 16 methods // Required methods fn step(&mut self, dt: f32); fn set_gravity(&mut self, gravity: Vec3); fn add_body(&mut self, desc: RigidBodyDesc) -> RigidBodyHandle; fn remove_body(&mut self, handle: RigidBodyHandle); fn add_collider(&mut self, desc: ColliderDesc) -> ColliderHandle; fn remove_collider(&mut self, handle: ColliderHandle); fn get_body_transform(&self, handle: RigidBodyHandle) -> (Vec3, Quat); fn set_body_transform( &mut self, handle: RigidBodyHandle, pos: Vec3, rot: Quat, ); fn get_all_bodies(&self) -> Vec<RigidBodyHandle>; fn get_all_colliders(&self) -> Vec<ColliderHandle>; fn update_body_properties( &mut self, handle: RigidBodyHandle, desc: RigidBodyDesc, ); fn update_collider_properties( &mut self, handle: ColliderHandle, desc: ColliderDesc, ); fn get_debug_render_data(&self) -> (Vec<Vec3>, Vec<[u32; 2]>); fn cast_ray( &self, ray: &Ray, max_toi: f32, solid: bool, ) -> Option<RaycastHit>; fn get_collision_events(&self) -> Vec<CollisionEvent>; fn move_character( &self, collider: ColliderHandle, desired_translation: Vec3, options: &CharacterControllerOptions, ) -> (Vec3, bool);
}
Expand description

Interface contract for any physics engine implementation (e.g., Rapier).

Required Methods§

Source

fn step(&mut self, dt: f32)

Advances the simulation by dt seconds.

Source

fn set_gravity(&mut self, gravity: Vec3)

Sets the global gravity vector.

Source

fn add_body(&mut self, desc: RigidBodyDesc) -> RigidBodyHandle

Adds a rigid body to the simulation.

Source

fn remove_body(&mut self, handle: RigidBodyHandle)

Removes a rigid body from the simulation.

Source

fn add_collider(&mut self, desc: ColliderDesc) -> ColliderHandle

Adds a collider to the simulation.

Source

fn remove_collider(&mut self, handle: ColliderHandle)

Removes a collider from the simulation.

Source

fn get_body_transform(&self, handle: RigidBodyHandle) -> (Vec3, Quat)

Synchronizes the position and rotation of a rigid body.

Source

fn set_body_transform(&mut self, handle: RigidBodyHandle, pos: Vec3, rot: Quat)

Manually sets the position and rotation of a rigid body.

Source

fn get_all_bodies(&self) -> Vec<RigidBodyHandle>

Returns a list of all active rigid body handles.

Source

fn get_all_colliders(&self) -> Vec<ColliderHandle>

Returns a list of all active collider handles.

Source

fn update_body_properties( &mut self, handle: RigidBodyHandle, desc: RigidBodyDesc, )

Updates the properties of an existing rigid body.

Source

fn update_collider_properties( &mut self, handle: ColliderHandle, desc: ColliderDesc, )

Updates the properties of an existing collider.

Source

fn get_debug_render_data(&self) -> (Vec<Vec3>, Vec<[u32; 2]>)

Returns debug rendering lines from the physics engine.

Source

fn cast_ray(&self, ray: &Ray, max_toi: f32, solid: bool) -> Option<RaycastHit>

Casts a ray into the physics world and returns the closest hit.

Source

fn get_collision_events(&self) -> Vec<CollisionEvent>

Returns the collision events that occurred during the last step.

Source

fn move_character( &self, collider: ColliderHandle, desired_translation: Vec3, options: &CharacterControllerOptions, ) -> (Vec3, bool)

Resolves movement for a kinematic character controller. Returns the actual translation applied and whether the character is grounded.

Implementors§