Skip to content

Commit

Permalink
update bevy_rapier to 0.28 + bevy to 0.15 (code only)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Jan 10, 2025
1 parent 59c61f0 commit 629c0bd
Show file tree
Hide file tree
Showing 19 changed files with 1,085 additions and 694 deletions.
4 changes: 2 additions & 2 deletions docs-examples/2d/bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = "0.14"
bevy_rapier2d = "0.27"
bevy = "0.15"
bevy_rapier2d = "0.28"
21 changes: 11 additions & 10 deletions docs-examples/2d/bevy/examples/advanced_collision_detection2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,22 @@ struct CustomInfo {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
/* Create the ground. */
let ground = commands
.spawn(Collider::cuboid(500.0, 50.0))
.insert(TransformBundle::from(Transform::from_xyz(0.0, -100.0, 0.0)))
.insert(Transform::from_xyz(0.0, -100.0, 0.0))
.id();
/* Create the bouncing ball. */
let ball1 = commands
.spawn(RigidBody::Dynamic)
.insert(ActiveEvents::CONTACT_FORCE_EVENTS)
.insert(Collider::ball(50.0))
.insert(Restitution::coefficient(0.7))
.insert(TransformBundle::from(Transform::from_xyz(
-55.0, 400.0, 0.0,
)))
.insert(Transform::from_xyz(-55.0, 400.0, 0.0))
.id();
commands.insert_resource(CustomInfo {
entity1: ground,
Expand All @@ -54,7 +52,7 @@ fn setup_physics(mut commands: Commands) {
.insert(ActiveEvents::COLLISION_EVENTS)
.insert(Collider::ball(50.0))
.insert(Restitution::coefficient(0.7))
.insert(TransformBundle::from(Transform::from_xyz(55.0, 300.0, 0.0)));
.insert(Transform::from_xyz(55.0, 300.0, 0.0));
}

// DOCUSAURUS: Events start
Expand All @@ -74,7 +72,7 @@ fn display_events(
// DOCUSAURUS: Events stop

// DOCUSAURUS: ContactGraph1 start
fn display_contact_info(rapier_context: Res<RapierContext>, custom_info: Res<CustomInfo>) {
fn display_contact_info(rapier_context: ReadDefaultRapierContext, custom_info: Res<CustomInfo>) {
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 @@ -121,7 +119,7 @@ fn display_contact_info(rapier_context: Res<RapierContext>, custom_info: Res<Cus

// DOCUSAURUS: ContactGraph2 start
fn display_contact_info_all_from_1_entity(
rapier_context: Res<RapierContext>,
rapier_context: ReadDefaultRapierContext,
custom_info: Res<CustomInfo>,
) {
let entity = custom_info.entity2; // An entity with a collider attached.
Expand All @@ -141,7 +139,10 @@ fn display_contact_info_all_from_1_entity(
// DOCUSAURUS: ContactGraph2 stop

// DOCUSAURUS: IntersectionGraph1 start
fn display_intersection_info(rapier_context: Res<RapierContext>, custom_info: Res<CustomInfo>) {
fn display_intersection_info(
rapier_context: ReadDefaultRapierContext,
custom_info: Res<CustomInfo>,
) {
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 @@ -157,7 +158,7 @@ fn display_intersection_info(rapier_context: Res<RapierContext>, custom_info: Re

// DOCUSAURUS: IntersectionGraph2 start
fn display_intersection_info_all_from_1_entity(
rapier_context: Res<RapierContext>,
rapier_context: ReadDefaultRapierContext,
custom_info: Res<CustomInfo>,
) {
let entity = custom_info.entity2; // An entity with a collider attached.
Expand Down
6 changes: 3 additions & 3 deletions docs-examples/2d/bevy/examples/basic_sim2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
/* Create the ground. */
commands
.spawn(Collider::cuboid(500.0, 50.0))
.insert(TransformBundle::from(Transform::from_xyz(0.0, -100.0, 0.0)));
.insert(Transform::from_xyz(0.0, -100.0, 0.0));

/* Create the bouncing ball. */
commands
.spawn(RigidBody::Dynamic)
.insert(Collider::ball(50.0))
.insert(Restitution::coefficient(0.7))
.insert(TransformBundle::from(Transform::from_xyz(0.0, 400.0, 0.0)));
.insert(Transform::from_xyz(0.0, 400.0, 0.0));
}

fn print_ball_altitude(positions: Query<&Transform, With<RigidBody>>) {
Expand Down
2 changes: 1 addition & 1 deletion docs-examples/2d/bevy/examples/character_controller2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics_more(mut commands: Commands) {
Expand Down
12 changes: 6 additions & 6 deletions docs-examples/2d/bevy/examples/colliders2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
Expand All @@ -31,7 +31,7 @@ fn setup_physics(mut commands: Commands) {
commands
.spawn(Collider::cuboid(1.0, 2.0))
.insert(Sensor)
.insert(TransformBundle::from(Transform::from_xyz(2.0, 0.0, 0.0)))
.insert(Transform::from_xyz(2.0, 0.0, 0.0))
.insert(Friction::coefficient(0.7))
.insert(Restitution::coefficient(0.3))
.insert(ColliderMassProperties::Density(2.0));
Expand All @@ -50,11 +50,11 @@ fn setup_physics(mut commands: Commands) {
children
.spawn(Collider::ball(0.5))
// Position the collider relative to the rigid-body.
.insert(TransformBundle::from(Transform::from_xyz(0.0, 0.0, -1.0)));
.insert(Transform::from_xyz(0.0, 0.0, -1.0));
children
.spawn(Collider::ball(0.5))
// Position the collider relative to the rigid-body.
.insert(TransformBundle::from(Transform::from_xyz(0.0, 0.0, 1.0)));
.insert(Transform::from_xyz(0.0, 0.0, 1.0));
});
// DOCUSAURUS: Creation2 stop

Expand Down Expand Up @@ -88,7 +88,7 @@ fn setup_physics(mut commands: Commands) {
/* Set the collider position when the collider is created. */
commands
.spawn(Collider::cuboid(0.5, 0.5))
.insert(TransformBundle::from(Transform::from_xyz(1.0, 2.0, 0.0)));
.insert(Transform::from_xyz(1.0, 2.0, 0.0));
// DOCUSAURUS: Position1 stop

// DOCUSAURUS: Position2 start
Expand All @@ -100,7 +100,7 @@ fn setup_physics(mut commands: Commands) {
.with_children(|children| {
children
.spawn(Collider::cuboid(0.5, 0.5))
.insert(TransformBundle::from(Transform::from_xyz(1.0, 2.0, 0.0)));
.insert(Transform::from_xyz(1.0, 2.0, 0.0));
});
// DOCUSAURUS: Position2 stop

Expand Down
2 changes: 1 addition & 1 deletion docs-examples/2d/bevy/examples/colliders_compound2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion docs-examples/2d/bevy/examples/joints2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
Expand Down
4 changes: 2 additions & 2 deletions docs-examples/2d/bevy/examples/rigid_bodies2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
Expand All @@ -38,7 +38,7 @@ fn setup_physics(mut commands: Commands) {
// DOCUSAURUS: Position1 start
commands
.spawn(RigidBody::Dynamic)
.insert(TransformBundle::from(Transform::from_xyz(0.0, 5.0, 0.0)))
.insert(Transform::from_xyz(0.0, 5.0, 0.0))
// DOCUSAURUS: Position1 stop
.insert(Velocity {
linvel: Vec2::new(1.0, 2.0),
Expand Down
2 changes: 1 addition & 1 deletion docs-examples/2d/bevy/examples/rigid_bodies_continued2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
Expand Down
22 changes: 11 additions & 11 deletions docs-examples/2d/bevy/examples/scene_queries2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::{prelude::*, render::primitives::Aabb};
use bevy_rapier2d::{parry::query::intersection_test, prelude::*};
use bevy::{math::bounding::Aabb2d, prelude::*};
use bevy_rapier2d::prelude::*;

#[derive(PartialEq, Eq, Clone, Copy, Component)]
struct CustomData {
Expand All @@ -26,27 +26,27 @@ struct Player;

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d::default());
}

fn setup_physics(mut commands: Commands) {
/* Create the ground. */
commands
.spawn(Collider::cuboid(500.0, 50.0))
.insert(TransformBundle::from(Transform::from_xyz(0.0, -100.0, 0.0)));
.insert(Transform::from_xyz(0.0, -100.0, 0.0));

/* Create the bouncing ball. */
commands
.spawn(RigidBody::Dynamic)
.insert(Player)
.insert(Collider::ball(50.0))
.insert(Restitution::coefficient(0.7))
.insert(TransformBundle::from(Transform::from_xyz(0.0, 400.0, 0.0)));
.insert(Transform::from_xyz(0.0, 400.0, 0.0));
}

// DOCUSAURUS: Raycast start
/* Cast a ray inside of a system. */
fn cast_ray(rapier_context: Res<RapierContext>) {
fn cast_ray(rapier_context: ReadDefaultRapierContext) {
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 +95,7 @@ fn cast_ray(rapier_context: Res<RapierContext>) {

// DOCUSAURUS: Shapecast start
/* Cast a shape inside of a system. */
fn cast_shape(rapier_context: Res<RapierContext>) {
fn cast_shape(rapier_context: ReadDefaultRapierContext) {
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 +123,7 @@ fn cast_shape(rapier_context: Res<RapierContext>) {

// DOCUSAURUS: PointProjection start
/* Project a point inside of a system. */
fn project_point(rapier_context: Res<RapierContext>) {
fn project_point(rapier_context: ReadDefaultRapierContext) {
let point = Vec2::new(1.0, 2.0);
let solid = true;
let filter = QueryFilter::default();
Expand Down Expand Up @@ -151,7 +151,7 @@ fn project_point(rapier_context: Res<RapierContext>) {

// DOCUSAURUS: IntersectionTest start
/* Test intersections inside of a system. */
fn test_intersections(rapier_context: Res<RapierContext>) {
fn test_intersections(rapier_context: ReadDefaultRapierContext) {
let shape = Collider::cuboid(1.0, 2.0);
let shape_pos = Vec2::new(0.0, 1.0);
let shape_rot = 0.8;
Expand All @@ -162,7 +162,7 @@ fn test_intersections(rapier_context: Res<RapierContext>) {
true // Return `false` instead if we want to stop searching for other colliders that contain this point.
});

let aabb = Aabb::from_min_max(Vec3::new(-1.0, -2.0, 0.0), Vec3::new(1.0, 2.0, 0.0));
let aabb = Aabb2d::new(Vec2::new(-1.0, -2.0), Vec2::new(1.0, 2.0));
rapier_context.colliders_with_aabb_intersecting_aabb(aabb, |entity| {
println!(
"The entity {:?} has an AABB intersecting our test AABB",
Expand All @@ -176,7 +176,7 @@ fn test_intersections(rapier_context: Res<RapierContext>) {
// DOCUSAURUS: QueryFilter start
/* Cast a ray inside of a system. */
fn cast_ray_filtered(
rapier_context: Res<RapierContext>,
rapier_context: ReadDefaultRapierContext,
player_query: Query<Entity, With<Player>>,
custom_data_query: Query<&CustomData>,
) {
Expand Down
4 changes: 2 additions & 2 deletions docs-examples/3d/bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = "0.14"
bevy_rapier3d = "0.27"
bevy = "0.15"
bevy_rapier3d = "0.28"
12 changes: 6 additions & 6 deletions docs-examples/3d/bevy/examples/basic_sim3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}

fn setup_physics(mut commands: Commands) {
/* Create the ground. */
commands
.spawn(Collider::cuboid(100.0, 0.1, 100.0))
.insert(TransformBundle::from(Transform::from_xyz(0.0, -2.0, 0.0)));
.insert(Transform::from_xyz(0.0, -2.0, 0.0));

/* Create the bouncing ball. */
commands
.spawn(RigidBody::Dynamic)
.insert(Collider::ball(0.5))
.insert(Restitution::coefficient(0.7))
.insert(TransformBundle::from(Transform::from_xyz(0.0, 4.0, 0.0)));
.insert(Transform::from_xyz(0.0, 4.0, 0.0));
}

fn print_ball_altitude(positions: Query<&Transform, With<RigidBody>>) {
Expand Down
18 changes: 8 additions & 10 deletions docs-examples/3d/bevy/examples/character_controller3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@ fn main() {

fn setup_graphics(mut commands: Commands) {
// Add a camera so we can see the debug-render.
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}

fn setup_physics_more(mut commands: Commands) {
/* Create the ground. */
commands
.spawn(Collider::cuboid(100.0, 0.1, 100.0))
.insert(TransformBundle::from(Transform::from_xyz(0.0, -0.9, 0.0)));
.insert(Transform::from_xyz(0.0, -0.9, 0.0));

// DOCUSAURUS: UpVector1 start
/* Character controller with the positive X axis as the up vector. */
commands
.spawn(RigidBody::KinematicPositionBased)
.insert(Collider::ball(0.5))
.insert(SpatialBundle::from_transform(
Transform::default().with_translation(Vec3::Z * -10f32),
))
.insert(Transform::default().with_translation(Vec3::Z * -10f32))
.insert(KinematicCharacterController {
up: Vec3::X,
..default()
Expand All @@ -52,15 +50,15 @@ fn setup_physics(mut commands: Commands) {
commands
.spawn(RigidBody::KinematicPositionBased)
.insert(Collider::ball(0.5))
.insert(SpatialBundle::default())
.insert(Transform::default())
.insert(KinematicCharacterController {
..KinematicCharacterController::default()
});
}

fn update_system(time: Res<Time>, mut controllers: Query<&mut KinematicCharacterController>) {
for mut controller in controllers.iter_mut() {
controller.translation = Some(Vec3::new(1.0, -5.0, -1.0) * time.delta_seconds());
controller.translation = Some(Vec3::new(1.0, -5.0, -1.0) * time.delta_secs());
}
}

Expand Down
Loading

0 comments on commit 629c0bd

Please sign in to comment.