]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/mesh.cpp
Include only tangent in mesh data and calculate binormal on the fly
[libs/gl.git] / source / core / mesh.cpp
index dba8a9915489aede7906f8a684b9d59e288428b5..d3fd7360f756680ef198c44916b9fe71ed7042ac 100644 (file)
@@ -155,6 +155,9 @@ void Mesh::draw(Renderer &renderer, const VertexSetup *vs, unsigned count) const
                        return;
        }
 
+       if(batches.empty())
+               return;
+
        if(dirty)
                resize_buffers();
 
@@ -177,7 +180,7 @@ void Mesh::resize_buffers() const
 {
        if(dirty&VERTEX_BUFFER)
                vbuf->storage(vertices.get_required_buffer_size());
-       if(dirty&INDEX_BUFFER)
+       if((dirty&INDEX_BUFFER) && !batches.empty())
                ibuf->storage(batches.front().get_required_buffer_size());
        dirty = 0;
 }
@@ -218,13 +221,13 @@ Mesh::Loader::Loader(Mesh &m, bool g):
        add("winding",  &Loader::winding);
 }
 
-void Mesh::Loader::vertices(const vector<VertexComponent> &c)
+void Mesh::Loader::vertices(const vector<VertexAttribute> &a)
 {
-       if(c.empty())
-               throw invalid_argument("No vertex components");
+       if(a.empty())
+               throw invalid_argument("No vertex attributes");
 
        VertexFormat fmt;
-       for(vector<VertexComponent>::const_iterator i=c.begin(); i!=c.end(); ++i)
+       for(vector<VertexAttribute>::const_iterator i=a.begin(); i!=a.end(); ++i)
                fmt = (fmt, *i);
        obj.vertices.reset(fmt);
        load_sub(obj.vertices);