From a5fb695381e22c07935e2aca3c5b336d70fce32f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 18:38:53 +0000 Subject: [PATCH] Preserve strict FBX geometry behavior --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- crates/formats/src/mesh_import/fbx.rs | 13 ++++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b27f7dac..e94d4e44 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=543098150ffc09914b662e61053d8cddf239bbe6#543098150ffc09914b662e61053d8cddf239bbe6" +source = "git+https://github.com/storytold/craft-libs?rev=4a84c00372972fb99755cba34978a5e73387c3f0#4a84c00372972fb99755cba34978a5e73387c3f0" dependencies = [ - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=543098150ffc09914b662e61053d8cddf239bbe6)", + "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4a84c00372972fb99755cba34978a5e73387c3f0)", "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=543098150ffc09914b662e61053d8cddf239bbe6#543098150ffc09914b662e61053d8cddf239bbe6" +source = "git+https://github.com/storytold/craft-libs?rev=4a84c00372972fb99755cba34978a5e73387c3f0#4a84c00372972fb99755cba34978a5e73387c3f0" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index 3a263a6c..a4a3231c 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 = "543098150ffc09914b662e61053d8cddf239bbe6", default-features = false, features = ["stl", "fbx"] } +craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "4a84c00372972fb99755cba34978a5e73387c3f0", 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 8faf623c..7b9fb643 100644 --- a/crates/formats/src/mesh_import/fbx.rs +++ b/crates/formats/src/mesh_import/fbx.rs @@ -8,6 +8,11 @@ fn limits() -> craft_mesh::Limits { craft_mesh::Limits { max_vertices: super::MAX_VERTICES, max_triangles: texturecraft_geom::MAX_TRIANGLES, + max_face_corners: super::MAX_VERTICES, + max_meshes: super::MAX_VERTICES, + max_parts: super::MAX_VERTICES, + max_materials: super::MAX_VERTICES, + max_nodes: super::MAX_VERTICES, max_data_bytes: 1 << 31, max_extras: 100_000, ..Default::default() @@ -52,7 +57,8 @@ 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 }).map_err(convert)?; + doc.scene_with_options(&limits, &mut craft_mesh::no_external, &craft_mesh::fbx::SceneOptions { apply_inactive_rotation: true, strict_geometry: true }) + .map_err(convert)?; craft_mesh::fbx::package::write(&doc, file_name, bytes, &limits, package_limits(), found).map_err(convert) }) } @@ -64,8 +70,9 @@ fn read_inner(bytes: &[u8], files: &mut Files) -> Result { return Err(malformed(KIND, "not an FBX file (no FBXHeaderExtension / FBXVersion)")); } 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 }).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 }) + .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)); let mut sink = PolygonSink::default();