feat: Enhance selection and grid functionality in sandbox stage and gizmos

This commit is contained in:
2026-08-29 00:18:57 -04:00
parent 2a6b4aa965
commit badff571f0
5 changed files with 128 additions and 55 deletions
+5 -3
View File
@@ -409,7 +409,7 @@ The stage is intentionally **extendable**: the spawn palette is registry-driven
**Mode management:**
- **Edit** (default) — `RigidBody2D` props are frozen (`freeze = true` + `freeze_mode = FREEZE_MODE_KINEMATIC`), stickmen stand as `ANIMATED` puppets, gizmos are visible, and selection is active.
- **Play** — props unfreeze and fall, stickmen ragdoll (`set_ragdoll(true)` with `auto_recover = false`), gizmos are hidden, and selection is cleared.
- **Play** — props unfreeze and fall, stickmen ragdoll (`set_ragdoll(true)` with `auto_recover = false`), gizmos are hidden, selection is cleared, and the spawn palette plus the Grid/Snap/Size controls are hidden (restored on returning to Edit).
- The mode toggle button (leftmost) flips between the two; a `mode_changed(mode: int)` signal is emitted on every toggle, and the camera view persists across the switch.
- **Restart-the-sim:** each object's position/rotation is saved whenever you place, move, or rotate it; returning to Edit restores that authored state (and zeroes prop velocity), so every Play session starts from the same authored layout. Stickmen snap straight back to standing (no stand-up glide).
@@ -427,18 +427,20 @@ Clicking a palette button enters **placement mode**, which shows a translucent *
- **Left-click** selects an object (deselects the previous); click empty space to deselect.
- **Direct drag** — click and drag an object to move it (no separate move handle); hold **Shift** while clicking to toggle its selection.
- **Box-select** — drag on empty space draws a marquee; release selects everything inside. Hold **Shift** to add to the selection.
- The **primary** selection shows a white bounding box and a blue **rotate** ring (around the box); drag the ring to rotate about the center. The ring is hit-tested first, so ring clicks rotate rather than move.
- Every selected object shows a white bounding box. A blue **rotate** ring appears around a **single** selection (drag it to rotate about the center); it is hidden for multi-selections. Hold **Ctrl** while rotating to snap to 15° increments.
- **Multi-translate** — dragging any selected object moves the whole selection together. The ring is hit-tested first, so ring clicks rotate rather than move.
- `object_selected(nodes)` / `object_deselected()` are emitted on selection changes.
**Grid & snap:**
- A **Grid** checkbox toggles a world-space grid overlay (major line every 5 cells); a **Snap** checkbox rounds placement and dragging to the grid; a **Size** spinbox sets the cell size (1100 px).
- The grid only shows in **Edit** mode and is hidden during **Play**.
- Grid size, snap, and grid visibility persist to `user://sandbox_settings.json`.
**Deletion & camera:**
- **Delete** / **Backspace** removes all selected objects (`queue_free()`) and emits `object_deleted(nodes)`.
- **Middle-mouse drag** pans; **mouse wheel** zooms within the exported `min_zoom` (0.1) / `max_zoom` (6.0) bounds. The view persists across mode toggles.
- **Middle-mouse drag** pans; **mouse wheel** zooms within the exported `min_zoom` (0.1) / `max_zoom` (6.0) bounds. **Touchpad**: pinch to zoom, two-finger drag to pan. The view persists across mode toggles.
**Status bar:** shows `Mode: EDIT/PLAY | Objects: N | Selected: <name or count>` and updates live on spawn, selection, deletion, and mode changes.