2 #include "objectinstance.h"
3 #include "instancescene.h"
9 void InstanceScene::add(Renderable &r)
11 renderables[r.get_instance_key()].insert(&r);
14 void InstanceScene::remove(Renderable &r)
16 InstanceMap::iterator i = renderables.find(r.get_instance_key());
17 if(i!=renderables.end())
25 void InstanceScene::setup_frame(Renderer &renderer)
27 for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
28 for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
29 (*j)->setup_frame(renderer);
32 void InstanceScene::finish_frame()
34 for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
35 for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
39 void InstanceScene::render(Renderer &renderer, const Tag &tag) const
41 if(setup_frustum(renderer))
43 for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
44 for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
45 if(!frustum_cull(**j))
46 renderer.render(**j, tag);
50 for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
51 for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
52 renderer.render(**j, tag);