Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
91a0812
working away
MiniMinerX Jan 21, 2025
c75da51
furthur done
MiniMinerX Jan 22, 2025
73582b3
egui and bevy version fixes
MiniMinerX Jan 22, 2025
fa53dfa
small fixes
MiniMinerX Jan 23, 2025
727bd57
more picking fixes
MiniMinerX Jan 23, 2025
668b2b1
stuffs so broke
MiniMinerX Jan 24, 2025
65d1e46
runs but no egui shows
MiniMinerX Jan 24, 2025
0f3a6e5
Fix ui showing
rewin123 Jan 25, 2025
ef0aec8
Merge pull request #1 from rewin123/update_for_update_fo_0.15
MiniMinerX Jan 25, 2025
245b509
Merge pull request #318 from MiniMinerX/0.15-dev
rewin123 Jan 25, 2025
4fb3849
Refactor selection system with observer pattern and simplify picking …
rewin123 Jan 26, 2025
227c10f
Selection works. Deselection is not working
rewin123 Jan 26, 2025
485b488
Update selection.rs
rewin123 Jan 26, 2025
c250d40
fixed reflect issues
MiniMinerX Jan 28, 2025
c9f96e9
Update Cargo.toml
MiniMinerX Feb 3, 2025
30456f3
removed editor relations
MiniMinerX Feb 4, 2025
537c16d
Update Cargo.toml
MiniMinerX Feb 4, 2025
2032044
Update plugins.rs
MiniMinerX Feb 4, 2025
378fe4a
Update Cargo.toml
MiniMinerX Feb 5, 2025
f3fc666
Update menu_toolbars.rs
MiniMinerX Feb 8, 2025
5b3538f
Update Cargo.toml
MiniMinerX Feb 8, 2025
a044782
Update Cargo.toml
MiniMinerX Feb 8, 2025
2333b25
Update Cargo.toml
MiniMinerX Feb 9, 2025
817f492
Update plugins.rs
MiniMinerX Feb 14, 2025
532c54a
Update plugins.rs
MiniMinerX Feb 14, 2025
b0278a1
progress
MiniMinerX May 6, 2025
4c3e013
almsot there
MiniMinerX May 6, 2025
731cc33
just ui left
MiniMinerX May 7, 2025
80f3fb9
reflect
MiniMinerX May 8, 2025
be92869
working ?
MiniMinerX May 11, 2025
cd158ce
one more
MiniMinerX May 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,579 changes: 2,178 additions & 1,401 deletions Cargo.lock

Large diffs are not rendered by default.

93 changes: 61 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ name = "plugin_test"
path = "external/editor_as_plugin/src/main.rs"

[workspace.package]
version = "0.6.0"
edition = "2021"
version = "0.8.0"
edition = "2024"
license = "MIT OR Apache-2.0"
authors = ["rewin <rewin1996@gmail.com>", "Julia Naomi <jnboeira@outlook.com>"]
keywords = ["gamedev", "editor", "bevy"]
Expand All @@ -42,42 +42,69 @@ repository = "https://github.com/rewin123/space_editor"
homepage = "https://github.com/rewin123/space_editor"

[workspace.dependencies]
bevy = "0.14.2"
bevy = { version = "0.16.0", default-features = false, features = [
"bevy_gltf",
"bevy_log",
"bevy_window",
"bevy_state",
"bevy_sprite",
"reflect_documentation",
"reflect_functions",
"bevy_gizmos",
"bevy_picking",
"bevy_mesh_picking_backend",
] }

# Editor Crates
space_prefab = { version = "0.6.0", path = "crates/prefab" }
space_shared = { version = "0.6.0", path = "crates/shared" }
space_undo = { version = "0.6.0", path = "crates/undo" }
space_persistence = { version = "0.6.0", path = "crates/persistence"}
space_editor_core = { version = "0.6.0", path = "crates/editor_core", features = ["persistence_editor"] }
space_editor_ui = { version = "0.6.0", path = "crates/editor_ui", features = ["persistence_editor"] }
space_editor_tabs = { version = "0.6.0", path = "crates/editor_tabs" }
space_prefab = { version = "0.8.0", path = "crates/prefab" }
space_shared = { version = "0.8.0", path = "crates/shared" }
space_undo = { version = "0.8.0", path = "crates/undo" }
space_persistence = { version = "0.8.0", path = "crates/persistence"}
space_editor_core = { version = "0.8.0", path = "crates/editor_core", features = ["persistence_editor"] }
space_editor_ui = { version = "0.8.0", path = "crates/editor_ui", features = ["persistence_editor"] }
space_editor_tabs = { version = "0.8.0", path = "crates/editor_tabs" }

# Crates inner libraries
anyhow = "1.0"
bevy_asset_loader = "0.21"
bevy_debug_grid = "0.6"
bevy_egui = "0.29"
bevy-inspector-egui = { version = "0.25", features = [
bevy_egui = "0.34"
egui_extras = { version = "0.31.1", features = ["all_loaders"] }
pretty-type-name = "1"
rand = "0.9.1"
ron = "0.10.1"
serde = "1.0"
convert_case = "0.8.0"
image = "0.25.6"
egui_dock = "0.16.0"
egui_file = "0.22.1"
egui-toast = "0.17.0"

bevy-scene-hook = {git = "https://github.com/MiniMinerX/bevy-scene-hook.git", branch= "dev-0.16"}
bevy_debug_grid = { git = "https://github.com/MiniMinerX/bevy_debug_grid.git", branch = "dev-0.16"}
bevy-inspector-egui = {version = "0.31.0", features = [
"bevy_pbr",
"highlight_changes",
] }
bevy_mod_billboard = { version = "0.7.0" }
bevy_mod_picking = { version = "0.20.1", default-features = false, features = ["backend_raycast", "selection",] }
bevy_panorbit_camera = { version = "0.19", default-features = false }
bevy-scene-hook = {git = "https://github.com/stargazing-dino/bevy-scene-hook.git", branch= "update-14.0"}
convert_case = "0.6"
egui_dock = "0.13"
egui_extras = { version = "0.28.1", features = ["all_loaders"] }
egui_file = "0.18"
transform-gizmo-egui = "0.3.0"
transform-gizmo-bevy = "0.3.0"
egui-toast = "0.14.0"
image = {version = "0.25.1", feature = ["png"] }
pretty-type-name = "1"
rand = "*"
ron = "0.8"
serde = "1"
]}
#bevy-inspector-egui = { branch = "space_edit", git = "https://github.com/MiniMinerX/bevy-inspector-egui.git", features = [
# "bevy_pbr",
# "highlight_changes",
#] }
bevy_mod_billboard = { branch = "dev-0.16", git = "https://github.com/MiniMinerX/bevy_mod_billboard.git"}
bevy_asset_loader = "0.23.0-rc.3"
bevy_panorbit_camera = "0.26"
# bevy_panorbit_camera = { branch = "reflect_component", git = "https://github.com/MiniMinerX/bevy_panorbit_camera.git"}
bevy_mod_outline = {git = "https://github.com/komadori/bevy_mod_outline.git", branch = "bevy-0.16"}

# below has not been updated to bevy 0.16

transform-gizmo-bevy = {git = "https://github.com/jakobhellermann/transform-gizmo.git", branch = "bevy-0.16", package = "transform-gizmo-bevy"}
transform-gizmo-egui = {git = "https://github.com/jakobhellermann/transform-gizmo.git", branch = "bevy-0.16", package = "transform-gizmo-egui"}


#transform-gizmo-egui = {git = "https://github.com/MiniMinerX/transform-gizmo.git"}
#transform-gizmo-bevy = { git = "https://github.com/MiniMinerX/transform-gizmo.git"}




# Community Modules
game_app = { version = "0.1.0", path = "game" }
Expand Down Expand Up @@ -127,9 +154,11 @@ workspace = true
opt-level = 1
overflow-checks = false
incremental = true # works well when target/ is stored
prefer-dynamic = true # prefer dynamic linking for faster builds

[profile.dev.package."*"]
opt-level = 3
prefer-dynamic = true

[profile.release-fast]
inherits = "release"
Expand All @@ -153,4 +182,4 @@ no_event_registration = ["space_prefab/no_event_registration"]
default = [
"persistence_editor",
"space_prefab/editor",
]
]
3 changes: 2 additions & 1 deletion crates/editor_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ bevy_egui.workspace = true
egui_dock.workspace = true
egui-toast.workspace = true

bevy_mod_outline = {git = "https://github.com/komadori/bevy_mod_outline.git", optional = true}
bevy_mod_outline.workspace = true
bevy_mod_outline.optional = true
workspace-hakari = { version = "0.1", path = "../../workspace-hakari" }

[features]
Expand Down
43 changes: 24 additions & 19 deletions crates/editor_core/src/gltf_unpack.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use bevy::{
asset::{AssetPath, LoadState},
ecs::world::CommandQueue,
gltf::{Gltf, GltfMesh, GltfNode},
prelude::*,
utils::HashMap,
asset::{AssetPath, LoadState}, ecs::world::CommandQueue, gltf::{Gltf, GltfMesh, GltfNode}, platform::collections::HashMap, prelude::*
};

use space_prefab::component::{AssetMaterial, AssetMesh, MaterialPrefab};
Expand Down Expand Up @@ -64,8 +60,9 @@ fn queue_push(
mut events: EventWriter<GltfLoaded>,
assets: Res<AssetServer>,
) {
if !queue.0.is_empty() && assets.get_load_state(&queue.0[0]) == Some(LoadState::Loaded) {
events.send(GltfLoaded(queue.0.remove(0)));
if !queue.0.is_empty() && matches!(assets.get_load_state(&queue.0[0]), Some(LoadState::Loaded))
{
events.write(GltfLoaded(queue.0.remove(0)));
}
}

Expand All @@ -74,14 +71,15 @@ struct UnpackContext<'a> {
mesh_map: &'a HashMap<Handle<GltfMesh>, usize>,
gltf_meshs: &'a Assets<GltfMesh>,
gltf_path: &'a AssetPath<'a>,
gltf_nodes: &'a Assets<GltfNode>,
}

fn unpack_gltf(world: &mut World) {
let loaded_scenes = {
let Some(mut events) = world.get_resource_mut::<Events<GltfLoaded>>() else {
return;
};
let mut reader = events.get_reader();
let mut reader = events.get_cursor();
let loaded = reader.read(&events).cloned().collect::<Vec<GltfLoaded>>();
events.clear();
loaded
Expand Down Expand Up @@ -151,17 +149,15 @@ fn unpack_gltf(world: &mut World) {
//find roots nodes
let mut roots = vec![];
for e in scene.world.iter_entities() {
if !e.contains::<Parent>() && e.contains::<Children>() {
if !e.contains::<ChildOf>() && e.contains::<Children>() {
let Some(children) = e.get::<Children>() else {
continue;
};
for child in children.iter() {
if let Some(name) = scene.world.entity(*child).get::<Name>() {
if let Some(name) = scene.world.entity(child.entity()).get::<Name>() {
info!("Name: {:?}", &name);
if let Some(node_handle) = gltf.named_nodes.get(name.as_str()) {
if let Some(node) = gltf_nodes.get(node_handle) {
roots.push(node.clone());
}
roots.push(node_handle.clone())
}
}
}
Expand All @@ -175,6 +171,7 @@ fn unpack_gltf(world: &mut World) {
mesh_map: &mesh_map,
gltf_meshs,
gltf_path: &gltf_path,
gltf_nodes: &gltf_nodes,
};

for root in roots.iter() {
Expand All @@ -190,16 +187,23 @@ fn unpack_gltf(world: &mut World) {

fn spawn_node(
commands: &mut Commands,
node: &GltfNode,
node_handle: &Handle<GltfNode>,
_gltf: &Gltf,
ctx: &UnpackContext<'_>,
) -> Entity {

let gltf_nodes = ctx.gltf_nodes;

let Some(node) = gltf_nodes.get(node_handle) else {
error!("Failed to get GltfNode for handle: {:?}", node_handle);
return commands.spawn_empty().id();
};


let id = commands
.spawn((
SpatialBundle {
transform: node.transform,
..default()
},
node.transform,
Visibility::default(),
PrefabMarker,
))
.id();
Expand Down Expand Up @@ -231,7 +235,8 @@ fn spawn_node(
commands.entity(id).with_children(|parent| {
for idx in 0..mesh.primitives.len() {
let mut id = parent.spawn((
SpatialBundle::default(),
Transform::default(),
Visibility::default(),
AssetMesh {
path: format!(
"{}#Mesh{}/Primitive{}",
Expand Down
8 changes: 4 additions & 4 deletions crates/editor_core/src/hotkeys.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(clippy::type_complexity)]
#![allow(clippy::too_many_arguments)]

use bevy::platform::collections::HashMap;
use bevy::prelude::*;
use bevy::reflect::GetTypeRegistration;
use bevy::utils::HashMap;
use bevy::reflect::{GetTypeRegistration, Typed};

#[cfg(feature = "persistence_editor")]
use space_persistence::AppPersistenceExt;
Expand Down Expand Up @@ -102,11 +102,11 @@ impl<T: Hotkey> UntypedHotkeySet for HotkeySet<T> {
}

pub trait HotkeyAppExt {
fn editor_hotkey<T: Hotkey>(&mut self, key: T, binding: Vec<KeyCode>) -> &mut Self;
fn editor_hotkey<T: Hotkey + Typed>(&mut self, key: T, binding: Vec<KeyCode>) -> &mut Self;
}

impl HotkeyAppExt for App {
fn editor_hotkey<T: Hotkey>(&mut self, key: T, binding: Vec<KeyCode>) -> &mut Self {
fn editor_hotkey<T: Hotkey + Typed>(&mut self, key: T, binding: Vec<KeyCode>) -> &mut Self {
if !self.world().contains_resource::<AllHotkeys>() {
self.insert_resource(AllHotkeys::default());
}
Expand Down
6 changes: 3 additions & 3 deletions crates/editor_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ impl Plugin for EditorCore {

app.add_systems(
Update,
(apply_deferred, load_listener)
(ApplyDeferred, load_listener)
.chain()
.in_set(EditorLoadSet),
);
app.add_systems(Update, editor_event_listener);

app.auto_reflected_undo::<Parent>();
//app.auto_reflected_undo::<ChildOf>();
app.auto_reflected_undo::<Children>();
app.auto_undo::<PrefabMarker>();
}
Expand Down Expand Up @@ -101,7 +101,7 @@ fn editor_event_listener(
start_game_state.set(EditorState::GamePrepare);
}
EditorEvent::LoadGltfAsPrefab(path) => {
gltf_events.send(gltf_unpack::EditorUnpackGltf { path: path.clone() });
gltf_events.write(gltf_unpack::EditorUnpackGltf { path: path.clone() });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/editor_core/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn load_listener(world: &mut World) {
.collect();
for (entity, name) in mark_to_delete {
let mut despawned = false;
if let Some(e) = world.get_entity_mut(entity) {
if let Some(e) = world.get_entity_mut(entity).ok() {
e.despawn_recursive();
despawned = true;
}
Expand Down
23 changes: 15 additions & 8 deletions crates/editor_core/src/selected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy::pbr::wireframe::{Wireframe, WireframePlugin};
use space_shared::{EditorSet, EditorState};

#[cfg(feature = "bevy_mod_outline")]
use bevy_mod_outline::{OutlineBundle, OutlinePlugin, OutlineVolume};
use bevy_mod_outline::{OutlinePlugin, OutlineVolume};

/// A marker for editor selected entities
#[derive(Component, Default, Clone)]
Expand Down Expand Up @@ -65,27 +65,34 @@ fn selected_entity_wireframe_update(
del_wireframe: Query<Entity, (With<OutlineVolume>, Without<Selected>)>,
need_wireframe: Query<Entity, (Without<OutlineVolume>, With<Selected>)>,
) {
use bevy_mod_outline::OutlineMode;

for e in del_wireframe.iter() {
cmds.entity(e).remove::<OutlineBundle>();
cmds.entity(e)
.remove::<OutlineVolume>()
.remove::<OutlineMode>();
}

for e in need_wireframe.iter() {
cmds.entity(e).insert(OutlineBundle {
outline: OutlineVolume {
cmds.entity(e).insert((
OutlineVolume {
visible: true,
colour: Color::srgb(1.0, 1.0, 0.0),
width: 2.0,
},
mode: bevy_mod_outline::OutlineMode::RealVertex,
..Default::default()
});
OutlineMode::ExtrudeReal,
));
}
}

#[cfg(feature = "bevy_mod_outline")]
fn clear_wireframes(mut cmds: Commands, del_wireframe: Query<Entity, With<OutlineVolume>>) {
use bevy_mod_outline::OutlineMode;

for e in del_wireframe.iter() {
cmds.entity(e).remove::<OutlineBundle>();
cmds.entity(e)
.remove::<OutlineVolume>()
.remove::<OutlineMode>();
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/editor_core/src/task_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn update_storage(mut storage: ResMut<BackgroundTaskStorage>, assets: Res<AssetS
match &storage.tasks[0] {
BackgroundTask::AssetLoading(_path, handle) => {
let load_state = assets.get_load_state(handle.id());
if load_state == Some(LoadState::Loaded)
if matches!(load_state, Some(LoadState::Loaded))
|| load_state.is_none()
|| matches!(load_state, Some(LoadState::Failed(_)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both matches can be patternmatched together

{
Expand Down
Loading
Loading