Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-examples/2d/bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"

[dependencies]
bevy = "0.15"
bevy_rapier2d = "0.28"
bevy_rapier2d = "0.29"
23 changes: 16 additions & 7 deletions docs-examples/2d/bevy/examples/advanced_collision_detection2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ fn display_events(
// DOCUSAURUS: Events stop

// DOCUSAURUS: ContactGraph1 start
fn display_contact_info(rapier_context: ReadDefaultRapierContext, custom_info: Res<CustomInfo>) {
fn display_contact_info(rapier_context: ReadRapierContext, custom_info: Res<CustomInfo>) {
// Get the rapier context
let rapier_context = rapier_context.single();

let entity1 = custom_info.entity1; // A first entity with a collider attached.
let entity2 = custom_info.entity2; // A second entity with a collider attached.

Expand Down Expand Up @@ -119,9 +122,12 @@ fn display_contact_info(rapier_context: ReadDefaultRapierContext, custom_info: R

// DOCUSAURUS: ContactGraph2 start
fn display_contact_info_all_from_1_entity(
rapier_context: ReadDefaultRapierContext,
rapier_context: ReadRapierContext,
custom_info: Res<CustomInfo>,
) {
// Get the rapier context
let rapier_context = rapier_context.single();

let entity = custom_info.entity2; // An entity with a collider attached.

/* Iterate through all the contact pairs involving a specific collider. */
Expand All @@ -139,10 +145,10 @@ fn display_contact_info_all_from_1_entity(
// DOCUSAURUS: ContactGraph2 stop

// DOCUSAURUS: IntersectionGraph1 start
fn display_intersection_info(
rapier_context: ReadDefaultRapierContext,
custom_info: Res<CustomInfo>,
) {
fn display_intersection_info(rapier_context: ReadRapierContext, custom_info: Res<CustomInfo>) {
// Get the rapier context
let rapier_context = rapier_context.single();

let entity1 = custom_info.entity1; // A first entity with a collider attached.
let entity2 = custom_info.entity2; // A second entity with a collider attached.

Expand All @@ -158,9 +164,12 @@ fn display_intersection_info(

// DOCUSAURUS: IntersectionGraph2 start
fn display_intersection_info_all_from_1_entity(
rapier_context: ReadDefaultRapierContext,
rapier_context: ReadRapierContext,
custom_info: Res<CustomInfo>,
) {
// Get the rapier context
let rapier_context = rapier_context.single();

let entity = custom_info.entity2; // An entity with a collider attached.

/* Iterate through all the intersection pairs involving a specific collider. */
Expand Down
9 changes: 7 additions & 2 deletions docs-examples/2d/bevy/examples/multiple_contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ fn main() {
fn create_contexts(mut commands: Commands) {
for i in 0..N_CONTEXTS {
// DOCUSAURUS: MultipleContexts_new start
let mut context = commands.spawn(RapierContext::default());
let mut context = commands.spawn((
RapierContextColliders::default(),
RapierContextJoints::default(),
RapierContextSimulation::default(),
RapierRigidBodySet::default(),
));
// DOCUSAURUS: MultipleContexts_new stop
context.insert(ContextId(i));
if i == 0 {
Expand Down Expand Up @@ -81,7 +86,7 @@ fn change_context(
}

pub fn setup_physics(
context: Query<(Entity, &ContextId), With<RapierContext>>,
context: Query<(Entity, &ContextId), With<RapierContextSimulation>>,
mut commands: Commands,
) {
for (context_entity, id) in context.iter() {
Expand Down
25 changes: 20 additions & 5 deletions docs-examples/2d/bevy/examples/scene_queries2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ fn setup_physics(mut commands: Commands) {

// DOCUSAURUS: Raycast start
/* Cast a ray inside of a system. */
fn cast_ray(rapier_context: ReadDefaultRapierContext) {
fn cast_ray(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let ray_pos = Vec2::new(1.0, 2.0);
let ray_dir = Vec2::new(0.0, 1.0);
let max_toi = 4.0;
Expand Down Expand Up @@ -95,7 +98,10 @@ fn cast_ray(rapier_context: ReadDefaultRapierContext) {

// DOCUSAURUS: Shapecast start
/* Cast a shape inside of a system. */
fn cast_shape(rapier_context: ReadDefaultRapierContext) {
fn cast_shape(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let shape = Collider::cuboid(1.0, 2.0);
let shape_pos = Vec2::new(1.0, 2.0);
let shape_rot = 0.8;
Expand Down Expand Up @@ -123,7 +129,10 @@ fn cast_shape(rapier_context: ReadDefaultRapierContext) {

// DOCUSAURUS: PointProjection start
/* Project a point inside of a system. */
fn project_point(rapier_context: ReadDefaultRapierContext) {
fn project_point(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let point = Vec2::new(1.0, 2.0);
let solid = true;
let filter = QueryFilter::default();
Expand Down Expand Up @@ -151,7 +160,10 @@ fn project_point(rapier_context: ReadDefaultRapierContext) {

// DOCUSAURUS: IntersectionTest start
/* Test intersections inside of a system. */
fn test_intersections(rapier_context: ReadDefaultRapierContext) {
fn test_intersections(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let shape = Collider::cuboid(1.0, 2.0);
let shape_pos = Vec2::new(0.0, 1.0);
let shape_rot = 0.8;
Expand All @@ -176,10 +188,13 @@ fn test_intersections(rapier_context: ReadDefaultRapierContext) {
// DOCUSAURUS: QueryFilter start
/* Cast a ray inside of a system. */
fn cast_ray_filtered(
rapier_context: ReadDefaultRapierContext,
rapier_context: ReadRapierContext,
player_query: Query<Entity, With<Player>>,
custom_data_query: Query<&CustomData>,
) {
// Get the rapier context
let rapier_context = rapier_context.single();

let player_handle = player_query.single();
let ray_pos = Vec2::new(1.0, 2.0);
let ray_dir = Vec2::new(0.0, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion docs-examples/3d/bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"

[dependencies]
bevy = "0.15"
bevy_rapier3d = "0.28"
bevy_rapier3d = "0.29"
20 changes: 16 additions & 4 deletions docs-examples/3d/bevy/examples/scene_queries3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ fn setup_physics(mut commands: Commands) {

// DOCUSAURUS: Raycast start
/* Cast a ray inside of a system. */
fn cast_ray(rapier_context: ReadDefaultRapierContext) {
fn cast_ray(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let ray_pos = Vec3::new(1.0, 2.0, 3.0);
let ray_dir = Vec3::new(0.0, 1.0, 0.0);
let max_toi = 4.0;
Expand Down Expand Up @@ -89,7 +92,10 @@ fn cast_ray(rapier_context: ReadDefaultRapierContext) {

// DOCUSAURUS: Shapecast start
/* Cast a shape inside of a system. */
fn cast_shape(rapier_context: ReadDefaultRapierContext) {
fn cast_shape(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let shape = Collider::cuboid(1.0, 2.0, 3.0);
let shape_pos = Vec3::new(1.0, 2.0, 3.0);
let shape_rot = Quat::from_rotation_z(0.8);
Expand Down Expand Up @@ -117,7 +123,10 @@ fn cast_shape(rapier_context: ReadDefaultRapierContext) {

// DOCUSAURUS: PointProjection start
/* Project a point inside of a system. */
fn project_point(rapier_context: ReadDefaultRapierContext) {
fn project_point(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let point = Vec3::new(1.0, 2.0, 3.0);
let solid = true;
let filter = QueryFilter::default();
Expand Down Expand Up @@ -145,7 +154,10 @@ fn project_point(rapier_context: ReadDefaultRapierContext) {

// DOCUSAURUS: IntersectionTest start
/* Test intersections inside of a system. */
fn test_intersections(rapier_context: ReadDefaultRapierContext) {
fn test_intersections(rapier_context: ReadRapierContext) {
// Get the rapier context
let rapier_context = rapier_context.single();

let shape = Collider::cuboid(1.0, 2.0, 3.0);
let shape_pos = Vec3::new(0.0, 1.0, 2.0);
let shape_rot = Quat::from_rotation_z(0.8);
Expand Down
Loading