From 3d31e212ee3ea2ba498bd15caf46728e5a46bb4d Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 21 May 2016 10:19:53 +0200 Subject: Fix some snapping bugs that lead to infinite transforms and crashes in 2geom Fixed bugs: - https://launchpad.net/bugs/1541727 (bzr r14905) --- src/pure-transform.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src/pure-transform.cpp') diff --git a/src/pure-transform.cpp b/src/pure-transform.cpp index 9c7054b9f..db4926258 100644 --- a/src/pure-transform.cpp +++ b/src/pure-transform.cpp @@ -63,9 +63,9 @@ void PureTransform::snap(::SnapManager *sm, std::vectorconstrainedSnap(p, dedicated_constraint, bbox_to_snap); } -void PureStretchConstrained::storeTransform(SnapCandidatePoint const original_point, SnappedPoint snapped_point) { +void PureStretchConstrained::storeTransform(SnapCandidatePoint const &original_point, SnappedPoint &snapped_point) { Geom::Point const a = snapped_point.getPoint() - _origin; // vector to snapped point Geom::Point const b = original_point.getPoint() - _origin; // vector to original point (not the transformed point!) _stretch_snapped = Geom::Scale(Geom::infinity(), Geom::infinity()); - if (fabs(b[_direction]) > 1e-6) { // if STRETCHING will occur for this point + if (fabs(b[_direction]) > 1e-4) { // if STRETCHING will occur for this point _stretch_snapped[_direction] = a[_direction] / b[_direction]; _stretch_snapped[1-_direction] = _uniform ? _stretch_snapped[_direction] : 1; } else { // STRETCHING might occur for this point, but only when the stretching is uniform - if (_uniform && fabs(b[1-_direction]) > 1e-6) { + if (_uniform && fabs(b[1-_direction]) > 1e-4) { _stretch_snapped[1-_direction] = a[1-_direction] / b[1-_direction]; _stretch_snapped[_direction] = _stretch_snapped[1-_direction]; } @@ -304,7 +318,7 @@ SnappedPoint PureSkewConstrained::snap(::SnapManager *sm, SnapCandidatePoint con return sm->constrainedSnap(p, Inkscape::Snapper::SnapConstraint(constraint_vector), bbox_to_snap); } -void PureSkewConstrained::storeTransform(SnapCandidatePoint const original_point, SnappedPoint snapped_point) { +void PureSkewConstrained::storeTransform(SnapCandidatePoint const &original_point, SnappedPoint &snapped_point) { Geom::Point const b = original_point.getPoint() - _origin; // vector to original point (not the transformed point!) _skew_snapped = (snapped_point.getPoint()[_direction] - (original_point.getPoint())[_direction]) / b[1 - _direction]; // skew factor @@ -335,7 +349,7 @@ SnappedPoint PureRotateConstrained::snap(::SnapManager *sm, SnapCandidatePoint c return sm->constrainedSnap(p, dedicated_constraint, bbox_to_snap); } -void PureRotateConstrained::storeTransform(SnapCandidatePoint const original_point, SnappedPoint snapped_point) { +void PureRotateConstrained::storeTransform(SnapCandidatePoint const &original_point, SnappedPoint &snapped_point) { Geom::Point const a = snapped_point.getPoint() - _origin; // vector to snapped point Geom::Point const b = (original_point.getPoint() - _origin); // vector to original point (not the transformed point!) // a is vector to snapped point; b is vector to original point; now lets calculate angle between a and b -- cgit v1.2.3