mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Fix self-chaining of transforms; fix compass rose getting offset when rotating a layer (#2296)
* Fix self-chaining of transforms and compass rose under single layer1340632846
1340608972
* When not invertible transformation, do nothing * Fix overlays and compass control when can't be visible * Simplify selection logic in compass states * Show compass only if it was possible that it could be seen before dragging * Prevent resizing line objects * Code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
e444785301
commit
90a8036c47
8 changed files with 141 additions and 98 deletions
|
@ -90,7 +90,7 @@ impl ClickTarget {
|
|||
// This bounding box is not very accurate as it is the axis aligned version of the transformed bounding box. However it is fast.
|
||||
if !self
|
||||
.bounding_box
|
||||
.is_some_and(|loose| intersects((layer_transform * Quad::from_box(loose)).bounding_box(), target_bounds))
|
||||
.is_some_and(|loose| (loose[0] - loose[1]).abs().cmpgt(DVec2::splat(1e-4)).all() && intersects((layer_transform * Quad::from_box(loose)).bounding_box(), target_bounds))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -44,13 +44,23 @@ impl Quad {
|
|||
}
|
||||
|
||||
/// Get all the edges in the quad.
|
||||
pub fn edges(&self) -> [[DVec2; 2]; 4] {
|
||||
pub fn all_edges(&self) -> [[DVec2; 2]; 4] {
|
||||
[[self.0[0], self.0[1]], [self.0[1], self.0[2]], [self.0[2], self.0[3]], [self.0[3], self.0[0]]]
|
||||
}
|
||||
|
||||
/// Get two edges as orthogonal bases.
|
||||
pub fn edges(&self) -> [[DVec2; 2]; 2] {
|
||||
[[self.0[0], self.0[1]], [self.0[1], self.0[2]]]
|
||||
}
|
||||
|
||||
/// Returns true only if the width and height are both greater than or equal to the given width.
|
||||
pub fn all_sides_at_least_width(&self, width: f64) -> bool {
|
||||
self.edges().into_iter().all(|[a, b]| (a - b).length_squared() >= width.powi(2))
|
||||
}
|
||||
|
||||
/// Get all the edges in the quad as linear bezier curves
|
||||
pub fn bezier_lines(&self) -> impl Iterator<Item = bezier_rs::Bezier> + '_ {
|
||||
self.edges().into_iter().map(|[start, end]| bezier_rs::Bezier::from_linear_dvec2(start, end))
|
||||
self.all_edges().into_iter().map(|[start, end]| bezier_rs::Bezier::from_linear_dvec2(start, end))
|
||||
}
|
||||
|
||||
/// Generates the axis aligned bounding box of the quad
|
||||
|
@ -126,9 +136,9 @@ impl Quad {
|
|||
|
||||
pub fn intersects(&self, other: Quad) -> bool {
|
||||
let intersects = self
|
||||
.edges()
|
||||
.all_edges()
|
||||
.into_iter()
|
||||
.any(|[a, b]| other.edges().into_iter().any(|[c, d]| Self::intersect_lines(a, b, c, d).is_some()));
|
||||
.any(|[a, b]| other.all_edges().into_iter().any(|[c, d]| Self::intersect_lines(a, b, c, d).is_some()));
|
||||
self.contains(other.center()) || other.contains(self.center()) || intersects
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue