Skip to content

Commit 9bd954d

Browse files
TMHSDigitalclaude
andcommitted
fix(examples): make ngon-triangulate's falsifier actually falsify
`--skip-triangulate` printed an error and returned 4 from its own branch. The flag announced a failure rather than causing one, and the handling assertions it exists to falsify never ran. It now skips the repair and lets those assertions catch the unrepaired mesh, which reports the real measurement (`ngons=1 tris=0 quads=4`). The contract, the assertions and the exit codes are unchanged. Proven identical before and after on 4.5.11 LTS, 5.1.2 and 5.2.1 LTS: default 0, --no-dissolve 3, --skip-triangulate 4. README: adds the verified `calc_tangents` abort text, which is byte-identical on all three binaries, a falsifier table naming what each flag breaks, and 4.5/5.2 API links for calc_tangents, dissolve_edges and triangulate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com>
1 parent 90779ce commit 9bd954d

2 files changed

Lines changed: 42 additions & 9 deletions

File tree

‎examples/ngon-triangulate/README.md‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,38 @@ glTF tris = 12 for a cube *or* this mesh. `--skip-triangulate` exits 4.
2222
No gallery still. A hexagon on a cube does not read at thumbnail
2323
without fake annotation.
2424

25+
## Verified behaviour
26+
27+
`Mesh.calc_tangents` raises `RuntimeError` on any face with more than
28+
four loops. The message is byte-identical on 4.5.11 LTS, 5.1.2, and
29+
5.2.1 LTS:
30+
31+
```
32+
Error: Tangent space can only be computed for tris/quads, aborting
33+
```
34+
35+
`TANGENT_ABORT` matches on the `tris/quads` substring, so the check
36+
survives a reword of the surrounding sentence but still fails if the
37+
abort stops happening at all.
38+
39+
## Falsifiers
40+
41+
Each flag breaks one stage and lands on the assertion that stage feeds.
42+
Neither announces a failure; both let a real check catch the mesh.
43+
44+
| Flag | What it breaks | Exit |
45+
| --- | --- | --- |
46+
| `--no-dissolve` | never makes the n-gon, so the pre-assertion finds no pathology (`ngon count 0 != 1`) | 3 |
47+
| `--skip-triangulate` | skips `bmesh.ops.triangulate`, so the handling assertion sees the n-gon survive (`ngons=1 tris=0 quads=4`) | 4 |
48+
49+
## API reference
50+
51+
| Name | 4.5 LTS | 5.2 LTS |
52+
| --- | --- | --- |
53+
| `Mesh.calc_tangents` | [4.5](https://docs.blender.org/api/4.5/bpy.types.Mesh.html#bpy.types.Mesh.calc_tangents) | [5.2](https://docs.blender.org/api/current/bpy.types.Mesh.html#bpy.types.Mesh.calc_tangents) |
54+
| `bmesh.ops.dissolve_edges` | [4.5](https://docs.blender.org/api/4.5/bmesh.ops.html#bmesh.ops.dissolve_edges) | [5.2](https://docs.blender.org/api/current/bmesh.ops.html#bmesh.ops.dissolve_edges) |
55+
| `bmesh.ops.triangulate` | [4.5](https://docs.blender.org/api/4.5/bmesh.ops.html#bmesh.ops.triangulate) | [5.2](https://docs.blender.org/api/current/bmesh.ops.html#bmesh.ops.triangulate) |
56+
2557
## Run
2658

2759
```bash
@@ -41,7 +73,7 @@ against it.
4173
| 1 | Uncaught exception (FATAL wrapper) |
4274
| 2 | argparse / usage |
4375
| 3 | Pathology missing: n-gon count, loops, or face count (`--no-dissolve` lands here) |
44-
| 4 | `calc_tangents` / triangulate handling (`--skip-triangulate` lands here) |
76+
| 4 | `calc_tangents` / triangulate handling (`--skip-triangulate` lands here, via the real handling assertion) |
4577

4678
The `blender-smoke` workflow runs the check on Blender 5.2 LTS and 4.5 LTS
4779
(5.1 on the weekly cron, the `needs-5.1` PR label, or manual dispatch).

‎examples/ngon-triangulate/ngon_triangulate.py‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
1010
* 5 faces, 1 n-gon, that face has 6 loops
1111
* ``Mesh.calc_tangents`` aborts until triangulated
12-
(same abort ``triangulate-tangents`` documents)
12+
(same abort ``triangulate-tangents`` documents). The message is
13+
byte-identical on 4.5.11 LTS, 5.1.2 and 5.2.1 LTS:
14+
"Error: Tangent space can only be computed for tris/quads, aborting"
1315
* triangulate the n-gon → 4 tris + 4 quads, 28 loops, tangents succeed
1416
1517
glTF tri count is 12 either way (hexagon+quads or a cube) — not a
@@ -117,13 +119,12 @@ def check(ob, skip_triangulate):
117119
file=sys.stderr,
118120
)
119121
return 4
120-
if skip_triangulate:
121-
print(
122-
"ERROR: skip-triangulate left the n-gon; handling unrepaired",
123-
file=sys.stderr,
124-
)
125-
return 4
126-
triangulate_ngons(me)
122+
# --skip-triangulate skips the repair and lets the handling assertions
123+
# below catch the unrepaired mesh. Returning 4 from here instead would
124+
# make the flag announce a failure rather than cause one, and the
125+
# assertions it is supposed to falsify would never run.
126+
if not skip_triangulate:
127+
triangulate_ngons(me)
127128
leftover = ngons(me)
128129
tris = sum(1 for p in me.polygons if len(p.vertices) == 3)
129130
quads = sum(1 for p in me.polygons if len(p.vertices) == 4)

0 commit comments

Comments
 (0)