Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.15 dev #318

Merged
merged 9 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2,627 changes: 1,514 additions & 1,113 deletions Cargo.lock

Large diffs are not rendered by default.

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

[workspace.package]
version = "0.6.0"
version = "0.7.0"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["rewin <[email protected]>", "Julia Naomi <[email protected]>"]
Expand All @@ -42,38 +42,37 @@ repository = "https://github.com/rewin123/space_editor"
homepage = "https://github.com/rewin123/space_editor"

[workspace.dependencies]
bevy = "0.14.2"
bevy = "0.15.1"

# 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.7.0", path = "crates/prefab" }
space_shared = { version = "0.7.0", path = "crates/shared" }
space_undo = { version = "0.7.0", path = "crates/undo" }
space_persistence = { version = "0.7.0", path = "crates/persistence"}
space_editor_core = { version = "0.7.0", path = "crates/editor_core", features = ["persistence_editor"] }
space_editor_ui = { version = "0.7.0", path = "crates/editor_ui", features = ["persistence_editor"] }
space_editor_tabs = { version = "0.7.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_asset_loader = "0.22.0"
bevy_debug_grid = { git = "https://github.com/romenjelly/bevy_debug_grid.git"}
bevy_egui = "0.32.0"
bevy-inspector-egui = { git = "https://github.com/MiniMinerX/bevy-inspector-egui.git", branch = "space_edit", 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"] }
bevy_mod_billboard = { branch = "migrate-0.15", git = "https://github.com/MiniMinerX/bevy_mod_billboard.git"}
bevy_panorbit_camera = { version = "0.22", default-features = false }
bevy-scene-hook = {git = "https://github.com/MiniMinerX/bevy-scene-hook.git", branch= "update-15.1"}
convert_case = "0.7.1"
egui_dock = "0.15.0"
egui_extras = { version = "0.30.0", features = ["all_loaders"] }
egui_file = { rev = "bcacedf", git = "https://github.com/Barugon/egui_file.git"}
transform-gizmo-egui = {git = "https://github.com/MiniMinerX/transform-gizmo.git"}
transform-gizmo-bevy = { git = "https://github.com/MiniMinerX/transform-gizmo.git"}
egui-toast = "0.16.0"
image = {version = "0.25.5", feature = ["png"] }
pretty-type-name = "1"
rand = "*"
ron = "0.8"
Expand Down Expand Up @@ -127,9 +126,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 Down
20 changes: 15 additions & 5 deletions crates/editor_core/src/gltf_unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ 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) {
if !queue.0.is_empty() && matches!(assets.get_load_state(&queue.0[0]), Some(LoadState::Loaded))
{
events.send(GltfLoaded(queue.0.remove(0)));
}
}
Expand All @@ -74,6 +75,7 @@ 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) {
Expand Down Expand Up @@ -159,9 +161,7 @@ fn unpack_gltf(world: &mut World) {
if let Some(name) = scene.world.entity(*child).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 +175,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,10 +191,19 @@ 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 node = match gltf_nodes.get(node_handle) {
Some(node) => node,
None => {
error!("Failed to get GltfNode for handle: {:?}", node_handle);
return commands.spawn_empty().id();
}
};

let id = commands
.spawn((
SpatialBundle {
Expand Down
6 changes: 3 additions & 3 deletions crates/editor_core/src/hotkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(clippy::too_many_arguments)]

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

#[cfg(feature = "persistence_editor")]
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
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(_)))
{
Expand Down
10 changes: 10 additions & 0 deletions crates/editor_tabs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ pub mod prelude {
/// This system use to show all egui editor ui on primary window
/// Will be useful in some specific cases to ad new system before/after this system
pub fn show_editor_ui(world: &mut World) {
// info!("show_editor_ui");

let Ok(egui_context) = world
.query_filtered::<&mut EguiContext, With<PrimaryWindow>>()
.get_single(world)
else {
info!("show_editor_ui: no egui context");
return;
};
let mut egui_context = egui_context.clone();
Expand All @@ -57,6 +60,8 @@ pub fn show_editor_ui(world: &mut World) {
world.resource_scope::<EditorUi, _>(|world, mut editor_ui| {
editor_ui.ui(world, ctx);
});
} else {
info!("show_editor_ui: no editor ui");
}
}

Expand Down Expand Up @@ -99,14 +104,19 @@ impl EditorUi {
tabs,
active: _,
scroll: _,
collapsed: _,
} => visible.extend(tabs.clone()),
egui_dock::Node::Vertical {
rect: _,
fraction: _,
collapsed_leaf_count: _,
fully_collapsed: _,
} => {}
egui_dock::Node::Horizontal {
rect: _,
fraction: _,
collapsed_leaf_count: _,
fully_collapsed: _,
} => {}
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/editor_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ transform-gizmo-egui.workspace = true
egui_dock.workspace = true
bevy_debug_grid.workspace = true
bevy-inspector-egui.workspace = true
bevy_mod_picking.workspace = true
bevy_asset_loader.workspace = true
bevy_panorbit_camera.workspace = true
bevy_mod_billboard.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions crates/editor_ui/src/camera_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ pub fn draw_camera_gizmo(
let rect_transform = transform.mul_transform(rect_transform);

gizmos.rect(
rect_transform.translation,
rect_transform.rotation,
Isometry3d::new(rect_transform.translation, rect_transform.rotation),
Vec2::splat(scale * 2.0),
pink,
);
Expand Down
28 changes: 12 additions & 16 deletions crates/editor_ui/src/camera_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ impl EditorTab for CameraViewTab {
self.real_camera = Some(
commands
.spawn((
Camera3dBundle {
camera: Camera {
is_active: true,
order: 2,
clear_color: bevy::render::camera::ClearColorConfig::Default,
..default()
},
Camera3d::default(),
Camera {
is_active: true,
order: 2,
clear_color: bevy::render::camera::ClearColorConfig::Default,
..default()
},
RenderLayers::layer(0),
Expand All @@ -106,13 +104,11 @@ impl EditorTab for CameraViewTab {
self.real_camera = Some(
commands
.spawn((
Camera2dBundle {
camera: Camera {
is_active: false,
order: 2,
clear_color: bevy::render::camera::ClearColorConfig::Default,
..default()
},
Camera2d::default(),
Camera {
is_active: false,
order: 2,
clear_color: bevy::render::camera::ClearColorConfig::Default,
..default()
},
RenderLayers::layer(0),
Expand Down Expand Up @@ -172,7 +168,7 @@ impl EditorTab for CameraViewTab {
Projection::Perspective(PerspectiveProjection::default()),
Name::new("Camera3d".to_string()),
Transform::default(),
VisibilityBundle::default(),
Visibility::default(),
PlaymodeCamera::default(),
PrefabMarker,
CameraRenderGraph::new(bevy::core_pipeline::core_3d::graph::Core3d),
Expand All @@ -183,7 +179,7 @@ impl EditorTab for CameraViewTab {
Camera2d {},
Name::new("Camera2d".to_string()),
Transform::default(),
VisibilityBundle::default(),
Visibility::default(),
PlaymodeCamera::default(),
CameraRenderGraph::new(bevy::core_pipeline::core_2d::graph::Core2d),
PrefabMarker,
Expand Down
Loading
Loading