Add wireframe and light gizmos

main
Elijah Voigt 4 months ago
parent cb20b0d6a6
commit 9af8cd13d2

@ -1,7 +1,5 @@
use bevy::{ use bevy::{
color::palettes::css::{GREY, MAGENTA}, color::palettes::css::{GREY, MAGENTA}, gizmos::{aabb::AabbGizmoPlugin, light::LightGizmoPlugin}, pbr::wireframe::{WireframeConfig, WireframePlugin}, platform::collections::HashMap
pbr::wireframe::{WireframeConfig, WireframePlugin},
platform::collections::HashMap,
}; };
use super::*; use super::*;
@ -14,6 +12,9 @@ impl Plugin for DebuggingPlugin {
app.init_state::<DebuggingState>() app.init_state::<DebuggingState>()
.init_resource::<ToolTip>() .init_resource::<ToolTip>()
.add_plugins(RapierDebugRenderPlugin::default().disabled()) .add_plugins(RapierDebugRenderPlugin::default().disabled())
// Added by Rapier
// .add_plugins(AabbGizmoPlugin)
// .add_plugins(LightGizmoPlugin)
.add_systems(Startup, init_debug_ui) .add_systems(Startup, init_debug_ui)
.add_systems( .add_systems(
Update, Update,
@ -21,6 +22,10 @@ impl Plugin for DebuggingPlugin {
(toggle_state_visibility::<DebuggingState>,) (toggle_state_visibility::<DebuggingState>,)
.run_if(state_changed::<DebuggingState>), .run_if(state_changed::<DebuggingState>),
toggle_debug_state.run_if(on_keyboard_press(KeyCode::F12)), toggle_debug_state.run_if(on_keyboard_press(KeyCode::F12)),
(
toggle_light_gizmo,
toggle_aabb_gizmo,
).run_if(state_changed::<DebuggingState>),
( (
(hover_mesh, hover_ui) (hover_mesh, hover_ui)
.run_if(on_event::<Pointer<Over>>.or(on_event::<Pointer<Out>>)), .run_if(on_event::<Pointer<Over>>.or(on_event::<Pointer<Out>>)),
@ -241,3 +246,21 @@ fn enable_wireframe(mut wireframe_config: ResMut<WireframeConfig>) {
fn disable_wireframe(mut wireframe_config: ResMut<WireframeConfig>) { fn disable_wireframe(mut wireframe_config: ResMut<WireframeConfig>) {
wireframe_config.global = false; wireframe_config.global = false;
} }
// Toggle the light gizmo config group
fn toggle_light_gizmo(
state: Res<State<DebuggingState>>,
mut config_store: ResMut<GizmoConfigStore>,
) {
let (_, light_group) = config_store.config_mut::<LightGizmoConfigGroup>();
light_group.draw_all = *state.get() == DebuggingState::On;
}
// Toggle the aabb gizmo config group
fn toggle_aabb_gizmo(
state: Res<State<DebuggingState>>,
mut config_store: ResMut<GizmoConfigStore>,
) {
let (_, aabb_group) = config_store.config_mut::<AabbGizmoConfigGroup>();
aabb_group.draw_all = *state.get() == DebuggingState::On;
}

Loading…
Cancel
Save