Resized maps no longer change textures, only mtl
This commit is contained in:
parent
2b9a1064a7
commit
973810b776
|
@ -102,7 +102,7 @@ pub struct Model {
|
||||||
pub materials: HashMap<String, Material>,
|
pub materials: HashMap<String, Material>,
|
||||||
|
|
||||||
/// Map associating the name of a texture and the real texture.
|
/// Map associating the name of a texture and the real texture.
|
||||||
pub textures: HashMap<String, (Rc<SrgbTexture2d>, Vector3<f32>)>,
|
pub textures: HashMap<String, Rc<SrgbTexture2d>>,
|
||||||
|
|
||||||
/// The list of parts of the model.
|
/// The list of parts of the model.
|
||||||
pub parts: Vec<Part>,
|
pub parts: Vec<Part>,
|
||||||
|
@ -544,15 +544,15 @@ 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, size)) = material.textures.get("map_Kd") {
|
if let Some((path, _)) = material.textures.get("map_Kd") {
|
||||||
let texture = renderer.make_texture(path);
|
let texture = renderer.make_texture(path);
|
||||||
// Don't need to insert multiple times the same texture
|
// Don't need to insert multiple times the same texture
|
||||||
self.textures.entry(path.to_owned()).or_insert((Rc::new(texture), *size));
|
self.textures.entry(path.to_owned()).or_insert(Rc::new(texture));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the rendering texture.
|
/// Returns the rendering texture.
|
||||||
pub fn get_texture_by_name(&self, name: &str) -> Option<&(Rc<SrgbTexture2d>, Vector3<f32>)> {
|
pub fn get_texture_by_name(&self, name: &str) -> Option<&Rc<SrgbTexture2d>> {
|
||||||
self.textures.get(name)
|
self.textures.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ impl Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a ref mut to the table of textures.
|
/// Returns a ref mut to the table of textures.
|
||||||
pub fn textures_mut(&mut self) -> &mut HashMap<String, (Rc<SrgbTexture2d>, Vector3<f32>)> {
|
pub fn textures_mut(&mut self) -> &mut HashMap<String, Rc<SrgbTexture2d>> {
|
||||||
&mut self.textures
|
&mut self.textures
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,8 +181,8 @@ impl Renderer {
|
||||||
fn get_texture_of_part<'a>(&self, model: &'a Model, part: &Part) -> Option<(&'a SrgbTexture2d, Vector3<f32>)> {
|
fn get_texture_of_part<'a>(&self, model: &'a Model, part: &Part) -> Option<(&'a SrgbTexture2d, Vector3<f32>)> {
|
||||||
if let Some(ref material_name) = part.material_name {
|
if let Some(ref material_name) = part.material_name {
|
||||||
if let Some(ref material) = model.materials.get(material_name) {
|
if let Some(ref material) = model.materials.get(material_name) {
|
||||||
if let Some((texture, _)) = material.textures.get("map_Kd") {
|
if let Some((texture, size)) = material.textures.get("map_Kd") {
|
||||||
if let Some((texture, size)) = model.get_texture_by_name(texture) {
|
if let Some(texture) = model.get_texture_by_name(texture) {
|
||||||
Some((texture, *size))
|
Some((texture, *size))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in New Issue