+ if(i>=links.size())
+ throw out_of_range("Track::break_link");
+
+ Track *other = links[i];
+ if(!other)
+ return false;
+
+ links[i] = 0;
+ other->break_link(*this);
+ // XXX Creates the blocks twice, because the other track calls this too
+ layout.create_blocks(*this);
+ signal_link_changed.emit(i, 0);
+
+ return true;
+}
+
+bool Track::collide_ray(const Vector &start, const Vector &ray) const
+{
+ Vector local_start(start.x-position.x, start.y-position.y, start.z-position.z);
+ float c = cos(rotation);
+ float s = sin(rotation);
+ local_start = Vector(c*local_start.x+s*local_start.y, c*local_start.y-s*local_start.x, local_start.z);
+ Vector local_ray(c*ray.x+s*ray.y, c*ray.y-s*ray.x, ray.z);
+
+ float width = layout.get_catalogue().get_ballast_profile().get_width();
+
+ return type.collide_ray(local_start, local_ray, width);