Avoid redefining textures

This commit is contained in:
Thomas Forgione 2018-04-18 14:42:46 +02:00
parent 0b6d39541f
commit 598365f913
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
1 changed files with 2 additions and 1 deletions

View File

@ -420,7 +420,8 @@ impl Model {
pub fn build_texture_for_material(&mut self, material: &Material, renderer: &Renderer) {
if let Some(path) = material.textures.get("map_Kd") {
let texture = renderer.make_texture(path);
self.textures.insert(path.to_owned(), Some(texture));
// Don't need to insert multiple times the same texture
self.textures.entry(path.to_owned()).or_insert(Some(texture));
};
}