Update the bounding box snapping modes to use Align with Edges for edges and alignment (#2185)

* Fix snapping to respect rotation of bounding box

Fixes snapping behaviour which defaulted to X and Y axes.

* Remove redundant align along edges

* Code review

* Update manual

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mTvare
2025-01-13 10:53:32 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent d692538736
commit 8dfdc2b98f
5 changed files with 13 additions and 33 deletions
@@ -19,7 +19,7 @@ impl AlignmentSnapper {
let document = snap_data.document;
self.bounding_box_points.clear();
if !document.snapping_state.bounding_box.align_with_corner_point {
if !document.snapping_state.bounding_box.align_with_edges {
return;
}
@@ -74,7 +74,9 @@ 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.map(|quad| quad.0) else { continue };
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))
};
let target_path = matches!(target_point.target, SnapTarget::Path(_));
@@ -86,9 +86,6 @@ impl LayerSnapper {
}
}
}
if !snap_data.ignore_bounds(layer) {
self.add_layer_bounds(document, layer, SnapTarget::BoundingBox(BoundingBoxSnapTarget::AlongEdge));
}
}
}