]> git.tdb.fi Git - libs/gl.git/blobdiff - source/mesh.cpp
Check for armature mismatches in Animation
[libs/gl.git] / source / mesh.cpp
index 55d7fc0648df0920dfb93419344d6ee53fdd30a5..b3b719c516942c42e5012a8ad92ad21dec06958d 100644 (file)
@@ -128,10 +128,29 @@ void Mesh::add_batch(const Batch &b)
                batches.back().append(b);
        else
        {
+               bool reallocate = (batches.size()==batches.capacity());
+               if(reallocate && ibuf)
+               {
+                       for(vector<Batch>::iterator i=batches.end(); i!=batches.begin(); )
+                               (--i)->use_buffer(0);
+               }
+
                Batch *prev = (batches.empty() ? 0 : &batches.back());
                batches.push_back(b);
                if(ibuf)
-                       batches.back().use_buffer(ibuf, prev);
+               {
+                       if(reallocate)
+                       {
+                               prev = 0;
+                               for(vector<Batch>::iterator i=batches.begin(); i!=batches.end(); ++i)
+                               {
+                                       i->use_buffer(ibuf, prev);
+                                       prev = &*i;
+                               }
+                       }
+                       else
+                               batches.back().use_buffer(ibuf, prev);
+               }
        }
 }
 
@@ -158,7 +177,7 @@ void Mesh::draw() const
        BindRestore bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER);
        Bind bind_winding(winding);
 
-       for(list<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
+       for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
                i->draw();
 }
 
@@ -174,7 +193,7 @@ void Mesh::draw(Renderer &renderer) const
        renderer.set_mesh(this);
        renderer.set_winding_test(winding);
 
-       for(list<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
+       for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
                renderer.draw(*i);
 }
 
@@ -275,7 +294,7 @@ Mesh::AsyncLoader::AsyncLoader(Mesh &m, IO::Seekable &i):
        phase(0)
 {
        // Make sure the extension is initialized in the rendering thread.
-       (bool)NV_primitive_restart;
+       (void)(bool)NV_primitive_restart;
 
        mesh.disallow_rendering = true;
        if(mesh.defer_buffers)