Disclosure: this article was prepared by an AI agent on behalf of Mr Q, the maintainer of Monster Forge. The numerical example below was executed successfully; the production fix and regression assertions were checked in the project source.

A clipping boundary that passes exactly through an existing vertex is a useful geometry test. An endpoint can be emitted both as a retained vertex and as an edge intersection. Welding those points to the same vertex index does not, by itself, remove the repeated index from the polygon that is about to be triangulated.

Monster Forge, an open-source modular low-poly character constructor, handles this case when constructing a fitted scalp shell. Here is the mechanism in a smaller two-dimensional example, followed by the production boundary and checks.

Monster Forge browser character constructor

Retaining a vertex and finding it again

Take the triangle A=(0,0), B=(1,1), C=(2,-1), and retain the side y >= 0. Walk its directed edges. A is retained on A→B. B is retained on B→C, and that edge crosses the boundary at D=(1.5,0). C→A also crosses from outside to inside, with its intersection exactly at A.

The emitted polygon is therefore [A, B, D, A]. 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.

This is why having a unique vertex table is a different property from having a valid polygon boundary.

A runnable minimal reproduction

The example uses only Python's standard library. Its round-to-ten-decimals key mirrors the coordinate-welding convention used by the project helper. The final assertions check both the repeated-index mechanism and the triangle areas.

triangle = [(0.0, 0.0), (1.0, 1.0), (2.0, -1.0)] polygon = [] for a, b in zip(triangle, triangle[1:] + triangle[:1]): ha, hb = a[1], b[1] if ha >= 0: polygon.append(a) if (ha >= 0) != (hb >= 0): t = ha / (ha - hb) polygon.append(tuple(x + (y - x) * t for x, y in zip(a, b))) vertices, lookup = [], {} def index(p): key = tuple(round(x, 10) for x in p) if key not in lookup: lookup[key] = len(vertices) vertices.append(p) return lookup[key] def fan(ids): return [(ids[0], ids[i], ids[i + 1]) for i in range(1, len(ids) - 1)] def area(face): a, b, c = [vertices[i] for i in face] return abs((b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])) / 2 ids = [index(p) for p in polygon] unique_ids = list(dict.fromkeys(ids)) before, after = fan(ids), fan(unique_ids) assert ids == [0, 1, 2, 0] assert before == [(0, 1, 2), (0, 2, 0)] assert after == [(0, 1, 2)] assert [area(f) for f in before] == [0.75, 0.0] assert [area(f) for f in after] == [0.75] print('before:', before, 'areas:', [area(f) for f in before]) print('after: ', after, 'areas:', [area(f) for f in after]) 

The output is:

before: [(0, 1, 2), (0, 2, 0)] areas: [0.75, 0.0] after: [(0, 1, 2)] areas: [0.75] 

Apply the fix before the fan

In scalp_shell, the production helper clips each skull triangle against the hairline classification, welds the resulting coordinates and then triangulates the clipped polygon. It now removes duplicate welded IDs while retaining their order:

ids = list(dict.fromkeys(index(p) for p in polygon)) for i in range(1, len(ids) - 1): faces.append([ids[0], ids[i], ids[i + 1]]) 

If clipping leaves only one or two unique IDs, this loop emits no face. In the boundary-through-A example, the duplicate closing endpoint disappears before it can create the second triangle.

The important scope is the small ordered polygon produced from one clipped triangle. This is not a general triangulator for arbitrary concave or self-intersecting polygons. It also does not prove that three distinct welded IDs are geometrically non-collinear. Area still needs its own check.

The shell builder subsequently creates outer and inner surfaces and closes the boundary. A degenerate face or self-edge introduced before that step can contaminate later topology work. Removing the repeated boundary ID at the clipping boundary keeps the fix close to the operation that produced it.

Test more than the picture

The regression case includes a female orc whose hairline passes through skull vertices. Its checks require finite coordinates, three distinct IDs per triangle, nonzero face area, two incident faces for each undirected edge, opposite edge directions, positive signed volume, and appropriate inward/outward shell orientation.

The regression also checks the shell's radial clearance from the skull and an unchanged human control mesh. These are separate assertions with separate purposes: a closed mesh can still have an invalid face, and a nonzero-area mesh can still have inconsistent winding.

For this case, the topology and area assertions explain the fix more directly than a render would. They do not establish artistic quality or validate every possible character combination.

Source and context

The implementation is in constructor_surface_fit.py. The regression assertions are in test_constructor_hair_fit.py.

Monster Forge includes 33 race and creature templates and 193 presets, with a local browser interface and Python build service. Rigged templates export skeleton and weights; existing unrigged authoring templates export static geometry. Code and the declared built-in source resources are Apache-2.0. Some stored positioning references were AI-generated; the running constructor builds from geometry recipes.

Project and launch instructions: https://github.com/QoobIY/monster-forge

Author: Mr Q. Public contact: https://github.com/QoobIY