feat: implement gltf loader
This commit is contained in:
1 parent
ba9b677545
commit
5eb71f06cf
16 files changed
+172
-1375211
No files matched your search
+1
-1
@@ -81,7 +81,7 @@ impl MeshRegistry {
|
||||
let obj_num_idx = obj.indices.len();
|
||||
buf_indices.extend(obj.indices);
|
||||
|
||||
println!("Loaded mesh {} with {} vertices and {} indices", id, obj_num_verts, obj_num_idx);
|
||||
println!("Loaded mesh \"{}\" with {} vertices and {} indices", id, obj_num_verts, obj_num_idx);
|
||||
|
||||
// TODO Create bounding boxes for each mesh and associate them with the struct.
|
||||
mesh_list.insert(
|
||||
|
||||
@@ -21,7 +21,7 @@ impl RenderBatch {
|
||||
instance_registry: Arc<InstanceRegistry>
|
||||
) -> Vec<Self> {
|
||||
mesh_registry.meshes.iter()
|
||||
.map(|(id, mesh)| {
|
||||
.filter_map(|(id, mesh)| {
|
||||
let instances = instance_registry.get_instances_for(id);
|
||||
|
||||
let gpu_instances = instances.iter()
|
||||
@@ -31,6 +31,10 @@ impl RenderBatch {
|
||||
})
|
||||
.collect::<Vec<GpuInstance>>();
|
||||
|
||||
if gpu_instances.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Build instances into a RenderBatch
|
||||
let instance_buffer = Buffer::from_iter(
|
||||
allocator.clone(),
|
||||
@@ -46,11 +50,11 @@ impl RenderBatch {
|
||||
gpu_instances
|
||||
).expect("Couldn't allocate instance buffer");
|
||||
|
||||
Self {
|
||||
Some(Self {
|
||||
mesh_id: id.clone(),
|
||||
instance_buffer,
|
||||
instance_count: instances.len() as u32,
|
||||
}
|
||||
})
|
||||
}).collect()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user