]> git.tdb.fi Git - r2c2.git/commitdiff
Limit Z difference when linking tracks
authorMikko Rasa <tdb@tdb.fi>
Tue, 26 Oct 2010 18:32:42 +0000 (18:32 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 26 Oct 2010 18:32:42 +0000 (18:32 +0000)
Correctly set track Z positions when snapped
Eliminate a glitch with new tracks

source/designer/designer.cpp
source/designer/manipulator.cpp
source/libmarklin/track.cpp

index c2c26da8332e3cc9d016a5af2eb3a48d731f6e12..024e9fe7fdc3869fa3148ed61e28f23dc7798514 100644 (file)
@@ -261,14 +261,14 @@ void Designer::tick()
        float dt = (t-last_tick)/Msp::Time::sec;
        last_tick = t;
 
-       for(list<Track *>::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<Track *>::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();
index 64cbbd4ac68e70745512f4ce56e96809c17f9e0e..35779a8ccc2896234f91e330b1872e7d75b7d58f 100644 (file)
@@ -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);
                        }
                }
index 0a9f1ac83f8977f02935fd6f5838d93265a62278..6ec1c6c8b295e3d6ff39a1b9446abcca8c96b99f 100644 (file)
@@ -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<limit)
+                       float dz = epp2.z-epp.z;
+                       if(dx*dx+dy*dy<limit && dz*dz<4e-4)
                        {
                                if(!link || (!flex && !other.get_flex()))
                                {