From 10295d0e92c07071953874d16d64f31f57fe996c Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Sun, 12 Mar 2023 16:15:17 -0700 Subject: [PATCH] fixing tesselation --- modules/geom/impl/curve/curve-tess.js | 8 ++++++-- web/app/cad/sketch/sketchModel.ts | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/geom/impl/curve/curve-tess.js b/modules/geom/impl/curve/curve-tess.js index 67bd5370..a573f48f 100644 --- a/modules/geom/impl/curve/curve-tess.js +++ b/modules/geom/impl/curve/curve-tess.js @@ -19,8 +19,12 @@ export function curveTessParams(curve, min, max, tessTol, scale) { splits.push(max); function refine(u1, u2, step) { - if (step < u2 - u1) { - const mid = u1 + (u2 - u1) * 0.5; + const uDist = u2 - u1; + if (uDist < 1e-3) { + return + } + if (step < uDist) { + const mid = u1 + uDist * 0.5; refine(u1, mid, step); out.push(mid); refine(mid, u2, curveStep(curve, mid, tessTol, scale)); diff --git a/web/app/cad/sketch/sketchModel.ts b/web/app/cad/sketch/sketchModel.ts index 0d6839ed..5488da47 100644 --- a/web/app/cad/sketch/sketchModel.ts +++ b/web/app/cad/sketch/sketchModel.ts @@ -457,10 +457,10 @@ export class Contour { return cc; } - tessellate(resolution) { + tessellate() { const tessellation = []; for (const segment of this.segments) { - const segmentTessellation = segment.tessellate(resolution); + const segmentTessellation = segment.tessellate(segment.massiveness() * 0.1); //skip last one because it's guaranteed to be closed for (let i = 0; i < segmentTessellation.length - 1; ++i) { tessellation.push(segmentTessellation[i]); @@ -470,7 +470,7 @@ export class Contour { } isCCW() { - return isCCW(this.tessellate(10)); + return isCCW(this.tessellate()); } reverse() {