Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rewin123 committed Nov 11, 2023
1 parent 4993949 commit 081aa3f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 68 deletions.
6 changes: 1 addition & 5 deletions examples/platformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/editor/core/gltf_unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> = 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;
Expand Down
43 changes: 22 additions & 21 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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::{
Expand Down Expand Up @@ -46,11 +50,11 @@ impl Plugin for EditorPlugin {
.add_plugins(PanOrbitCameraPlugin);

if !app.is_plugin_added::<bevy_mod_picking::prelude::SelectionPlugin>() {
app.add_plugins(
bevy_mod_picking::DefaultPickingPlugins
);
app.add_plugins(bevy_mod_picking::DefaultPickingPlugins);

app.world.resource_mut::<backends::raycast::RaycastBackendSettings>().require_markers = true;
app.world
.resource_mut::<backends::raycast::RaycastBackendSettings>()
.require_markers = true;
}

if !app.is_plugin_added::<bevy_debug_grid::DebugGridPlugin>() {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -165,16 +164,18 @@ fn auto_add_picking(
}

type AutoAddQueryFilter = (
Without<PrefabMarker>,
Without<Pickable>,
With<Parent>,
Changed<Handle<Mesh>>);
Without<PrefabMarker>,
Without<Pickable>,
With<Parent>,
Changed<Handle<Mesh>>,
);

//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<Mesh>), AutoAddQueryFilter>,
meshs : Res<Assets<Mesh>>) {
mut commands: Commands,
query: Query<(Entity, &Handle<Mesh>), AutoAddQueryFilter>,
meshs: Res<Assets<Mesh>>,
) {
for (e, mesh) in query.iter() {
//Only meshed entity need to be pickable
if let Some(mesh) = meshs.get(mesh) {
Expand Down Expand Up @@ -392,4 +393,4 @@ fn draw_camera_gizmo(
// for e in grids.iter() {
// commands.entity(e).remove::<Pickable>();
// }
// }
// }
48 changes: 18 additions & 30 deletions src/editor/ui/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&registration.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(
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -136,6 +136,5 @@ pub fn simple_editor_setup(mut commands: Commands) {
.insert(PickableBundle::default())
.insert(RaycastPickable);


bevy_debug_grid::spawn_floor_grid(commands);
}
4 changes: 3 additions & 1 deletion src/optional/bevy_xpbd_plugin/collider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
17 changes: 9 additions & 8 deletions src/prefab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ impl Plugin for BasePrefabPlugin {
app.editor_relation::<PlayerStart, ViewVisibility>();
app.editor_relation::<PlayerStart, InheritedVisibility>();


app.editor_relation::<Transform, GlobalTransform>();

//Light
Expand Down Expand Up @@ -232,9 +231,10 @@ fn add_computed_visibility(
query: Query<Entity, (With<Visibility>, Without<ViewVisibility>)>,
) {
for e in query.iter() {
commands.entity(e)
.insert(ViewVisibility::default())
.insert(InheritedVisibility::VISIBLE);
commands
.entity(e)
.insert(ViewVisibility::default())
.insert(InheritedVisibility::VISIBLE);
}
}

Expand All @@ -243,7 +243,10 @@ fn remove_computed_visibility(
query: Query<Entity, (Without<Visibility>, With<ViewVisibility>)>,
) {
for e in query.iter() {
commands.entity(e).remove::<ViewVisibility>().remove::<InheritedVisibility>();
commands
.entity(e)
.remove::<ViewVisibility>()
.remove::<InheritedVisibility>();
}
}

Expand All @@ -254,9 +257,7 @@ fn sync_asset_mesh(
assets: Res<AssetServer>,
) {
for (e, mesh) in changed.iter() {
commands
.entity(e)
.insert(assets.load::<Mesh>(&mesh.path));
commands.entity(e).insert(assets.load::<Mesh>(&mesh.path));
}

for e in deleted.read() {
Expand Down

0 comments on commit 081aa3f

Please sign in to comment.