Dont reload textures if some already exist

This commit is contained in:
Thomas Forgione 2018-10-30 16:44:14 +01:00
parent 92e1f1d0ec
commit 4a4ae65cc1
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 5 additions and 3 deletions

View File

@ -545,9 +545,11 @@ impl Model {
/// Builds the SrgbTextures for rendering. /// Builds the SrgbTextures for rendering.
pub fn build_texture_for_material(&mut self, material: &Material, renderer: &Renderer) { pub fn build_texture_for_material(&mut self, material: &Material, renderer: &Renderer) {
if let Some((path, _)) = material.textures.get("map_Kd") { if let Some((path, _)) = material.textures.get("map_Kd") {
let texture = renderer.make_texture(path); if ! self.textures.contains_key(path) {
// Don't need to insert multiple times the same texture let texture = renderer.make_texture(path);
self.textures.entry(path.to_owned()).or_insert(Rc::new(texture)); // Don't need to insert multiple times the same texture
self.textures.entry(path.to_owned()).or_insert(Rc::new(texture));
}
}; };
} }