tirbofish/dropbear · commit
5b2e1a21ac1e117e61b07282462e9e933c8b5418
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.
Signature present but could not be verified.
Unverified
@@ -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 @@ -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