]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/trackattachment.cpp
New approach for displaying track state
[r2c2.git] / source / libr2c2 / trackattachment.cpp
index 3d28651d882395bdd8baab18162e3e201ad3b1bc..eb2d563561c6fcf7864d00c1a8a170f943c7e624 100644 (file)
@@ -20,6 +20,14 @@ TrackAttachment::~TrackAttachment()
                track->remove_attachment(*this);
 }
 
+float TrackAttachment::get_offset_from_endpoint(unsigned epi) const
+{
+       if(epi==track.entry())
+               return offset;
+       else
+               return track->get_type().get_path_length(0)-offset;
+}
+
 void TrackAttachment::attach_to(const TrackIter &t, float o)
 {
        if(track)
@@ -81,7 +89,7 @@ float TrackAttachment::find_offset(const TrackIter &trk, const Vector &point)
        Vector epp = trk->get_snap_node(trk.entry()).position;
 
        float dist = distance(epp, point);
-       float offs = dist;
+       float offs = min(dist, trk->get_type().get_path_length(0));
        while(1)
        {
                TrackPoint tp = trk->get_point(trk.entry(), offs);