in native/src/work_asset/meld.rs [170:206]
fn meld_in_material(
base: &mut WorkAsset,
other: &WorkAsset,
other_ix: Index<Material>,
) -> Index<Material> {
let other_ix = other_ix.value();
let key = &other.material_keys[other_ix];
if let Some(ix) = base.material_ix(key) {
return Index::new(ix as u32);
}
let mut new_object = other.materials()[other_ix].clone();
// laboriously hand-meld the five relevant textures
if let Some(mut info) = new_object.normal_texture {
info.index = meld_in_texture(base, other, info.index);
new_object.normal_texture = Some(info);
}
if let Some(mut info) = new_object.occlusion_texture {
info.index = meld_in_texture(base, other, info.index);
new_object.occlusion_texture = Some(info);
}
if let Some(mut info) = new_object.emissive_texture {
info.index = meld_in_texture(base, other, info.index);
new_object.emissive_texture = Some(info);
}
if let Some(mut info) = new_object.pbr_metallic_roughness.base_color_texture {
info.index = meld_in_texture(base, other, info.index);
new_object.pbr_metallic_roughness.base_color_texture = Some(info);
}
if let Some(mut info) = new_object.pbr_metallic_roughness.metallic_roughness_texture {
info.index = meld_in_texture(base, other, info.index);
new_object.pbr_metallic_roughness.metallic_roughness_texture = Some(info);
}
// end meld logic
Index::new(base.push_material(new_object, key) as u32)
}