viewport: select a section plane, highlight it, delete the selected one

Previously Del always removed the most recently added section plane. Now a
plane can be picked and deleted individually:

- ViewportCore tracks a selected plane index, kept valid as planes are
  added (the new one becomes selected), removed, or cleared.
- Clicking a gizmo with the section tool active selects that plane.
- The section gizmo geometry is baked white and coloured via its per-plane
  tint, so the selected plane draws in a bright amber highlight while the
  rest stay red (unchanged look).
- Del/Backspace removes the selected plane, falling back to the most recent
  one when nothing is selected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-07-09 12:48:38 +10:00
parent 12002ace86
commit 6e86072d5a
5 changed files with 58 additions and 18 deletions
+3 -1
View File
@@ -51,9 +51,11 @@ public:
bool ready() const { return pipeline_ != nullptr; }
// Draw one gizmo per plane into an already-open render pass (the main pass).
// `selected_index` (or -1) is drawn with a highlight tint to show selection.
void encode(WGPURenderPassEncoder pass, const Eigen::Matrix4f& view_proj,
const std::vector<SectionPlane>& planes,
int viewport_w_px, int viewport_h_px, int device_pixel_ratio);
int viewport_w_px, int viewport_h_px, int device_pixel_ratio,
int selected_index = -1);
// Screen-space hit test: index of the plane whose gizmo (arrow segment,
// origin→origin+normal) the (x, y) logical-pixel point lies within