fix(select): pin box-selection anchor to the world during zoom/pan (#234)

The window/crossing selection anchor was stored only in screen pixels, so
zooming or panning mid-drag left it frozen while the drawing moved under
it — the rectangle then covered the wrong world area and selected too much
or too little.

Store the anchor's world point and re-project it to the screen anchor
whenever the model-space view zooms (on_viewport_scroll) or pans
(on_viewport_move), so the rectangle tracks the drawing. The moving corner
already follows the cursor. (MSPACE floating-viewport box-select would
need the viewport camera and is left as-is.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-01 21:10:04 +03:00
1 parent d6e5b38847
commit c303900bd2
2 files changed
+42

No files matched your search

+5
View File
@@ -6,6 +6,11 @@ use iced::Point;
pub struct SelectionState {
pub vp_size: (f32, f32),
pub box_anchor: Option<Point>,
/// World point under the box-selection anchor, so the anchor can be
/// re-projected to screen when the camera zooms/pans mid-drag instead of
/// staying frozen at its original pixel (which selected the wrong area).
/// (#234)
pub box_anchor_world: Option<glam::DVec3>,
pub box_current: Option<Point>,
pub box_last: Option<(Point, Point)>,
pub box_crossing: bool,