X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.cpp;h=cf496c41ddae554b98da55d62e67bc2b3e0179b4;hb=a20b8421d002629a9f4d97c0c378e9f9cb29e292;hp=0d4052ea999a83b6394bb79f7d03f9216604fc39;hpb=f8a7788cee0261babfc4c804a58515aad6dfbc3d;p=r2c2.git diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 0d4052e..cf496c4 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include "block.h" #include "catalogue.h" @@ -333,6 +326,19 @@ TrackPoint Track::get_point(unsigned epi, float d) const return get_point(epi, active_path, d); } +bool Track::collide_ray(const Vector &start, const Vector &ray) +{ + Vector local_start(start.x-pos.x, start.y-pos.y, start.z-pos.z); + float c = cos(rot); + float s = sin(rot); + 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); +} + void Track::save(list &st) const { st.push_back((DataFile::Statement("position"), pos.x, pos.y, pos.z));