feat(grip): value-prompt actions Lengthen/Radius/Arc Length

Lengthen / Radius / Arc Length need a number after the pick. Stash
`grip_pending` on the picked action, push prompt to command line,
route next `CommandSubmit` parse into `apply_grip_menu_value`.
Escape cancels.

- `Grippable::grip_menu_value_prompt` returns label when action
  wants value; `apply_grip_menu_value` runs the edit. Dispatched
  via `EntityTypeOps`.
- Line: Lengthen extends either endpoint along line direction.
- Arc: Radius sets radius; Arc Length redrives end angle from
  `value / radius`; Lengthen extends start / end angle the same
  way.
This commit is contained in:
Hakan Seven committed 2026-05-29 14:58:35 +03:00
1 parent 86ca1b7033
commit 559cd76369
5 files changed
+243 -5

No files matched your search

+49 -1
View File
@@ -182,7 +182,55 @@ impl crate::entities::traits::Grippable for Line {
_grip_id: usize,
_action: crate::scene::object::GripMenuAction,
) {
// Lengthen requires a follow-up distance prompt — Phase 3.
// Lengthen needs a follow-up distance — handled by
// `apply_grip_menu_value`.
}
fn grip_menu_value_prompt(
&self,
_grip_id: usize,
action: crate::scene::object::GripMenuAction,
) -> Option<&'static str> {
use crate::scene::object::GripMenuAction as A;
match action {
A::Lengthen => Some("Distance"),
_ => None,
}
}
fn apply_grip_menu_value(
&mut self,
grip_id: usize,
action: crate::scene::object::GripMenuAction,
value: f64,
) {
use crate::scene::object::GripMenuAction as A;
if !matches!(action, A::Lengthen) {
return;
}
let dx = self.end.x - self.start.x;
let dy = self.end.y - self.start.y;
let dz = self.end.z - self.start.z;
let len = (dx * dx + dy * dy + dz * dz).sqrt();
if len < 1e-12 {
return;
}
let (ux, uy, uz) = (dx / len, dy / len, dz / len);
match grip_id {
0 => {
// Move start endpoint backward along the line by `value`
// (positive = lengthen; negative = shorten).
self.start.x -= ux * value;
self.start.y -= uy * value;
self.start.z -= uz * value;
}
1 => {
self.end.x += ux * value;
self.end.y += uy * value;
self.end.z += uz * value;
}
_ => {}
}
}
}