void Mesh::draw(Renderer &renderer) const
{
- if(manager)
- {
- manager->resource_used(*this);
- if(disallow_rendering)
- return;
- }
-
- renderer.set_vertex_setup(&vtx_setup);
- renderer.set_winding_test(winding);
-
- for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
- renderer.draw(*i);
+ draw(renderer, 0, 0);
}
void Mesh::draw_instanced(Renderer &renderer, const VertexSetup &vs, unsigned count) const
if(vs.get_vertex_array()!=&vertices)
throw invalid_argument("Mesh::draw_instanced");
+ draw(renderer, &vs, count);
+}
+
+void Mesh::draw(Renderer &renderer, const VertexSetup *vs, unsigned count) const
+{
if(manager)
{
manager->resource_used(*this);
return;
}
- renderer.set_vertex_setup(&vs);
+ renderer.set_vertex_setup(vs ? vs : &vtx_setup);
renderer.set_winding_test(winding);
- for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
- renderer.draw_instanced(*i, count);
+ if(!count)
+ {
+ for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
+ renderer.draw(*i);
+ }
+ else
+ {
+ for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
+ renderer.draw_instanced(*i, count);
+ }
}
Resource::AsyncLoader *Mesh::load(IO::Seekable &io, const Resources *)
void draw(Renderer &) const;
void draw_instanced(Renderer &, const VertexSetup &, unsigned) const;
+private:
+ void draw(Renderer &, const VertexSetup *, unsigned) const;
+public:
virtual int get_load_priority() const { return 1; }
virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
virtual UInt64 get_data_size() const;