diff --git a/Cargo.toml b/Cargo.toml index 47977985..8bc0c048 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,8 @@ resolver = "2" #parry2d-f64 = { git = "https://github.com/dimforge/parry", branch = "master" } #parry3d-f64 = { git = "https://github.com/dimforge/parry", branch = "master" } +bevy_egui = { git = "https://github.com/Vrixyz/bevy_egui", branch = "bevy_main" } + [profile.release] #debug = true #codegen-units = 1 diff --git a/crates/rapier_testbed2d-f64/Cargo.toml b/crates/rapier_testbed2d-f64/Cargo.toml index 9770080b..f53d8a6b 100644 --- a/crates/rapier_testbed2d-f64/Cargo.toml +++ b/crates/rapier_testbed2d-f64/Cargo.toml @@ -39,7 +39,7 @@ other-backends = ["wrapped2d"] features = ["parallel", "other-backends"] [dependencies] -nalgebra = { version = "0.33", features = ["rand", "glam027"] } +nalgebra = { version = "0.33", features = ["rand", "glam029"] } rand = "0.8" rand_pcg = "0.3" instant = { version = "0.1", features = ["web-sys", "now"] } @@ -50,16 +50,16 @@ crossbeam = "0.8" bincode = "1" Inflector = "0.11" md5 = "0.7" -bevy_egui = "0.29" -bevy_ecs = "0.14" -bevy_core_pipeline = "0.14" -bevy_pbr = "0.14" -bevy_sprite = "0.14" +bevy_egui = "0.30" +bevy_ecs = "0.15.0-rc.3" +bevy_core_pipeline = "0.15.0-rc.3" +bevy_pbr = "0.15.0-rc.3" +bevy_sprite = "0.15.0-rc.3" #bevy_prototype_debug_lines = "0.7" # Dependencies for native only. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_asset", "bevy_winit", "x11", @@ -73,7 +73,7 @@ bevy = { version = "0.14", default-features = false, features = [ # Dependencies for WASM only. [target.'cfg(target_arch = "wasm32")'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_asset", "bevy_winit", "tonemapping_luts", diff --git a/crates/rapier_testbed2d/Cargo.toml b/crates/rapier_testbed2d/Cargo.toml index 77373bd4..7d8d5b86 100644 --- a/crates/rapier_testbed2d/Cargo.toml +++ b/crates/rapier_testbed2d/Cargo.toml @@ -39,7 +39,7 @@ other-backends = ["wrapped2d"] features = ["parallel", "other-backends"] [dependencies] -nalgebra = { version = "0.33", features = ["rand", "glam027"] } +nalgebra = { version = "0.33", features = ["rand", "glam029"] } rand = "0.8" rand_pcg = "0.3" instant = { version = "0.1", features = ["web-sys", "now"] } @@ -50,16 +50,16 @@ crossbeam = "0.8" bincode = "1" Inflector = "0.11" md5 = "0.7" -bevy_egui = "0.29" -bevy_ecs = "0.14" -bevy_core_pipeline = "0.14" -bevy_pbr = "0.14" -bevy_sprite = "0.14" +bevy_egui = "0.30" +bevy_ecs = "0.15.0-rc.3" +bevy_core_pipeline = "0.15.0-rc.3" +bevy_pbr = "0.15.0-rc.3" +bevy_sprite = "0.15.0-rc.3" #bevy_prototype_debug_lines = "0.7" # Dependencies for native only. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_sprite", "bevy_winit", "x11", @@ -73,7 +73,7 @@ bevy = { version = "0.14", default-features = false, features = [ # Dependencies for WASM only. [target.'cfg(target_arch = "wasm32")'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_sprite", "bevy_winit", "tonemapping_luts", diff --git a/crates/rapier_testbed3d-f64/Cargo.toml b/crates/rapier_testbed3d-f64/Cargo.toml index 3fa2511f..509c7bea 100644 --- a/crates/rapier_testbed3d-f64/Cargo.toml +++ b/crates/rapier_testbed3d-f64/Cargo.toml @@ -41,7 +41,7 @@ parallel = ["rapier/parallel", "num_cpus"] features = ["parallel"] [dependencies] -nalgebra = { version = "0.33", features = ["rand", "glam027"] } +nalgebra = { version = "0.33", features = ["rand", "glam029"] } rand = "0.8" rand_pcg = "0.3" instant = { version = "0.1", features = ["web-sys", "now"] } @@ -52,16 +52,16 @@ bincode = "1" md5 = "0.7" Inflector = "0.11" serde = { version = "1", features = ["derive"] } -bevy_egui = "0.29" -bevy_ecs = "0.14" -bevy_core_pipeline = "0.14" -bevy_pbr = "0.14" -bevy_sprite = "0.14" +bevy_egui = "0.30" +bevy_ecs = "0.15.0-rc.3" +bevy_core_pipeline = "0.15.0-rc.3" +bevy_pbr = "0.15.0-rc.3" +bevy_sprite = "0.15.0-rc.3" #bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] } # Dependencies for native only. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_winit", "x11", "tonemapping_luts", @@ -74,7 +74,7 @@ bevy = { version = "0.14", default-features = false, features = [ # Dependencies for WASM only. [target.'cfg(target_arch = "wasm32")'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_winit", "tonemapping_luts", "ktx2", diff --git a/crates/rapier_testbed3d/Cargo.toml b/crates/rapier_testbed3d/Cargo.toml index a7a3fe85..f2ba6641 100644 --- a/crates/rapier_testbed3d/Cargo.toml +++ b/crates/rapier_testbed3d/Cargo.toml @@ -39,7 +39,7 @@ other-backends = ["physx", "physx-sys", "glam"] features = ["parallel", "other-backends"] [dependencies] -nalgebra = { version = "0.33", features = ["rand", "glam027"] } +nalgebra = { version = "0.33", features = ["rand", "glam029"] } rand = "0.8" rand_pcg = "0.3" instant = { version = "0.1", features = ["web-sys", "now"] } @@ -53,16 +53,16 @@ bincode = "1" md5 = "0.7" Inflector = "0.11" serde = { version = "1", features = ["derive"] } -bevy_egui = "0.29" -bevy_ecs = "0.14" -bevy_core_pipeline = "0.14" -bevy_pbr = "0.14" -bevy_sprite = "0.14" +bevy_egui = "0.30" +bevy_ecs = "0.15.0-rc.3" +bevy_core_pipeline = "0.15.0-rc.3" +bevy_pbr = "0.15.0-rc.3" +bevy_sprite = "0.15.0-rc.3" #bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] } # Dependencies for native only. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_winit", "x11", "tonemapping_luts", @@ -75,7 +75,7 @@ bevy = { version = "0.14", default-features = false, features = [ # Dependencies for WASM only. [target.'cfg(target_arch = "wasm32")'.dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_winit", "tonemapping_luts", "ktx2", diff --git a/src_testbed/camera3d.rs b/src_testbed/camera3d.rs index b2313b75..c9ad2daa 100644 --- a/src_testbed/camera3d.rs +++ b/src_testbed/camera3d.rs @@ -74,8 +74,8 @@ impl OrbitCameraPlugin { } if mouse_button_input.pressed(camera.rotate_button) { - camera.x -= delta.x * camera.rotate_sensitivity * time.delta_seconds(); - camera.y -= delta.y * camera.rotate_sensitivity * time.delta_seconds(); + camera.x -= delta.x * camera.rotate_sensitivity * time.delta_secs(); + camera.y -= delta.y * camera.rotate_sensitivity * time.delta_secs(); camera.y = camera .y .max(*camera.pitch_range.start()) @@ -87,7 +87,7 @@ impl OrbitCameraPlugin { let up_dir = transform.rotation * Vec3::Y; let pan_vector = (delta.x * right_dir + delta.y * up_dir) * camera.pan_sensitivity - * time.delta_seconds(); + * time.delta_secs(); camera.center += pan_vector; } } diff --git a/src_testbed/graphics.rs b/src_testbed/graphics.rs index 226be4d9..17852e19 100644 --- a/src_testbed/graphics.rs +++ b/src_testbed/graphics.rs @@ -21,6 +21,10 @@ use std::collections::HashMap; pub type BevyMaterial = ColorMaterial; #[cfg(feature = "dim3")] pub type BevyMaterial = StandardMaterial; +#[cfg(feature = "dim2")] +pub type BevyMaterialComponent = MeshMaterial2d; +#[cfg(feature = "dim3")] +pub type BevyMaterialComponent = MeshMaterial3d; pub type InstancedMaterials = HashMap, Handle>; pub const SELECTED_OBJECT_MATERIAL_KEY: Point3 = point![42, 42, 42]; diff --git a/src_testbed/objects/node.rs b/src_testbed/objects/node.rs index a5f7d510..c3cca5db 100644 --- a/src_testbed/objects/node.rs +++ b/src_testbed/objects/node.rs @@ -17,7 +17,6 @@ use rapier::math::{Isometry, Real, Vector}; use crate::graphics::{BevyMaterial, InstancedMaterials, SELECTED_OBJECT_MATERIAL_KEY}; #[cfg(feature = "dim2")] use { - bevy_sprite::MaterialMesh2dBundle, na::{Point2, Vector2}, rapier::geometry::{Ball, Cuboid}, }; @@ -46,6 +45,7 @@ impl EntityWithGraphics { let selection_material = ColorMaterial { color: Color::from(Srgba::rgb(1.0, 0.0, 0.0)), texture: None, + ..default() }; #[cfg(feature = "dim3")] let selection_material = StandardMaterial { @@ -112,6 +112,7 @@ impl EntityWithGraphics { let material = ColorMaterial { color: bevy_color, texture: None, + ..default() }; #[cfg(feature = "dim3")] let material = StandardMaterial { @@ -127,19 +128,17 @@ impl EntityWithGraphics { if let Some(mesh) = mesh { #[cfg(feature = "dim2")] - let bundle = MaterialMesh2dBundle { - mesh: mesh.into(), - material: material_handle.clone_weak(), + let bundle = ( + Mesh2d(mesh), + MeshMaterial2d(material_handle.clone_weak()), transform, - ..Default::default() - }; + ); #[cfg(feature = "dim3")] - let bundle = PbrBundle { - mesh, - material: material_handle.clone_weak(), + let bundle = ( + Mesh2d(mesh), + MeshMaterial3d(material_handle.clone_weak()), transform, - ..Default::default() - }; + ); let mut entity_commands = commands.entity(entity); entity_commands.insert(bundle); diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs index 7b2f0fdc..20279fa2 100644 --- a/src_testbed/testbed.rs +++ b/src_testbed/testbed.rs @@ -8,6 +8,7 @@ use std::num::NonZeroUsize; use bevy::prelude::*; use crate::debug_render::{DebugRenderPipelineResource, RapierDebugRenderPlugin}; +use crate::graphics::BevyMaterialComponent; use crate::physics::{DeserializedPhysicsSnapshot, PhysicsEvents, PhysicsSnapshot, PhysicsState}; use crate::plugin::TestbedPlugin; use crate::{graphics::GraphicsManager, harness::RunState}; @@ -432,7 +433,6 @@ impl TestbedApp { let mut app = App::new(); app.insert_resource(ClearColor(Color::from(Srgba::rgb(0.15, 0.15, 0.15)))) - .insert_resource(Msaa::Sample4) .insert_resource(AmbientLight { brightness: 0.3, ..Default::default() @@ -1084,36 +1084,35 @@ fn setup_graphics_environment(mut commands: Commands) { ..Default::default() }); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { shadows_enabled: false, ..Default::default() }, - transform: Transform { + Transform { translation: Vec3::new(10.0, 2.0, 10.0), rotation: Quat::from_rotation_x(-std::f32::consts::FRAC_PI_4), ..Default::default() }, - ..Default::default() - }); - - commands - .spawn(Camera3dBundle { - transform: Transform::from_matrix( - Mat4::look_at_rh( - Vec3::new(-30.0, 30.0, 100.0), - Vec3::new(0.0, 10.0, 0.0), - Vec3::new(0.0, 1.0, 0.0), - ) - .inverse(), - ), - ..Default::default() - }) - .insert(OrbitCamera { + )); + + commands.spawn(( + Camera3d::default(), + Msaa::Sample4, + MainCamera, + Transform::from_matrix( + Mat4::look_at_rh( + Vec3::new(-30.0, 30.0, 100.0), + Vec3::new(0.0, 10.0, 0.0), + Vec3::new(0.0, 1.0, 0.0), + ) + .inverse(), + ), + OrbitCamera { rotate_sensitivity: 0.05, ..OrbitCamera::default() - }) - .insert(MainCamera); + }, + )); } #[cfg(feature = "dim2")] @@ -1132,14 +1131,14 @@ fn setup_graphics_environment(mut commands: Commands) { // ..Default::default() // }); commands - .spawn(Camera2dBundle { - transform: Transform { + .spawn(( + Camera2d, + Transform { translation: Vec3::new(0.0, 0.0, 0.0), rotation: Quat::IDENTITY, scale: Vec3::new(0.01, 0.01, 1.0), }, - ..Camera2dBundle::default() - }) + )) .insert(OrbitCamera { zoom: 100.0, pan_sensitivity: 0.02, @@ -1180,7 +1179,7 @@ fn update_testbed( (mut gfx_components, mut cameras, mut material_handles): ( Query<&mut Transform>, Query<(&Camera, &GlobalTransform, &mut OrbitCamera)>, - Query<&mut Handle>, + Query<&mut BevyMaterialComponent>, ), keys: Res>, ) { @@ -1570,7 +1569,7 @@ fn clear( #[cfg(feature = "dim2")] fn highlight_hovered_body( - _material_handles: &mut Query<&mut Handle>, + _material_handles: &mut Query<&mut BevyMaterialComponent>, _graphics_manager: &mut GraphicsManager, _testbed_state: &mut TestbedState, _physics: &PhysicsState, @@ -1583,7 +1582,7 @@ fn highlight_hovered_body( #[cfg(feature = "dim3")] fn highlight_hovered_body( - material_handles: &mut Query<&mut Handle>, + material_handles: &mut Query<&mut BevyMaterialComponent>, graphics_manager: &mut GraphicsManager, testbed_state: &mut TestbedState, physics: &PhysicsState, @@ -1595,7 +1594,7 @@ fn highlight_hovered_body( if let Some(nodes) = graphics_manager.body_nodes_mut(highlighted_body) { for node in nodes { if let Ok(mut handle) = material_handles.get_mut(node.entity) { - *handle = node.material.clone_weak() + **handle = node.material.clone_weak() }; } } @@ -1632,7 +1631,7 @@ fn highlight_hovered_body( for node in graphics_manager.body_nodes_mut(parent_handle).unwrap() { if let Ok(mut handle) = material_handles.get_mut(node.entity) { - *handle = selection_material.clone_weak(); + **handle = selection_material.clone_weak(); } } } diff --git a/src_testbed/ui.rs b/src_testbed/ui.rs index b27ea7a6..9fbeda87 100644 --- a/src_testbed/ui.rs +++ b/src_testbed/ui.rs @@ -327,13 +327,13 @@ fn profiling_ui(ui: &mut Ui, counters: &Counters) { counters.step_time(), (1000.0 / counters.step_time()).round() )) - .id_source("total") + .id_salt("total") .show(ui, |ui| { egui::CollapsingHeader::new(format!( "Collision detection: {:.2}ms", counters.collision_detection_time() )) - .id_source("collision detection") + .id_salt("collision detection") .show(ui, |ui| { ui.label(format!("Broad-phase: {:.2}ms", counters.broad_phase_time())); ui.label(format!( @@ -342,7 +342,7 @@ fn profiling_ui(ui: &mut Ui, counters: &Counters) { )); }); egui::CollapsingHeader::new(format!("Solver: {:.2}ms", counters.solver_time())) - .id_source("solver") + .id_salt("solver") .show(ui, |ui| { ui.label(format!( "Velocity assembly: {:.2}ms", @@ -362,7 +362,7 @@ fn profiling_ui(ui: &mut Ui, counters: &Counters) { )); }); egui::CollapsingHeader::new(format!("CCD: {:.2}ms", counters.ccd_time())) - .id_source("ccd") + .id_salt("ccd") .show(ui, |ui| { ui.label(format!("# of substeps: {}", counters.ccd.num_substeps)); ui.label(format!(