From: Mikko Rasa Date: Tue, 26 Oct 2010 18:32:42 +0000 (+0000) Subject: Limit Z difference when linking tracks X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=52ba962c6f24873e8db99f2452a8ace216b9540a;p=r2c2.git Limit Z difference when linking tracks Correctly set track Z positions when snapped Eliminate a glitch with new tracks --- diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index c2c26da..024e9fe 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -261,14 +261,14 @@ void Designer::tick() float dt = (t-last_tick)/Msp::Time::sec; last_tick = t; - for(list::iterator i=new_tracks.begin(); i!=new_tracks.end(); ++i) - layout_3d->get_track(**i).get_path().set_mask(0); - new_tracks.clear(); - window.get_display().tick(); root->tick(); camera_ctl.tick(dt); + for(list::iterator i=new_tracks.begin(); i!=new_tracks.end(); ++i) + layout_3d->get_track(**i).get_path().set_mask(0); + new_tracks.clear(); + render(); window.swap_buffers(); diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 64cbbd4..35779a8 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -285,7 +285,7 @@ void Manipulator::pointer_motion(int, int y, float gx, float gy) continue; Point dp(i->pos.x-snapped->pos.x, i->pos.y-snapped->pos.y, 0); - i->track->set_position(Point(sp.x+c*dp.x-s*dp.y, sp.y+s*dp.x+c*dp.y, sp.z)); + i->track->set_position(Point(sp.x+c*dp.x-s*dp.y, sp.y+s*dp.x+c*dp.y, sp.z+i->pos.z-snapped->pos.z)); i->track->set_rotation(i->rot+da); } } diff --git a/source/libmarklin/track.cpp b/source/libmarklin/track.cpp index 0a9f1ac..6ec1c6c 100644 --- a/source/libmarklin/track.cpp +++ b/source/libmarklin/track.cpp @@ -212,7 +212,8 @@ bool Track::snap_to(Track &other, bool link) Point epp2 = other.get_endpoint_position(j); float dx = epp2.x-epp.x; float dy = epp2.y-epp.y; - if(dx*dx+dy*dy