diff --git a/Cargo.lock b/Cargo.lock index adfd6cdc1..e98d10275 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,7 +81,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "acadrust" version = "0.5.5" -source = "git+https://github.com/HakanSeven12/cadcodec.git?rev=5eea24cf35ba1739c22e982fc398ddb6c285def5#5eea24cf35ba1739c22e982fc398ddb6c285def5" +source = "git+https://github.com/HakanSeven12/cadcodec.git?rev=de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad#de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad" dependencies = [ "ahash 0.8.12", "anyhow", @@ -896,7 +896,7 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cadkernel" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=5f0cdffc0faa9db03346aa794e22285c365b5f7f#5f0cdffc0faa9db03346aa794e22285c365b5f7f" +source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=773070e4e5dcfcceddf9750a876bf67353642922#773070e4e5dcfcceddf9750a876bf67353642922" dependencies = [ "acadrust", "cavalier_contours", @@ -907,7 +907,7 @@ dependencies = [ [[package]] name = "cadkernel-constraints" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=5f0cdffc0faa9db03346aa794e22285c365b5f7f#5f0cdffc0faa9db03346aa794e22285c365b5f7f" +source = "git+https://github.com/HakanSeven12/cadkernel.git?rev=773070e4e5dcfcceddf9750a876bf67353642922#773070e4e5dcfcceddf9750a876bf67353642922" dependencies = [ "nalgebra", ] diff --git a/Cargo.toml b/Cargo.toml index b01082514..78bdbd874 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,9 +31,9 @@ glam = { version = "0.33", features = ["bytemuck"] } rfd = "0.17" clap = { version = "4", features = ["derive", "string"] } env_logger = "0.11" -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5", features = ["serde"] } -cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "5f0cdffc0faa9db03346aa794e22285c365b5f7f", features = ["acis", "offset"] } -cadkernel-constraints = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "5f0cdffc0faa9db03346aa794e22285c365b5f7f" } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad", features = ["serde"] } +cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "773070e4e5dcfcceddf9750a876bf67353642922", features = ["acis", "offset"] } +cadkernel-constraints = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "773070e4e5dcfcceddf9750a876bf67353642922" } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } flate2 = "1" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] } diff --git a/crates/ocs_plugin_api/Cargo.toml b/crates/ocs_plugin_api/Cargo.toml index 0687ff106..06b5319a6 100644 --- a/crates/ocs_plugin_api/Cargo.toml +++ b/crates/ocs_plugin_api/Cargo.toml @@ -14,7 +14,7 @@ serde = { version = "1", features = ["derive"] } # Pulled in only by the `host` feature, which adds the `acadrust`-typed # `HostApi` runtime surface. The default crate stays dependency-free so engine # crates and external tooling can depend on the manifest/ribbon contract cheaply. -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5", optional = true, features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad", optional = true, features = ["serde"] } # Runtime IPC and serialization (host feature only). interprocess = { version = "2", optional = true } @@ -38,7 +38,7 @@ serde_json = "1" serde = { version = "1", features = ["derive"] } cargo-lock = "11" # acadrust is scanned at build time to generate the embedded type registry. -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5", features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad", features = ["serde"] } [dev-dependencies] serde_json = "1" diff --git a/crates/ocs_web_worker/Cargo.toml b/crates/ocs_web_worker/Cargo.toml index 6696d3ff4..2b1b72071 100644 --- a/crates/ocs_web_worker/Cargo.toml +++ b/crates/ocs_web_worker/Cargo.toml @@ -8,7 +8,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5", features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad", features = ["serde"] } bincode = "1.3" serde = { version = "1", features = ["derive"] } console_error_panic_hook = "0.1" diff --git a/crates/plugin-template-api2/Cargo.toml b/crates/plugin-template-api2/Cargo.toml index 399a1f929..6630f38fa 100644 --- a/crates/plugin-template-api2/Cargo.toml +++ b/crates/plugin-template-api2/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] [dependencies] ocs_plugin_api = { path = "../ocs_plugin_api", features = ["host"] } -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5", features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad", features = ["serde"] } diff --git a/docs/plugin-template-v2/Cargo.toml b/docs/plugin-template-v2/Cargo.toml index e5cbea928..e44f97abf 100644 --- a/docs/plugin-template-v2/Cargo.toml +++ b/docs/plugin-template-v2/Cargo.toml @@ -12,4 +12,4 @@ crate-type = ["cdylib"] [dependencies] ocs_plugin_api = { path = "../../crates/ocs_plugin_api", features = ["host"] } -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5" } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad" } diff --git a/src/entities/common.rs b/src/entities/common.rs index c31b8e25e..bbb215f7b 100644 --- a/src/entities/common.rs +++ b/src/entities/common.rs @@ -110,7 +110,12 @@ pub fn format_length(value: f64) -> String { /// rotation leaves coordinates like -1e-15 behind, which read as `-0.0000`. fn without_negative_zero(text: String) -> String { match text.strip_prefix('-') { - Some(rest) if !rest.chars().any(|c| matches!(c, '1'..='9')) => rest.to_string(), + Some(rest) + if rest.chars().any(|c| c.is_ascii_digit()) + && !rest.chars().any(|c| matches!(c, '1'..='9')) => + { + rest.to_string() + } _ => text, } } @@ -1276,4 +1281,10 @@ mod negative_zero_format_tests { assert_eq!(angle(0, 0, -45f64.to_radians()), "-45°"); assert_eq!(angle(1, 1, -0.0001f64.to_radians()), "-0d0'0.4\""); } + + #[test] + fn a_negative_infinite_value_keeps_its_sign() { + assert_eq!(length(2, 4, f64::NEG_INFINITY), "-inf"); + assert_eq!(angle(0, 0, f64::NEG_INFINITY), "-inf°"); + } } diff --git a/src/io/obj.rs b/src/io/obj.rs index 4b1a5e157..06231c838 100644 --- a/src/io/obj.rs +++ b/src/io/obj.rs @@ -75,7 +75,12 @@ pub fn parse_obj(src: &str, color: [f32; 4]) -> Option { for (vi, (pos_i, norm_i)) in face_verts.iter().enumerate() { let pos = *positions.get(*pos_i).unwrap_or(&[0.0; 3]); verts.push(pos); - let norm = norm_i.and_then(|ni| normals_raw.get(ni).copied()); + let norm = norm_i + .and_then(|ni| normals_raw.get(ni).copied()) + .filter(|n| { + n.iter().all(|value| value.is_finite()) + && n.iter().map(|value| value * value).sum::() > 1e-12 + }); has_normal.push(norm.is_some()); norms.push(norm.unwrap_or([0.0, 0.0, 0.0])); indices.push(vi as u32); @@ -153,6 +158,13 @@ mod tests { assert_normals(&mesh.normals, [0.0, 0.0, 1.0]); } + #[test] + fn a_zero_normal_gets_the_face_normal() { + let src = format!("{SQUARE}vn 0 0 0\nf 1//1 2//1 3//1\n"); + let mesh = parse_obj(&src, COLOR).expect("mesh"); + assert_normals(&mesh.normals, [0.0, 0.0, 1.0]); + } + /// Only the vertex with a bad index is filled; its neighbours keep theirs. #[test] fn only_the_vertex_without_a_normal_is_filled() {