- setup_render(pass);
-
- for(list<const ObjectInstance *>::const_iterator i=insts.begin(); i!=insts.end(); ++i)
- {
- (*i)->setup_render(pass);
+ unsigned lod = min<unsigned>(inst.get_level_of_detail(renderer), lods.size()-1);
+ const RenderPass *pass = get_pass(tag, lod);
+ if(!pass)
+ return;
+
+ const Mesh *mesh = lods[lod].mesh.get();
+ if (!mesh)
+ throw logic_error("no mesh");
+
+ Renderer::Push push(renderer);
+ pass->apply(renderer);
+
+ setup_render(renderer, tag);
+ inst.setup_render(renderer, tag);
+ mesh->draw(renderer);
+ inst.finish_render(renderer, tag);
+ finish_render(renderer, tag);
+}