forked from 1b-agent/opencadstudio-upstream
fix: address open PR review findings
This commit is contained in:
1 parent
3fe91fa6e1
commit
2f741d689f
8 files changed
+36
-13
No files matched your search
Generated
+3
-3
@@ -81,7 +81,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "acadrust"
|
name = "acadrust"
|
||||||
version = "0.5.5"
|
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 = [
|
dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -896,7 +896,7 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "cadkernel"
|
name = "cadkernel"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"acadrust",
|
"acadrust",
|
||||||
"cavalier_contours",
|
"cavalier_contours",
|
||||||
@@ -907,7 +907,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "cadkernel-constraints"
|
name = "cadkernel-constraints"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"nalgebra",
|
"nalgebra",
|
||||||
]
|
]
|
||||||
|
|||||||
+3
-3
@@ -31,9 +31,9 @@ glam = { version = "0.33", features = ["bytemuck"] }
|
|||||||
rfd = "0.17"
|
rfd = "0.17"
|
||||||
clap = { version = "4", features = ["derive", "string"] }
|
clap = { version = "4", features = ["derive", "string"] }
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "5eea24cf35ba1739c22e982fc398ddb6c285def5", features = ["serde"] }
|
acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "de72d5c9d4a78d5dff7138bbc9a9b8fcdf7430ad", features = ["serde"] }
|
||||||
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "5f0cdffc0faa9db03346aa794e22285c365b5f7f", features = ["acis", "offset"] }
|
cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "773070e4e5dcfcceddf9750a876bf67353642922", features = ["acis", "offset"] }
|
||||||
cadkernel-constraints = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "5f0cdffc0faa9db03346aa794e22285c365b5f7f" }
|
cadkernel-constraints = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "773070e4e5dcfcceddf9750a876bf67353642922" }
|
||||||
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
dwg-thumbnailer = { path = "crates/dwg-thumbnailer" }
|
||||||
flate2 = "1"
|
flate2 = "1"
|
||||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] }
|
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ serde = { version = "1", features = ["derive"] }
|
|||||||
# Pulled in only by the `host` feature, which adds the `acadrust`-typed
|
# Pulled in only by the `host` feature, which adds the `acadrust`-typed
|
||||||
# `HostApi` runtime surface. The default crate stays dependency-free so engine
|
# `HostApi` runtime surface. The default crate stays dependency-free so engine
|
||||||
# crates and external tooling can depend on the manifest/ribbon contract cheaply.
|
# 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).
|
# Runtime IPC and serialization (host feature only).
|
||||||
interprocess = { version = "2", optional = true }
|
interprocess = { version = "2", optional = true }
|
||||||
@@ -38,7 +38,7 @@ serde_json = "1"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
cargo-lock = "11"
|
cargo-lock = "11"
|
||||||
# acadrust is scanned at build time to generate the embedded type registry.
|
# 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]
|
[dev-dependencies]
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
@@ -8,7 +8,7 @@ publish = false
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[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"
|
bincode = "1.3"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ocs_plugin_api = { path = "../ocs_plugin_api", features = ["host"] }
|
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"] }
|
||||||
@@ -12,4 +12,4 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ocs_plugin_api = { path = "../../crates/ocs_plugin_api", features = ["host"] }
|
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
@@ -110,7 +110,12 @@ pub fn format_length(value: f64) -> String {
|
|||||||
/// rotation leaves coordinates like -1e-15 behind, which read as `-0.0000`.
|
/// rotation leaves coordinates like -1e-15 behind, which read as `-0.0000`.
|
||||||
fn without_negative_zero(text: String) -> String {
|
fn without_negative_zero(text: String) -> String {
|
||||||
match text.strip_prefix('-') {
|
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,
|
_ => text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1276,4 +1281,10 @@ mod negative_zero_format_tests {
|
|||||||
assert_eq!(angle(0, 0, -45f64.to_radians()), "-45°");
|
assert_eq!(angle(0, 0, -45f64.to_radians()), "-45°");
|
||||||
assert_eq!(angle(1, 1, -0.0001f64.to_radians()), "-0d0'0.4\"");
|
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
@@ -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() {
|
for (vi, (pos_i, norm_i)) in face_verts.iter().enumerate() {
|
||||||
let pos = *positions.get(*pos_i).unwrap_or(&[0.0; 3]);
|
let pos = *positions.get(*pos_i).unwrap_or(&[0.0; 3]);
|
||||||
verts.push(pos);
|
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());
|
has_normal.push(norm.is_some());
|
||||||
norms.push(norm.unwrap_or([0.0, 0.0, 0.0]));
|
norms.push(norm.unwrap_or([0.0, 0.0, 0.0]));
|
||||||
indices.push(vi as u32);
|
indices.push(vi as u32);
|
||||||
@@ -153,6 +158,13 @@ mod tests {
|
|||||||
assert_normals(&mesh.normals, [0.0, 0.0, 1.0]);
|
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.
|
/// Only the vertex with a bad index is filled; its neighbours keep theirs.
|
||||||
#[test]
|
#[test]
|
||||||
fn only_the_vertex_without_a_normal_is_filled() {
|
fn only_the_vertex_without_a_normal_is_filled() {
|
||||||
|
|||||||
Reference in new issue
Block a user