From: Mikko Rasa Date: Sat, 25 May 2013 22:59:11 +0000 (+0300) Subject: Snap to segments in both directions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=107795c76fccb99f7ebd89ad83b0a14eeb0e5fbc;p=r2c2.git Snap to segments in both directions Choose whichever is closer to the current rotation. --- 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; } }