Skip to content

Fix #200: Exclude shared edges between coplanar triangles from outlines#246

Merged
bertt merged 5 commits intofix/issue-200-improve-outlinesfrom
copilot/sub-pr-245
Feb 2, 2026
Merged

Fix #200: Exclude shared edges between coplanar triangles from outlines#246
bertt merged 5 commits intofix/issue-200-improve-outlinesfrom
copilot/sub-pr-245

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

The outline detection algorithm was drawing unwanted lines between coplanar triangles that don't appear sequentially in the geometry, creating diagonal artifacts on flat surfaces.

Changes

Coplanarity Detection

  • Added Triangle.AreCoplanar() to detect coplanar triangles via normal comparison
  • Handles both same-direction (dot ≈ 1) and opposite-direction (dot ≈ -1) normals to account for reversed winding orders

Adjacency Calculation

  • Modified Adjacency.GetAdjacencyList() to include only shared edges between coplanar triangles
  • These edges are excluded from outlines (internal to flat surfaces), while non-coplanar edges remain (creases/folds)

Cross-Partition Handling

  • Updated OutlineDetection.GetOutlines2() to compute global adjacency before partitioning
  • Partitioning separates triangles by normal direction, so coplanar triangles with opposite normals end up in different parts
  • Maps global adjacency indices to local per-part indices
  • Modified Part.GetOutlines() to accept pre-calculated adjacency and handle single-triangle parts

Example

Given this geometry where triangles 1 and 3 are coplanar (z=5) but triangle 2 is angled:

// Triangle 1: horizontal at z=5
var t0 = new Triangle(
    new Point(121346, 487295, 5),
    new Point(121446, 487295, 5),
    new Point(121396, 487381.603, 5), 0);

// Triangle 2: angled (non-coplanar)
var t1 = new Triangle(
    new Point(121446, 487295, 5),
    new Point(121396, 487381.603, 5),
    new Point(121346, 487295, 100), 0);

// Triangle 3: horizontal at z=5 (coplanar with t0)
var t2 = new Triangle(
    new Point(121346, 487295, 5),
    new Point(121446, 487295, 5),
    new Point(121396, 487208.397, 5), 0);

The shared edge between t0 and t2 is now correctly excluded from the outline, while the shared edge between t0 and t1 is included.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 2, 2026 16:05
… changes

Co-authored-by: bertt <538812+bertt@users.noreply.github.com>
Co-authored-by: bertt <538812+bertt@users.noreply.github.com>
Co-authored-by: bertt <538812+bertt@users.noreply.github.com>
Co-authored-by: bertt <538812+bertt@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix outlines for coplanar polygons to prevent diagonal lines Fix #200: Exclude shared edges between coplanar triangles from outlines Feb 2, 2026
Copilot AI requested a review from bertt February 2, 2026 16:24
@bertt bertt marked this pull request as ready for review February 2, 2026 17:10
@bertt bertt merged commit 34b2d5a into fix/issue-200-improve-outlines Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants