-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt to update for Bevy 0.2 #10
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method was removed in Bevy 0.2.0. Since the release blog post mentioned disabling sync was an unwanted workaround on the old transform system, I guessed that it was no longer necessary and switched to
|
||
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), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guessed that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. z value is used in bevy for sprite layering, so I think rapier should not touch the value set originally by the user. |
||
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, | ||
); | ||
)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not certain if there's some additional component that's supposed to be added to indicate that there's a non-uniform scale that should be looked at. |
||
), | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On macOS this crashes with the following error on both Bevy 0.1.x and Bevy 0.2.x: