]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/layout.cpp
Use raycasting instead of OpenGL selection mode to pick tracks
[r2c2.git] / source / libr2c2 / layout.cpp
index d6bd9ee909dee6f11c7016559ccdd24acbf7386a..5c4cf9e1d82d26f604fbb4f5a20736cf944937d6 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of R²C²
-Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
+Copyright © 2006-2011  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
@@ -86,6 +86,15 @@ void Layout::remove_track(Track &t)
        }
 }
 
+Track *Layout::pick_track(const Vector &start, const Vector &ray)
+{
+       for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               if((*i)->collide_ray(start, ray))
+                       return *i;
+
+       return 0;
+}
+
 unsigned Layout::allocate_turnout_id()
 {
        set<unsigned> used_ids;