feat(tess): use angular sampling

Route curve, hatch, sweep, loft, surface, edge, and isoline tessellation through the shared kernel policy.
This commit is contained in:
Hakan Seven committed 2026-08-10 12:12:16 +03:00
1 parent f607422c9d
commit 96be8214f9
21 files changed
+158 -767

No files matched your search

+7 -6
View File
@@ -17,16 +17,17 @@ use acadrust::kernel::brep::{self, Body};
use crate::scene::model::mesh_model::{MeshLodSet, MeshModel};
/// How far a triangle may sit from the surface it lies on. A drawing is
/// measured in millimetres, and a twentieth of one is past what a screen
/// resolves at any sane zoom.
const SAG: f64 = 0.05;
/// What counts as the same point when the kernel checks a body over.
const TOL: f64 = 1e-9;
fn tessellation(body: &Body) -> brep::mesh::BodyMesh {
brep::mesh::tessellate(body, brep::mesh::TessellationTolerance::new(SAG, TOL))
brep::mesh::tessellate(
body,
brep::mesh::TessellationTolerance::new(
acadrust::kernel::tessellation::DEFAULT_ANGLE,
TOL,
),
)
}
/// Axis-aligned box from its center and full extents.
+7 -7
View File
@@ -112,26 +112,26 @@ use crate::scene::model::mesh_model::{MeshLodSet, MeshModel};
/// SWEEP through the kernel's tolerance-driven mesh API.
pub fn swept(profile: &EntityType, path: &EntityType, color: [f32; 4]) -> Option<MeshLodSet> {
let tolerance = crate::scene::convert::curve_tol::current_curve_tol();
let max_angle = acadrust::kernel::tessellation::DEFAULT_ANGLE;
let surface = brep::mesh::sweep_surface(
&entity_curve(profile)?,
&entity_curve(path)?,
tolerance,
max_angle,
)?;
mesh_set(surface, color, tolerance)
mesh_set(surface, color, 1e-9)
}
/// LOFT through the kernel's tolerance-driven mesh API.
pub fn lofted(profiles: &[EntityType], color: [f32; 4]) -> Option<MeshLodSet> {
let curves: Vec<PlanarCurve> = profiles.iter().filter_map(entity_curve).collect();
let tolerance = crate::scene::convert::curve_tol::current_curve_tol();
mesh_set(brep::mesh::loft_surface(&curves, tolerance)?, color, tolerance)
let max_angle = acadrust::kernel::tessellation::DEFAULT_ANGLE;
mesh_set(brep::mesh::loft_surface(&curves, max_angle)?, color, 1e-9)
}
fn mesh_set(
surface: brep::mesh::SurfaceMesh,
color: [f32; 4],
tolerance: f64,
precision: f64,
) -> Option<MeshLodSet> {
if surface.mesh.is_empty() {
return None;
@@ -141,7 +141,7 @@ fn mesh_set(
for point in &surface.mesh.positions {
push_point(&mut verts, &mut verts_low, *point);
}
let silhouette = surface.silhouette_source(tolerance);
let silhouette = surface.silhouette_source(precision);
let mut set = MeshLodSet::from_single(MeshModel {
name: String::new(),
verts,