mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-21 15:00:42 +01:00
Merge pull request #714 from FredApps/fix/778-collada-material-names
fix(formats): preserve empty COLLADA material bindings
This commit is contained in:
2 files changed
+12
-1
No files matched your search
@@ -74,7 +74,8 @@ fn read_inner(bytes: &[u8]) -> Result<RawMesh> {
|
||||
sink.part = node.name.clone();
|
||||
let uvs = mesh.uv_sets.first();
|
||||
for part in &mesh.parts {
|
||||
let material = part.material.and_then(|m| scene.materials.get(m)).filter(|m| !m.name.is_empty()).map_or("Default", |m| m.name.as_str());
|
||||
// An explicit empty name is a binding; only an absent material uses the default.
|
||||
let material = part.material.and_then(|m| scene.materials.get(m)).map_or("Default", |m| m.name.as_str());
|
||||
for face in part.faces() {
|
||||
let mut corners = Vec::with_capacity(face.len());
|
||||
for c in face {
|
||||
|
||||
@@ -841,6 +841,16 @@ fn dae_attribute_and_text_entities_are_decoded() {
|
||||
assert!((cam.fov - 30.0).abs() < 1e-3, "{cam:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dae_empty_material_binding_stays_distinct_from_named_default() {
|
||||
let dae = DAE.replace(r#"name="Red""#, r#"name="""#).replace(r#"name="Blue""#, r#"name="Default""#);
|
||||
let m = import_mesh_bytes("scene.dae", dae.as_bytes()).unwrap().mesh;
|
||||
assert_eq!(m.materials.len(), 2);
|
||||
let material_for = |part: &str| m.submeshes.iter().find(|s| s.name == part).map(|s| m.materials[s.material].as_str());
|
||||
assert_eq!(material_for("child"), Some(""));
|
||||
assert_eq!(material_for("other"), Some("Default"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glb_export_round_trips_with_textures() {
|
||||
let mesh = texturecraft_geom::primitives::material_ball();
|
||||
|
||||
Reference in new issue
Block a user