|
|
|
@ -389,12 +389,9 @@ Before we can draw the model, we need to be able to draw an individual mesh. Let
|
|
|
|
|
// model.rs
|
|
|
|
|
pub trait DrawModel<'a> {
|
|
|
|
|
fn draw_mesh(&mut self, mesh: &'a Mesh);
|
|
|
|
|
fn draw_mesh_instanced(
|
|
|
|
|
&mut self,
|
|
|
|
|
mesh: &'a Mesh,
|
|
|
|
|
instances: Range<u32>,
|
|
|
|
|
);
|
|
|
|
|
fn draw_mesh_instanced(&mut self, mesh: &'a Mesh, instances: Range<u32>);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a, 'b> DrawModel<'b> for wgpu::RenderPass<'a>
|
|
|
|
|
where
|
|
|
|
|
'b: 'a,
|
|
|
|
@ -403,11 +400,7 @@ where
|
|
|
|
|
self.draw_mesh_instanced(mesh, 0..1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw_mesh_instanced(
|
|
|
|
|
&mut self,
|
|
|
|
|
mesh: &'b Mesh,
|
|
|
|
|
instances: Range<u32>,
|
|
|
|
|
){
|
|
|
|
|
fn draw_mesh_instanced(&mut self, mesh: &'b Mesh, instances: Range<u32>) {
|
|
|
|
|
self.set_vertex_buffer(0, mesh.vertex_buffer.slice(..));
|
|
|
|
|
self.set_index_buffer(mesh.index_buffer.slice(..), wgpu::IndexFormat::Uint32);
|
|
|
|
|
self.draw_indexed(0..mesh.num_elements, 0, instances);
|
|
|
|
|