Use a default white texture, srgb clear color
This commit is contained in:
+7
-4
@@ -91,7 +91,7 @@ pub struct Model {
|
||||
pub materials: HashMap<String, Material>,
|
||||
|
||||
/// Map associating the name of a texture and the real texture.
|
||||
pub textures: HashMap<String, Option<SrgbTexture2d>>,
|
||||
pub textures: HashMap<String, SrgbTexture2d>,
|
||||
|
||||
/// The list of parts of the model.
|
||||
pub parts: Vec<Part>,
|
||||
@@ -157,6 +157,7 @@ impl Model {
|
||||
if let Some(id) = face.id {
|
||||
face.id = Some(id + face_offset);
|
||||
}
|
||||
face.material_name = new_part.material_name.clone();
|
||||
new_part.faces.push(face.clone());
|
||||
self.faces.push(face.clone());
|
||||
}
|
||||
@@ -167,6 +168,7 @@ impl Model {
|
||||
for (name, material) in other.materials {
|
||||
let entry = self.materials.entry(name);
|
||||
if let Entry::Occupied(_) = entry {
|
||||
eprintln!("Warning: materials merged but sharing the same name");
|
||||
// Return error
|
||||
} else {
|
||||
entry.or_insert(material);
|
||||
@@ -177,6 +179,7 @@ impl Model {
|
||||
for (name, texture) in other.textures {
|
||||
let entry = self.textures.entry(name);
|
||||
if let Entry::Occupied(_) = entry {
|
||||
eprintln!("Warning: textures merged but sharing the same name");
|
||||
// return Error;
|
||||
} else {
|
||||
entry.or_insert(texture);
|
||||
@@ -435,17 +438,17 @@ impl Model {
|
||||
if let Some(path) = material.textures.get("map_Kd") {
|
||||
let texture = renderer.make_texture(path);
|
||||
// Don't need to insert multiple times the same texture
|
||||
self.textures.entry(path.to_owned()).or_insert(Some(texture));
|
||||
self.textures.entry(path.to_owned()).or_insert(texture);
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns the rendering texture.
|
||||
pub fn get_texture_by_name(&self, name: &str) -> Option<&SrgbTexture2d> {
|
||||
self.textures[name].as_ref()
|
||||
self.textures.get(name)
|
||||
}
|
||||
|
||||
/// Returns a ref mut to the table of textures.
|
||||
pub fn textures_mut(&mut self) -> &mut HashMap<String, Option<SrgbTexture2d>> {
|
||||
pub fn textures_mut(&mut self) -> &mut HashMap<String, SrgbTexture2d> {
|
||||
&mut self.textures
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user