X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftracktype.cpp;h=29bf47be5409d42eb79fbd9644fbf1a62e08e1bc;hb=64340dad429ba4040538fc06b6882aabdb489925;hp=35d220821500e1621dbb19bc732587398154507b;hpb=c5f5ec54e81a6a85f911fa1075a0939a7352fbfd;p=r2c2.git diff --git a/source/libr2c2/tracktype.cpp b/source/libr2c2/tracktype.cpp index 35d2208..29bf47b 100644 --- a/source/libr2c2/tracktype.cpp +++ b/source/libr2c2/tracktype.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 "tracktype.h" @@ -62,7 +55,7 @@ bool TrackType::is_dead_end() const const TrackType::Endpoint &TrackType::get_endpoint(unsigned i) const { if(i>=endpoints.size()) - throw InvalidParameterValue("Endpoint index out of range"); + throw out_of_range("TrackType::get_endpoint"); return endpoints[i]; } @@ -70,7 +63,7 @@ const TrackType::Endpoint &TrackType::get_endpoint(unsigned i) const TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const { if(epi>=endpoints.size()) - throw InvalidParameterValue("Endpoint index out of range"); + throw out_of_range("TrackType::get_point"); const TrackPart *part = 0; unsigned part_ep = 0; @@ -94,7 +87,7 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const } if(!part) - throw Exception("Internal error (endpoint does not match any part)"); + throw logic_error("internal error (endpoint does not match any part)"); while(1) { @@ -113,13 +106,22 @@ TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const d -= plen; TrackPart *next = part->get_link(1-part_ep); if(!next) - throw InvalidParameterValue("Distance out of range"); + throw invalid_argument("TrackType::get_point"); part_ep = (next->get_link(0)==part ? 0 : 1); part = next; } } } +bool TrackType::collide_ray(const Vector &start, const Vector &dir, float width) const +{ + for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) + if(i->collide_ray(start, dir, width)) + return true; + + return false; +} + void TrackType::collect_endpoints() { endpoints.clear(); @@ -171,7 +173,7 @@ TrackType::Endpoint::Endpoint(float x, float y, float d, unsigned p): TrackType::Loader::Loader(TrackType &t): - Msp::DataFile::BasicLoader(t), + Msp::DataFile::ObjectLoader(t), state_bits_set(false) { add("autofit_preference", &TrackType::autofit_preference);