Add HasMeshHandle and impl for MeshHandle

This commit is contained in:
mars 2022-04-16 23:36:19 -06:00
parent 5b75299832
commit c6a3ee6b19
1 changed files with 15 additions and 2 deletions

View File

@ -45,9 +45,9 @@
//! TODO: make spillover buffers GPU-transferrable on iGPUs
use slab::Slab;
use std::sync::Arc;
use smallvec::SmallVec;
use std::collections::HashMap;
use std::sync::Arc;
pub mod attr;
pub mod group;
@ -93,6 +93,18 @@ pub struct MeshHandle {
pub(crate) sub: usize,
}
impl HasMeshHandle for MeshHandle {
fn get_mesh_handle(&self) -> &Self {
self
}
}
/// A trait for structs containing [MeshHandles][MeshHandle] that are not
/// themselves handles. Used for iteration.
pub trait HasMeshHandle {
fn get_mesh_handle(&self) -> &MeshHandle;
}
/// The top-level mesh data pool.
pub struct MeshPool {
staging: StagingPool,
@ -122,7 +134,8 @@ impl MeshPool {
}
let group_index = self.groups.len();
self.groups.push(MeshGroup::new(group_index, self.attr_store.clone()));
let attr_store = self.attr_store.clone();
self.groups.push(MeshGroup::new(group_index, attr_store));
let group = self.groups.get_mut(group_index).unwrap();
let (handle, copies) = group.load(buf)?;