]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/tracktype.cpp
Fix linking issues with mspnet
[r2c2.git] / source / libr2c2 / tracktype.cpp
index 29bf47be5409d42eb79fbd9644fbf1a62e08e1bc..bf038c52d76c2d19576e5b9a1b30e059a4837306 100644 (file)
@@ -69,7 +69,7 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const
        unsigned part_ep = 0;
        for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
        {
-               if((endpoints[epi].paths&(1<<path)) && i->get_path()!=path)
+               if(endpoints[epi].has_path(path) && i->get_path()!=path)
                        continue;
 
                unsigned n_part_eps = (i->is_dead_end() ? 1 : 2);
@@ -113,6 +113,25 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const
        }
 }
 
+TrackPoint TrackType::get_nearest_point(const Vector &p) const
+{
+       TrackPoint result;
+       float dist = -1;
+
+       for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+       {
+               TrackPoint n = i->get_nearest_point(p);
+               float d = distance(n.pos, p);
+               if(d<dist || dist<0)
+               {
+                       result = n;
+                       dist = d;
+               }
+       }
+
+       return result;
+}
+
 bool TrackType::collide_ray(const Vector &start, const Vector &dir, float width) const
 {
        for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)