+ // TODO Make profile width configurable
+ Profile profile;
+ if(i==0)
+ {
+ float rail_w = (rail_max.x-rail_min.x)*2;
+ profile.append_vertex(Vector(rail_w*-0.5, 0, 0), false);
+ profile.append_vertex(Vector(rail_w*0.5, 0, 0), false);
+ }
+ else
+ {
+ profile.append_vertex(Vector(i*(gauge*0.5+rail_min.x*2), 0, 0), false);
+ profile.append_vertex(Vector(i*(gauge*0.5+rail_max.x*2), 0, 0), false);
+ }
+
+ // TODO Avoid generating redundant meshes for single-path tracks
+ for(int j=-1; j<=4; ++j)
+ {
+ if(j>=0 && !((paths>>j)&1))
+ continue;
+
+ GL::Mesh *m = new GL::Mesh(GL::VERTEX3);
+ GL::MeshBuilder bld(*m);
+ unsigned index = 0;
+ for(vector<TrackPart>::const_iterator k=parts.begin(); k!=parts.end(); ++k)
+ if(j<0 || k->get_path()==static_cast<unsigned>(j))
+ build_part(*k, profile, Vector(0, 0, ballast_h+1.5*rail_h), false, bld, index);
+ path_meshes[(j&0xFF)|((i&3)<<8)] = m;
+ }