From f0bbfc6c3adf28e8700c6337dbf50956db0faab1 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sat, 19 Sep 2020 22:49:18 -0600 Subject: [PATCH 1/4] Attempt to update for Bevy 0.2 --- bevy_rapier2d/Cargo.toml | 2 +- bevy_rapier2d/examples/boxes2.rs | 6 +++--- bevy_rapier2d/examples/events2.rs | 6 +++--- bevy_rapier2d/examples/joints2.rs | 6 +++--- bevy_rapier3d/Cargo.toml | 2 +- bevy_rapier3d/examples/boxes3.rs | 6 +++--- bevy_rapier3d/examples/events3.rs | 6 +++--- bevy_rapier3d/examples/joints3.rs | 6 +++--- src/physics/systems.rs | 17 +++++++---------- src/render/systems.rs | 4 +--- 10 files changed, 28 insertions(+), 33 deletions(-) diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index 95f6436d..e0c87efd 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -28,7 +28,7 @@ serde-serialize = [ "rapier2d/serde-serialize" ] enhanced-determinism = [ "rapier2d/enhanced-determinism" ] [dependencies] -bevy = "0.1" +bevy = "0.2" nalgebra = "0.22" rapier2d = "0.1" concurrent-queue = "1" diff --git a/bevy_rapier2d/examples/boxes2.rs b/bevy_rapier2d/examples/boxes2.rs index 3e437590..2d46ff97 100644 --- a/bevy_rapier2d/examples/boxes2.rs +++ b/bevy_rapier2d/examples/boxes2.rs @@ -19,7 +19,7 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_resource(Msaa { samples: 2 }) + .add_resource(Msaa::default()) .add_default_plugins() .add_plugin(RapierPhysicsPlugin) .add_plugin(RapierRenderPlugin) @@ -39,11 +39,11 @@ fn setup_graphics(mut commands: Commands, mut scale: ResMut) commands .spawn(LightComponents { - translation: Translation::new(1000.0, 100.0, 2000.0), + transform: Transform::from_translation(Vec3::new(1000.0, 100.0, 2000.0)), ..Default::default() }) .spawn(Camera2dComponents { - translation: Translation::new(0.0, 200.0, 0.0), + transform: Transform::from_translation(Vec3::new(0.0, 200.0, 0.0)), ..Camera2dComponents::default() }); } diff --git a/bevy_rapier2d/examples/events2.rs b/bevy_rapier2d/examples/events2.rs index 01875594..a8b0ca60 100644 --- a/bevy_rapier2d/examples/events2.rs +++ b/bevy_rapier2d/examples/events2.rs @@ -19,7 +19,7 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_resource(Msaa { samples: 2 }) + .add_resource(Msaa::default()) .add_default_plugins() .add_plugin(RapierPhysicsPlugin) .add_plugin(RapierRenderPlugin) @@ -40,11 +40,11 @@ fn setup_graphics(mut commands: Commands, mut scale: ResMut) commands .spawn(LightComponents { - translation: Translation::new(1000.0, 100.0, 2000.0), + transform: Transform::from_translation(Vec3::new(1000.0, 100.0, 2000.0)), ..Default::default() }) .spawn(Camera2dComponents { - translation: Translation::new(0.0, 0.0, 0.0), + transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), ..Camera2dComponents::default() }); } diff --git a/bevy_rapier2d/examples/joints2.rs b/bevy_rapier2d/examples/joints2.rs index dabc48e0..49952e29 100644 --- a/bevy_rapier2d/examples/joints2.rs +++ b/bevy_rapier2d/examples/joints2.rs @@ -21,7 +21,7 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_resource(Msaa { samples: 2 }) + .add_resource(Msaa::default()) .add_default_plugins() .add_plugin(RapierPhysicsPlugin) .add_plugin(RapierRenderPlugin) @@ -41,11 +41,11 @@ fn setup_graphics(mut commands: Commands, mut scale: ResMut) commands .spawn(LightComponents { - translation: Translation::new(1000.0, 100.0, 2000.0), + transform: Transform::from_translation(Vec3::new(1000.0, 100.0, 2000.0)), ..Default::default() }) .spawn(Camera2dComponents { - translation: Translation::new(200.0, -200.0, 0.0), + transform: Transform::from_translation(Vec3::new(200.0, -200.0, 0.0)), ..Camera2dComponents::default() }); } diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index a4ed2f20..2e990876 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -28,7 +28,7 @@ serde-serialize = [ "rapier3d/serde-serialize" ] enhanced-determinism = [ "rapier3d/enhanced-determinism" ] [dependencies] -bevy = "0.1" +bevy = "0.2" nalgebra = "0.22" rapier3d = "0.1" concurrent-queue = "1" diff --git a/bevy_rapier3d/examples/boxes3.rs b/bevy_rapier3d/examples/boxes3.rs index d0fb65f2..fb5c72e6 100644 --- a/bevy_rapier3d/examples/boxes3.rs +++ b/bevy_rapier3d/examples/boxes3.rs @@ -19,7 +19,7 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_resource(Msaa { samples: 2 }) + .add_resource(Msaa::default()) .add_default_plugins() .add_plugin(RapierPhysicsPlugin) .add_plugin(RapierRenderPlugin) @@ -37,11 +37,11 @@ fn enable_physics_profiling(mut pipeline: ResMut) { fn setup_graphics(mut commands: Commands) { commands .spawn(LightComponents { - translation: Translation::new(1000.0, 100.0, 2000.0), + transform: Transform::from_translation(Vec3::new(1000.0, 100.0, 2000.0)), ..Default::default() }) .spawn(Camera3dComponents { - transform: Transform::new_sync_disabled(Mat4::face_toward( + transform: Transform::new(Mat4::face_toward( Vec3::new(-30.0, 30.0, 100.0), Vec3::new(0.0, 10.0, 0.0), Vec3::new(0.0, 1.0, 0.0), diff --git a/bevy_rapier3d/examples/events3.rs b/bevy_rapier3d/examples/events3.rs index ecc039c3..b5164189 100644 --- a/bevy_rapier3d/examples/events3.rs +++ b/bevy_rapier3d/examples/events3.rs @@ -19,7 +19,7 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_resource(Msaa { samples: 2 }) + .add_resource(Msaa::default()) .add_default_plugins() .add_plugin(RapierPhysicsPlugin) .add_plugin(RapierRenderPlugin) @@ -38,11 +38,11 @@ fn enable_physics_profiling(mut pipeline: ResMut) { fn setup_graphics(mut commands: Commands) { commands .spawn(LightComponents { - translation: Translation::new(1000.0, 100.0, 2000.0), + transform: Transform::from_translation(Vec3::new(1000.0, 100.0, 2000.0)), ..Default::default() }) .spawn(Camera3dComponents { - transform: Transform::new_sync_disabled(Mat4::face_toward( + transform: Transform::new(Mat4::face_toward( Vec3::new(0.0, 0.0, 25.0), Vec3::new(0.0, 0.0, 0.0), Vec3::new(0.0, 1.0, 0.0), diff --git a/bevy_rapier3d/examples/joints3.rs b/bevy_rapier3d/examples/joints3.rs index 552c98e6..c21708ee 100644 --- a/bevy_rapier3d/examples/joints3.rs +++ b/bevy_rapier3d/examples/joints3.rs @@ -22,7 +22,7 @@ fn main() { 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) - .add_resource(Msaa { samples: 2 }) + .add_resource(Msaa::default()) .add_default_plugins() .add_plugin(RapierPhysicsPlugin) .add_plugin(RapierRenderPlugin) @@ -40,11 +40,11 @@ fn enable_physics_profiling(mut pipeline: ResMut) { fn setup_graphics(mut commands: Commands) { commands .spawn(LightComponents { - translation: Translation::new(1000.0, 100.0, 2000.0), + transform: Transform::from_translation(Vec3::new(1000.0, 100.0, 2000.0)), ..Default::default() }) .spawn(Camera3dComponents { - transform: Transform::new_sync_disabled(Mat4::face_toward( + transform: Transform::new(Mat4::face_toward( Vec3::new(15.0, 5.0, 42.0), Vec3::new(13.0, 1.0, 1.0), Vec3::new(0.0, 1.0, 0.0), diff --git a/src/physics/systems.rs b/src/physics/systems.rs index ac8b19e6..8b5886b4 100644 --- a/src/physics/systems.rs +++ b/src/physics/systems.rs @@ -93,8 +93,7 @@ pub fn sync_transform_system( bodies: ResMut, scale: Res, rigid_body: &RigidBodyHandleComponent, - mut translation: Mut, - mut rotation: Mut, + mut transform: Mut, ) { if let Some(rb) = bodies.get(rigid_body.handle()) { let pos = rb.position; @@ -102,26 +101,24 @@ pub fn sync_transform_system( #[cfg(feature = "dim2")] { let rot = na::UnitQuaternion::new(na::Vector3::z() * pos.rotation.angle()); - - *translation.0.x_mut() = pos.translation.vector.x * scale.0; - *translation.0.y_mut() = pos.translation.vector.y * scale.0; - rotation.0 = Quat::from_xyzw(rot.i, rot.j, rot.k, rot.w); + transform.set_translation(Vec3::new(pos.translation.vector.x * scale.0, pos.translation.vector.y * scale.0, 0.0)); + transform.set_rotation(Quat::from_xyzw(rot.i, rot.j, rot.k, rot.w)); } #[cfg(feature = "dim3")] { - translation.0 = Vec3::new( + transform.set_translation(Vec3::new( pos.translation.vector.x, pos.translation.vector.y, pos.translation.vector.z, - ) * scale.0; + ) * scale.0); - rotation.0 = Quat::from_xyzw( + transform.set_rotation(Quat::from_xyzw( pos.rotation.i, pos.rotation.j, pos.rotation.k, pos.rotation.w, - ); + )); } } } diff --git a/src/render/systems.rs b/src/render/systems.rs index fe882fba..fd4800f4 100644 --- a/src/render/systems.rs +++ b/src/render/systems.rs @@ -85,6 +85,7 @@ pub fn create_collider_renders_system( let ground_pbr = PbrComponents { mesh: meshes.add(mesh), material: materials.add(color.into()), + transform: Transform::from_non_uniform_scale(scale), ..Default::default() }; @@ -97,9 +98,6 @@ pub fn create_collider_renders_system( ground_pbr.draw, ground_pbr.render_pipelines, ground_pbr.transform, - ground_pbr.translation, - ground_pbr.rotation, - NonUniformScale(scale), ), ); } From c4196f8b92fad41e62b25761e276c964d7942c36 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sun, 20 Sep 2020 11:47:04 -0600 Subject: [PATCH 2/4] Remove unused dev dependency bevy_fly_camera --- bevy_rapier2d/Cargo.toml | 2 +- bevy_rapier3d/Cargo.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index e0c87efd..351b6bd5 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -34,4 +34,4 @@ rapier2d = "0.1" concurrent-queue = "1" [dev-dependencies] -bevy_fly_camera = "0.1" + diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index 2e990876..9f1b03dc 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -34,4 +34,3 @@ rapier3d = "0.1" concurrent-queue = "1" [dev-dependencies] -bevy_fly_camera = "0.1" From cd6e6aedf1a950be321fa2ebaa38b11f633fc787 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Mon, 21 Sep 2020 09:29:48 -0600 Subject: [PATCH 3/4] Fix adding pbr without needed components --- src/render/systems.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/render/systems.rs b/src/render/systems.rs index fd4800f4..d70502b4 100644 --- a/src/render/systems.rs +++ b/src/render/systems.rs @@ -89,17 +89,7 @@ pub fn create_collider_renders_system( ..Default::default() }; - commands.insert( - entity, - ( - ground_pbr.mesh, - ground_pbr.material, - ground_pbr.main_pass, - ground_pbr.draw, - ground_pbr.render_pipelines, - ground_pbr.transform, - ), - ); + commands.insert(entity, ground_pbr); } } } From 68c9b9945fa65727616fb64ff0a8667d654a13eb Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Mon, 21 Sep 2020 09:29:54 -0600 Subject: [PATCH 4/4] Fix path to font --- src_debug_ui/systems.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_debug_ui/systems.rs b/src_debug_ui/systems.rs index 02bcc5b1..660a1b67 100644 --- a/src_debug_ui/systems.rs +++ b/src_debug_ui/systems.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; use rapier::pipeline::PhysicsPipeline; pub fn setup_ui(mut commands: Commands, asset_server: Res) { - let font_handle = asset_server.load("assets/FiraSans-Bold.ttf").unwrap(); + let font_handle = asset_server.load("../assets/FiraSans-Bold.ttf").unwrap(); commands // 2d camera .spawn(UiCameraComponents::default())