Textures are now shared between materials
This commit is contained in:
@@ -136,10 +136,12 @@ impl Model {
|
||||
let normal_offset = self.normals.len();
|
||||
let face_offset = self.faces.len();
|
||||
|
||||
// Merge the elements
|
||||
self.vertices.append(&mut other.vertices);
|
||||
self.texture_coordinates.append(&mut other.texture_coordinates);
|
||||
self.normals.append(&mut other.normals);
|
||||
|
||||
// Merge the parts and faces
|
||||
for part in &mut other.parts {
|
||||
let mut new_part = Part::new(part.material_name.clone());
|
||||
for face in &mut part.faces {
|
||||
@@ -161,6 +163,7 @@ impl Model {
|
||||
self.parts.push(new_part);
|
||||
}
|
||||
|
||||
// Merge the materials
|
||||
for (name, material) in other.materials {
|
||||
let entry = self.materials.entry(name);
|
||||
if let Entry::Occupied(_) = entry {
|
||||
@@ -169,6 +172,16 @@ impl Model {
|
||||
entry.or_insert(material);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge the textures
|
||||
for (name, texture) in other.textures {
|
||||
let entry = self.textures.entry(name);
|
||||
if let Entry::Occupied(_) = entry {
|
||||
// return Error;
|
||||
} else {
|
||||
entry.or_insert(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a model from a file.
|
||||
|
||||
Reference in New Issue
Block a user