Skip to content

Upgrade to Bevy 0.14 & upgrade egui-gizmo dependency #110

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

Merged
merged 31 commits into from
Aug 11, 2024
Merged
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
1bf2e57
wip: basic example works
ActuallyHappening Jun 9, 2024
5899792
revert: basic example
ActuallyHappening Jun 9, 2024
cb4e8b3
feat: gizmos are completely integrated
ActuallyHappening Jun 10, 2024
fd3f4c7
fmt: Fixed formatting
ActuallyHappening Jun 10, 2024
f9c500e
clean: remove unnecessary code
ActuallyHappening Jun 10, 2024
0027011
fix: More defensive programming
ActuallyHappening Jun 20, 2024
df9dfc2
Change bevy dependencies to 0.14.0-rc in Cargo.toml
zhaop Jun 24, 2024
73257a1
Use app.world_mut() or .world() instead of .world
zhaop Jun 24, 2024
5dc8c40
Clone RenderLayers when necessary & change underlying type to usize
zhaop Jun 24, 2024
be6eab0
Match app.get_sub_app as Option instead of Result
zhaop Jun 24, 2024
76f6f9e
Use Color::srgb* instead of Color::rgb*
zhaop Jun 24, 2024
ba60866
Change to DynamicScene::serialize(&TypeRegistry)
zhaop Jun 24, 2024
8a71420
Temporarily patch dependencies to forks that support bevy 0.14.0-rc too
zhaop Jun 25, 2024
a9e1867
Update colors in examples from rgb* -> srgb*
zhaop Jun 25, 2024
81760c5
Upgrade to egui 0.28, egui_dock 0.13 + Remove bevy_egui patch
zhaop Jul 6, 2024
7bf7db6
Upgrade Bevy -> 0.14.*
zhaop Jul 6, 2024
2ede2b2
Replace Label::wrap(false) -> Label::extend()
zhaop Jul 6, 2024
00673ec
Rename DragValue::clamp_range -> DragValue::range
zhaop Jul 6, 2024
92145a6
Use ui.add_enabled_ui instead of ui.set_enabled
zhaop Jul 6, 2024
340a0e2
Use bevy-0.14 branch of tentatively upgraded transform-gizmo-bevy
zhaop Jul 6, 2024
09dac4b
Upgrade bevy-inspector-egui to 0.25.0 & use crates.io version (in ant…
zhaop Jul 6, 2024
e9bec52
Bump version to 0.9.0 & update README, CHANGELOG
zhaop Jul 6, 2024
afd78ee
Reimplement close_on_esc in breakout example
zhaop Jul 7, 2024
43e6645
Change Color::rgb -> Color::srgb
zhaop Jul 7, 2024
67e5b53
Add half_size arg to Plane3d::new calls instead of PlaneMeshBuilder
zhaop Jul 7, 2024
59bb5df
Fix ambiguous camera order in 2d_3d_mixed example
zhaop Jul 7, 2024
315b55c
Fix panic when requesting negatively sized space from egui
zhaop Jul 7, 2024
42bc2fd
Upgrade bevy_mod_debugdump 0.10 -> 0.11 from crates.io
zhaop Jul 7, 2024
61c453d
Swap camera order so the 2d part is visible in 2d_3d_mixed example
zhaop Jul 7, 2024
78aa34c
Upgrade transform-gizmo-bevy 0.2 -> 0.3 & remove git-repo patch
zhaop Jul 8, 2024
8ae7170
remove auto_shrink false
jakobhellermann Aug 11, 2024
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 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Version 0.9
- update to bevy 0.14

## Version 0.8
- update to bevy 0.13

Expand Down
17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.8.1"
version = "0.9.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/jakobhellermann/bevy_editor_pls"
description = "In-App editor tools for bevy apps"
readme = "README.md"

[workspace.dependencies]
bevy_editor_pls = { version = "0.8.0", path = "crates/bevy_editor_pls" }
bevy_editor_pls_core = { version = "0.8.0", path = "crates/bevy_editor_pls_core" }
bevy_editor_pls_default_windows = { version = "0.8.0", path = "crates/bevy_editor_pls_default_windows" }
bevy_editor_pls = { version = "0.9.0", path = "crates/bevy_editor_pls" }
bevy_editor_pls_core = { version = "0.9.0", path = "crates/bevy_editor_pls_core" }
bevy_editor_pls_default_windows = { version = "0.9.0", path = "crates/bevy_editor_pls_default_windows" }

bevy-inspector-egui = "0.23.0"
egui = "0.26"
egui_dock = "0.11"
egui-gizmo = "0.16"
bevy-inspector-egui = "0.25.0"
egui = "0.28"
egui_dock = "0.13"
# used to be egui-gizmo 0.16
transform-gizmo-bevy = "0.3"

[profile.dev.package."*"]
opt-level = 2
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ fn set_cam3d_controls(

| bevy | bevy\_editor\_pls |
| ---- | ----------------- |
| 0.14 | 0.9 |
| 0.13 | 0.8 |
| 0.12 | 0.7 |
| 0.12 | 0.6 |
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_editor_pls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ default = ["default_windows"]
[dependencies]
bevy_editor_pls_core.workspace = true
bevy_editor_pls_default_windows = { workspace = true, optional = true }
bevy = { version = "0.13", default-features = false, features = ["x11"] }
bevy = { version = "0.14", default-features = false, features = ["x11"] }
egui.workspace = true
egui-gizmo.workspace = true
transform-gizmo-bevy.workspace = true
# bevy_framepace = { version = "0.12", default-features = false }

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { version = "0.14", default-features = false, features = [
"bevy_winit",
"bevy_core_pipeline",
"x11",
Expand Down
13 changes: 8 additions & 5 deletions crates/bevy_editor_pls/examples/2d_3d_mixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ fn main() {
}

fn setup_2d(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2dBundle {
camera: Camera { order: 1, ..Default::default() },
..Default::default()
});
commands.spawn(SpriteBundle {
sprite: Sprite {
color: Color::rgb(0.25, 0.25, 0.75),
color: Color::srgb(0.25, 0.25, 0.75),
custom_size: Some(Vec2::new(50.0, 50.0)),
..Default::default()
},
Expand All @@ -26,13 +29,13 @@ fn setup_3d(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(0.5, 0.5)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
mesh: meshes.add(Plane3d::new(Vec3::Y, Vec2::new(0.25, 0.25)).mesh()),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..Default::default()
});
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::ONE))),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_editor_pls/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ fn setup(
) {
// plane
commands.spawn(PbrBundle {
// mesh: meshes.add(Mesh::from(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0))),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
// mesh: meshes.add(Mesh::from(Plane3d::new(Vec3::Y, Vec2::new(2.5, 2.5)).mesh())),
mesh: meshes.add(Plane3d::new(Vec3::Y, Vec2::new(2.5, 2.5)).mesh()),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..Default::default()
});
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::ONE))),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down
32 changes: 24 additions & 8 deletions crates/bevy_editor_pls/examples/breakout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ const GAP_BETWEEN_BRICKS_AND_SIDES: f32 = 20.0;
const SCOREBOARD_FONT_SIZE: f32 = 40.0;
const SCOREBOARD_TEXT_PADDING: Val = Val::Px(5.0);

const BACKGROUND_COLOR: Color = Color::rgb(0.9, 0.9, 0.9);
const PADDLE_COLOR: Color = Color::rgb(0.3, 0.3, 0.7);
const BALL_COLOR: Color = Color::rgb(1.0, 0.5, 0.5);
const BRICK_COLOR: Color = Color::rgb(0.5, 0.5, 1.0);
const WALL_COLOR: Color = Color::rgb(0.8, 0.8, 0.8);
const TEXT_COLOR: Color = Color::rgb(0.5, 0.5, 1.0);
const SCORE_COLOR: Color = Color::rgb(1.0, 0.5, 0.5);
const BACKGROUND_COLOR: Color = Color::srgb(0.9, 0.9, 0.9);
const PADDLE_COLOR: Color = Color::srgb(0.3, 0.3, 0.7);
const BALL_COLOR: Color = Color::srgb(1.0, 0.5, 0.5);
const BRICK_COLOR: Color = Color::srgb(0.5, 0.5, 1.0);
const WALL_COLOR: Color = Color::srgb(0.8, 0.8, 0.8);
const TEXT_COLOR: Color = Color::srgb(0.5, 0.5, 1.0);
const SCORE_COLOR: Color = Color::srgb(1.0, 0.5, 0.5);

fn main() {
App::new()
Expand All @@ -63,7 +63,7 @@ fn main() {
// `chain`ing systems together runs them in order
.chain(),
)
.add_systems(Update, (update_scoreboard, bevy::window::close_on_esc))
.add_systems(Update, (update_scoreboard, close_on_esc))
.run();
}

Expand Down Expand Up @@ -417,3 +417,19 @@ fn collide_with_side(ball: BoundingCircle, wall: Aabb2d) -> Option<Collision> {

Some(side)
}

fn close_on_esc(
mut commands: Commands,
focused_windows: Query<(Entity, &Window)>,
input: Res<ButtonInput<KeyCode>>,
) {
for (window, focus) in focused_windows.iter() {
if !focus.focused {
continue;
}

if input.just_pressed(KeyCode::Escape) {
commands.entity(window).despawn();
}
}
}
6 changes: 3 additions & 3 deletions crates/bevy_editor_pls/examples/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ fn setup(
) {
// plane
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0))),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
mesh: meshes.add(Mesh::from(Plane3d::new(Vec3::Y, Vec2::new(2.5, 2.5)).mesh())),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..Default::default()
});
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::ONE))),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_editor_pls/examples/separate_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ fn setup(
) {
// plane
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0))),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
mesh: meshes.add(Mesh::from(Plane3d::new(Vec3::Y, Vec2::new(2.5, 2.5)).mesh())),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..Default::default()
});
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::ONE))),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
Expand Down
22 changes: 11 additions & 11 deletions crates/bevy_editor_pls/examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
border: UiRect::all(Val::Px(2.0)),
..default()
},
background_color: Color::rgb(0.65, 0.65, 0.65).into(),
background_color: Color::srgb(0.65, 0.65, 0.65).into(),
..default()
})
.with_children(|parent| {
Expand All @@ -55,7 +55,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
height: Val::Percent(100.0),
..default()
},
background_color: Color::rgb(0.15, 0.15, 0.15).into(),
background_color: Color::srgb(0.15, 0.15, 0.15).into(),
..default()
})
.with_children(|parent| {
Expand Down Expand Up @@ -86,7 +86,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
height: Val::Percent(100.0),
..default()
},
background_color: Color::rgb(0.15, 0.15, 0.15).into(),
background_color: Color::srgb(0.15, 0.15, 0.15).into(),
..default()
})
.with_children(|parent| {
Expand Down Expand Up @@ -122,7 +122,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
overflow: Overflow::clip(),
..default()
},
background_color: Color::rgb(0.10, 0.10, 0.10).into(),
background_color: Color::srgb(0.10, 0.10, 0.10).into(),
..default()
})
.with_children(|parent| {
Expand Down Expand Up @@ -178,7 +178,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
border: UiRect::all(Val::Px(20.0)),
..default()
},
background_color: Color::rgb(0.4, 0.4, 1.0).into(),
background_color: Color::srgb(0.4, 0.4, 1.0).into(),
..default()
})
.with_children(|parent| {
Expand All @@ -188,7 +188,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
height: Val::Percent(100.0),
..default()
},
background_color: Color::rgb(0.8, 0.8, 1.0).into(),
background_color: Color::srgb(0.8, 0.8, 1.0).into(),
..default()
});
});
Expand All @@ -213,7 +213,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
height: Val::Px(100.0),
..default()
},
background_color: Color::rgb(1.0, 0.0, 0.0).into(),
background_color: Color::srgb(1.0, 0.0, 0.0).into(),
..default()
})
.with_children(|parent| {
Expand All @@ -226,7 +226,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
bottom: Val::Px(20.0),
..default()
},
background_color: Color::rgb(1.0, 0.3, 0.3).into(),
background_color: Color::srgb(1.0, 0.3, 0.3).into(),
..default()
});
parent.spawn(NodeBundle {
Expand All @@ -238,7 +238,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
bottom: Val::Px(40.0),
..default()
},
background_color: Color::rgb(1.0, 0.5, 0.5).into(),
background_color: Color::srgb(1.0, 0.5, 0.5).into(),
..default()
});
parent.spawn(NodeBundle {
Expand All @@ -250,7 +250,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
bottom: Val::Px(60.0),
..default()
},
background_color: Color::rgb(1.0, 0.7, 0.7).into(),
background_color: Color::srgb(1.0, 0.7, 0.7).into(),
..default()
});
// alpha test
Expand All @@ -263,7 +263,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
bottom: Val::Px(80.0),
..default()
},
background_color: Color::rgba(1.0, 0.9, 0.9, 0.4).into(),
background_color: Color::srgba(1.0, 0.9, 0.9, 0.4).into(),
..default()
});
});
Expand Down
10 changes: 6 additions & 4 deletions crates/bevy_editor_pls/src/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ pub enum Action {
PauseUnpauseTime,
FocusSelected,

// maybe investigate [GizmoOptions].hotkeys
// https://docs.rs/transform-gizmo-bevy/latest/transform_gizmo_bevy/struct.GizmoHotkeys.html
#[cfg(feature = "default_windows")]
SetGizmoModeTranslate,
#[cfg(feature = "default_windows")]
Expand Down Expand Up @@ -240,7 +242,7 @@ pub fn editor_controls_system(
editor
.window_state_mut::<bevy_editor_pls_default_windows::gizmos::GizmoWindow>()
.unwrap()
.gizmo_mode = egui_gizmo::GizmoMode::Translate;
.gizmo_modes = transform_gizmo_bevy::GizmoMode::all_translate();
}
if controls.just_pressed(
Action::SetGizmoModeRotate,
Expand All @@ -251,7 +253,7 @@ pub fn editor_controls_system(
editor
.window_state_mut::<bevy_editor_pls_default_windows::gizmos::GizmoWindow>()
.unwrap()
.gizmo_mode = egui_gizmo::GizmoMode::Rotate;
.gizmo_modes = transform_gizmo_bevy::GizmoMode::all_rotate();
}
if controls.just_pressed(
Action::SetGizmoModeScale,
Expand All @@ -262,7 +264,7 @@ pub fn editor_controls_system(
editor
.window_state_mut::<bevy_editor_pls_default_windows::gizmos::GizmoWindow>()
.unwrap()
.gizmo_mode = egui_gizmo::GizmoMode::Scale;
.gizmo_modes = transform_gizmo_bevy::GizmoMode::all_scale();
}
}
}
Expand Down Expand Up @@ -395,7 +397,7 @@ impl EditorWindow for ControlsWindow {
ui.label(egui::RichText::new(action.to_string()).strong());
let bindings = controls.get(action);
for binding in bindings {
ui.add(egui::Label::new(format!("{}", binding)).wrap(false));
ui.add(egui::Label::new(format!("{}", binding)).extend());
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions crates/bevy_editor_pls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Plugin for EditorPlugin {
if window.title == "Bevy App" {
window.title = "bevy_editor_pls".into();
}
let entity = app.world.spawn(window);
let entity = app.world_mut().spawn(window);
WindowRef::Entity(entity.id())
}
EditorWindowPlacement::Window(entity) => WindowRef::Entity(entity),
Expand Down Expand Up @@ -128,10 +128,15 @@ impl Plugin for EditorPlugin {

app.add_plugins(bevy::pbr::wireframe::WireframePlugin);

// required for the GizmoWindow
if !app.is_plugin_added::<transform_gizmo_bevy::TransformGizmoPlugin>() {
app.add_plugins(transform_gizmo_bevy::TransformGizmoPlugin);
}

app.insert_resource(controls::EditorControls::default_bindings())
.add_systems(Update, controls::editor_controls_system);

let mut internal_state = app.world.resource_mut::<editor::EditorInternalState>();
let mut internal_state = app.world_mut().resource_mut::<editor::EditorInternalState>();

let [game, _inspector] =
internal_state.split_right::<InspectorWindow>(egui_dock::NodeIndex::root(), 0.75);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_editor_pls_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description.workspace = true
readme.workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy = { version = "0.14", default-features = false }
bevy-inspector-egui.workspace = true
indexmap = "2"
egui_dock.workspace = true
3 changes: 2 additions & 1 deletion crates/bevy_editor_pls_core/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ impl Editor {
}
window.show(ctx, |ui| {
self.editor_window_inner(world, internal_state, floating_window.window, ui);
ui.allocate_space(ui.available_size() - (5.0, 5.0).into());
let desired_size = (ui.available_size() - (5.0, 5.0).into()).max((0.0, 0.0).into());
ui.allocate_space(desired_size);
});

if !open {
Expand Down
Loading