+unsigned Signal::get_n_snap_nodes() const
+{
+ return 1;
+}
+
+Snap Signal::get_snap_node(unsigned i) const
+{
+ if(i>=1)
+ throw out_of_range("Signal::get_snap_node");
+
+ Snap sn;
+ sn.position = position;
+ sn.rotation = rotation;
+ return sn;
+}
+
+SnapType Signal::get_default_snap_type_to(const Object &other) const
+{
+ if(dynamic_cast<const Track *>(&other))
+ return SNAP_SEGMENT;
+
+ return NO_SNAP;
+}
+
+bool Signal::collide_ray(const Vector &start, const Vector &ray) const
+{
+ // XXX Totally hardcoded stuff, should be replaced with a geometry system
+ Vector center = position;
+ center.x += sin(rotation)*0.035;
+ center.y -= cos(rotation)*0.035;
+ Vector d(center.x-start.x, center.y-start.y);
+ float x = (d.x*ray.x+d.y*ray.y)/(ray.x*ray.x+ray.y*ray.y);
+ Vector nearest(start.x+ray.x*x-center.x, start.y+ray.y*x-center.y, start.z+ray.z*x-center.z);
+ if(nearest.z<0|| nearest.z>0.12)
+ return false;
+ return nearest.x*nearest.x+nearest.y*nearest.y<0.0001;
+}
+