Skip to content

Commit bcdff1a

Browse files
ActuallyHappeningjakobhellermann
authored andcommitted
feat: gizmos are completely integrated
1 parent 9f4c9e9 commit bcdff1a

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

crates/bevy_editor_pls/src/controls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub fn editor_controls_system(
240240
editor
241241
.window_state_mut::<bevy_editor_pls_default_windows::gizmos::GizmoWindow>()
242242
.unwrap()
243-
.gizmo_mode = transform_gizmo_bevy::GizmoMode::all_translate();
243+
.gizmo_modes = transform_gizmo_bevy::GizmoMode::all_translate();
244244
}
245245
if controls.just_pressed(
246246
Action::SetGizmoModeRotate,
@@ -251,7 +251,7 @@ pub fn editor_controls_system(
251251
editor
252252
.window_state_mut::<bevy_editor_pls_default_windows::gizmos::GizmoWindow>()
253253
.unwrap()
254-
.gizmo_mode = transform_gizmo_bevy::GizmoMode::all_rotate();
254+
.gizmo_modes = transform_gizmo_bevy::GizmoMode::all_rotate();
255255
}
256256
if controls.just_pressed(
257257
Action::SetGizmoModeScale,
@@ -262,7 +262,7 @@ pub fn editor_controls_system(
262262
editor
263263
.window_state_mut::<bevy_editor_pls_default_windows::gizmos::GizmoWindow>()
264264
.unwrap()
265-
.gizmo_mode = transform_gizmo_bevy::GizmoMode::all_scale();
265+
.gizmo_modes = transform_gizmo_bevy::GizmoMode::all_scale();
266266
}
267267
}
268268
}

crates/bevy_editor_pls/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl Plugin for EditorPlugin {
128128

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

131-
// required for the GizmoWindow
131+
// required for the GizmoWindow
132132
if !app.is_plugin_added::<transform_gizmo_bevy::TransformGizmoPlugin>() {
133133
app.add_plugins(transform_gizmo_bevy::TransformGizmoPlugin);
134134
}

crates/bevy_editor_pls_core/src/editor_window.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub trait EditorWindow: 'static {
1313
const DEFAULT_SIZE: (f32, f32) = (0.0, 0.0);
1414

1515
fn ui(world: &mut World, cx: EditorWindowContext, ui: &mut egui::Ui);
16+
1617
/// Ui shown in the `Open Window` menu item. By default opens the window as a floating window.
1718
fn menu_ui(world: &mut World, mut cx: EditorWindowContext, ui: &mut egui::Ui) {
1819
let _ = world;

crates/bevy_editor_pls_default_windows/src/gizmos.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ use crate::{
1717
pub struct GizmoState {
1818
pub camera_gizmo_active: bool,
1919
/// TODO: Take these settings into account
20-
pub gizmo_mode: EnumSet<GizmoMode>,
20+
pub gizmo_modes: EnumSet<GizmoMode>,
2121
}
2222

2323
impl Default for GizmoState {
2424
fn default() -> Self {
2525
Self {
2626
camera_gizmo_active: true,
27-
gizmo_mode: GizmoMode::all_translate(),
27+
gizmo_modes: GizmoMode::all_translate(),
2828
}
2929
}
3030
}
@@ -38,18 +38,19 @@ impl EditorWindow for GizmoWindow {
3838

3939
fn ui(_world: &mut World, _cx: EditorWindowContext, ui: &mut egui::Ui) {
4040
ui.label("Gizmos can currently not be configured");
41+
// could definitely change some settings here in the future
4142
}
4243

43-
fn viewport_toolbar_ui(world: &mut World, cx: EditorWindowContext, ui: &mut egui::Ui) {
44+
/// Called every frame (hopefully), could this invariant (namely being called every frame) be documented,
45+
/// ideally in the [EditorWindow] trait?
46+
fn viewport_toolbar_ui(world: &mut World, cx: EditorWindowContext, _ui: &mut egui::Ui) {
4447
let gizmo_state = cx.state::<GizmoWindow>().unwrap();
4548

46-
if gizmo_state.camera_gizmo_active {
47-
// if let (Some(hierarchy_state), Some(_camera_state)) =
48-
// (cx.state::<HierarchyWindow>(), cx.state::<CameraWindow>())
49-
// {
50-
// draw_gizmo(ui, world, &hierarchy_state.selected, gizmo_state.gizmo_mode);
51-
// }
49+
// syncs the [GizmoOptions] resource with the current state of the gizmo window
50+
let mut gizmo_options = world.resource_mut::<transform_gizmo_bevy::GizmoOptions>();
51+
gizmo_options.gizmo_modes = gizmo_state.gizmo_modes;
5252

53+
if gizmo_state.camera_gizmo_active {
5354
/// Before [hydrate_gizmos] and [deconstruct_gizmos] are run, this system resets the state of all entities that have a [EntityShouldShowGizmo] component.
5455
/// Then, according to selection logic some entities are marked as focussed, and [hydrate_gizmos] and [deconstruct_gizmos] is run to sync the gizmo state with the selection state.
5556
fn reset_gizmos_selected_state(

0 commit comments

Comments
 (0)