kitgit

tirbofish/dropbear · diff

5b2e1a2 · Thribhu K

refactor: created new TextureBuilder struct to clean up the mess that was before. refactor: made AssetViewer use Arc<T> instead of references. fix: on colour change, it constantly recreates the texture.

Unverified

diff --git a/crates/dropbear-engine/Cargo.toml b/crates/dropbear-engine/Cargo.toml
index 19a0a30..a7df5a3 100644
--- a/crates/dropbear-engine/Cargo.toml
+++ b/crates/dropbear-engine/Cargo.toml
@@ -11,6 +11,7 @@ readme.workspace = true
 [dependencies]
 dropbear_future-queue = { path = "../dropbear_future-queue" }
 dropbear-macro = { path = "../dropbear-macro" }
+dropbear-utils = { path = "../dropbear-utils" }
 slank = { path = "../slank", features = ["download-slang", "use-wgpu"] }
 
 anyhow.workspace = true
diff --git a/crates/dropbear-engine/src/asset.rs b/crates/dropbear-engine/src/asset.rs
index ae82706..bc7970b 100644
--- a/crates/dropbear-engine/src/asset.rs
+++ b/crates/dropbear-engine/src/asset.rs
@@ -66,10 +66,10 @@ impl<T> Handle<T> {
 }
 
 pub struct AssetRegistry {
-    textures: HashMap<u64, Texture>,
+    textures: HashMap<u64, Arc<Texture>>,
     texture_labels: HashMap<String, Handle<Texture>>,
 
-    models: HashMap<u64, Model>,
+    models: HashMap<u64, Arc<Model>>,
     model_labels: HashMap<String, Handle<Model>>,
 }
 
@@ -113,13 +113,6 @@ impl AssetRegistry {
         hasher.finish()
     }
 
-    /// A convenient helper function for hashing a byte slice of data.
-    pub(crate) fn hash_contents<T: Hash>(data: T) -> u64 {
-        let mut hasher = DefaultHasher::new();
-        data.hash(&mut hasher);
-        hasher.finish()
-    }
-
     /// Checks if the asset registry contains a handle with the given hash.
     ///
     /// It will check all different types, so it does not point out specifically where.
@@ -146,7 +139,7 @@ impl AssetRegistry {
             .hash
             .map(|v| Handle::new(v))
             .unwrap_or_else(|| Handle::NULL);
-        self.textures.entry(handle.id).or_insert(texture);
+        self.textures.entry(handle.id).or_insert(Arc::new(texture));
         handle

Large diffs are not rendered by default. Showing the first 50 of 3121 lines. Show full diff