Skip to content

Commit

Permalink
Merge pull request #10 from CleanCut/master
Browse files Browse the repository at this point in the history
Attempt to update for Bevy 0.2
  • Loading branch information
sebcrozet authored Sep 21, 2020
2 parents eed8c0d + 68c9b99 commit 449d785
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 47 deletions.
4 changes: 2 additions & 2 deletions bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ 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"

[dev-dependencies]
bevy_fly_camera = "0.1"

6 changes: 3 additions & 3 deletions bevy_rapier2d/examples/boxes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -39,11 +39,11 @@ fn setup_graphics(mut commands: Commands, mut scale: ResMut<RapierPhysicsScale>)

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()
});
}
Expand Down
6 changes: 3 additions & 3 deletions bevy_rapier2d/examples/events2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -40,11 +40,11 @@ fn setup_graphics(mut commands: Commands, mut scale: ResMut<RapierPhysicsScale>)

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()
});
}
Expand Down
6 changes: 3 additions & 3 deletions bevy_rapier2d/examples/joints2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -41,11 +41,11 @@ fn setup_graphics(mut commands: Commands, mut scale: ResMut<RapierPhysicsScale>)

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()
});
}
Expand Down
3 changes: 1 addition & 2 deletions bevy_rapier3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ 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"

[dev-dependencies]
bevy_fly_camera = "0.1"
6 changes: 3 additions & 3 deletions bevy_rapier3d/examples/boxes3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -37,11 +37,11 @@ fn enable_physics_profiling(mut pipeline: ResMut<PhysicsPipeline>) {
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),
Expand Down
6 changes: 3 additions & 3 deletions bevy_rapier3d/examples/events3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -38,11 +38,11 @@ fn enable_physics_profiling(mut pipeline: ResMut<PhysicsPipeline>) {
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),
Expand Down
6 changes: 3 additions & 3 deletions bevy_rapier3d/examples/joints3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -40,11 +40,11 @@ fn enable_physics_profiling(mut pipeline: ResMut<PhysicsPipeline>) {
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),
Expand Down
17 changes: 7 additions & 10 deletions src/physics/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,32 @@ pub fn sync_transform_system(
bodies: ResMut<RigidBodySet>,
scale: Res<RapierPhysicsScale>,
rigid_body: &RigidBodyHandleComponent,
mut translation: Mut<Translation>,
mut rotation: Mut<Rotation>,
mut transform: Mut<Transform>,
) {
if let Some(rb) = bodies.get(rigid_body.handle()) {
let pos = rb.position;

#[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,
);
));
}
}
}
16 changes: 2 additions & 14 deletions src/render/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,11 @@ 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()
};

commands.insert(
entity,
(
ground_pbr.mesh,
ground_pbr.material,
ground_pbr.main_pass,
ground_pbr.draw,
ground_pbr.render_pipelines,
ground_pbr.transform,
ground_pbr.translation,
ground_pbr.rotation,
NonUniformScale(scale),
),
);
commands.insert(entity, ground_pbr);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src_debug_ui/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::prelude::*;
use rapier::pipeline::PhysicsPipeline;

pub fn setup_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
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())
Expand Down

0 comments on commit 449d785

Please sign in to comment.