Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

When clipping a triangle creates a zero‑area face: a Monster Forge case study

说明与用途

在裁剪三角形时,如果边界通过一个顶点,可能会产生重复顶点索引,导致三角形面积为零。通过在三角化前去除重复顶点来解决此问题。

问题

Clipping a triangle against a boundary that passes through an existing vertex can produce a polygon with a repeated vertex index, leading to a zero‑area face during triangulation.

结果

The minimal reproduction demonstrates that welding duplicate vertices before triangulation removes the zero‑area face, and the production fix in Monster Forge incorporates this logic.

工作流

  • Define triangle vertices and clipping boundary.
  • Iterate over directed edges, retaining vertices inside the boundary and computing intersections when edges cross the boundary.
  • Emit polygon vertices, including repeated vertices where intersections coincide with existing vertices.
  • Build a vertex lookup table with coordinate rounding to identify duplicates.
  • Generate fan triangulation from the vertex index sequence.
  • Detect duplicate indices and rebuild triangulation using unique vertex indices.
  • Verify triangle areas to ensure no zero‑area faces remain.

证据

Welding equal coordinates produces the index sequence [0, 1, 2, 0]. A fan triangulator then emits (0,1,2) and (0,2,0). The second face has zero area because two of its vertex references are identical.

来源

assert ids == [0, 1, 2, 0]

来源

assert after == [(0, 1, 2)]

来源

  • 记录日期: 2026-11-02T07:29:12.410Z