feat(ucs): build axis-aligned shapes in the active UCS

Commands that construct geometry with implicit axis directions ignored
the UCS, so a rectangle drawn under a rotated UCS came out world-aligned.
Give commands the UCS and build square to it:

- CadCommand::set_ucs(Mat4) (UCS→wire affine, default no-op); the host
  pushes the current UCS via App::push_ucs_to_cmd before each point /
  preview / text dispatch (DocumentTab::ucs_wire_affine, identity outside
  model space). New axis-aligned commands just override set_ucs.
- RECT (two-corner) and RECT_CEN (center) place their derived corners on
  the UCS axes (ucs_box_corners / ucs_box_around_center).
- ARRAYRECT row/column offsets run along the UCS axes.

RECT_ROT, POLYGON, and ELLIPSE already take their orientation from picked
points, so they need no change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-22 17:30:42 +03:00
1 parent d63602161f
commit 0c2a97e17e
5 files changed
+128 -35

No files matched your search

+7
View File
@@ -416,6 +416,13 @@ pub trait CadCommand: Send {
/// Current prompt string to display in the command line.
fn prompt(&self) -> String;
/// Push the active UCS into the command as a UCS→render(wire)-space affine
/// (identity = plain WCS). Commands that build axis-aligned geometry (RECT,
/// rectangular ARRAY, …) override this to store it and rotate their implicit
/// axes into the UCS; most commands work purely from picked points and
/// ignore it. Called before each point / preview dispatch.
fn set_ucs(&mut self, _ucs: glam::Mat4) {}
/// Called when the user left-clicks in the viewport (point pick).
fn on_point(&mut self, pt: Vec3) -> CmdResult;