]> git.tdb.fi Git - r2c2.git/commitdiff
Determine the border of tracktypes with custom object
authorMikko Rasa <tdb@tdb.fi>
Mon, 4 Apr 2011 16:46:40 +0000 (16:46 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 4 Apr 2011 16:46:40 +0000 (16:46 +0000)
source/3d/tracktype.cpp

index 47c85ab4dea6f85562346380ccaf86085358f1f7..a60c9a6f7611425c737fb09c2e69ec3f6b8d717e 100644 (file)
@@ -95,7 +95,17 @@ TrackType3D::TrackType3D(Catalogue3D &cat3d, const TrackType &tt):
        if(!obj_name.empty())
        {
                object = catalogue.get<GL::Object>(obj_name);
-               // XXX border
+               const GL::Mesh *m = object->get_mesh();
+               const GL::VertexArray &vertices = m->get_vertices();
+               int vertex_offs = vertices.get_format().offset(GL::VERTEX2);
+               if(vertex_offs>=0)
+               {
+                       for(unsigned i=0; i<vertices.size(); ++i)
+                       {
+                               const float *v = vertices[i]+vertex_offs;
+                               border.push_back(Vector(v[0], v[1]));
+                       }
+               }
        }
        else
        {