oxide_asset/
mesh_cache.rs1use oxide_renderer::mesh::Mesh3D;
4
5use super::{Assets, Handle};
6
7pub struct MeshCache {
9 meshes: Assets<Mesh3D>,
10}
11
12impl MeshCache {
13 pub fn new() -> Self {
15 Self {
16 meshes: Assets::new(),
17 }
18 }
19
20 pub fn insert(&mut self, handle: Handle<Mesh3D>, mesh: Mesh3D) {
22 self.meshes.insert(handle, mesh);
23 }
24
25 pub fn get(&self, handle: Handle<Mesh3D>) -> Option<&Mesh3D> {
27 self.meshes.get(&handle)
28 }
29
30 pub fn remove(&mut self, handle: Handle<Mesh3D>) -> Option<Mesh3D> {
32 self.meshes.remove(&handle)
33 }
34
35 pub fn len(&self) -> usize {
37 self.meshes.len()
38 }
39
40 pub fn is_empty(&self) -> bool {
42 self.meshes.is_empty()
43 }
44}
45
46impl Default for MeshCache {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52#[derive(Clone, Debug)]
54pub struct MeshFilter {
55 pub mesh: Handle<Mesh3D>,
57}
58
59impl MeshFilter {
60 pub fn new(mesh: Handle<Mesh3D>) -> Self {
62 Self { mesh }
63 }
64}