A 1.2 MB pure-Rust rewrite of headless Blender built for AI agents — 3D B-rep modeling engine, CLI, and MCP server
text3d names unsupported characters; revolve rejects negative or non-finite radii (issue #26)
finalpantasy8497749df0d0
diff --git a/crates/forma-core/src/primitives.rs b/crates/forma-core/src/primitives.rsindex c29bbd1..744e4b4 100644--- a/crates/forma-core/src/primitives.rs+++ b/crates/forma-core/src/primitives.rs@@ -201,6 +201,14 @@ pub fn make_revolve(profile: &[(f64, f64)], segs: usize, op_id: u32) -> Result<Pif profile.len() < 2 {return Err("revolve profile requires at least 2 (r, z) points".into());}+ if let Some((i, &(r, z))) = profile.iter().enumerate().find(|(_, p)| !p.0.is_finite() || !p.1.is_finite()) {+ return Err(format!("revolve: profile point {i} ({r}, {z}) is not finite"));+ }+ if let Some((i, &(r, z))) = profile.iter().enumerate().find(|(_, p)| p.0 < 0.0) {+ return Err(format!(+ "revolve: profile point {i} ({r}, {z}) has a negative radius; radii must be >= 0 (the profile is (r, z) on one side of the axis)"+ ));+ }let segs = segs.clamp(6, 128);// Clean consecutive duplicates and build explicit list starting/ending at r=0 if neededlet mut pts: Vec<(f64, f64)> = Vec::new();@@ -795,7 +803,7 @@ pub fn make_text_3d(text: &str, height: f64, depth: f64, op_id: u32) -> Result<Pif text.chars().count() > 64 {return Err("text3d exceeds maximum of 64 characters".into());}- if height <= 1e-5 || depth <= 1e-5 {+ if !height.is_finite() || !depth.is_finite() || height <= 1e-5 || depth <= 1e-5 {return Err("text3d height and depth must be positive".into());}let glyph = |ch: char| -> [u8; 7] {@@ -845,6 +853,24 @@ pub fn make_text_3d(text: &str, height: f64, depth: f64, op_id: u32) -> Result<P};let chars: Vec<char> = text.chars().collect();+ // A character outside the built-in 5x7 font would render as a blank cell: refuse it by name+ // instead of silently dropping part of the text.+ let mut unsupported: Vec<char> = Vec::new();+ for &ch in &chars {+ if ch != ' ' && glyph(ch) == [0; 7] && !unsupported.contains(&ch) {+ unsupported.push(ch);+ }+ }+ if !unsupported.is_empty() {+ let list: Vec<String> = unsupported+ .iter()+ .map(|c| if c.is_control() { format!("'{}'", c.escape_default()) } else { format!("'{c}'") })+ .collect();+ return Err(format!(+ "text3d: unsupported character(s) {} (the built-in font has A-Z, 0-9, space and - . _ : only)",+ list.join(" ")+ ));+ }let cell = height / 7.0;let pitch_x = cell * 6.0;let total_w = (chars.len() as f64) * pitch_x - cell;diff --git a/crates/forma-core/tests/issue_regressions.rs b/crates/forma-core/tests/issue_regressions.rsindex 5b28fa2..d215460 100644--- a/crates/forma-core/tests/issue_regressions.rs+++ b/crates/forma-core/tests/issue_regressions.rs@@ -362,3 +362,31 @@ fn issue25_inset_that_cannot_fit_or_is_not_positive_is_an_error() {}assert!(forma_core::ops::inset_faces(&b, &FaceSelector::Top, 0.1, f64::NAN, 2).is_err());}++// ---------------------------------------------------------------------------------------------+// Issue #26: text3d blanked unsupported glyphs; revolve accepted negative radii.+// ---------------------------------------------------------------------------------------------++#[test]+fn issue26_text3d_names_unsupported_characters() {+ use forma_core::primitives::make_text_3d;+ assert!(make_text_3d("Acao 12-3.4_5:6", 0.5, 0.1, 1).is_ok());+ let err = make_text_3d("A\u{e7}\u{e3}o \u{f1} \u{20ac}", 0.5, 0.1, 1).unwrap_err();+ assert!(err.starts_with("text3d: unsupported character"), "{err}");+ for c in ["\u{e7}", "\u{e3}", "\u{f1}", "\u{20ac}"] {+ assert!(err.contains(c), "error must list {c}: {err}");+ }+ assert!(make_text_3d("A!B", 0.5, 0.1, 1).unwrap_err().contains("'!'"));+ assert!(make_text_3d("AB", f64::NAN, 0.1, 1).is_err());+ assert!(make_text_3d("AB", 0.5, f64::INFINITY, 1).is_err());+}++#[test]+fn issue26_revolve_rejects_negative_and_non_finite_radii() {+ use forma_core::primitives::make_revolve;+ let err = make_revolve(&[(0.0, 0.0), (1.0, 0.0), (-0.5, 1.0), (0.0, 1.0)], 32, 1).unwrap_err();+ assert!(err.starts_with("revolve:") && err.contains("negative radius") && err.contains("point 2"), "{err}");+ assert!(make_revolve(&[(0.0, 0.0), (f64::NAN, 0.0), (0.5, 1.0)], 32, 1).is_err());+ assert!(make_revolve(&[(0.0, 0.0), (1.0, f64::INFINITY), (0.5, 1.0)], 32, 1).is_err());+ assert!(make_revolve(&[(0.0, 0.0), (1.0, 0.0), (0.5, 1.0), (0.0, 1.0)], 32, 1).is_ok());+}