Skip to content

Update to Bevy 0.16 #121

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Changelog

## Version 0.9
- update to `bevy-inspector-egui 0.26` / `egui 0.28`
## Version 0.11
- update to bevy 0.16
- update to `bevy-inspector-egui 0.31` / `egui 0.31`

## Version 0.9
- update to bevy 0.14
## Version 0.10
- update to `bevy-inspector-egui 0.26`

## Version 0.9
- update to bevy 0.14
- update to `bevy-inspector-egui 0.25` / `egui 0.28`

## Version 0.8
- update to bevy 0.13
- update to `bevy-inspector-egui 0.23` / `egui 0.26`

## Version 0.7.1
- fix mouse control glitches introduced in version 0.6

## Version 0.7
- update to `bevy-inspector-egui` 0.22 and `egui` 0.24
- update to `bevy-inspector-egui 0.22` / `egui 0.24`

## Version 0.6
- update to bevy 0.12
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ description = "In-App editor tools for bevy apps"
readme = "README.md"

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

bevy-inspector-egui = "0.28.0"
egui = "0.29"
egui_dock = "0.14"
transform-gizmo-bevy = "0.5"
bevy-inspector-egui = "0.31"
egui = "0.31"
egui_dock = "0.16"
transform-gizmo-bevy = "0.6"

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

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

[dev-dependencies]
accesskit = "0.17.1"
bevy = { version = "0.15", default-features = false, features = [
accesskit = "0.19"
bevy = { version = "0.16", default-features = false, features = [
"bevy_winit",
"bevy_ui",
"bevy_core_pipeline",
"bevy_gizmos",
"bevy_dev_tools",
"bevy_picking",
"x11",

"tonemapping_luts",
"zstd",
"ktx2", # https://github.com/bevyengine/bevy/discussions/9100
] }

[build-dependencies]
# Workaround for <https://github.com/bevyengine/bevy/issues/18668>.
bevy_reflect = { version = "0.16", features = ["documentation"] }

[[example]]
name = "load_gltf"
required-features = ["bevy/bevy_gltf", "bevy/png", "bevy/ktx2", "bevy/zstd"]
2 changes: 1 addition & 1 deletion crates/bevy_editor_pls/examples/breakout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ fn check_for_collisions(

if let Some(collision) = collision {
// Sends a collision event so that other systems can react to the collision
collision_events.send_default();
collision_events.write_default();

// Bricks should be despawned and increment the scoreboard on collision
if maybe_brick.is_some() {
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_editor_pls/src/controls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::{prelude::*, utils::HashMap};
use bevy::{platform::collections::HashMap, prelude::*};
use bevy_editor_pls_core::{editor_window::EditorWindow, Editor, EditorEvent};

#[derive(Debug)]
Expand Down Expand Up @@ -206,7 +206,7 @@ pub fn editor_controls_system(
{
let was_active = editor.active();
editor.set_active(!was_active);
editor_events.send(EditorEvent::Toggle {
editor_events.write(EditorEvent::Toggle {
now_active: !was_active,
});
}
Expand All @@ -228,7 +228,7 @@ pub fn editor_controls_system(
&mouse_input,
&editor,
) {
editor_events.send(EditorEvent::FocusSelected);
editor_events.write(EditorEvent::FocusSelected);
}

#[cfg(feature = "default_windows")]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_editor_pls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Plugin for EditorPlugin {
app.add_editor_window::<GizmoWindow>();
app.add_editor_window::<controls::ControlsWindow>();

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

// required for the GizmoWindow
if !app.is_plugin_added::<transform_gizmo_bevy::TransformGizmoPlugin>() {
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_editor_pls_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ description.workspace = true
readme.workspace = true

[dependencies]
bevy = { version = "0.15", default-features = false, features = [
bevy = { version = "0.16", default-features = false, features = [
"bevy_log",
"bevy_window",
] }
bevy-inspector-egui.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_editor_pls_core/src/editor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::any::{Any, TypeId};

use bevy::window::WindowMode;
use bevy::{prelude::*, utils::HashMap};
use bevy::{platform::collections::HashMap, prelude::*};
use bevy_inspector_egui::bevy_egui::{egui, EguiContext};
use egui_dock::{NodeIndex, SurfaceIndex, TabBarStyle, TabIndex};
use indexmap::IndexMap;
Expand Down
19 changes: 9 additions & 10 deletions crates/bevy_editor_pls_core/src/editor_window.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::platform::collections::HashMap;
use bevy::prelude::{App, World};
use bevy::utils::HashMap;
use bevy_inspector_egui::egui;
use std::any::{Any, TypeId};

Expand Down Expand Up @@ -64,8 +64,7 @@ impl EditorWindowContext<'_> {
) -> [&mut (dyn Any + Send + Sync + 'static); N] {
self.window_states
.get_many_mut(ids)
.unwrap()
.map(|val| &mut **val)
.map(|val| &mut **val.unwrap())
}
pub fn state_mut_triplet<W1: EditorWindow, W2: EditorWindow, W3: EditorWindow>(
&mut self,
Expand All @@ -74,11 +73,11 @@ impl EditorWindowContext<'_> {
&TypeId::of::<W1>(),
&TypeId::of::<W2>(),
&TypeId::of::<W3>(),
])?;
]);

let a = a.downcast_mut::<W1::State>()?;
let b = b.downcast_mut::<W2::State>()?;
let c = c.downcast_mut::<W3::State>()?;
let a = a?.downcast_mut::<W1::State>()?;
let b = b?.downcast_mut::<W2::State>()?;
let c = c?.downcast_mut::<W3::State>()?;
Some((a, b, c))
}

Expand All @@ -89,10 +88,10 @@ impl EditorWindowContext<'_> {

let [a, b] = self
.window_states
.get_many_mut([&TypeId::of::<W1>(), &TypeId::of::<W2>()])?;
.get_many_mut([&TypeId::of::<W1>(), &TypeId::of::<W2>()]);

let a = a.downcast_mut::<W1::State>()?;
let b = b.downcast_mut::<W2::State>()?;
let a = a?.downcast_mut::<W1::State>()?;
let b = b?.downcast_mut::<W2::State>()?;
Some((a, b))
}

Expand Down
9 changes: 4 additions & 5 deletions crates/bevy_editor_pls_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy::render::camera::CameraUpdateSystem;
use bevy::transform::TransformSystem;
use bevy::window::{PrimaryWindow, WindowRef};
use bevy_inspector_egui::{
bevy_egui::{EguiPlugin, EguiSet},
bevy_egui::EguiPlugin,
DefaultInspectorConfigPlugin,
};
use editor::EditorInternalState;
Expand Down Expand Up @@ -63,7 +63,7 @@ impl Plugin for EditorPlugin {
app.add_plugins(DefaultInspectorConfigPlugin);
}
if !app.is_plugin_added::<EguiPlugin>() {
app.add_plugins(EguiPlugin);
app.add_plugins(EguiPlugin { enable_multipass_for_primary_context: false });
}

let (window_entity, always_active) = match self.window {
Expand All @@ -72,7 +72,7 @@ impl Plugin for EditorPlugin {
.world_mut()
.query_filtered::<Entity, With<PrimaryWindow>>()
.single(app.world());
(entity, false)
(entity.unwrap(), false)
}
WindowRef::Entity(entity) => (entity, true),
};
Expand All @@ -86,8 +86,7 @@ impl Plugin for EditorPlugin {
Editor::system
.in_set(EditorSet::UI)
.before(TransformSystem::TransformPropagate)
.before(CameraUpdateSystem)
.before(EguiSet::ProcessOutput),
.before(CameraUpdateSystem),
);
}
}
6 changes: 3 additions & 3 deletions crates/bevy_editor_pls_default_windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme.workspace = true
highlight_changes = ["bevy-inspector-egui/highlight_changes"]

[dependencies]
bevy = { version = "0.15", default-features = false, features = [
bevy = { version = "0.16", default-features = false, features = [
"bevy_scene",
"bevy_text",
"bevy_ui",
Expand All @@ -29,6 +29,6 @@ bevy-inspector-egui.workspace = true
# ] }
indexmap = "2"
pretty-type-name = "1.0"
bevy_mod_debugdump = "0.12"
opener = "0.6.0"
bevy_mod_debugdump = "0.13"
opener = "0.7"
transform-gizmo-bevy.workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Plugin for PanCamPlugin {

// Zoom doesn't work on bevy 0.5 due to: https://github.com/bevyengine/bevy/pull/2015
fn camera_zoom(
mut query: Query<(&PanCamControls, &mut OrthographicProjection)>,
mut query: Query<(&PanCamControls, &mut Projection)>,
mut scroll_events: EventReader<MouseWheel>,
) {
let pixels_per_line = 100.; // Maybe make configurable?
Expand All @@ -42,16 +42,19 @@ fn camera_zoom(
return;
}

for (_cam, mut projection) in query.iter_mut() {
projection.scale = (projection.scale * (1. + -scroll * 0.001)).max(0.00001);
for (_cam, projection) in &mut query {
let Projection::Orthographic(ortho) = projection.into_inner() else {
continue;
};
ortho.scale = (ortho.scale * (1. + -scroll * 0.001)).max(0.00001);
}
}

fn camera_movement(
editor: Res<Editor>,
window: Query<&Window>,
mouse_buttons: Res<ButtonInput<MouseButton>>,
mut query: Query<(&PanCamControls, &mut Transform, &OrthographicProjection)>,
mut query: Query<(&PanCamControls, &mut Transform, &Projection)>,
mut last_pos: Local<Option<Vec2>>,
) {
let Ok(window) = window.get(editor.window()) else {
Expand All @@ -71,16 +74,19 @@ fn camera_movement(
if !cam.enabled {
continue;
}
let Projection::Orthographic(ortho) = projection else {
continue;
};

if cam
.grab_buttons
.iter()
.any(|btn| mouse_buttons.pressed(*btn))
{
let scaling = Vec2::new(
window.width() / projection.area.width(),
window.height() / projection.area.height(),
) * projection.scale;
window.width() / ortho.area.width(),
window.height() / ortho.area.height(),
) * ortho.scale;

transform.translation -= (delta * scaling).extend(0.);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn camera_movement(
time: Res<Time>,
keyboard_input: Res<ButtonInput<KeyCode>>,
) {
let (flycam, mut cam_transform) = cam.single_mut();
let (flycam, mut cam_transform) = cam.single_mut().unwrap();
if !flycam.enable_movement {
return;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ fn camera_look(
mut mouse_motion_event_reader: EventReader<MouseMotion>,
mut query: Query<(&mut FlycamControls, &mut Transform)>,
) {
let (mut flycam, mut transform) = query.single_mut();
let (mut flycam, mut transform) = query.single_mut().unwrap();
if !flycam.enable_look || !mouse_input.pressed(MouseButton::Right) {
//Prevent accumulation of irrelevant events
mouse_motion_event_reader.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn pan_orbit_camera(
};

// change input mapping for orbit and panning here
let (mut pan_orbit, mut transform, projection) = query.single_mut();
let (mut pan_orbit, mut transform, projection) = query.single_mut().unwrap();

if !pan_orbit.enabled {
//Prevent accumulation of irrelevant events
Expand Down
Loading