forge-topology — Topology, Retopo, LOD, Boolean Cleanup & Transform Math
The mesh-quality gate. Every downstream skill (rigging, UV, bake, export, subdivision)
fails silently on broken topology. This skill audits, repairs, and enforces correctness
before the pipeline continues.
Project memory: if FORGE.md exists at the project root, read it first — it
carries the target engine, coordinate system (Y-up/Z-up), handedness, scale unit,
poly budget, and output paths. All decisions in this skill are constrained by FORGE.md.
When no FORGE.md is present, ask forge-brief to create one (Run = call the Skill
tool with name forge-brief).
If ATELIER.md is present, note the aesthetic world/signature — it can inform
edge-flow density and silhouette-preservation targets during retopo/decimation.
Suite map
| Upstream |
This skill |
Downstream |
| forge-model (raw bpy mesh) |
forge-topology (audit → repair → LOD → coords) |
forge-uv (unwrap) |
| forge-parametric (CAD/OpenSCAD output) |
|
forge-texture (bake H→L) |
| forge-procedural (Geo-Nodes output) |
|
forge-rig (armature/skin) |
| forge-intake (scans/AI output) |
|
forge-export (glTF/FBX/USD) |
|
|
forge-validate (final gate) |
forge-standards is the canonical home for coordinate-system tables, handedness,
pivots and poly budgets — read it when you need the full reference (Run = Skill tool
forge-standards).
Web handoff (ordered): forge-export (glTF/GLB) → forge-optimize
(Draco/Meshopt/KTX2) → atelier-webgl (R3F/Three.js scene). forge-export owns
engine-specific export settings; forge-optimize owns gltf-transform + KTX2 compression.
Decide first — pick the tool and verify it is available
Before any execution, identify which tool the task requires and confirm it exists:
| Task |
Primary tool |
Fallback |
| Topology audit + repair on .blend/.glb/.fbx |
Blender 4.5 LTS + bmesh |
trimesh (triangle meshes only) |
| LOD chain from GLB for web |
gltfpack CLI |
gltf-transform CLI (Node.js) |
| Quad remesh / retopo |
Blender QuadriFlow |
Instant Meshes (batch mode) |
| Boolean CSG (programmatic) |
manifold3d (pip) |
Blender EXACT solver |
| Mesh repair without Blender |
trimesh + PyMeshLab |
Open3D |
| Coordinate / transform math |
Blender bpy + mathutils |
numpy + transforms3d (pip) |
Run the preflight check first (invoke forge's scripts/probe.py to confirm tool
availability, or run the PowerShell one-liner below):
# Verify Blender is reachable — adjust path if installed elsewhere
$b = "C:\Program Files\Blender Foundation\Blender 4.5\blender.exe"
& $b --version | Select-Object -First 1
If Blender is missing, fall back to the pure-Python tier (trimesh / manifold3d / Open3D)
for the subset of tasks they can handle. Document the fallback in a comment.
Run = call the Skill tool with the exact name. Writing "next: forge-uv" in prose
runs nothing.
The flow
1. Read FORGE.md — extract: target engine, coordinate system, poly budget, output paths.
If absent, call Skill(forge-brief) before continuing.
2. Preflight — verify tool availability (Blender exe path, gltfpack/gltf-transform on
PATH, manifold3d installed). Fail loudly if the required tool is missing; do not silently
downgrade without logging the fallback.
3. Classify the task — pick exactly one lane from the table below:
| Lane |
Trigger |
Reference |
| A — Audit + repair |
Non-manifold edges, bad normals, ngons, high-valence poles |
references/topo-audit-repair.md |
| B — Retopo + LOD |
Sculpt/scan/CAD needs retopologized mesh or LOD chain |
references/retopo-lod.md |
| C — Boolean cleanup |
Post-boolean debris, coplanar artifacts, union/difference CSG |
references/boolean-csg.md |
| D — Transform / coordinate math |
Axis swap, handedness, TRS apply, quaternion serialization |
references/transform-math.md |
| E — Mesh-processing lib |
trimesh / Open3D / PyMeshLab repair, decimate, validate |
references/mesh-libs.md |
Read the relevant reference file before executing. Each file contains
copy-paste-ready code, parameter tables, and gotcha→fix tables.
4. Execute headlessly — emit a .py script or PowerShell invocation; run it via Bash
or PowerShell. The mandatory Blender invocation pattern:
blender -b scene.blend -P script.py -- --input C:/path/mesh.glb --output C:/path/out.json
The -- separator is non-negotiable. Without it, Blender tries to parse your script
args as blend filenames and fails silently. Use absolute forward-slash paths in all Python
filepath strings inside Blender scripts.
5. Validate — after every repair or LOD generation, run the quality-gate check:
read the JSON audit report and confirm all thresholds pass (>90% quads, 0
non-manifold edges, 0 flipped normals, 0 degenerate faces for subdivision/deform
meshes; see references/topo-audit-repair.md §Quality gates).
6. Render wireframe PNG — use Blender Workbench engine to render a wireframe
overlay, then call Read on the PNG to visually confirm: continuous loops at
joints, even density, no stray edges, poles in flat zones.
7. Hand off — once topology is clean:
- UV work → Skill(
forge-uv)
- Baking → Skill(
forge-texture)
- Rigging → Skill(
forge-rig)
- Export → Skill(
forge-export)
- Web delivery → Skill(
forge-export) → Skill(forge-optimize) → Skill(atelier-webgl)
- Final gate → Skill(
forge-validate)
Operating principles
- Verify before trusting. Run
topo_audit.py before and after every repair or
boolean. Read back the JSON report; do not assume the operation succeeded.
- Always free bmesh. Wrap every
bm = bmesh.new() in try/finally: bm.free().
Leaking bmesh objects causes OOM on batch jobs — this is the #1 headless crash.
- Cascade LOD decimation, never re-decimate from source. Each LOD is generated
from the previous LOD using step ratios. From-source decimation produces visual
discontinuities at LOD transitions.
- Coordinate math is typed. Scale swizzles have no sign flip; location swizzles do.
Quaternion component order differs between Blender (w,x,y,z) and glTF/Unity/Unreal
(x,y,z,w). Confusing them is silent and produces wrong geometry in the target engine.
- Booleans require watertight inputs and produce broken topology. Always validate
manifold status before a boolean and run audit + repair immediately after. Use the
Blender
EXACT solver (not MANIFOLD — bug #140590 in Blender 4.5, coplanar faces).
1---2name: forge-topology3description: Forge suite — topology & edge-flow discipline. Audit, repair, and enforce mesh quality before any downstream work (subdivision, rigging, baking, export, booleans). Produces: JSON topology report, auto-repaired mesh, wireframe QA PNG, LOD chain GLBs, and boolean-cleaned geometry. Use whenever you need to: audit topology, fix non-manifold geometry, check or place poles, enforce quad flow, retopologize a high-poly mesh, generate an LOD chain, decimate for web/game budgets, run QuadriFlow or Voxel remesh, bake high-to-low normals, repair after a boolean operation, validate watertightness, apply a TRS or axis-swap to an existing mesh, serialize a quaternion for export, or bake handedness/ up-axis conversion into the geometry before export. Defining the project-wide coordinate system, handedness, scale unit and pivot rules is **forge-standards**'s job — this skill OPERATES on a mesh, it does not set the standard. Also triggers on: "bad normals", "flipped faces", "ngon cleanup", "LOD0 LOD1 LOD2", "simplify mesh", "r4---56# forge-topology — Topology, Retopo, LOD, Boolean Cleanup & Transform Math78The mesh-quality gate. Every downstream skill (rigging, UV, bake, export, subdivision)9fails silently on broken topology. This skill audits, repairs, and enforces correctness10before the pipeline continues.1112> **Project memory:** if **`FORGE.md`** exists at the project root, read it first — it13> carries the target engine, coordinate system (Y-up/Z-up), handedness, scale unit,14> poly budget, and output paths. All decisions in this skill are constrained by FORGE.md.15> When no FORGE.md is present, ask **forge-brief** to create one (Run = call the Skill16> tool with name `forge-brief`).17> If **ATELIER.md** is present, note the aesthetic world/signature — it can inform18> edge-flow density and silhouette-preservation targets during retopo/decimation.1920---2122> **Suite map**23>24> | Upstream | This skill | Downstream |25> |---|---|---|26> | **forge-model** (raw bpy mesh) | **forge-topology** (audit → repair → LOD → coords) | **forge-uv** (unwrap) |27> | **forge-parametric** (CAD/OpenSCAD output) | | **forge-texture** (bake H→L) |28> | **forge-procedural** (Geo-Nodes output) | | **forge-rig** (armature/skin) |29> | **forge-intake** (scans/AI output) | | **forge-export** (glTF/FBX/USD) |30> | | | **forge-validate** (final gate) |31>32> **forge-standards** is the canonical home for coordinate-system tables, handedness,33> pivots and poly budgets — read it when you need the full reference (Run = Skill tool34> `forge-standards`).35> **Web handoff (ordered):** **forge-export** (glTF/GLB) → **forge-optimize**36> (Draco/Meshopt/KTX2) → **atelier-webgl** (R3F/Three.js scene). forge-export owns37> engine-specific export settings; forge-optimize owns gltf-transform + KTX2 compression.3839---4041## Decide first — pick the tool and verify it is available4243Before any execution, identify which tool the task requires and confirm it exists:4445| Task | Primary tool | Fallback |46|---|---|---|47| Topology audit + repair on .blend/.glb/.fbx | Blender 4.5 LTS + bmesh | trimesh (triangle meshes only) |48| LOD chain from GLB for web | gltfpack CLI | gltf-transform CLI (Node.js) |49| Quad remesh / retopo | Blender QuadriFlow | Instant Meshes (batch mode) |50| Boolean CSG (programmatic) | manifold3d (pip) | Blender EXACT solver |51| Mesh repair without Blender | trimesh + PyMeshLab | Open3D |52| Coordinate / transform math | Blender bpy + mathutils | numpy + transforms3d (pip) |5354**Run the preflight check first** (invoke `forge`'s `scripts/probe.py` to confirm tool55availability, or run the PowerShell one-liner below):5657```powershell58# Verify Blender is reachable — adjust path if installed elsewhere59$b = "C:\Program Files\Blender Foundation\Blender 4.5\blender.exe"60& $b --version | Select-Object -First 161```6263If Blender is missing, fall back to the pure-Python tier (trimesh / manifold3d / Open3D)64for the subset of tasks they can handle. Document the fallback in a comment.6566**Run = call the Skill tool with the exact name. Writing "next: forge-uv" in prose67runs nothing.**6869---7071## The flow7273**1. Read FORGE.md** — extract: target engine, coordinate system, poly budget, output paths.74 If absent, call Skill(`forge-brief`) before continuing.7576**2. Preflight** — verify tool availability (Blender exe path, gltfpack/gltf-transform on77 PATH, manifold3d installed). Fail loudly if the required tool is missing; do not silently78 downgrade without logging the fallback.7980**3. Classify the task** — pick exactly one lane from the table below:8182 | Lane | Trigger | Reference |83 |---|---|---|84 | A — Audit + repair | Non-manifold edges, bad normals, ngons, high-valence poles | `references/topo-audit-repair.md` |85 | B — Retopo + LOD | Sculpt/scan/CAD needs retopologized mesh or LOD chain | `references/retopo-lod.md` |86 | C — Boolean cleanup | Post-boolean debris, coplanar artifacts, union/difference CSG | `references/boolean-csg.md` |87 | D — Transform / coordinate math | Axis swap, handedness, TRS apply, quaternion serialization | `references/transform-math.md` |88 | E — Mesh-processing lib | trimesh / Open3D / PyMeshLab repair, decimate, validate | `references/mesh-libs.md` |8990 **Read the relevant reference file** before executing. Each file contains91 copy-paste-ready code, parameter tables, and gotcha→fix tables.9293**4. Execute headlessly** — emit a `.py` script or PowerShell invocation; run it via Bash94 or PowerShell. The mandatory Blender invocation pattern:9596 ```97 blender -b scene.blend -P script.py -- --input C:/path/mesh.glb --output C:/path/out.json98 ```99100 The `--` separator is **non-negotiable**. Without it, Blender tries to parse your script101 args as blend filenames and fails silently. Use absolute forward-slash paths in all Python102 filepath strings inside Blender scripts.103104**5. Validate** — after every repair or LOD generation, run the quality-gate check:105 read the JSON audit report and confirm all thresholds pass (>90% quads, 0106 non-manifold edges, 0 flipped normals, 0 degenerate faces for subdivision/deform107 meshes; see `references/topo-audit-repair.md §Quality gates`).108109**6. Render wireframe PNG** — use Blender Workbench engine to render a wireframe110 overlay, then call `Read` on the PNG to visually confirm: continuous loops at111 joints, even density, no stray edges, poles in flat zones.112113**7. Hand off** — once topology is clean:114 - UV work → Skill(`forge-uv`)115 - Baking → Skill(`forge-texture`)116 - Rigging → Skill(`forge-rig`)117 - Export → Skill(`forge-export`)118 - Web delivery → Skill(`forge-export`) → Skill(`forge-optimize`) → Skill(`atelier-webgl`)119 - Final gate → Skill(`forge-validate`)120121---122123## Operating principles124125- **Verify before trusting.** Run `topo_audit.py` before and after every repair or126 boolean. Read back the JSON report; do not assume the operation succeeded.127- **Always free bmesh.** Wrap every `bm = bmesh.new()` in `try/finally: bm.free()`.128 Leaking bmesh objects causes OOM on batch jobs — this is the #1 headless crash.129- **Cascade LOD decimation, never re-decimate from source.** Each LOD is generated130 from the previous LOD using step ratios. From-source decimation produces visual131 discontinuities at LOD transitions.132- **Coordinate math is typed.** Scale swizzles have no sign flip; location swizzles do.133 Quaternion component order differs between Blender (w,x,y,z) and glTF/Unity/Unreal134 (x,y,z,w). Confusing them is silent and produces wrong geometry in the target engine.135- **Booleans require watertight inputs and produce broken topology.** Always validate136 manifold status before a boolean and run audit + repair immediately after. Use the137 Blender `EXACT` solver (not `MANIFOLD` — bug #140590 in Blender 4.5, coplanar faces).