Skip to content

Commit

Permalink
Fix snapping to respect rotation of bounding box
Browse files Browse the repository at this point in the history
Fixes snapping behaviour which defaulted to X and Y axes.
  • Loading branch information
mTvare6 authored and Keavon committed Jan 13, 2025
1 parent d692538 commit 4e64c7a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ impl AlignmentSnapper {
Quad::intersect_rays(target_point.document_point, DVec2::X, origin, direction),
]
} else {
[DVec2::new(point.document_point.x, target_position.y), DVec2::new(target_position.x, point.document_point.y)].map(Some)
let Some(quad) = target_point.quad else {
continue;
};
let quad = quad.0;
let edges = [quad[1] - quad[0], quad[3] - quad[0]];
edges
.map(|edge| edge.try_normalize().map(|edge| (point.document_point - target_position).project_onto(edge) + target_position))
.into()
};

let target_path = matches!(target_point.target, SnapTarget::Path(_));
Expand Down

0 comments on commit 4e64c7a

Please sign in to comment.