fix: address open PR review findings

This commit is contained in:
Hakan Seven committed 2026-09-14 09:45:37 +03:00
1 parent 3fe91fa6e1
commit 2f741d689f
8 files changed
+36 -13

No files matched your search

Generated
+3 -3
View File
@@ -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",
]
+3 -3
View File
@@ -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"] }
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"] }
+1 -1
View File
@@ -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" }
+12 -1
View File
@@ -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°");
}
}
+13 -1
View File
@@ -75,7 +75,12 @@ pub fn parse_obj(src: &str, color: [f32; 4]) -> Option<MeshModel> {
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::<f32>() > 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() {