From e3c81f2b3e66a05dc3060c86f520e41028963d72 Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 19:52:27 +0300 Subject: [PATCH 1/9] Fix compilation with bevy 0.12 Only compilation, many bugs exists --- Cargo.toml | 25 +++++----- src/editor/core/gltf_unpack.rs | 11 +++-- src/editor/core/load.rs | 4 +- src/editor/mod.rs | 57 ++++++++++++++++------- src/editor/ui/hierarchy.rs | 2 +- src/editor/ui/inspector/mod.rs | 26 ++++++++--- src/editor/ui/mod.rs | 2 +- src/editor_registry/mod.rs | 4 +- src/lib.rs | 15 ++---- src/optional/bevy_xpbd_plugin/collider.rs | 18 +++---- src/prefab/component/mod.rs | 2 +- src/prefab/load.rs | 3 +- src/prefab/mod.rs | 18 +++---- src/prefab/save.rs | 2 +- 14 files changed, 109 insertions(+), 80 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc2f60ba..a597bbb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,19 +13,20 @@ homepage = "https://github.com/rewin123/space_editor" repository = "https://github.com/rewin123/space_editor" [dependencies] -bevy = "0.11" -bevy_egui = "0.21" -egui-gizmo = "0.11.0" -bevy-scene-hook = "7" -ron = "0.8.0" -bevy_panorbit_camera = "0.7.0" -bevy-inspector-egui = {version = "0.19.0", features = ["bevy_pbr", "highlight_changes"]} -bevy_mod_picking = {version = "0.15.0", features = ["backend_egui"]} -bevy_infinite_grid = "0.8.1" -egui_dock = "0.7" -egui_file = "0.10.2" +bevy = "0.12" +bevy_egui = "0.23" +egui-gizmo = "0.12" +bevy-scene-hook = "9" +ron = "0.8" +bevy_panorbit_camera = {version = "0.9", features=["bevy_egui"]} +bevy-inspector-egui = {version = "0.21", features = ["bevy_pbr", "highlight_changes"]} +pretty-type-name = "1.0" +bevy_mod_picking = {version = "0.17", features = ["backend_egui"]} +bevy_debug_grid = "0.3" +egui_dock = "0.8" +egui_file = "0.11" -bevy_xpbd_3d = {git = "https://github.com/Jondolf/bevy_xpbd.git", rev = "2e257b2910233af44a5f6571f4cb0c3817d010f0", default-features = false, optional = true} +bevy_xpbd_3d = {version="0.3", default-features = false, optional = true} [profile.dev.package.bevy_xpbd_3d] opt-level = 3 diff --git a/src/editor/core/gltf_unpack.rs b/src/editor/core/gltf_unpack.rs index 18b80aa5..f1c7b7a0 100644 --- a/src/editor/core/gltf_unpack.rs +++ b/src/editor/core/gltf_unpack.rs @@ -60,7 +60,7 @@ fn queue_push( mut events: EventWriter, assets: Res, ) { - if !queue.0.is_empty() && assets.get_load_state(&queue.0[0]) == LoadState::Loaded { + if !queue.0.is_empty() && assets.get_load_state(&queue.0[0]) == Some(LoadState::Loaded) { events.send(GltfLoaded(queue.0.remove(0))); } } @@ -84,10 +84,11 @@ fn unpack_gltf(world: &mut World) { let mut command_queue = CommandQueue::default(); for gltf in loaded_scenes.iter() { let handle: Handle = gltf.0.clone(); - let gltf_path = world - .resource::() - .get_handle_path(&handle) - .unwrap(); + let gltf_path= if let Some(path) = handle.path() { + path.clone() + } else { + continue; + }; info!("Path: {:?}", &gltf_path); let Some(gltf) = world.resource::>().get(&gltf.0) else { diff --git a/src/editor/core/load.rs b/src/editor/core/load.rs index fe5a47e3..8412de1b 100644 --- a/src/editor/core/load.rs +++ b/src/editor/core/load.rs @@ -1,4 +1,4 @@ -use bevy::{ecs::entity::EntityMap, prelude::*}; +use bevy::{prelude::*, utils::HashMap}; use crate::{prelude::EditorLoader, PrefabMarker}; @@ -34,7 +34,7 @@ pub fn load_listener(world: &mut World) { entity.components.push(Box::new(PrefabMarker)); } - let mut map = EntityMap::default(); + let mut map = HashMap::new(); let res = prefab.write_to_world(world, &mut map); match res { Ok(_) => { /*some info planned*/ } diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 723e8f38..6732e81f 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -1,6 +1,6 @@ //code only for editor gui -use bevy::{prelude::*, window::PrimaryWindow}; +use bevy::{prelude::*, window::PrimaryWindow, render::render_resource::PrimitiveTopology}; pub mod core; pub mod ui; @@ -8,9 +8,8 @@ pub mod ui; pub mod ui_registration; use bevy_egui::{EguiContext, EguiContexts}; -use bevy_infinite_grid::{InfiniteGrid, InfiniteGridBundle}; use bevy_inspector_egui::{quick::WorldInspectorPlugin, DefaultInspectorConfigPlugin}; -use bevy_mod_picking::{prelude::*, PickableBundle}; +use bevy_mod_picking::{prelude::*, PickableBundle, backends::raycast::bevy_mod_raycast::prelude::RaycastSettings}; use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin, PanOrbitCameraSystemSet}; use crate::{ @@ -53,10 +52,12 @@ impl Plugin for EditorPlugin { .disable::() .disable::(), ); + + app.world.resource_mut::().require_markers = true; } - if !app.is_plugin_added::() { - app.add_plugins(bevy_infinite_grid::InfiniteGridPlugin); + if !app.is_plugin_added::() { + app.add_plugins(bevy_debug_grid::DebugGridPlugin::without_floor_grid()); } app.init_resource::(); @@ -113,10 +114,12 @@ impl Plugin for EditorPlugin { ( auto_add_picking, select_listener.after(UiSystemSet), - auto_add_picking_dummy, ) .run_if(in_state(EditorState::Editor)), ); + app.add_systems( + PostUpdate, + auto_add_picking_dummy); app.add_systems( Update, @@ -142,10 +145,10 @@ struct SelectEvent { } fn create_grid_lines(mut commands: Commands) { - commands.spawn(InfiniteGridBundle::default()); + bevy_debug_grid::spawn_floor_grid(commands); } -fn cleanup_grid_lines(mut commands: Commands, query: Query>) { +fn cleanup_grid_lines(mut commands: Commands, query: Query>) { for e in query.iter() { commands.entity(e).despawn_recursive(); } @@ -159,19 +162,30 @@ fn auto_add_picking( commands .entity(e) .insert(PickableBundle::default()) - .insert(RaycastPickTarget::default()) .insert(On::>::send_event::()); } } -type AutoAddQueryFilter = (Without, Without, With); - -fn auto_add_picking_dummy(mut commands: Commands, query: Query) { - for e in query.iter() { - commands - .entity(e) - .insert(PickableBundle::default()) - .insert(RaycastPickTarget::default()); +type AutoAddQueryFilter = ( + Without, + Without, + With, + Changed>); + +//Auto add picking for each child to propagate picking event up to prefab entitiy +fn auto_add_picking_dummy( + mut commands: Commands, + query : Query<(Entity, &Handle), AutoAddQueryFilter>, + meshs : Res>) { + for (e, mesh) in query.iter() { + //Only meshed entity need to be pickable + if let Some(mesh) = meshs.get(mesh) { + if mesh.primitive_topology() == PrimitiveTopology::TriangleList { + commands + .entity(e) + .insert(PickableBundle::default()); + } + } } } @@ -370,3 +384,12 @@ fn draw_camera_gizmo( ); } } + +// fn auto_remove_pickable( +// mut commands : Commands, +// grids : Query, Or<(With, With)>)> +// ) { +// for e in grids.iter() { +// commands.entity(e).remove::(); +// } +// } \ No newline at end of file diff --git a/src/editor/ui/hierarchy.rs b/src/editor/ui/hierarchy.rs index a8be93f2..1446b1f9 100644 --- a/src/editor/ui/hierarchy.rs +++ b/src/editor/ui/hierarchy.rs @@ -180,7 +180,7 @@ fn clone_enitites( mut events: EventReader, editor_registry: Res, ) { - for event in events.into_iter() { + for event in events.read() { let mut queue = vec![(event.id, commands.spawn_empty().id())]; let mut map = HashMap::new(); diff --git a/src/editor/ui/inspector/mod.rs b/src/editor/ui/inspector/mod.rs index 1d9838f1..c820df9c 100644 --- a/src/editor/ui/inspector/mod.rs +++ b/src/editor/ui/inspector/mod.rs @@ -201,18 +201,30 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { { let (ptr, mut set_changed) = mut_untyped_split(data); - let value = reflect_from_ptr.as_reflect_ptr_mut(ptr); + let value = reflect_from_ptr.from_ptr_mut()(ptr); + + let name = { + if let Some(c_id) = cell.components().get_resource_id(registration.type_id()) { + let info = cell.components().get_info(c_id).unwrap(); + pretty_type_name::pretty_type_name_str(info.name()) + } else { + "Unknown".to_string() + } + }; + + pretty_type_name::pretty_type_name_str(registration.type_info().type_path()); + if !editor_registry.silent.contains(®istration.type_id()) { ui.push_id( - format!("{:?}-{}", &e.id(), ®istration.short_name()), + format!("{:?}-{}", &e.id(), &name), |ui| { - ui.collapsing(registration.short_name(), |ui| { + ui.collapsing(&name, |ui| { ui.push_id( format!( "content-{:?}-{}", &e.id(), - ®istration.short_name() + &name ), |ui| { if env.ui_for_reflect_with_options( @@ -233,7 +245,7 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { format!( "del component {:?}-{}", &e.id(), - ®istration.short_name() + &name ), |ui| { //must be on top @@ -272,7 +284,9 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { for idx in 0..components_id.len() { let c_id = components_id[idx]; let t_id = types_id[idx]; - let name = registry.get(t_id).unwrap().short_name(); + let name = pretty_type_name::pretty_type_name_str( + cell.components().get_info(c_id).unwrap().name(), + ); if name.to_lowercase().contains(&lower_filter) { ui.label(name); diff --git a/src/editor/ui/mod.rs b/src/editor/ui/mod.rs index e3cf9eef..87913510 100644 --- a/src/editor/ui/mod.rs +++ b/src/editor/ui/mod.rs @@ -251,7 +251,7 @@ impl EditorUiAppExt for App { tab_systesm: impl IntoSystemConfigs, ) -> &mut Self { let mut tab = ScheduleEditorTab { - schedule: Schedule::new(), + schedule: Schedule::default(), title, }; diff --git a/src/editor_registry/mod.rs b/src/editor_registry/mod.rs index b68880e3..e1f04aaa 100644 --- a/src/editor_registry/mod.rs +++ b/src/editor_registry/mod.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use bevy::{ ecs::system::{EntityCommand, EntityCommands}, prelude::*, - reflect::{GetTypeRegistration, TypePath, TypeRegistry}, + reflect::{GetTypeRegistration, TypePath, TypeRegistry, TypeRegistryArc}, utils::{HashMap, HashSet}, }; @@ -84,7 +84,7 @@ impl AddDefaultComponent { /// Resource, which contains all custom editor registry #[derive(Default, Resource, Clone)] pub struct EditorRegistry { - pub registry: TypeRegistry, + pub registry: TypeRegistryArc, pub spawn_components: HashMap, pub clone_components: Vec, pub remove_components: HashMap, diff --git a/src/lib.rs b/src/lib.rs index e2edb449..6d450742 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ use prefab::PrefabPlugin; pub mod ext { pub use bevy::prelude::*; pub use bevy_egui::*; - pub use bevy_infinite_grid::*; + pub use bevy_debug_grid::*; pub use bevy_inspector_egui::prelude::*; pub use bevy_mod_picking::prelude::*; pub use bevy_panorbit_camera::*; @@ -124,15 +124,6 @@ pub fn simple_editor_setup(mut commands: Commands) { ..default() }); - //grid - commands.spawn(bevy_infinite_grid::InfiniteGridBundle { - grid: bevy_infinite_grid::InfiniteGrid { - // shadow_color: None, - ..default() - }, - ..default() - }); - // camera commands .spawn(Camera3dBundle { @@ -140,6 +131,8 @@ pub fn simple_editor_setup(mut commands: Commands) { ..default() }) .insert(bevy_panorbit_camera::PanOrbitCamera::default()) - .insert(bevy_mod_picking::prelude::RaycastPickCamera::default()) .insert(EditorCameraMarker); + + + bevy_debug_grid::spawn_floor_grid(commands); } diff --git a/src/optional/bevy_xpbd_plugin/collider.rs b/src/optional/bevy_xpbd_plugin/collider.rs index 8828958d..0ca322cb 100644 --- a/src/optional/bevy_xpbd_plugin/collider.rs +++ b/src/optional/bevy_xpbd_plugin/collider.rs @@ -141,13 +141,7 @@ pub fn update_collider( for (e, collider, mesh) in updated_meshes.iter() { if *collider == ColliderPrefab::FromMesh { if let Some(mesh) = meshes.get(mesh) { - if let Some(col) = Collider::convex_decomposition_from_bevy_mesh(mesh) { - commands.entity(e).insert(col); - } else { - commands - .entity(e) - .insert(Collider::trimesh_from_bevy_mesh(mesh).unwrap_or_default()); - } + commands.entity(e).insert(Collider::trimesh_from_mesh(mesh).unwrap_or_default()); } else { commands.entity(e).insert(Collider::default()); } @@ -172,7 +166,7 @@ fn get_collider( ColliderPrefab::FromMesh => { if let Some(mesh) = mesh { if let Some(mesh) = meshes.get(mesh) { - Collider::trimesh_from_bevy_mesh(mesh).unwrap_or_default() + Collider::trimesh_from_mesh(mesh).unwrap_or_default() } else { Collider::default() } @@ -233,20 +227,20 @@ fn get_prefab_mesh_collider(mesh: &MeshPrimitivePrefab) -> Collider { } MeshPrimitivePrefab::Capsule(val) => Collider::capsule(1.0, val.r as Scalar), MeshPrimitivePrefab::Circle(val) => { - Collider::trimesh_from_bevy_mesh(&val.to_mesh()).unwrap_or_default() + Collider::trimesh_from_mesh(&val.to_mesh()).unwrap_or_default() } MeshPrimitivePrefab::Cylinder(val) => Collider::cylinder(1.0, val.r as Scalar), MeshPrimitivePrefab::Icosphere(val) => { - Collider::trimesh_from_bevy_mesh(&val.to_mesh()).unwrap_or_default() + Collider::trimesh_from_mesh(&val.to_mesh()).unwrap_or_default() } MeshPrimitivePrefab::Plane(val) => { Collider::cuboid(val.size as Scalar, EPS as Scalar, val.size as Scalar) } MeshPrimitivePrefab::RegularPolygon(val) => { - Collider::trimesh_from_bevy_mesh(&val.to_mesh()).unwrap_or_default() + Collider::trimesh_from_mesh(&val.to_mesh()).unwrap_or_default() } MeshPrimitivePrefab::Torus(val) => { - Collider::trimesh_from_bevy_mesh(&val.to_mesh()).unwrap_or_default() + Collider::trimesh_from_mesh(&val.to_mesh()).unwrap_or_default() } } } diff --git a/src/prefab/component/mod.rs b/src/prefab/component/mod.rs index 6de0d8c4..be37b024 100644 --- a/src/prefab/component/mod.rs +++ b/src/prefab/component/mod.rs @@ -62,7 +62,7 @@ impl AutoStruct { let field_name = s.name_at(idx).unwrap(); let field = s.field_at(idx).unwrap(); if let Some(handle) = field.downcast_ref::>() { - if let Some(path) = assets.get_handle_path(handle) { + if let Some(path) = handle.path() { let path = path.path().to_str().unwrap().to_string(); paths.insert(field_name.to_string(), path); } diff --git a/src/prefab/load.rs b/src/prefab/load.rs index efb83547..dc8506eb 100644 --- a/src/prefab/load.rs +++ b/src/prefab/load.rs @@ -12,7 +12,8 @@ pub struct PrefabBundle { global_transform: GlobalTransform, visiblity: Visibility, - computed_visiblity: ComputedVisibility, + computed_visiblity: ViewVisibility, + inherited_visibility: InheritedVisibility, } impl PrefabBundle { diff --git a/src/prefab/mod.rs b/src/prefab/mod.rs index 161d4f6f..4adab550 100644 --- a/src/prefab/mod.rs +++ b/src/prefab/mod.rs @@ -129,7 +129,9 @@ impl Plugin for BasePrefabPlugin { app.editor_relation::(); app.editor_relation::(); app.editor_relation::(); - app.editor_relation::(); + app.editor_relation::(); + app.editor_relation::(); + app.editor_relation::(); @@ -227,19 +229,19 @@ fn remove_global_transform( fn add_computed_visibility( mut commands: Commands, - query: Query, Without)>, + query: Query, Without)>, ) { for e in query.iter() { - commands.entity(e).insert(ComputedVisibility::default()); + commands.entity(e).insert(ViewVisibility::default()).insert(InheritedVisibility::default()); } } fn remove_computed_visibility( mut commands: Commands, - query: Query, With)>, + query: Query, With)>, ) { for e in query.iter() { - commands.entity(e).remove::(); + commands.entity(e).remove::().remove::(); } } @@ -252,10 +254,10 @@ fn sync_asset_mesh( for (e, mesh) in changed.iter() { commands .entity(e) - .insert(assets.load::(&mesh.path)); + .insert(assets.load::(&mesh.path)); } - for e in deleted.iter() { + for e in deleted.read() { if let Some(mut cmd) = commands.get_entity(e) { cmd.remove::>(); info!("Removed mesh handle for {:?}", e); @@ -272,7 +274,7 @@ fn sync_asset_material( for (e, material) in changed.iter() { commands .entity(e) - .insert(assets.load::(&material.path)); + .insert(assets.load::(&material.path)); } for e in deleted.iter() { diff --git a/src/prefab/save.rs b/src/prefab/save.rs index 7bb052c6..9a670228 100644 --- a/src/prefab/save.rs +++ b/src/prefab/save.rs @@ -96,7 +96,7 @@ pub fn serialize_prefab(world: &mut World) { .map(|a| a.type_id()) .collect(); let mut builder = DynamicSceneBuilder::from_world(world); - builder + builder = builder .allow_all() .with_filter(SceneFilter::Allowlist(HashSet::from_iter( allow_types.iter().cloned(), From 0e00eec559466bc3b99377739b29d344d37084c1 Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 20:04:06 +0300 Subject: [PATCH 2/9] FIxed omponents name and visible defaults --- src/editor/ui/inspector/mod.rs | 12 +++--------- src/prefab/mod.rs | 4 +++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/editor/ui/inspector/mod.rs b/src/editor/ui/inspector/mod.rs index c820df9c..92674db8 100644 --- a/src/editor/ui/inspector/mod.rs +++ b/src/editor/ui/inspector/mod.rs @@ -181,7 +181,7 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { let e_id = e.id().index(); egui::Grid::new(format!("{e_id}")).show(ui, |ui| { for idx in 0..components_id.len() { - let c_id = components_by_entity + let c_id: ComponentId = components_by_entity .entry(e_id) .or_insert(Vec::new()) .get(idx) @@ -204,16 +204,10 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { let value = reflect_from_ptr.from_ptr_mut()(ptr); let name = { - if let Some(c_id) = cell.components().get_resource_id(registration.type_id()) { - let info = cell.components().get_info(c_id).unwrap(); - pretty_type_name::pretty_type_name_str(info.name()) - } else { - "Unknown".to_string() - } + let info = cell.components().get_info(c_id).unwrap(); + pretty_type_name::pretty_type_name_str(info.name()) }; - pretty_type_name::pretty_type_name_str(registration.type_info().type_path()); - if !editor_registry.silent.contains(®istration.type_id()) { ui.push_id( diff --git a/src/prefab/mod.rs b/src/prefab/mod.rs index 4adab550..162cc54a 100644 --- a/src/prefab/mod.rs +++ b/src/prefab/mod.rs @@ -232,7 +232,9 @@ fn add_computed_visibility( query: Query, Without)>, ) { for e in query.iter() { - commands.entity(e).insert(ViewVisibility::default()).insert(InheritedVisibility::default()); + commands.entity(e) + .insert(ViewVisibility::default()) + .insert(InheritedVisibility::VISIBLE); } } From e58fef0dd65facc666f32ca552fdbef53c9ab515 Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:19:15 +0300 Subject: [PATCH 3/9] Fix picking, fix platformer scene --- Cargo.toml | 2 +- assets/level_test.scn.ron | 32 ++++++++++++++++---------------- src/editor/mod.rs | 14 +++++++------- src/lib.rs | 5 ++++- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a597bbb7..dc28da8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ ron = "0.8" bevy_panorbit_camera = {version = "0.9", features=["bevy_egui"]} bevy-inspector-egui = {version = "0.21", features = ["bevy_pbr", "highlight_changes"]} pretty-type-name = "1.0" -bevy_mod_picking = {version = "0.17", features = ["backend_egui"]} +bevy_mod_picking = {version = "0.17", default-features = false, features = ["backend_raycast", "selection"]} bevy_debug_grid = "0.3" egui_dock = "0.8" egui_file = "0.11" diff --git a/assets/level_test.scn.ron b/assets/level_test.scn.ron index c45bd8a4..3a0bab3c 100644 --- a/assets/level_test.scn.ron +++ b/assets/level_test.scn.ron @@ -9,7 +9,7 @@ y: 1.5396833, z: -25.659279, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -102,7 +102,7 @@ y: 0.0, z: -16.504646, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -195,7 +195,7 @@ y: 0.0, z: -6.3498917, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -288,7 +288,7 @@ y: 0.21842504, z: -0.4569779, ), - rotation: (0.0, -0.00000000046566123, 0.0, 1.0), + rotation: (x: 0.0, y: -0.00000000046566123, z: 0.0, w: 1.0), scale: ( x: 1.0000001, y: 1.0, @@ -343,7 +343,7 @@ y: 0.0, z: -25.785236, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -436,7 +436,7 @@ y: -0.28648877, z: -0.28093243, ), - rotation: (-0.6675922, 0.0, 0.0, 0.7445271), + rotation: (x: -0.6675922, y: 0.0, z: 0.0, w: 0.7445271), scale: ( x: 1.0, y: 1.0, @@ -511,7 +511,7 @@ y: -0.07585633, z: -0.5607872, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -566,7 +566,7 @@ y: -1.2103212, z: -25.835867, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -659,7 +659,7 @@ y: 1.4635863, z: -30.082056, ), - rotation: (-0.7019975, 0.0, 0.0, 0.7121794), + rotation: (x: -0.7019975, y: 0.0, z: 0.0, w: 0.7121794), scale: ( x: 1.0, y: 0.99999726, @@ -734,7 +734,7 @@ y: 1.5396833, z: -43.377647, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -827,7 +827,7 @@ y: -0.000009655952, z: 7.3677998, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -920,7 +920,7 @@ y: 1.5396833, z: -38.380207, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -1013,7 +1013,7 @@ y: 0.21842492, z: -0.45153165, ), - rotation: (0.0, -0.00000000046566123, 0.0, 1.0), + rotation: (x: 0.0, y: -0.00000000046566123, z: 0.0, w: 1.0), scale: ( x: 1.0000001, y: 0.99999964, @@ -1068,7 +1068,7 @@ y: 0.0, z: 2.2603722, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -1161,7 +1161,7 @@ y: 2.7637057, z: 6.4066534, ), - rotation: (-0.00000000033425, 0.71091986, -0.00000000033425004, -0.7032731), + rotation: (x: -0.00000000033425, y: 0.71091986, z: -0.00000000033425004, w: -0.7032731), scale: ( x: 1.0000397, y: 0.9999999, @@ -1272,7 +1272,7 @@ y: 3.735711, z: 0.0, ), - rotation: (-0.1146213, 0.6778526, 0.12107966, 0.716043), + rotation: (x: -0.1146213, y: 0.6778526, z: 0.12107966, w: 0.716043), scale: ( x: 0.9999996, y: 0.9999984, diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 6732e81f..3b1299f7 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -9,7 +9,7 @@ pub mod ui_registration; use bevy_egui::{EguiContext, EguiContexts}; use bevy_inspector_egui::{quick::WorldInspectorPlugin, DefaultInspectorConfigPlugin}; -use bevy_mod_picking::{prelude::*, PickableBundle, backends::raycast::bevy_mod_raycast::prelude::RaycastSettings}; +use bevy_mod_picking::{prelude::*, PickableBundle, backends::raycast::{bevy_mod_raycast::prelude::RaycastSettings, RaycastPickable}}; use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin, PanOrbitCameraSystemSet}; use crate::{ @@ -48,9 +48,6 @@ impl Plugin for EditorPlugin { if !app.is_plugin_added::() { app.add_plugins( bevy_mod_picking::DefaultPickingPlugins - .build() - .disable::() - .disable::(), ); app.world.resource_mut::().require_markers = true; @@ -162,7 +159,8 @@ fn auto_add_picking( commands .entity(e) .insert(PickableBundle::default()) - .insert(On::>::send_event::()); + .insert(On::>::send_event::()) + .insert(RaycastPickable); } } @@ -183,7 +181,8 @@ fn auto_add_picking_dummy( if mesh.primitive_topology() == PrimitiveTopology::TriangleList { commands .entity(e) - .insert(PickableBundle::default()); + .insert(PickableBundle::default()) + .insert(RaycastPickable); } } } @@ -200,7 +199,8 @@ fn select_listener( if !pan_orbit_state.0 { return; } - for event in events.iter() { + for event in events.read() { + info!("Select Event: {:?}", event.e); match event.event.button { PointerButton::Primary => { commands.entity(event.e).insert(core::Selected); diff --git a/src/lib.rs b/src/lib.rs index 6d450742..b41562db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,7 @@ pub mod optional; use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*}; +use bevy_mod_picking::{backends::raycast::RaycastPickable, PickableBundle}; use editor::EditorPlugin; use optional::OptionalPlugin; use prefab::PrefabPlugin; @@ -131,7 +132,9 @@ pub fn simple_editor_setup(mut commands: Commands) { ..default() }) .insert(bevy_panorbit_camera::PanOrbitCamera::default()) - .insert(EditorCameraMarker); + .insert(EditorCameraMarker) + .insert(PickableBundle::default()) + .insert(RaycastPickable); bevy_debug_grid::spawn_floor_grid(commands); From 12b10984e050e580e6ef0295a250e1cbeddbd05a Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:28:15 +0300 Subject: [PATCH 4/9] Fix platformer example --- examples/platformer.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/platformer.rs b/examples/platformer.rs index 8142c26e..8a286dd8 100644 --- a/examples/platformer.rs +++ b/examples/platformer.rs @@ -29,10 +29,9 @@ fn main() { simple_tab_system, ) .add_systems( - PhysicsSchedule, + Update, move_player - .run_if(in_state(EditorState::Game)) - .before(PhysicsStepSet::BroadPhase), + .run_if(in_state(EditorState::Game)), ) .add_systems(Update, camera_follow.run_if(in_state(EditorState::Game))) .run(); @@ -105,7 +104,7 @@ fn move_player( ) { for (_e, mut vel, mut rot, mut controller, hits, tranform) in query.iter_mut() { //take 1th hit, because 0th hit is self hit - if let Some(hit) = hits.iter_sorted().nth(1) { + if let Some(hit) = hits.iter_sorted().nth(0) { if hit.time_of_impact > 0.7 { continue; } From 499394909d8932072707b89dd7cecb3893f48772 Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:32:45 +0300 Subject: [PATCH 5/9] Fix physics spawn and simple spawn examples --- assets/physics_loading_test.scn.ron | 10 +++++----- assets/tile.scn.ron | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/physics_loading_test.scn.ron b/assets/physics_loading_test.scn.ron index d125d78d..4c4946f2 100644 --- a/assets/physics_loading_test.scn.ron +++ b/assets/physics_loading_test.scn.ron @@ -9,7 +9,7 @@ y: 11.90253, z: 0.574896, ), - rotation: (-0.0000000005767191, 0.7109159, -0.0000000005767191, -0.70327705), + rotation: (x: -0.0000000005767191, y: 0.7109159, z: -0.0000000005767191, w: -0.70327705), scale: ( x: 1.0000631, y: 1.0000006, @@ -103,7 +103,7 @@ y: 0.21842492, z: -0.45153165, ), - rotation: (0.0, -0.00000000046566123, 0.0, 1.0), + rotation: (x: 0.0, y: -0.00000000046566123, z: 0.0, w: 1.0), scale: ( x: 1.0000001, y: 0.99999964, @@ -158,7 +158,7 @@ y: -0.000009655952, z: 0.38997746, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 1.0, y: 1.0, @@ -251,7 +251,7 @@ y: 0.0, z: -0.4533022, ), - rotation: (0.000000000000018831962, -0.00000000046566245, 0.0000000000019876305, 1.0), + rotation: (x: 0.000000000000018831962, y: -0.00000000046566245, z: 0.0000000000019876305, w: 1.0), scale: ( x: 0.99999756, y: 0.9999971, @@ -306,7 +306,7 @@ y: 0.21842504, z: -0.4569779, ), - rotation: (0.0, -0.00000000046566123, 0.0, 1.0), + rotation: (x: 0.0, y: -0.00000000046566123, z: 0.0, w: 1.0), scale: ( x: 1.0000001, y: 1.0, diff --git a/assets/tile.scn.ron b/assets/tile.scn.ron index 15516b5a..e1757a5f 100644 --- a/assets/tile.scn.ron +++ b/assets/tile.scn.ron @@ -9,7 +9,7 @@ y: 0.0, z: 0.0, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 2.4347973, y: 0.15754807, @@ -34,7 +34,7 @@ y: 0.13795531, z: -2.1002147, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 0.4790529, y: 0.36931515, @@ -60,7 +60,7 @@ y: 0.13795531, z: -2.0787163, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 0.4790529, y: 0.36931515, @@ -87,7 +87,7 @@ y: 0.13796866, z: 2.0884218, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 0.4790529, y: 0.36931515, @@ -114,7 +114,7 @@ y: 0.13795578, z: 2.0741177, ), - rotation: (0.0, 0.0, 0.0, 1.0), + rotation: (x: 0.0, y: 0.0, z: 0.0, w: 1.0), scale: ( x: 0.4790529, y: 0.36931515, From 081aa3f0a74d0e6626ee5ef9e4c65729f8c39f65 Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:35:04 +0300 Subject: [PATCH 6/9] cargo fmt --- examples/platformer.rs | 6 +-- src/editor/core/gltf_unpack.rs | 2 +- src/editor/mod.rs | 43 ++++++++++---------- src/editor/ui/inspector/mod.rs | 48 +++++++++-------------- src/lib.rs | 3 +- src/optional/bevy_xpbd_plugin/collider.rs | 4 +- src/prefab/mod.rs | 17 ++++---- 7 files changed, 55 insertions(+), 68 deletions(-) diff --git a/examples/platformer.rs b/examples/platformer.rs index 8a286dd8..f4a36bd1 100644 --- a/examples/platformer.rs +++ b/examples/platformer.rs @@ -28,11 +28,7 @@ fn main() { "Simnple tab".into(), simple_tab_system, ) - .add_systems( - Update, - move_player - .run_if(in_state(EditorState::Game)), - ) + .add_systems(Update, move_player.run_if(in_state(EditorState::Game))) .add_systems(Update, camera_follow.run_if(in_state(EditorState::Game))) .run(); } diff --git a/src/editor/core/gltf_unpack.rs b/src/editor/core/gltf_unpack.rs index f1c7b7a0..1655f2ef 100644 --- a/src/editor/core/gltf_unpack.rs +++ b/src/editor/core/gltf_unpack.rs @@ -84,7 +84,7 @@ fn unpack_gltf(world: &mut World) { let mut command_queue = CommandQueue::default(); for gltf in loaded_scenes.iter() { let handle: Handle = gltf.0.clone(); - let gltf_path= if let Some(path) = handle.path() { + let gltf_path = if let Some(path) = handle.path() { path.clone() } else { continue; diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 3b1299f7..6044135d 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -1,6 +1,6 @@ //code only for editor gui -use bevy::{prelude::*, window::PrimaryWindow, render::render_resource::PrimitiveTopology}; +use bevy::{prelude::*, render::render_resource::PrimitiveTopology, window::PrimaryWindow}; pub mod core; pub mod ui; @@ -9,7 +9,11 @@ pub mod ui_registration; use bevy_egui::{EguiContext, EguiContexts}; use bevy_inspector_egui::{quick::WorldInspectorPlugin, DefaultInspectorConfigPlugin}; -use bevy_mod_picking::{prelude::*, PickableBundle, backends::raycast::{bevy_mod_raycast::prelude::RaycastSettings, RaycastPickable}}; +use bevy_mod_picking::{ + backends::raycast::{bevy_mod_raycast::prelude::RaycastSettings, RaycastPickable}, + prelude::*, + PickableBundle, +}; use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin, PanOrbitCameraSystemSet}; use crate::{ @@ -46,11 +50,11 @@ impl Plugin for EditorPlugin { .add_plugins(PanOrbitCameraPlugin); if !app.is_plugin_added::() { - app.add_plugins( - bevy_mod_picking::DefaultPickingPlugins - ); + app.add_plugins(bevy_mod_picking::DefaultPickingPlugins); - app.world.resource_mut::().require_markers = true; + app.world + .resource_mut::() + .require_markers = true; } if !app.is_plugin_added::() { @@ -108,15 +112,10 @@ impl Plugin for EditorPlugin { app.add_systems( PostUpdate, - ( - auto_add_picking, - select_listener.after(UiSystemSet), - ) + (auto_add_picking, select_listener.after(UiSystemSet)) .run_if(in_state(EditorState::Editor)), ); - app.add_systems( - PostUpdate, - auto_add_picking_dummy); + app.add_systems(PostUpdate, auto_add_picking_dummy); app.add_systems( Update, @@ -165,16 +164,18 @@ fn auto_add_picking( } type AutoAddQueryFilter = ( - Without, - Without, - With, - Changed>); + Without, + Without, + With, + Changed>, +); //Auto add picking for each child to propagate picking event up to prefab entitiy fn auto_add_picking_dummy( - mut commands: Commands, - query : Query<(Entity, &Handle), AutoAddQueryFilter>, - meshs : Res>) { + mut commands: Commands, + query: Query<(Entity, &Handle), AutoAddQueryFilter>, + meshs: Res>, +) { for (e, mesh) in query.iter() { //Only meshed entity need to be pickable if let Some(mesh) = meshs.get(mesh) { @@ -392,4 +393,4 @@ fn draw_camera_gizmo( // for e in grids.iter() { // commands.entity(e).remove::(); // } -// } \ No newline at end of file +// } diff --git a/src/editor/ui/inspector/mod.rs b/src/editor/ui/inspector/mod.rs index 92674db8..c141de07 100644 --- a/src/editor/ui/inspector/mod.rs +++ b/src/editor/ui/inspector/mod.rs @@ -208,39 +208,27 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { pretty_type_name::pretty_type_name_str(info.name()) }; - if !editor_registry.silent.contains(®istration.type_id()) { - ui.push_id( - format!("{:?}-{}", &e.id(), &name), - |ui| { - ui.collapsing(&name, |ui| { - ui.push_id( - format!( - "content-{:?}-{}", - &e.id(), - &name - ), - |ui| { - if env.ui_for_reflect_with_options( - value, - ui, - ui.id(), - &(), - ) { - set_changed(); - } - }, - ); - }); - }, - ); + ui.push_id(format!("{:?}-{}", &e.id(), &name), |ui| { + ui.collapsing(&name, |ui| { + ui.push_id( + format!("content-{:?}-{}", &e.id(), &name), + |ui| { + if env.ui_for_reflect_with_options( + value, + ui, + ui.id(), + &(), + ) { + set_changed(); + } + }, + ); + }); + }); ui.push_id( - format!( - "del component {:?}-{}", - &e.id(), - &name - ), + format!("del component {:?}-{}", &e.id(), &name), |ui| { //must be on top ui.with_layout( diff --git a/src/lib.rs b/src/lib.rs index b41562db..9f2d0ddf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,8 +26,8 @@ use prefab::PrefabPlugin; /// Public usage of packages that used in this crate pub mod ext { pub use bevy::prelude::*; - pub use bevy_egui::*; pub use bevy_debug_grid::*; + pub use bevy_egui::*; pub use bevy_inspector_egui::prelude::*; pub use bevy_mod_picking::prelude::*; pub use bevy_panorbit_camera::*; @@ -136,6 +136,5 @@ pub fn simple_editor_setup(mut commands: Commands) { .insert(PickableBundle::default()) .insert(RaycastPickable); - bevy_debug_grid::spawn_floor_grid(commands); } diff --git a/src/optional/bevy_xpbd_plugin/collider.rs b/src/optional/bevy_xpbd_plugin/collider.rs index 0ca322cb..5a7fd4d4 100644 --- a/src/optional/bevy_xpbd_plugin/collider.rs +++ b/src/optional/bevy_xpbd_plugin/collider.rs @@ -141,7 +141,9 @@ pub fn update_collider( for (e, collider, mesh) in updated_meshes.iter() { if *collider == ColliderPrefab::FromMesh { if let Some(mesh) = meshes.get(mesh) { - commands.entity(e).insert(Collider::trimesh_from_mesh(mesh).unwrap_or_default()); + commands + .entity(e) + .insert(Collider::trimesh_from_mesh(mesh).unwrap_or_default()); } else { commands.entity(e).insert(Collider::default()); } diff --git a/src/prefab/mod.rs b/src/prefab/mod.rs index 162cc54a..11a65abf 100644 --- a/src/prefab/mod.rs +++ b/src/prefab/mod.rs @@ -132,7 +132,6 @@ impl Plugin for BasePrefabPlugin { app.editor_relation::(); app.editor_relation::(); - app.editor_relation::(); //Light @@ -232,9 +231,10 @@ fn add_computed_visibility( query: Query, Without)>, ) { for e in query.iter() { - commands.entity(e) - .insert(ViewVisibility::default()) - .insert(InheritedVisibility::VISIBLE); + commands + .entity(e) + .insert(ViewVisibility::default()) + .insert(InheritedVisibility::VISIBLE); } } @@ -243,7 +243,10 @@ fn remove_computed_visibility( query: Query, With)>, ) { for e in query.iter() { - commands.entity(e).remove::().remove::(); + commands + .entity(e) + .remove::() + .remove::(); } } @@ -254,9 +257,7 @@ fn sync_asset_mesh( assets: Res, ) { for (e, mesh) in changed.iter() { - commands - .entity(e) - .insert(assets.load::(&mesh.path)); + commands.entity(e).insert(assets.load::(&mesh.path)); } for e in deleted.read() { From 475c88995fc5063bba9603049bbd3d5165283ebf Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:38:41 +0300 Subject: [PATCH 7/9] cargo clippy --- examples/platformer.rs | 3 +-- src/editor/core/gltf_unpack.rs | 4 ++-- src/editor/core/mod.rs | 2 +- src/editor/mod.rs | 4 ++-- src/editor/ui/bot_menu.rs | 2 +- src/editor/ui/inspector/mod.rs | 2 +- src/editor/ui/mod.rs | 2 +- src/editor_registry/mod.rs | 2 +- src/lib.rs | 2 +- src/prefab/component/mod.rs | 2 +- src/prefab/mod.rs | 6 +++--- src/prefab/spawn_system.rs | 2 +- 12 files changed, 16 insertions(+), 17 deletions(-) diff --git a/examples/platformer.rs b/examples/platformer.rs index f4a36bd1..5f48a07a 100644 --- a/examples/platformer.rs +++ b/examples/platformer.rs @@ -8,7 +8,6 @@ use bevy::{ }; use bevy_xpbd_3d::{ prelude::{AngularVelocity, LinearVelocity, Position, RayHits}, - PhysicsSchedule, PhysicsStepSet, }; use space_editor::prelude::{component::EntityLink, spatial_query::RayCasterPrefab, *}; @@ -100,7 +99,7 @@ fn move_player( ) { for (_e, mut vel, mut rot, mut controller, hits, tranform) in query.iter_mut() { //take 1th hit, because 0th hit is self hit - if let Some(hit) = hits.iter_sorted().nth(0) { + if let Some(hit) = hits.iter_sorted().next() { if hit.time_of_impact > 0.7 { continue; } diff --git a/src/editor/core/gltf_unpack.rs b/src/editor/core/gltf_unpack.rs index 1655f2ef..560db208 100644 --- a/src/editor/core/gltf_unpack.rs +++ b/src/editor/core/gltf_unpack.rs @@ -48,7 +48,7 @@ fn unpack_gltf_event( assets: Res, mut queue: ResMut, ) { - for event in events.iter() { + for event in events.read() { queue.0.push(assets.load(event.path.clone())); } events.clear(); @@ -76,7 +76,7 @@ fn unpack_gltf(world: &mut World) { let loaded_scenes = { let mut events = world.resource_mut::>(); let mut reader = events.get_reader(); - let loaded = reader.iter(&events).cloned().collect::>(); + let loaded = reader.read(&events).cloned().collect::>(); events.clear(); loaded }; diff --git a/src/editor/core/mod.rs b/src/editor/core/mod.rs index 19fd7390..700475c1 100644 --- a/src/editor/core/mod.rs +++ b/src/editor/core/mod.rs @@ -70,7 +70,7 @@ fn editor_event_listener( cache: ResMut, mut gltf_events: EventWriter, ) { - for event in events.iter() { + for event in events.read() { match event { EditorEvent::Load(path) => match path { EditorPrefabPath::File(path) => { diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 6044135d..f023f32e 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -10,7 +10,7 @@ pub mod ui_registration; use bevy_egui::{EguiContext, EguiContexts}; use bevy_inspector_egui::{quick::WorldInspectorPlugin, DefaultInspectorConfigPlugin}; use bevy_mod_picking::{ - backends::raycast::{bevy_mod_raycast::prelude::RaycastSettings, RaycastPickable}, + backends::raycast::{RaycastPickable}, prelude::*, PickableBundle, }; @@ -140,7 +140,7 @@ struct SelectEvent { event: ListenerInput>, } -fn create_grid_lines(mut commands: Commands) { +fn create_grid_lines(commands: Commands) { bevy_debug_grid::spawn_floor_grid(commands); } diff --git a/src/editor/ui/bot_menu.rs b/src/editor/ui/bot_menu.rs index 21caed36..b5eabdae 100644 --- a/src/editor/ui/bot_menu.rs +++ b/src/editor/ui/bot_menu.rs @@ -184,7 +184,7 @@ pub fn bot_menu( }); }); - for event in events.iter() { + for event in events.read() { menu_state.path = event.path.clone(); editor_events.send(EditorEvent::Load(EditorPrefabPath::File(format!( "{}.scn.ron", diff --git a/src/editor/ui/inspector/mod.rs b/src/editor/ui/inspector/mod.rs index c141de07..02a0d5ae 100644 --- a/src/editor/ui/inspector/mod.rs +++ b/src/editor/ui/inspector/mod.rs @@ -265,7 +265,7 @@ pub fn inspect(ui: &mut egui::Ui, world: &mut World) { let _counter = 0; for idx in 0..components_id.len() { let c_id = components_id[idx]; - let t_id = types_id[idx]; + let _t_id = types_id[idx]; let name = pretty_type_name::pretty_type_name_str( cell.components().get_info(c_id).unwrap().name(), ); diff --git a/src/editor/ui/mod.rs b/src/editor/ui/mod.rs index 87913510..878e7bcb 100644 --- a/src/editor/ui/mod.rs +++ b/src/editor/ui/mod.rs @@ -62,7 +62,7 @@ impl Plugin for EditorUiPlugin { app.add_plugins(bot_menu::BotMenuPlugin); - app.configure_set( + app.configure_sets( Update, UiSystemSet .in_set(EditorSet::Editor) diff --git a/src/editor_registry/mod.rs b/src/editor_registry/mod.rs index e1f04aaa..e5887003 100644 --- a/src/editor_registry/mod.rs +++ b/src/editor_registry/mod.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use bevy::{ ecs::system::{EntityCommand, EntityCommands}, prelude::*, - reflect::{GetTypeRegistration, TypePath, TypeRegistry, TypeRegistryArc}, + reflect::{GetTypeRegistration, TypePath, TypeRegistryArc}, utils::{HashMap, HashSet}, }; diff --git a/src/lib.rs b/src/lib.rs index 9f2d0ddf..80e1c6e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ use prefab::PrefabPlugin; /// Public usage of packages that used in this crate pub mod ext { pub use bevy::prelude::*; - pub use bevy_debug_grid::*; + pub use bevy_debug_grid; pub use bevy_egui::*; pub use bevy_inspector_egui::prelude::*; pub use bevy_mod_picking::prelude::*; diff --git a/src/prefab/component/mod.rs b/src/prefab/component/mod.rs index be37b024..2814e32b 100644 --- a/src/prefab/component/mod.rs +++ b/src/prefab/component/mod.rs @@ -54,7 +54,7 @@ pub struct AutoStruct { } impl AutoStruct { - pub fn new(data: &T, assets: &AssetServer) -> AutoStruct { + pub fn new(data: &T, _assets: &AssetServer) -> AutoStruct { let mut paths = HashMap::new(); if let ReflectRef::Struct(s) = data.reflect_ref() { diff --git a/src/prefab/mod.rs b/src/prefab/mod.rs index 11a65abf..774531f8 100644 --- a/src/prefab/mod.rs +++ b/src/prefab/mod.rs @@ -58,8 +58,8 @@ impl Plugin for BasePrefabPlugin { app.add_plugins(EditorRegistryPlugin); } - app.configure_set(Update, EditorSet::Game.run_if(in_state(EditorState::Game))); - app.configure_set( + app.configure_sets(Update, EditorSet::Game.run_if(in_state(EditorState::Game))); + app.configure_sets( Update, EditorSet::Editor.run_if(in_state(EditorState::Editor)), ); @@ -280,7 +280,7 @@ fn sync_asset_material( .insert(assets.load::(&material.path)); } - for e in deleted.iter() { + for e in deleted.read() { if let Some(mut cmd) = commands.get_entity(e) { cmd.remove::>(); } diff --git a/src/prefab/spawn_system.rs b/src/prefab/spawn_system.rs index bd8702e5..7d9e4915 100644 --- a/src/prefab/spawn_system.rs +++ b/src/prefab/spawn_system.rs @@ -88,7 +88,7 @@ pub fn editor_remove_mesh( mut commands: Commands, mut query: RemovedComponents, ) { - for e in query.iter() { + for e in query.read() { if let Some(mut cmd) = commands.get_entity(e) { cmd.remove::>(); info!("Removed mesh handle for {:?}", e); From 033c747afa28a6cf54f75c88245dc509937d1c9d Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:43:11 +0300 Subject: [PATCH 8/9] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index dc28da8d..a0f545bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ bevy_egui = "0.23" egui-gizmo = "0.12" bevy-scene-hook = "9" ron = "0.8" -bevy_panorbit_camera = {version = "0.9", features=["bevy_egui"]} +bevy_panorbit_camera = "0.9" bevy-inspector-egui = {version = "0.21", features = ["bevy_pbr", "highlight_changes"]} pretty-type-name = "1.0" bevy_mod_picking = {version = "0.17", default-features = false, features = ["backend_raycast", "selection"]} From 0d99388e8c593c0519eac45c8fa1618f576db16d Mon Sep 17 00:00:00 2001 From: rewin Date: Sat, 11 Nov 2023 22:47:10 +0300 Subject: [PATCH 9/9] cargo fmt again --- examples/platformer.rs | 4 +--- src/editor/mod.rs | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/platformer.rs b/examples/platformer.rs index 5f48a07a..d6f58108 100644 --- a/examples/platformer.rs +++ b/examples/platformer.rs @@ -6,9 +6,7 @@ use bevy::{ ecs::{entity::MapEntities, reflect::ReflectMapEntities}, prelude::*, }; -use bevy_xpbd_3d::{ - prelude::{AngularVelocity, LinearVelocity, Position, RayHits}, -}; +use bevy_xpbd_3d::prelude::{AngularVelocity, LinearVelocity, Position, RayHits}; use space_editor::prelude::{component::EntityLink, spatial_query::RayCasterPrefab, *}; fn main() { diff --git a/src/editor/mod.rs b/src/editor/mod.rs index f023f32e..a48560b1 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -9,11 +9,7 @@ pub mod ui_registration; use bevy_egui::{EguiContext, EguiContexts}; use bevy_inspector_egui::{quick::WorldInspectorPlugin, DefaultInspectorConfigPlugin}; -use bevy_mod_picking::{ - backends::raycast::{RaycastPickable}, - prelude::*, - PickableBundle, -}; +use bevy_mod_picking::{backends::raycast::RaycastPickable, prelude::*, PickableBundle}; use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin, PanOrbitCameraSystemSet}; use crate::{