pub struct RapierContext {
    pub islands: IslandManager,
    pub broad_phase: BroadPhase,
    pub narrow_phase: NarrowPhase,
    pub bodies: RigidBodySet,
    pub colliders: ColliderSet,
    pub impulse_joints: ImpulseJointSet,
    pub multibody_joints: MultibodyJointSet,
    pub ccd_solver: CCDSolver,
    pub pipeline: PhysicsPipeline,
    pub query_pipeline: QueryPipeline,
    pub integration_parameters: IntegrationParameters,
    /* private fields */
}
Expand description

The Rapier context, containing all the state of the physics engine.

Fields

islands: IslandManager

The island manager, which detects what object is sleeping (not moving much) to reduce computations.

broad_phase: BroadPhase

The broad-phase, which detects potential contact pairs.

narrow_phase: NarrowPhase

The narrow-phase, which computes contact points, tests intersections, and maintain the contact and intersection graphs.

bodies: RigidBodySet

The set of rigid-bodies part of the simulation.

colliders: ColliderSet

The set of colliders part of the simulation.

impulse_joints: ImpulseJointSet

The set of impulse joints part of the simulation.

multibody_joints: MultibodyJointSet

The set of multibody joints part of the simulation.

ccd_solver: CCDSolver

The solver, which handles Continuous Collision Detection (CCD).

pipeline: PhysicsPipeline

The physics pipeline, which advance the simulation step by step.

query_pipeline: QueryPipeline

The query pipeline, which performs scene queries (ray-casting, point projection, etc.)

integration_parameters: IntegrationParameters

The integration parameters, controlling various low-level coefficient of the simulation.

Implementations

If the collider attached to entity is attached to a rigid-body, this returns the Entity containing that rigid-body.

Retrieve the Bevy entity the given Rapier collider (identified by its handle) is attached.

Retrieve the Bevy entity the given Rapier rigid-body (identified by its handle) is attached.

Advance the simulation, based on the given timestep mode.

This method makes sure tha the rigid-body positions have been propagated to their attached colliders, without having to perform a srimulation step.

Updates the state of the query pipeline, based on the collider positions known from the last timestep or the last call to self.propagate_modified_body_positions_to_colliders().

The map from entities to rigid-body handles.

The map from entities to collider handles.

The map from entities to impulse joint handles.

The map from entities to multibody joint handles.

Find the closest intersection between a ray and a set of collider.

Parameters
  • ray_origin: the starting point of the ray to cast.
  • ray_dir: the direction of the ray to cast.
  • max_toi: the maximum time-of-impact that can be reported by this cast. This effectively limits the length of the ray to ray.dir.norm() * max_toi. Use Real::MAX for an unbounded ray.
  • solid: if this is true an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
  • filter: set of rules used to determine which collider is taken into account by this scene query.

Find the closest intersection between a ray and a set of collider.

Parameters
  • ray_origin: the starting point of the ray to cast.
  • ray_dir: the direction of the ray to cast.
  • max_toi: the maximum time-of-impact that can be reported by this cast. This effectively limits the length of the ray to ray.dir.norm() * max_toi. Use Real::MAX for an unbounded ray.
  • solid: if this is true an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
  • filter: set of rules used to determine which collider is taken into account by this scene query.

Find the all intersections between a ray and a set of collider and passes them to a callback.

Parameters
  • ray_origin: the starting point of the ray to cast.
  • ray_dir: the direction of the ray to cast.
  • max_toi: the maximum time-of-impact that can be reported by this cast. This effectively limits the length of the ray to ray.dir.norm() * max_toi. Use Real::MAX for an unbounded ray.
  • solid: if this is true an impact at time 0.0 (i.e. at the ray origin) is returned if it starts inside of a shape. If this false then the ray will hit the shape’s boundary even if its starts inside of it.
  • filter: set of rules used to determine which collider is taken into account by this scene query.
  • callback: function executed on each collider for which a ray intersection has been found. There is no guarantees on the order the results will be yielded. If this callback returns false, this method will exit early, ignore any further raycast.

Gets the handle of up to one collider intersecting the given shape.

Parameters
  • shape_pos - The position of the shape used for the intersection test.
  • shape - The shape used for the intersection test.
  • filter: set of rules used to determine which collider is taken into account by this scene query.

Find the projection of a point on the closest collider.

Parameters
  • point - The point to project.
  • solid - If this is set to true then the collider shapes are considered to be plain (if the point is located inside of a plain shape, its projection is the point itself). If it is set to false the collider shapes are considered to be hollow (if the point is located inside of an hollow shape, it is projected on the shape’s boundary).
  • filter: set of rules used to determine which collider is taken into account by this scene query.

Find all the colliders containing the given point.

Parameters
  • point - The point used for the containment test.
  • filter: set of rules used to determine which collider is taken into account by this scene query.
  • callback - A function called with each collider with a shape containing the point. If this callback returns false, this method will exit early, ignore any further point projection.

Find the projection of a point on the closest collider.

The results include the ID of the feature hit by the point.

Parameters
  • point - The point to project.
  • solid - If this is set to true then the collider shapes are considered to be plain (if the point is located inside of a plain shape, its projection is the point itself). If it is set to false the collider shapes are considered to be hollow (if the point is located inside of an hollow shape, it is projected on the shape’s boundary).
  • filter: set of rules used to determine which collider is taken into account by this scene query.

Finds all entities of all the colliders with an AABB intersecting the given AABB.

Casts a shape at a constant linear velocity and retrieve the first collider it hits.

This is similar to ray-casting except that we are casting a whole shape instead of just a point (the ray origin). In the resulting TOI, witness and normal 1 refer to the world collider, and are in world space.

Parameters
  • shape_pos - The initial position of the shape to cast.
  • shape_vel - The constant velocity of the shape to cast (i.e. the cast direction).
  • shape - The shape to cast.
  • max_toi - The maximum time-of-impact that can be reported by this cast. This effectively limits the distance traveled by the shape to shapeVel.norm() * maxToi.
  • filter: set of rules used to determine which collider is taken into account by this scene query.

Retrieve all the colliders intersecting the given shape.

Parameters
  • shapePos - The position of the shape to test.
  • shapeRot - The orientation of the shape to test.
  • shape - The shape to test.
  • filter: set of rules used to determine which collider is taken into account by this scene query.
  • callback - A function called with the entities of each collider intersecting the shape.

All the contacts involving the non-sensor collider attached to the given entity.

All the intersections involving the collider attached to the given entity.

Intersections between two colliders are reported only if at least one of them is a sensor.

The contact pair involving two specific colliders.

If this returns None, there is no contact between the two colliders. If this returns Some, then there may be a contact between the two colliders. Check the result [ContactPair::has_any_active_collider] method to see if there is an actual contact.

The intersection pair involving two specific colliders (at least one being a sensor).

If this returns None or Some(false), then there is no intersection between the two colliders. If this returns Some(true), then there may be an intersection between the two colliders.

All the contact pairs detected during the last timestep.

All the intersection pairs detected during the last timestep.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Creates Self using data from the given [World]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more