Mesh export: twisted ruled faces are divided to the chord tolerance (#1666) (#1670)

Thanks @DuBearte.
This commit is contained in:
DuBearte authored and GitHub committed 2026-10-16 08:26:32 -04:00
1 parent 737c9358d0
commit 4a4911b473
3 files changed
+50 -1

No files matched your search

+5
View File
@@ -155,6 +155,11 @@ Changes:
compares the two.
- `lib.rs`: compiler warnings no longer fail the build. Example, test and bench targets are
dropped (their sources are not vendored).
- `tessellation/triangulation.rs`: adaptive division also splits a cell that bows off its
corners' plane by more than the chord tolerance (a quarter of its twist `p00 - p01 - p10 +
p11`, across that plane, at the middle). A bilinear patch equals the blend of its corners the
division compared against, so a twisted ruled face (a loft between polylines) went out as two
triangles per face (#1666); a flat cell such as a cone's trapezoid between rulings is not split.
## matext4cgmath 0.1.0 (Apache-2.0, © RICOS Co. Ltd., https://github.com/ricosjp/matext4cgmath)
+8 -1
View File
@@ -971,7 +971,14 @@ fn bounded_surface_division<S: PreMeshableSurface>(surface: &S, (ur, vr): ((f64,
let pt10 = surface.subs(u[1], v[0]).to_vec();
let pt11 = surface.subs(u[1], v[1]).to_vec();
let pt = Point3::from_vec(pt00 * (1.0 - p) * (1.0 - q) + pt01 * (1.0 - p) * q + pt10 * p * (1.0 - q) + pt11 * p * q);
let far = p0.distance2(pt) > tol * tol;
// SolidCraft (#1666): a cell is drawn as two triangles, not as the bilinear blend
// of its corners. A twisted cell (a bilinear patch is the blend exactly, so `pt`
// never tells) bows off its corners' plane by a quarter of its twist at the middle,
// across that plane: a cone's trapezoid between two rulings is flat and needs none.
let normal = (pt10 - pt00).cross(pt01 - pt00);
let bow = (pt00 - pt01 - pt10 + pt11).dot(normal) * 0.25;
let twisted = normal.magnitude2() > 0.0 && bow * bow > tol * tol * normal.magnitude2();
let far = p0.distance2(pt) > tol * tol || twisted;
// Which direction bends: refine only that one (a cylinder needs no division
// along its rulings).
let (su, sv) = ([surface.subs(u[0], v0), surface.subs(u[1], v0)], [surface.subs(u0, v[0]), surface.subs(u0, v[1])]);