From 3b03be7dbfb4c4990fb0dfb43a682924bd3cbbe1 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Thu, 11 Jul 2024 09:32:37 -0500 Subject: [PATCH] Scaffolding for selection & scanning modes The gizmo currently draws as an annulus with the intention that it is an area selection tool. These new components will serve as mode selectors so that different selection modes can be used. --- src/debug_plugin.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/debug_plugin.rs b/src/debug_plugin.rs index 792e128d..3016bee9 100644 --- a/src/debug_plugin.rs +++ b/src/debug_plugin.rs @@ -15,7 +15,7 @@ fn setup( mut materials: ResMut>, ) { commands.spawn(( - Cursor, + ScannerWidget::default(), MaterialMesh2dBundle { mesh: meshes.add(Annulus::new(9.5, 10.0)).into(), material: materials.add(Color::srgb(0.0, 0.0, 0.0)), @@ -24,9 +24,38 @@ fn setup( )); } +#[derive(Bundle)] +struct ScannerWidget { + cursor: Cursor, + select: SelectionMode, + scan: ScannerMode, +} + +impl Default for ScannerWidget { + fn default() -> Self { + Self { + cursor: Cursor, + select: SelectionMode::CircularArea, + scan: ScannerMode::CenterOfMass, + } + } +} + #[derive(Component)] struct Cursor; +#[derive(Component)] +enum SelectionMode { + NearestSingle, + CircularArea, +} + +#[derive(Component)] +enum ScannerMode { + CenterOfMass, + Velocity, +} + fn update_cursor( window: Query<&Window, With>, camera: Query<(&Camera, &GlobalTransform)>,