namespace R2C2 {
TrackType::TrackType(const ArticleNumber &an):
- art_nr(an),
+ ObjectType(an),
state_bits(0),
autofit_preference(1)
{ }
unsigned part_ep = 0;
for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
{
- if((endpoints[epi].paths&(1<<path)) && i->get_path()!=path)
+ if(endpoints[epi].has_path(path) && i->get_path()!=path)
continue;
unsigned n_part_eps = (i->is_dead_end() ? 1 : 2);
}
}
+TrackPoint TrackType::get_nearest_point(const Vector &p) const
+{
+ TrackPoint result;
+ float dist = -1;
+
+ for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+ {
+ TrackPoint n = i->get_nearest_point(p);
+ float d = distance(n.pos, p);
+ if(d<dist || dist<0)
+ {
+ result = n;
+ dist = d;
+ }
+ }
+
+ return result;
+}
+
bool TrackType::collide_ray(const Vector &start, const Vector &dir, float width) const
{
for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
TrackType::Loader::Loader(TrackType &t):
- Msp::DataFile::BasicLoader<TrackType>(t),
+ DataFile::DerivedObjectLoader<TrackType, ObjectType::Loader>(t),
state_bits_set(false)
{
add("autofit_preference", &TrackType::autofit_preference);
- add("description", &TrackType::description);
add("object", &TrackType::object);
add("state_bits", &Loader::state_bits);
add("part", &Loader::part);