From f22c9d31a5eb8dc27bbbc761a7ec7271df0269c8 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 18:44:07 +0000 Subject: [PATCH] Preserve FBX parent connection precedence --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- crates/formats/src/mesh_import/fbx.rs | 14 +++++++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63ba1709..3de76013 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -842,9 +842,9 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=17e18e31c29fb8c4bf56bb7242ff9dcdb3d3a66f#17e18e31c29fb8c4bf56bb7242ff9dcdb3d3a66f" +source = "git+https://github.com/storytold/craft-libs?rev=f4edcdcad9ce138dc6bf36e8214b4844c0cf8fbc#f4edcdcad9ce138dc6bf36e8214b4844c0cf8fbc" dependencies = [ - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=17e18e31c29fb8c4bf56bb7242ff9dcdb3d3a66f)", + "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f4edcdcad9ce138dc6bf36e8214b4844c0cf8fbc)", "miniz_oxide 0.9.1", ] @@ -931,7 +931,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=17e18e31c29fb8c4bf56bb7242ff9dcdb3d3a66f#17e18e31c29fb8c4bf56bb7242ff9dcdb3d3a66f" +source = "git+https://github.com/storytold/craft-libs?rev=828b07f3c9f3f6a2e935087b859016a5e46b1c31#828b07f3c9f3f6a2e935087b859016a5e46b1c31" dependencies = [ "flate2", "thiserror 2.0.21", @@ -941,7 +941,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=828b07f3c9f3f6a2e935087b859016a5e46b1c31#828b07f3c9f3f6a2e935087b859016a5e46b1c31" +source = "git+https://github.com/storytold/craft-libs?rev=f4edcdcad9ce138dc6bf36e8214b4844c0cf8fbc#f4edcdcad9ce138dc6bf36e8214b4844c0cf8fbc" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index c6f1dcfc..88363c22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" } craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585", features = ["serde"] } craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" } -craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "17e18e31c29fb8c4bf56bb7242ff9dcdb3d3a66f", default-features = false, features = ["stl", "fbx"] } +craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "f4edcdcad9ce138dc6bf36e8214b4844c0cf8fbc", default-features = false, features = ["stl", "fbx"] } craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "828b07f3c9f3f6a2e935087b859016a5e46b1c31" } craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "828b07f3c9f3f6a2e935087b859016a5e46b1c31" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). diff --git a/crates/formats/src/mesh_import/fbx.rs b/crates/formats/src/mesh_import/fbx.rs index 470cf433..d63cf89a 100644 --- a/crates/formats/src/mesh_import/fbx.rs +++ b/crates/formats/src/mesh_import/fbx.rs @@ -57,8 +57,12 @@ pub(crate) fn package(file_name: &str, bytes: &[u8], found: &mut dyn FnMut(&str) if doc.version == 0 { return Err(malformed(KIND, "not an FBX file (no FBXHeaderExtension / FBXVersion)")); } - doc.scene_with_options(&limits, &mut craft_mesh::no_external, &craft_mesh::fbx::SceneOptions { apply_inactive_rotation: true, strict_geometry: true }) - .map_err(convert)?; + doc.scene_with_options( + &limits, + &mut craft_mesh::no_external, + &craft_mesh::fbx::SceneOptions { apply_inactive_rotation: true, strict_geometry: true, prefer_last_parent: true }, + ) + .map_err(convert)?; craft_mesh::fbx::package::write(&doc, file_name, bytes, &limits, package_limits(), found).map_err(convert) }) } @@ -71,7 +75,11 @@ fn read_inner(bytes: &[u8], files: &mut Files) -> Result { } let colors = doc.diffuse_materials(&limits, files).map_err(convert)?; let scene = doc - .scene_with_options(&limits, &mut craft_mesh::no_external, &craft_mesh::fbx::SceneOptions { apply_inactive_rotation: true, strict_geometry: true }) + .scene_with_options( + &limits, + &mut craft_mesh::no_external, + &craft_mesh::fbx::SceneOptions { apply_inactive_rotation: true, strict_geometry: true, prefer_last_parent: true }, + ) .map_err(convert)?; let to_mat = |m: craft_mesh::Mat4| Mat4::from_cols_array(&m.map(|v| v as f32)); let global = to_mat(doc.axes_to_y_up()) * Mat4::from_scale(Vec3::splat((doc.unit_scale().unwrap_or(1.0) / 100.0) as f32));