Skip to content

Commit 6a9d9d4

Browse files
committed
adapt to changes from dimforge/bevy_rapier#585
1 parent 1e631b7 commit 6a9d9d4

File tree

9 files changed

+58
-129
lines changed

9 files changed

+58
-129
lines changed

docs-examples/2d/bevy/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ edition = "2021"
77

88
[dependencies]
99
bevy = "0.14"
10-
bevy_rapier2d = "0.27"
10+
# bevy_rapier2d = "0.28"
11+
bevy_rapier2d = { path = "../../../../bevy_rapier/bevy_rapier2d" }

docs-examples/2d/bevy/examples/advanced_collision_detection2.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ fn display_events(
7474
// DOCUSAURUS: Events stop
7575

7676
// DOCUSAURUS: ContactGraph1 start
77-
fn display_contact_info(rapier_context: Res<RapierContext>, custom_info: Res<CustomInfo>) {
77+
fn display_contact_info(rapier_context: ReadRapierContext, custom_info: Res<CustomInfo>) {
7878
let entity1 = custom_info.entity1; // A first entity with a collider attached.
7979
let entity2 = custom_info.entity2; // A second entity with a collider attached.
80+
let rapier_context = rapier_context.single();
8081

8182
/* Find the contact pair, if it exists, between two colliders. */
8283
if let Some(contact_pair) = rapier_context.contact_pair(entity1, entity2) {
@@ -121,10 +122,11 @@ fn display_contact_info(rapier_context: Res<RapierContext>, custom_info: Res<Cus
121122

122123
// DOCUSAURUS: ContactGraph2 start
123124
fn display_contact_info_all_from_1_entity(
124-
rapier_context: Res<RapierContext>,
125+
rapier_context: ReadRapierContext,
125126
custom_info: Res<CustomInfo>,
126127
) {
127128
let entity = custom_info.entity2; // An entity with a collider attached.
129+
let rapier_context = rapier_context.single();
128130

129131
/* Iterate through all the contact pairs involving a specific collider. */
130132
for contact_pair in rapier_context.contact_pairs_with(entity) {
@@ -141,9 +143,10 @@ fn display_contact_info_all_from_1_entity(
141143
// DOCUSAURUS: ContactGraph2 stop
142144

143145
// DOCUSAURUS: IntersectionGraph1 start
144-
fn display_intersection_info(rapier_context: Res<RapierContext>, custom_info: Res<CustomInfo>) {
146+
fn display_intersection_info(rapier_context: ReadRapierContext, custom_info: Res<CustomInfo>) {
145147
let entity1 = custom_info.entity1; // A first entity with a collider attached.
146148
let entity2 = custom_info.entity2; // A second entity with a collider attached.
149+
let rapier_context = rapier_context.single();
147150

148151
/* Find the intersection pair, if it exists, between two colliders. */
149152
if rapier_context.intersection_pair(entity1, entity2) == Some(true) {
@@ -157,10 +160,11 @@ fn display_intersection_info(rapier_context: Res<RapierContext>, custom_info: Re
157160

158161
// DOCUSAURUS: IntersectionGraph2 start
159162
fn display_intersection_info_all_from_1_entity(
160-
rapier_context: Res<RapierContext>,
163+
rapier_context: ReadRapierContext,
161164
custom_info: Res<CustomInfo>,
162165
) {
163166
let entity = custom_info.entity2; // An entity with a collider attached.
167+
let rapier_context = rapier_context.single();
164168

165169
/* Iterate through all the intersection pairs involving a specific collider. */
166170
for (collider1, collider2, intersecting) in rapier_context.intersection_pairs_with(entity) {

docs-examples/2d/bevy/examples/scene_queries2.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bevy::{prelude::*, render::primitives::Aabb};
2-
use bevy_rapier2d::{parry::query::intersection_test, prelude::*};
2+
use bevy_rapier2d::prelude::*;
33

44
#[derive(PartialEq, Eq, Clone, Copy, Component)]
55
struct CustomData {
@@ -46,13 +46,15 @@ fn setup_physics(mut commands: Commands) {
4646

4747
// DOCUSAURUS: Raycast start
4848
/* Cast a ray inside of a system. */
49-
fn cast_ray(rapier_context: Res<RapierContext>) {
49+
fn cast_ray(rapier_context: ReadRapierContext) {
5050
let ray_pos = Vec2::new(1.0, 2.0);
5151
let ray_dir = Vec2::new(0.0, 1.0);
5252
let max_toi = 4.0;
5353
let solid = true;
5454
let filter = QueryFilter::default();
5555

56+
let rapier_context = rapier_context.single();
57+
5658
if let Some((entity, toi)) = rapier_context.cast_ray(ray_pos, ray_dir, max_toi, solid, filter) {
5759
// The first collider hit has the entity `entity` and it hit after
5860
// the ray travelled a distance equal to `ray_dir * toi`.
@@ -95,7 +97,7 @@ fn cast_ray(rapier_context: Res<RapierContext>) {
9597

9698
// DOCUSAURUS: Shapecast start
9799
/* Cast a shape inside of a system. */
98-
fn cast_shape(rapier_context: Res<RapierContext>) {
100+
fn cast_shape(rapier_context: ReadRapierContext) {
99101
let shape = Collider::cuboid(1.0, 2.0);
100102
let shape_pos = Vec2::new(1.0, 2.0);
101103
let shape_rot = 0.8;
@@ -107,6 +109,7 @@ fn cast_shape(rapier_context: Res<RapierContext>) {
107109
stop_at_penetration: false,
108110
compute_impact_geometry_on_penetration: false,
109111
};
112+
let rapier_context = rapier_context.single();
110113

111114
if let Some((entity, hit)) =
112115
rapier_context.cast_shape(shape_pos, shape_rot, shape_vel, &shape, options, filter)
@@ -123,11 +126,12 @@ fn cast_shape(rapier_context: Res<RapierContext>) {
123126

124127
// DOCUSAURUS: PointProjection start
125128
/* Project a point inside of a system. */
126-
fn project_point(rapier_context: Res<RapierContext>) {
129+
fn project_point(rapier_context: ReadRapierContext) {
127130
let point = Vec2::new(1.0, 2.0);
128131
let solid = true;
129132
let filter = QueryFilter::default();
130133

134+
let rapier_context = rapier_context.single();
131135
if let Some((entity, projection)) = rapier_context.project_point(point, solid, filter) {
132136
// The collider closest to the point has this `handle`.
133137
println!(
@@ -151,12 +155,13 @@ fn project_point(rapier_context: Res<RapierContext>) {
151155

152156
// DOCUSAURUS: IntersectionTest start
153157
/* Test intersections inside of a system. */
154-
fn test_intersections(rapier_context: Res<RapierContext>) {
158+
fn test_intersections(rapier_context: ReadRapierContext) {
155159
let shape = Collider::cuboid(1.0, 2.0);
156160
let shape_pos = Vec2::new(0.0, 1.0);
157161
let shape_rot = 0.8;
158162
let filter = QueryFilter::default();
159163

164+
let rapier_context = rapier_context.single();
160165
rapier_context.intersections_with_shape(shape_pos, shape_rot, &shape, filter, |entity| {
161166
println!("The entity {:?} intersects our shape.", entity);
162167
true // Return `false` instead if we want to stop searching for other colliders that contain this point.
@@ -176,11 +181,13 @@ fn test_intersections(rapier_context: Res<RapierContext>) {
176181
// DOCUSAURUS: QueryFilter start
177182
/* Cast a ray inside of a system. */
178183
fn cast_ray_filtered(
179-
rapier_context: Res<RapierContext>,
184+
rapier_context: ReadRapierContext,
180185
player_query: Query<Entity, With<Player>>,
181186
custom_data_query: Query<&CustomData>,
182187
) {
183188
let player_handle = player_query.single();
189+
let rapier_context = rapier_context.single();
190+
184191
let ray_pos = Vec2::new(1.0, 2.0);
185192
let ray_dir = Vec2::new(0.0, 1.0);
186193
let max_toi = 4.0;

docs-examples/3d/bevy/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ edition = "2021"
77

88
[dependencies]
99
bevy = "0.14"
10-
bevy_rapier3d = "0.27"
10+
# bevy_rapier3d = "0.27"
11+
bevy_rapier3d = { path = "../../../../bevy_rapier/bevy_rapier3d" }

docs-examples/3d/bevy/examples/scene_queries3.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use bevy::prelude::*;
22
use bevy::render::primitives::Aabb;
33
use bevy_rapier3d::prelude::*;
4-
use bevy_rapier3d::rapier::geometry::InteractionGroups;
54

65
fn main() {
76
App::new()
@@ -41,7 +40,9 @@ fn setup_physics(mut commands: Commands) {
4140

4241
// DOCUSAURUS: Raycast start
4342
/* Cast a ray inside of a system. */
44-
fn cast_ray(rapier_context: Res<RapierContext>) {
43+
fn cast_ray(rapier_context: ReadRapierContext) {
44+
let rapier_context = rapier_context.single();
45+
4546
let ray_pos = Vec3::new(1.0, 2.0, 3.0);
4647
let ray_dir = Vec3::new(0.0, 1.0, 0.0);
4748
let max_toi = 4.0;
@@ -90,7 +91,8 @@ fn cast_ray(rapier_context: Res<RapierContext>) {
9091

9192
// DOCUSAURUS: Shapecast start
9293
/* Cast a shape inside of a system. */
93-
fn cast_shape(rapier_context: Res<RapierContext>) {
94+
fn cast_shape(rapier_context: ReadRapierContext) {
95+
let rapier_context = rapier_context.single();
9496
let shape = Collider::cuboid(1.0, 2.0, 3.0);
9597
let shape_pos = Vec3::new(1.0, 2.0, 3.0);
9698
let shape_rot = Quat::from_rotation_z(0.8);
@@ -118,7 +120,8 @@ fn cast_shape(rapier_context: Res<RapierContext>) {
118120

119121
// DOCUSAURUS: PointProjection start
120122
/* Project a point inside of a system. */
121-
fn project_point(rapier_context: Res<RapierContext>) {
123+
fn project_point(rapier_context: ReadRapierContext) {
124+
let rapier_context = rapier_context.single();
122125
let point = Vec3::new(1.0, 2.0, 3.0);
123126
let solid = true;
124127
let filter = QueryFilter::default();
@@ -146,7 +149,8 @@ fn project_point(rapier_context: Res<RapierContext>) {
146149

147150
// DOCUSAURUS: IntersectionTest start
148151
/* Test intersections inside of a system. */
149-
fn test_intersections(rapier_context: Res<RapierContext>) {
152+
fn test_intersections(rapier_context: ReadRapierContext) {
153+
let rapier_context = rapier_context.single();
150154
let shape = Collider::cuboid(1.0, 2.0, 3.0);
151155
let shape_pos = Vec3::new(0.0, 1.0, 2.0);
152156
let shape_rot = Quat::from_rotation_z(0.8);

docs-examples/Cargo.lock

Lines changed: 6 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/user_guides/templates/rigid_body_gravity.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
44
Gravity is such a common force that it is implemented as a special case (even if it could easily be implemented
55
by the user using [force application](#forces-and-impulses)). <rapier>The gravity is given as an argument to the
66
`PhysicsPipeline::step` method and can be modified at will by simply modifying that argument.</rapier><bevy>The gravity
7-
is given by the field `RapierConfiguration::gravity` of the resource `RapierConfiguration` and can be modified at
7+
is given by the field `RapierConfiguration::gravity` of the component `RapierConfiguration` and can be modified at
88
will.</bevy><js>The gravity is given to the constructor of the physics `World`. It can be modified by modifying the
99
field `World.gravity`.</js> Note however that a change of gravity won't automatically wake-up the
1010
[sleeping bodies](#sleeping) so keep in mind that you may want to wake them up manually before a gravity change.

0 commit comments

Comments
 (0)