Add wireframe and light gizmos

main
Elijah Voigt 4 months ago
parent cb20b0d6a6
commit 9af8cd13d2

@ -1,7 +1,5 @@
use bevy::{
color::palettes::css::{GREY, MAGENTA},
pbr::wireframe::{WireframeConfig, WireframePlugin},
platform::collections::HashMap,
color::palettes::css::{GREY, MAGENTA}, gizmos::{aabb::AabbGizmoPlugin, light::LightGizmoPlugin}, pbr::wireframe::{WireframeConfig, WireframePlugin}, platform::collections::HashMap
};
use super::*;
@ -14,6 +12,9 @@ impl Plugin for DebuggingPlugin {
app.init_state::<DebuggingState>()
.init_resource::<ToolTip>()
.add_plugins(RapierDebugRenderPlugin::default().disabled())
// Added by Rapier
// .add_plugins(AabbGizmoPlugin)
// .add_plugins(LightGizmoPlugin)
.add_systems(Startup, init_debug_ui)
.add_systems(
Update,
@ -21,6 +22,10 @@ impl Plugin for DebuggingPlugin {
(toggle_state_visibility::<DebuggingState>,)
.run_if(state_changed::<DebuggingState>),
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)
.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>) {
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