diff --git a/Cargo.toml b/Cargo.toml index 684265ff..cd1b8bc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,10 @@ codegen-units = 1 #parry3d = { path = "../parry/crates/parry3d" } #rapier2d = { path = "../rapier/crates/rapier2d" } #rapier3d = { path = "../rapier/crates/rapier3d" } - #nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "dev" } #parry2d = { git = "https://github.com/dimforge/parry", branch = "master" } #parry3d = { git = "https://github.com/dimforge/parry", branch = "master" } #rapier2d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } #rapier3d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } +bevy_egui = { git = "https://github.com/Vrixyz/bevy_egui", branch = "bevy_main" } +bevy-inspector-egui = { git = "https://github.com/Vrixyz/bevy-inspector-egui", branch = "bevy_0.15" } diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml index d1d1d6ca..983e9b33 100644 --- a/bevy_rapier2d/Cargo.toml +++ b/bevy_rapier2d/Cargo.toml @@ -49,25 +49,27 @@ headless = [] async-collider = ["bevy/bevy_asset", "bevy/bevy_scene"] [dependencies] -bevy = { version = "0.14", default-features = false } -nalgebra = { version = "0.33", features = ["convert-glam027"] } +bevy = { version = "0.15.0-rc.2", default-features = false } +nalgebra = { version = "0.33", features = ["convert-glam029"] } rapier2d = "0.22" bitflags = "2.4" log = "0.4" serde = { version = "1", features = ["derive"], optional = true } [dev-dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.2", default-features = false, features = [ "x11", "bevy_state", "bevy_debug_stepping", ] } oorandom = "11" approx = "0.5.1" -glam = { version = "0.27", features = ["approx"] } -bevy-inspector-egui = "0.25.1" -bevy_egui = "0.28.0" -bevy_mod_debugdump = "0.11" +glam = { version = "0.29", features = ["approx"] } +bevy-inspector-egui = "0.28.0" +bevy_egui = "0.30.0" +# bevy_mod_debugdump = "0.11" +bevy_mod_debugdump = { git = "https://github.com/andriyDev/bevy_mod_debugdump.git", branch = "bevy-0.15" } +bevy_transform_interpolation = { git = "https://github.com/Jondolf/bevy_transform_interpolation.git" } [package.metadata.docs.rs] # Enable all the features when building the docs on docs.rs diff --git a/bevy_rapier2d/examples/boxes2.rs b/bevy_rapier2d/examples/boxes2.rs index a653575e..b63f7f56 100644 --- a/bevy_rapier2d/examples/boxes2.rs +++ b/bevy_rapier2d/examples/boxes2.rs @@ -18,10 +18,7 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera2dBundle { - transform: Transform::from_xyz(0.0, 20.0, 0.0), - ..default() - }); + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0))); } pub fn setup_physics(mut commands: Commands) { @@ -32,7 +29,7 @@ pub fn setup_physics(mut commands: Commands) { let ground_height = 10.0; commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0)), + Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0), Collider::cuboid(ground_size, ground_height), )); @@ -54,7 +51,7 @@ pub fn setup_physics(mut commands: Commands) { let y = j as f32 * shift + centery + 30.0; commands.spawn(( - TransformBundle::from(Transform::from_xyz(x, y, 0.0)), + Transform::from_xyz(x, y, 0.0), RigidBody::Dynamic, Collider::cuboid(rad, rad), )); diff --git a/bevy_rapier2d/examples/contact_filter2.rs b/bevy_rapier2d/examples/contact_filter2.rs index d286151d..7e3538c2 100644 --- a/bevy_rapier2d/examples/contact_filter2.rs +++ b/bevy_rapier2d/examples/contact_filter2.rs @@ -45,10 +45,7 @@ fn main() { } fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera2dBundle { - transform: Transform::from_xyz(0.0, 20.0, 0.0), - ..default() - }); + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0))); } pub fn setup_physics(mut commands: Commands) { @@ -58,13 +55,13 @@ pub fn setup_physics(mut commands: Commands) { let ground_size = 100.0; commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, -100.0, 0.0)), + Transform::from_xyz(0.0, -100.0, 0.0), Collider::cuboid(ground_size, 12.0), CustomFilterTag::GroupA, )); commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, 0.0, 0.0)), + Transform::from_xyz(0.0, 0.0, 0.0), Collider::cuboid(ground_size, 12.0), CustomFilterTag::GroupB, )); @@ -89,7 +86,7 @@ pub fn setup_physics(mut commands: Commands) { group_id += 1; commands.spawn(( - TransformBundle::from(Transform::from_xyz(x, y, 0.0)), + Transform::from_xyz(x, y, 0.0), RigidBody::Dynamic, Collider::cuboid(rad, rad), ActiveHooks::FILTER_CONTACT_PAIRS, diff --git a/bevy_rapier2d/examples/custom_system_setup2.rs b/bevy_rapier2d/examples/custom_system_setup2.rs index 31232e9f..71b5ac56 100644 --- a/bevy_rapier2d/examples/custom_system_setup2.rs +++ b/bevy_rapier2d/examples/custom_system_setup2.rs @@ -61,10 +61,7 @@ fn despawn_one_box( } fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera2dBundle { - transform: Transform::from_xyz(0.0, 20.0, 0.0), - ..default() - }); + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0))); } pub fn setup_physics(mut commands: Commands) { @@ -75,7 +72,7 @@ pub fn setup_physics(mut commands: Commands) { let ground_height = 10.0; commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0)), + Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0), Collider::cuboid(ground_size, ground_height), )); @@ -97,7 +94,7 @@ pub fn setup_physics(mut commands: Commands) { let y = j as f32 * shift + centery + 30.0; commands.spawn(( - TransformBundle::from(Transform::from_xyz(x, y, 0.0)), + Transform::from_xyz(x, y, 0.0), RigidBody::Dynamic, Collider::cuboid(rad, rad), )); diff --git a/bevy_rapier2d/examples/debug_despawn2.rs b/bevy_rapier2d/examples/debug_despawn2.rs index 3eeab482..4fdf28b5 100644 --- a/bevy_rapier2d/examples/debug_despawn2.rs +++ b/bevy_rapier2d/examples/debug_despawn2.rs @@ -92,7 +92,7 @@ pub fn setup_game(mut commands: Commands, mut game: ResMut) { byte_rgb(255, 0, 0), ]; - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); setup_board(&mut commands, &game); @@ -131,15 +131,12 @@ fn setup_board(commands: &mut Commands, game: &Game) { // Add floor commands.spawn(( - SpriteBundle { - sprite: Sprite { - color: Color::srgb(0.5, 0.5, 0.5), - custom_size: Some(Vec2::new(game.n_lanes as f32 * 30.0, 60.0)), - ..Default::default() - }, - transform: Transform::from_xyz(0.0, floor_y - 30.0 * 0.5, 0.0), + Sprite { + color: Color::srgb(0.5, 0.5, 0.5), + custom_size: Some(Vec2::new(game.n_lanes as f32 * 30.0, 60.0)), ..Default::default() }, + Transform::from_xyz(0.0, floor_y - 30.0 * 0.5, 0.0), RigidBody::Fixed, Collider::cuboid(game.n_lanes as f32 * 30.0 / 2.0, 60.0 / 2.0), )); @@ -200,15 +197,12 @@ fn spawn_block( commands .spawn(( - SpriteBundle { - sprite: Sprite { - color: game.cube_colors[kind as usize], - custom_size: Some(Vec2::new(30.0, 30.0)), - ..Default::default() - }, - transform: Transform::from_xyz(x, y, 0.0), + Sprite { + color: game.cube_colors[kind as usize], + custom_size: Some(Vec2::new(30.0, 30.0)), ..Default::default() }, + Transform::from_xyz(x, y, 0.0), RigidBody::Dynamic, Damping { linear_damping, diff --git a/bevy_rapier2d/examples/debug_toggle2.rs b/bevy_rapier2d/examples/debug_toggle2.rs index da161f1b..a5b1e1e0 100644 --- a/bevy_rapier2d/examples/debug_toggle2.rs +++ b/bevy_rapier2d/examples/debug_toggle2.rs @@ -31,11 +31,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), + )); } #[derive(Component)] @@ -49,7 +48,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), )); @@ -81,12 +80,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), ColliderDebugColor(colors[color % 3]), diff --git a/bevy_rapier2d/examples/debugdump2.rs b/bevy_rapier2d/examples/debugdump2.rs index 190a5079..88b302d0 100644 --- a/bevy_rapier2d/examples/debugdump2.rs +++ b/bevy_rapier2d/examples/debugdump2.rs @@ -28,6 +28,6 @@ fn main() { } true })); - let dot = schedule_graph_dot(&mut app, PostUpdate, &debugdump_settings); + let dot = schedule_graph_dot(&mut app, FixedUpdate, &debugdump_settings); println!("{dot}"); } diff --git a/bevy_rapier2d/examples/despawn2.rs b/bevy_rapier2d/examples/despawn2.rs index a2b5288d..ed20bc80 100644 --- a/bevy_rapier2d/examples/despawn2.rs +++ b/bevy_rapier2d/examples/despawn2.rs @@ -43,10 +43,7 @@ pub fn setup_graphics( resize.timer = Timer::from_seconds(6.0, TimerMode::Once); despawn.timer = Timer::from_seconds(5.0, TimerMode::Once); - commands.spawn(Camera2dBundle { - transform: Transform::from_xyz(0.0, 20.0, 0.0), - ..default() - }); + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0))); } pub fn setup_physics(mut commands: Commands) { @@ -58,12 +55,12 @@ pub fn setup_physics(mut commands: Commands) { commands.spawn((Collider::cuboid(ground_size, 12.0), Despawn)); commands.spawn(( - TransformBundle::from(Transform::from_xyz(ground_size, ground_size * 2.0, 0.0)), + Transform::from_xyz(ground_size, ground_size * 2.0, 0.0), Collider::cuboid(12.0, ground_size * 2.0), )); commands.spawn(( - TransformBundle::from(Transform::from_xyz(-ground_size, ground_size * 2.0, 0.0)), + Transform::from_xyz(-ground_size, ground_size * 2.0, 0.0), Collider::cuboid(12.0, ground_size * 2.0), )); @@ -83,7 +80,7 @@ pub fn setup_physics(mut commands: Commands) { let y = j as f32 * shift + centery + 2.0; let mut entity = commands.spawn(( - TransformBundle::from(Transform::from_xyz(x, y, 0.0)), + Transform::from_xyz(x, y, 0.0), RigidBody::Dynamic, Collider::cuboid(rad, rad), )); diff --git a/bevy_rapier2d/examples/events2.rs b/bevy_rapier2d/examples/events2.rs index d772d3f8..0b49e486 100644 --- a/bevy_rapier2d/examples/events2.rs +++ b/bevy_rapier2d/examples/events2.rs @@ -19,7 +19,7 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera2dBundle::default()); + commands.spawn(Camera2d::default()); } pub fn display_events( @@ -40,18 +40,18 @@ pub fn setup_physics(mut commands: Commands) { * Ground */ commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, -24.0, 0.0)), + Transform::from_xyz(0.0, -24.0, 0.0), Collider::cuboid(80.0, 20.0), )); commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, 100.0, 0.0)), + Transform::from_xyz(0.0, 100.0, 0.0), Collider::cuboid(80.0, 30.0), Sensor, )); commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, 260.0, 0.0)), + Transform::from_xyz(0.0, 260.0, 0.0), RigidBody::Dynamic, Collider::cuboid(10.0, 10.0), ActiveEvents::COLLISION_EVENTS, diff --git a/bevy_rapier2d/examples/interpolation2.rs b/bevy_rapier2d/examples/interpolation2.rs new file mode 100644 index 00000000..535b6356 --- /dev/null +++ b/bevy_rapier2d/examples/interpolation2.rs @@ -0,0 +1,116 @@ +use std::{fs::File, io::Write}; + +use bevy::{color::palettes, prelude::*}; +use bevy_mod_debugdump::{schedule_graph, schedule_graph_dot}; +use bevy_rapier2d::prelude::*; +use bevy_transform_interpolation::prelude::{ + RotationInterpolation, TransformInterpolationPlugin, TranslationInterpolation, +}; + +fn main() { + let mut app = App::new(); + app.insert_resource(ClearColor(Color::srgb( + 0xF9 as f32 / 255.0, + 0xF9 as f32 / 255.0, + 0xFF as f32 / 255.0, + ))) + .insert_resource(TimestepMode::Variable { + max_dt: 100f32, + time_scale: 1f32, + substeps: 10, + }) + .insert_resource(Time::::from_hz(5.0)) + .add_plugins(( + DefaultPlugins, + TransformInterpolationPlugin::default(), + RapierPhysicsPlugin::::pixels_per_meter(100.0).in_fixed_schedule(), + RapierDebugRenderPlugin::default(), + )) + .add_systems(Startup, (setup_graphics, setup_physics)); + app.add_systems( + PostUpdate, + debug_with_transform_info.after(TransformSystem::TransformPropagate), + ); + let mut debugdump_settings = schedule_graph::Settings::default(); + // Filter out some less relevant systems. + debugdump_settings.include_system = + Some(Box::new(|system: &(dyn System)| { + if system.name().starts_with("bevy_pbr") + || system.name().starts_with("bevy_render") + || system.name().starts_with("bevy_gizmos") + || system.name().starts_with("bevy_winit") + || system.name().starts_with("bevy_sprite") + { + return false; + } + true + })); + let dot = schedule_graph_dot(&mut app, PostUpdate, &debugdump_settings); + + let mut file = File::create("interpolation2.dot").expect("could not create file."); + file.set_len(0).unwrap(); + file.write_all(&dot.as_bytes()) + .expect("Could not write to file"); + + app.run(); +} +#[derive(Component, Clone)] +pub struct VisualBallDebug; + +pub fn setup_graphics(mut commands: Commands) { + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, 20.0, 0.0))); +} + +pub fn setup_physics(mut commands: Commands) { + /* + * Ground + */ + let ground_size = 500.0; + let ground_height = 10.0; + + commands.spawn(( + Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0), + Collider::cuboid(ground_size, ground_height), + )); + + let interpolated_ball = ( + Transform::from_xyz(-0.0, 200.0, 0.0), + RigidBody::Dynamic, + Collider::ball(20.0), + Restitution { + coefficient: 0.99, + combine_rule: CoefficientCombineRule::Max, + }, + TranslationInterpolation, + RotationInterpolation, + VisualBallDebug, + ); + commands.spawn(interpolated_ball.clone()); + commands.spawn(interpolated_ball).insert(( + ColliderDebug::NeverRender, + Transform::from_xyz(-80.0, 200.0, 0.0), + )); + commands.spawn(( + Transform::from_xyz(80.0, 200.0, 0.0), + RigidBody::Dynamic, + Collider::ball(20.0), + Restitution { + coefficient: 0.99, + combine_rule: CoefficientCombineRule::Max, + }, + VisualBallDebug, + )); +} + +pub fn debug_with_transform_info( + mut gizmos: Gizmos, + entities: Query<(&Transform, &Collider), With>, +) { + for (transform, collider) in entities.iter() { + gizmos.circle( + transform.translation, + collider.as_ball().unwrap().radius(), + palettes::basic::RED, + ); + } +} diff --git a/bevy_rapier2d/examples/joints2.rs b/bevy_rapier2d/examples/joints2.rs index e30352ca..a7c16cee 100644 --- a/bevy_rapier2d/examples/joints2.rs +++ b/bevy_rapier2d/examples/joints2.rs @@ -18,10 +18,7 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera2dBundle { - transform: Transform::from_xyz(0.0, -200.0, 0.0), - ..default() - }); + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, -200.0, 0.0))); } pub fn setup_physics(mut commands: Commands) { @@ -46,7 +43,7 @@ pub fn setup_physics(mut commands: Commands) { let child_entity = commands .spawn(( - TransformBundle::from(Transform::from_xyz(fk * shift, -fi * shift, 0.0)), + Transform::from_xyz(fk * shift, -fi * shift, 0.0), rigid_body, Collider::cuboid(rad, rad), )) diff --git a/bevy_rapier2d/examples/joints_despawn2.rs b/bevy_rapier2d/examples/joints_despawn2.rs index 736d868b..f5fa1977 100644 --- a/bevy_rapier2d/examples/joints_despawn2.rs +++ b/bevy_rapier2d/examples/joints_despawn2.rs @@ -28,10 +28,7 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera2dBundle { - transform: Transform::from_xyz(0.0, -200.0, 0.0), - ..default() - }); + commands.spawn((Camera2d::default(), Transform::from_xyz(0.0, -200.0, 0.0))); } pub fn setup_physics(mut commands: Commands, mut despawn: ResMut) { @@ -58,7 +55,7 @@ pub fn setup_physics(mut commands: Commands, mut despawn: ResMut), ) .chain(), @@ -260,7 +260,7 @@ fn change_example( ) { next_state.set(examples_available.0[example_selected.0].state); } - +/* fn ui_example_system( mut contexts: EguiContexts, mut current_example: ResMut, @@ -284,3 +284,4 @@ fn ui_example_system( } }); } +*/ diff --git a/bevy_rapier3d/Cargo.toml b/bevy_rapier3d/Cargo.toml index 3ab3cfcb..c17f1ccf 100644 --- a/bevy_rapier3d/Cargo.toml +++ b/bevy_rapier3d/Cargo.toml @@ -50,24 +50,24 @@ headless = [] async-collider = ["bevy/bevy_asset", "bevy/bevy_scene"] [dependencies] -bevy = { version = "0.14", default-features = false } -nalgebra = { version = "0.33", features = ["convert-glam027"] } +bevy = { version = "0.15.0-rc.2", default-features = false } +nalgebra = { version = "0.33", features = ["convert-glam029"] } rapier3d = "0.22" bitflags = "2.4" log = "0.4" serde = { version = "1", features = ["derive"], optional = true } [dev-dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "x11", "tonemapping_luts", "bevy_state", "bevy_debug_stepping", ] } approx = "0.5.1" -glam = { version = "0.27", features = ["approx"] } -bevy-inspector-egui = "0.25.1" -bevy_egui = "0.28.0" +glam = { version = "0.29", features = ["approx"] } +bevy-inspector-egui = "0.28" +bevy_egui = "0.30.0" divan = "0.1" bevy_rapier_benches3d = { version = "0.1", path = "../bevy_rapier_benches3d" } diff --git a/bevy_rapier3d/examples/boxes3.rs b/bevy_rapier3d/examples/boxes3.rs index e1078f40..9f862212 100644 --- a/bevy_rapier3d/examples/boxes3.rs +++ b/bevy_rapier3d/examples/boxes3.rs @@ -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) { @@ -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), )); @@ -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]), diff --git a/bevy_rapier3d/examples/character_controller3.rs b/bevy_rapier3d/examples/character_controller3.rs index 7670da54..f99e3701 100644 --- a/bevy_rapier3d/examples/character_controller3.rs +++ b/bevy_rapier3d/examples/character_controller3.rs @@ -34,10 +34,8 @@ fn main() { pub fn setup_player(mut commands: Commands) { commands .spawn(( - SpatialBundle { - transform: Transform::from_xyz(0.0, 5.0, 0.0), - ..default() - }, + Transform::from_xyz(0.0, 5.0, 0.0), + Visibility::default(), Collider::round_cylinder(0.9, 0.3, 0.2), KinematicCharacterController { custom_mass: Some(5.0), @@ -60,10 +58,7 @@ pub fn setup_player(mut commands: Commands) { )) .with_children(|b| { // FPS Camera - b.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 0.2, -0.1), - ..Default::default() - }); + b.spawn((Camera3d::default(), Transform::from_xyz(0.0, 0.2, -0.1))); }); } @@ -75,7 +70,7 @@ fn setup_map(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), )); /* @@ -87,35 +82,19 @@ fn setup_map(mut commands: Commands) { let step = i as f32; let collider = Collider::cuboid(1.0, step * stair_step, 1.0); commands.spawn(( - TransformBundle::from(Transform::from_xyz( - 40.0, - step * stair_step, - step * 2.0 - 20.0, - )), + Transform::from_xyz(40.0, step * stair_step, step * 2.0 - 20.0), collider.clone(), )); commands.spawn(( - TransformBundle::from(Transform::from_xyz( - -40.0, - step * stair_step, - step * -2.0 + 20.0, - )), + Transform::from_xyz(-40.0, step * stair_step, step * -2.0 + 20.0), collider.clone(), )); commands.spawn(( - TransformBundle::from(Transform::from_xyz( - step * 2.0 - 20.0, - step * stair_step, - 40.0, - )), + Transform::from_xyz(step * 2.0 - 20.0, step * stair_step, 40.0), collider.clone(), )); commands.spawn(( - TransformBundle::from(Transform::from_xyz( - step * -2.0 + 20.0, - step * stair_step, - -40.0, - )), + Transform::from_xyz(step * -2.0 + 20.0, step * stair_step, -40.0), collider.clone(), )); } @@ -176,7 +155,7 @@ fn player_movement( let Ok((transform, mut controller, output)) = player.get_single_mut() else { return; }; - let delta_time = time.delta_seconds(); + let delta_time = time.delta_secs(); // Retrieve input let mut movement = Vec3::new(input.x, 0.0, input.z) * MOVEMENT_SPEED; let jump_speed = input.y * JUMP_SPEED; diff --git a/bevy_rapier3d/examples/contact_filter3.rs b/bevy_rapier3d/examples/contact_filter3.rs index de9f0b9d..7aca1316 100644 --- a/bevy_rapier3d/examples/contact_filter3.rs +++ b/bevy_rapier3d/examples/contact_filter3.rs @@ -45,11 +45,10 @@ fn main() { } 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) { @@ -59,13 +58,13 @@ pub fn setup_physics(mut commands: Commands) { let ground_size = 10.0; commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, -10.0, 0.0)), + Transform::from_xyz(0.0, -10.0, 0.0), Collider::cuboid(ground_size, 1.2, ground_size), CustomFilterTag::GroupA, )); commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, 0.0, 0.0)), + Transform::from_xyz(0.0, 0.0, 0.0), Collider::cuboid(ground_size, 1.2, ground_size), CustomFilterTag::GroupB, )); @@ -90,7 +89,7 @@ pub fn setup_physics(mut commands: Commands) { group_id += 1; commands.spawn(( - TransformBundle::from(Transform::from_xyz(x, y, 0.0)), + Transform::from_xyz(x, y, 0.0), RigidBody::Dynamic, Collider::cuboid(rad, rad, rad), ActiveHooks::FILTER_CONTACT_PAIRS, diff --git a/bevy_rapier3d/examples/custom_system_setup3.rs b/bevy_rapier3d/examples/custom_system_setup3.rs index 77b14b45..cfb88bae 100644 --- a/bevy_rapier3d/examples/custom_system_setup3.rs +++ b/bevy_rapier3d/examples/custom_system_setup3.rs @@ -61,11 +61,10 @@ fn despawn_one_box( } 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) { @@ -76,7 +75,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), )); @@ -108,7 +107,7 @@ pub fn setup_physics(mut commands: Commands) { color += 1; commands.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]), diff --git a/bevy_rapier3d/examples/debug_toggle3.rs b/bevy_rapier3d/examples/debug_toggle3.rs index cf1a240a..78468750 100644 --- a/bevy_rapier3d/examples/debug_toggle3.rs +++ b/bevy_rapier3d/examples/debug_toggle3.rs @@ -31,11 +31,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), + )); } #[derive(Component)] @@ -49,7 +48,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), )); @@ -81,12 +80,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]), diff --git a/bevy_rapier3d/examples/despawn3.rs b/bevy_rapier3d/examples/despawn3.rs index cf747c95..e6eb717e 100644 --- a/bevy_rapier3d/examples/despawn3.rs +++ b/bevy_rapier3d/examples/despawn3.rs @@ -30,11 +30,10 @@ fn main() { pub fn setup_graphics(mut commands: Commands, mut res: ResMut) { res.timer = Timer::from_seconds(5.0, TimerMode::Once); - 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) { @@ -45,7 +44,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), Despawn, )); @@ -78,7 +77,7 @@ pub fn setup_physics(mut commands: Commands) { color += 1; commands.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]), diff --git a/bevy_rapier3d/examples/events3.rs b/bevy_rapier3d/examples/events3.rs index 3f8791d7..9f1a23e8 100644 --- a/bevy_rapier3d/examples/events3.rs +++ b/bevy_rapier3d/examples/events3.rs @@ -19,10 +19,10 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 0.0, 25.0).looking_at(Vec3::ZERO, Vec3::Y), - ..Default::default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.0, 0.0, 25.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } pub fn display_events( @@ -43,18 +43,18 @@ pub fn setup_physics(mut commands: Commands) { * Ground */ commands.spawn(( - TransformBundle::from(Transform::from_xyz(0.0, -1.2, 0.0)), + Transform::from_xyz(0.0, -1.2, 0.0), Collider::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), Collider::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, Collider::cuboid(0.5, 0.5, 0.5), ActiveEvents::COLLISION_EVENTS, diff --git a/bevy_rapier3d/examples/joints3.rs b/bevy_rapier3d/examples/joints3.rs index 2864d33b..3edecc74 100644 --- a/bevy_rapier3d/examples/joints3.rs +++ b/bevy_rapier3d/examples/joints3.rs @@ -25,11 +25,10 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(15.0, 5.0, 42.0) - .looking_at(Vec3::new(13.0, 1.0, 1.0), Vec3::Y), - ..Default::default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(15.0, 5.0, 42.0).looking_at(Vec3::new(13.0, 1.0, 1.0), Vec3::Y), + )); } fn create_prismatic_joints(commands: &mut Commands, origin: Vect, num: usize) { @@ -38,7 +37,7 @@ fn create_prismatic_joints(commands: &mut Commands, origin: Vect, num: usize) { let mut curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, origin.z)), + Transform::from_xyz(origin.x, origin.y, origin.z), RigidBody::Fixed, Collider::cuboid(rad, rad, rad), )) @@ -60,7 +59,7 @@ fn create_prismatic_joints(commands: &mut Commands, origin: Vect, num: usize) { curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, origin.z + dz)), + Transform::from_xyz(origin.x, origin.y, origin.z + dz), RigidBody::Dynamic, Collider::cuboid(rad, rad, rad), joint, @@ -75,7 +74,7 @@ fn create_rope_joints(commands: &mut Commands, origin: Vect, num: usize) { let mut curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, origin.z)), + Transform::from_xyz(origin.x, origin.y, origin.z), RigidBody::Fixed, Collider::cuboid(rad, rad, rad), )) @@ -89,7 +88,7 @@ fn create_rope_joints(commands: &mut Commands, origin: Vect, num: usize) { curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, origin.z + dz)), + Transform::from_xyz(origin.x, origin.y, origin.z + dz), RigidBody::Dynamic, Collider::cuboid(rad, rad, rad), joint, @@ -104,7 +103,7 @@ fn create_revolute_joints(commands: &mut Commands, origin: Vec3, num: usize) { let mut curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, 0.0)), + Transform::from_xyz(origin.x, origin.y, 0.0), RigidBody::Fixed, Collider::cuboid(rad, rad, rad), )) @@ -124,7 +123,7 @@ fn create_revolute_joints(commands: &mut Commands, origin: Vec3, num: usize) { for k in 0..4 { handles[k] = commands .spawn(( - TransformBundle::from(Transform::from_translation(positions[k])), + Transform::from_translation(positions[k]), RigidBody::Dynamic, Collider::cuboid(rad, rad, rad), )) @@ -180,11 +179,7 @@ fn create_fixed_joints(commands: &mut Commands, origin: Vec3, num: usize) { let child_entity = commands .spawn(( - TransformBundle::from(Transform::from_xyz( - origin.x + fk * shift, - origin.y, - origin.z + fi * shift, - )), + Transform::from_xyz(origin.x + fk * shift, origin.y, origin.z + fi * shift), rigid_body, Collider::ball(rad), )) @@ -239,7 +234,7 @@ fn create_ball_joints(commands: &mut Commands, num: usize) { let child_entity = commands .spawn(( - TransformBundle::from(Transform::from_xyz(fk * shift, 0.0, fi * shift)), + Transform::from_xyz(fk * shift, 0.0, fi * shift), rigid_body, Collider::ball(rad), )) diff --git a/bevy_rapier3d/examples/joints_despawn3.rs b/bevy_rapier3d/examples/joints_despawn3.rs index 17d1608f..fe1795c7 100644 --- a/bevy_rapier3d/examples/joints_despawn3.rs +++ b/bevy_rapier3d/examples/joints_despawn3.rs @@ -30,11 +30,10 @@ fn main() { pub fn setup_graphics(mut commands: Commands, mut res: ResMut) { res.timer = Timer::from_seconds(5.0, TimerMode::Once); - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(15.0, 5.0, 42.0) - .looking_at(Vec3::new(13.0, 1.0, 1.0), Vec3::Y), - ..Default::default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(15.0, 5.0, 42.0).looking_at(Vec3::new(13.0, 1.0, 1.0), Vec3::Y), + )); } fn create_prismatic_joints(commands: &mut Commands, origin: Vect, num: usize) { @@ -43,7 +42,7 @@ fn create_prismatic_joints(commands: &mut Commands, origin: Vect, num: usize) { let mut curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, origin.z)), + Transform::from_xyz(origin.x, origin.y, origin.z), RigidBody::Fixed, Collider::cuboid(rad, rad, rad), )) @@ -64,7 +63,7 @@ fn create_prismatic_joints(commands: &mut Commands, origin: Vect, num: usize) { let joint = ImpulseJoint::new(curr_parent, prism); let mut entity = commands.spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, origin.z + dz)), + Transform::from_xyz(origin.x, origin.y, origin.z + dz), RigidBody::Dynamic, Collider::cuboid(rad, rad, rad), joint, @@ -84,7 +83,7 @@ fn create_revolute_joints(commands: &mut Commands, origin: Vec3, num: usize) { let mut curr_parent = commands .spawn(( - TransformBundle::from(Transform::from_xyz(origin.x, origin.y, 0.0)), + Transform::from_xyz(origin.x, origin.y, 0.0), RigidBody::Fixed, Collider::cuboid(rad, rad, rad), )) @@ -104,7 +103,7 @@ fn create_revolute_joints(commands: &mut Commands, origin: Vec3, num: usize) { for k in 0..4 { handles[k] = commands .spawn(( - TransformBundle::from(Transform::from_translation(positions[k])), + Transform::from_translation(positions[k]), RigidBody::Dynamic, Collider::cuboid(rad, rad, rad), )) @@ -167,11 +166,7 @@ fn create_fixed_joints(commands: &mut Commands, origin: Vec3, num: usize) { let child_entity = commands .spawn(( - TransformBundle::from(Transform::from_xyz( - origin.x + fk * shift, - origin.y, - origin.z + fi * shift, - )), + Transform::from_xyz(origin.x + fk * shift, origin.y, origin.z + fi * shift), rigid_body, Collider::ball(rad), )) @@ -226,7 +221,7 @@ fn create_ball_joints(commands: &mut Commands, num: usize) { let child_entity = commands .spawn(( - TransformBundle::from(Transform::from_xyz(fk * shift, 0.0, fi * shift)), + Transform::from_xyz(fk * shift, 0.0, fi * shift), rigid_body, Collider::ball(rad), )) diff --git a/bevy_rapier3d/examples/locked_rotations3.rs b/bevy_rapier3d/examples/locked_rotations3.rs index 0288db5f..a4feab94 100644 --- a/bevy_rapier3d/examples/locked_rotations3.rs +++ b/bevy_rapier3d/examples/locked_rotations3.rs @@ -18,11 +18,10 @@ fn main() { } pub fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(10.0, 3.0, 0.0) - .looking_at(Vec3::new(0.0, 3.0, 0.0), Vec3::Y), - ..Default::default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(10.0, 3.0, 0.0).looking_at(Vec3::new(0.0, 3.0, 0.0), Vec3::Y), + )); } pub fn setup_physics(mut commands: Commands) { @@ -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), )); @@ -41,7 +40,7 @@ pub fn setup_physics(mut commands: Commands) { * 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 @@ -53,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), diff --git a/bevy_rapier3d/examples/multi_world3.rs b/bevy_rapier3d/examples/multi_world3.rs index dc5fa807..54a0ad93 100644 --- a/bevy_rapier3d/examples/multi_world3.rs +++ b/bevy_rapier3d/examples/multi_world3.rs @@ -38,11 +38,10 @@ fn create_worlds(mut commands: Commands) { } fn setup_graphics(mut commands: Commands) { - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(0.0, 3.0, -10.0) - .looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), - ..Default::default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(0.0, 3.0, -10.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), + )); } #[derive(Component)] @@ -55,7 +54,7 @@ struct Platform { fn move_platforms(time: Res