From c6a3ee6b19656e37f007edf92c8805b292515ea2 Mon Sep 17 00:00:00 2001 From: mars Date: Sat, 16 Apr 2022 23:36:19 -0600 Subject: [PATCH] Add HasMeshHandle and impl for MeshHandle --- src/mesh/mod.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mesh/mod.rs b/src/mesh/mod.rs index a570fdd..5970520 100644 --- a/src/mesh/mod.rs +++ b/src/mesh/mod.rs @@ -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)?;