Skip to content
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

Only draw debug circle and drag indicators (in debug_draw_egui) when DebugPickingMode is set to noisy #339

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ all-features = true
members = ["crates/*", "backends/*"]

[dependencies]
bevy_app = { version = "0.14.0", default-features = false }
bevy_core = { version = "0.14.0", default-features = false }
bevy_core_pipeline = { version = "0.14.0", optional = true, default-features = false }
bevy_ecs = { version = "0.14.0", default-features = false }
bevy_math = { version = "0.14.0", default-features = false }
bevy_reflect = { version = "0.14.0", default-features = false }
bevy_render = { version = "0.14.0", default-features = false }
bevy_text = { version = "0.14.0", optional = true, default-features = false, features = [
bevy_app = { version = "0.14", default-features = false }
bevy_core = { version = "0.14", default-features = false }
bevy_core_pipeline = { version = "0.14", optional = true, default-features = false }
bevy_ecs = { version = "0.14", default-features = false }
bevy_math = { version = "0.14", default-features = false }
bevy_reflect = { version = "0.14", default-features = false }
bevy_render = { version = "0.14", default-features = false }
bevy_text = { version = "0.14", optional = true, default-features = false, features = [
"default_font",
] }
bevy_utils = { version = "0.14.0", default-features = false }
bevy_window = { version = "0.14.0", default-features = false }
bevy_utils = { version = "0.14", default-features = false }
bevy_window = { version = "0.14", default-features = false }

# Optional
bevy_color = { version = "0.14.0", optional = true, default-features = false }
bevy_ui = { version = "0.14.0", optional = true, default-features = false }
bevy_color = { version = "0.14", optional = true, default-features = false }
bevy_ui = { version = "0.14", optional = true, default-features = false }

bevy_eventlistener = "0.8.0"
bevy_egui = { optional = true, version = "0.28.0" } # >=0.28, <=0.XX
bevy_rapier3d = { optional = true, version = "0.27.0-rc.1" }
bevy_xpbd_3d = { optional = true, version = "0.5.0" }
bevy_eventlistener = "0.8"
bevy_egui = { optional = true, version = "0.28" } # >=0.28, <=0.XX
bevy_rapier3d = { optional = true, version = "0.27" }
bevy_xpbd_3d = { optional = true, version = "0.5" }
avian3d = { optional = true, version = '0.1' }

# Local
Expand All @@ -55,7 +55,7 @@ bevy_picking_xpbd = { optional = true, path = "backends/bevy_picking_xpbd", vers
bevy_picking_avian = { optional = true, path = "backends/bevy_picking_avian", version = "0.20.0" }

[dev-dependencies]
bevy = { version = "0.14.0", default-features = false, features = [
bevy = { version = "0.14", default-features = false, features = [
"bevy_winit",
"x11",
"bevy_gltf",
Expand Down
39 changes: 21 additions & 18 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ pub fn update_debug_data(
pub fn debug_draw_egui(
mut egui: bevy_egui::EguiContexts,
pointers: Query<(&pointer::PointerId, &PointerDebug)>,
debug_mode: Res<DebugPickingMode>,
) {
use bevy_egui::egui::{self, Color32};
use bevy_render::camera::NormalizedRenderTarget;
Expand All @@ -310,25 +311,27 @@ pub fn debug_draw_egui(
let to_egui_pos = |v: Vec2| egui::pos2(v.x, v.y);
let dbg_painter = ctx.layer_painter(egui::LayerId::debug());

dbg_painter.circle(
to_egui_pos(location.position),
20.0,
Color32::from_rgba_unmultiplied(255, 255, 255, 32),
stroke,
);

debug.drag_start.iter().for_each(|(button, drag_start)| {
let (start, end) = (to_egui_pos(*drag_start), to_egui_pos(location.position));
dbg_painter.line_segment([start, end], stroke);
dbg_painter.circle(start, 20.0, egui::Color32::TRANSPARENT, stroke);
let drag_dist = location.position - *drag_start;
dbg_painter.debug_text(
((end.to_vec2() + start.to_vec2()) * 0.5).to_pos2(),
egui::Align2::CENTER_CENTER,
Color32::WHITE,
format!("{button:?}: [{:.1}, {:.1}]", drag_dist.x, drag_dist.y),
if matches!(*debug_mode, DebugPickingMode::Noisy) {
dbg_painter.circle(
to_egui_pos(location.position),
20.0,
Color32::from_rgba_unmultiplied(255, 255, 255, 32),
stroke,
);
});

debug.drag_start.iter().for_each(|(button, drag_start)| {
let (start, end) = (to_egui_pos(*drag_start), to_egui_pos(location.position));
dbg_painter.line_segment([start, end], stroke);
dbg_painter.circle(start, 20.0, egui::Color32::TRANSPARENT, stroke);
let drag_dist = location.position - *drag_start;
dbg_painter.debug_text(
((end.to_vec2() + start.to_vec2()) * 0.5).to_pos2(),
egui::Align2::CENTER_CENTER,
Color32::WHITE,
format!("{button:?}: [{:.1}, {:.1}]", drag_dist.x, drag_dist.y),
);
});
}

let text = format!("{id:?} {debug}");
let alignment = egui::Align2::LEFT_TOP;
Expand Down
Loading