Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Nov 5, 2024
1 parent e79b691 commit 7c29a87
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
17 changes: 7 additions & 10 deletions bevy_rapier3d/examples/boxes3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ fn main() {
}

pub fn setup_graphics(mut commands: Commands) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-30.0, 30.0, 100.0)
.looking_at(Vec3::new(0.0, 10.0, 0.0), Vec3::Y),
..Default::default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-30.0, 30.0, 100.0).looking_at(Vec3::new(0.0, 10.0, 0.0), Vec3::Y),
));
}

pub fn setup_physics(mut commands: Commands) {
Expand All @@ -33,7 +32,7 @@ pub fn setup_physics(mut commands: Commands) {
let ground_height = 0.1;

commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, -ground_height, 0.0)),
Transform::from_xyz(0.0, -ground_height, 0.0),
Collider::cuboid(ground_size, ground_height, ground_size),
));

Expand Down Expand Up @@ -65,12 +64,10 @@ pub fn setup_physics(mut commands: Commands) {
color += 1;

commands
.spawn(TransformBundle::from(Transform::from_rotation(
Quat::from_rotation_x(0.2),
)))
.spawn(Transform::from_rotation(Quat::from_rotation_x(0.2)))
.with_children(|child| {
child.spawn((
TransformBundle::from(Transform::from_xyz(x, y, z)),
Transform::from_xyz(x, y, z),
RigidBody::Dynamic,
Collider::cuboid(rad, rad, rad),
ColliderDebugColor(colors[color % 3]),
Expand Down
8 changes: 3 additions & 5 deletions bevy_rapier3d/examples/locked_rotations3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ pub fn setup_physics(mut commands: Commands) {
let ground_height = 0.1;

commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, -ground_height, 0.0)),
Transform::from_xyz(0.0, -ground_height, 0.0),
Collider::cuboid(ground_size, ground_height, ground_size),
));

/*
* A rectangle that only rotates along the `x` axis.
*/
commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, 3.0, 0.0)),
Transform::from_xyz(0.0, 3.0, 0.0),
RigidBody::Dynamic,
LockedAxes::TRANSLATION_LOCKED
| LockedAxes::ROTATION_LOCKED_Y
Expand All @@ -52,9 +52,7 @@ pub fn setup_physics(mut commands: Commands) {
* A tilted cuboid that cannot rotate.
*/
commands.spawn((
TransformBundle::from(
Transform::from_xyz(0.0, 5.0, 0.0).with_rotation(Quat::from_rotation_x(1.0)),
),
Transform::from_xyz(0.0, 5.0, 0.0).with_rotation(Quat::from_rotation_x(1.0)),
RigidBody::Dynamic,
LockedAxes::ROTATION_LOCKED,
Collider::cuboid(0.6, 0.4, 0.4),
Expand Down
17 changes: 6 additions & 11 deletions src/pipeline/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ mod test {
app::{App, Startup, Update},
prelude::{Commands, Component, Entity, Query, With},
time::{TimePlugin, TimeUpdateStrategy},
transform::{bundles::TransformBundle, components::Transform, TransformPlugin},
transform::{components::Transform, TransformPlugin},
MinimalPlugins,
};
use systems::tests::HeadlessRenderPlugin;
Expand Down Expand Up @@ -214,19 +214,16 @@ mod test {
/*
* Ground
*/
commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, -1.2, 0.0)),
cuboid(4.0, 1.0, 1.0),
));
commands.spawn((Transform::from_xyz(0.0, -1.2, 0.0), cuboid(4.0, 1.0, 1.0)));

commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, 5.0, 0.0)),
Transform::from_xyz(0.0, 5.0, 0.0),
cuboid(4.0, 1.5, 1.0),
Sensor,
));

commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, 13.0, 0.0)),
Transform::from_xyz(0.0, 13.0, 0.0),
RigidBody::Dynamic,
cuboid(0.5, 0.5, 0.5),
ActiveEvents::COLLISION_EVENTS,
Expand Down Expand Up @@ -274,8 +271,7 @@ mod test {
}
pub fn setup_physics(mut commands: Commands) {
for _i in 0..100 {
commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, 0.0, 0.0)),
commands.spawn((Transform::from_xyz(0.0, 0.0, 0.0),
RigidBody::Dynamic,
cuboid(0.5, 0.5, 0.5),
ActiveEvents::all(),
Expand All @@ -289,8 +285,7 @@ mod test {
let ground_height = 0.1;
let starting_y = -0.5 - ground_height;

commands.spawn((
TransformBundle::from(Transform::from_xyz(0.0, starting_y, 0.0)),
commands.spawn((Transform::from_xyz(0.0, starting_y, 0.0),
cuboid(ground_size, ground_height, ground_size),
));
}
Expand Down

0 comments on commit 7c29a87

Please sign in to comment.