From 107795c76fccb99f7ebd89ad83b0a14eeb0e5fbc Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 26 May 2013 01:59:11 +0300 Subject: [PATCH] Snap to segments in both directions Choose whichever is closer to the current rotation. --- source/libr2c2/object.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/libr2c2/object.cpp b/source/libr2c2/object.cpp index e9e58ab..d7c7db2 100644 --- a/source/libr2c2/object.cpp +++ b/source/libr2c2/object.cpp @@ -45,9 +45,15 @@ bool Object::snap_to(const Object &other, float limit, SnapType what) Snap ssn = sn; if(other.snap(ssn, limit, what)) { - set_rotation(rotation+ssn.rotation-sn.rotation-Angle::half_turn()); + if(what==SNAP_NODE) + set_rotation(rotation+ssn.rotation-sn.rotation-Angle::half_turn()); + else + { + Angle adiff = wrap_balanced((ssn.rotation-sn.rotation)*2.0f)/2.0f; + set_rotation(rotation+adiff); + } sn = get_snap_node(i); - position += ssn.position-sn.position; + set_position(position+ssn.position-sn.position); return true; } } -- 2.45.2