]> git.tdb.fi Git - libs/gl.git/blobdiff - source/simplescene.cpp
Store Renderables as non-const pointers or references
[libs/gl.git] / source / simplescene.cpp
index 4ccc714b79d7eefbe898a43677c0284a81e0a2ff..137873dad8808b99a0717b31721e4fb67db5b1f5 100644 (file)
@@ -4,13 +4,14 @@
 namespace Msp {
 namespace GL {
 
-void SimpleScene::add(const Renderable &r)
+void SimpleScene::add(Renderable &r)
 {
-       renderables.insert(&r);
-       cache.clear();
+       // Add to cache as well if the cache is valid
+       if(renderables.insert(&r).second && !cache.empty())
+               cache.push_back(&r);
 }
 
-void SimpleScene::remove(const Renderable &r)
+void SimpleScene::remove(Renderable &r)
 {
        renderables.erase(&r);
        cache.clear();