@babylonjs-toolkit/agent 1.2.16 → 1.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +3 -2
  2. package/package.json +1 -1
  3. package/skills/bt-blender/SKILL.md +448 -0
  4. package/skills/bt-blender/THIRD_PARTY_NOTICES.md +141 -0
  5. package/skills/bt-blender/references/art-style-and-genre.md +173 -0
  6. package/skills/bt-blender/references/characters-and-creatures.md +644 -0
  7. package/skills/bt-blender/references/environments.md +478 -0
  8. package/skills/bt-blender/references/game-engine-export.md +284 -0
  9. package/skills/bt-blender/references/geometry-nodes.md +447 -0
  10. package/skills/bt-blender/references/hard-surface.md +724 -0
  11. package/skills/bt-blender/references/procedural-generation.md +358 -0
  12. package/skills/bt-blender/references/rigging-and-animation.md +1080 -0
  13. package/skills/bt-blender/references/sculpting-and-retopology.md +544 -0
  14. package/skills/bt-blender/references/uv-and-pbr-materials.md +381 -0
  15. package/skills/bt-blender/references/vehicles.md +637 -0
  16. package/skills/bt-blender/scripts/blender/__pycache__/construction_kit.cpython-313.pyc +0 -0
  17. package/skills/bt-blender/scripts/blender/__pycache__/geometry_nodes_builders.cpython-313.pyc +0 -0
  18. package/skills/bt-blender/scripts/blender/__pycache__/image_measure.cpython-313.pyc +0 -0
  19. package/skills/bt-blender/scripts/blender/__pycache__/reference_traces.cpython-313.pyc +0 -0
  20. package/skills/bt-blender/scripts/blender/assembly_check.py +420 -0
  21. package/skills/bt-blender/scripts/blender/blueprint.py +293 -0
  22. package/skills/bt-blender/scripts/blender/character_blockout.py +462 -0
  23. package/skills/bt-blender/scripts/blender/construction_kit.py +1770 -0
  24. package/skills/bt-blender/scripts/blender/coverage_check.py +221 -0
  25. package/skills/bt-blender/scripts/blender/environment_kit.py +525 -0
  26. package/skills/bt-blender/scripts/blender/evidence_sheet.py +243 -0
  27. package/skills/bt-blender/scripts/blender/export_asset.py +623 -0
  28. package/skills/bt-blender/scripts/blender/geometry_nodes_builders.py +575 -0
  29. package/skills/bt-blender/scripts/blender/hard_surface_panels.py +374 -0
  30. package/skills/bt-blender/scripts/blender/hard_surface_trims.py +200 -0
  31. package/skills/bt-blender/scripts/blender/image_measure.py +917 -0
  32. package/skills/bt-blender/scripts/blender/materials_pbr.py +439 -0
  33. package/skills/bt-blender/scripts/blender/measure_stations.py +496 -0
  34. package/skills/bt-blender/scripts/blender/ortho_views.py +309 -0
  35. package/skills/bt-blender/scripts/blender/overlay_sheet.py +238 -0
  36. package/skills/bt-blender/scripts/blender/procedural_game_ready.py +258 -0
  37. package/skills/bt-blender/scripts/blender/procedural_generators.py +842 -0
  38. package/skills/bt-blender/scripts/blender/qa_check.py +729 -0
  39. package/skills/bt-blender/scripts/blender/reference_traces.py +344 -0
  40. package/skills/bt-blender/scripts/blender/retopology_tools.py +781 -0
  41. package/skills/bt-blender/scripts/blender/review_render.py +358 -0
  42. package/skills/bt-blender/scripts/blender/rigging_tools.py +1170 -0
  43. package/skills/bt-blender/scripts/blender/style_palette.py +190 -0
  44. package/skills/bt-blender/scripts/blender/tool_common.py +289 -0
  45. package/skills/bt-blender/scripts/blender/trace.py +283 -0
  46. package/skills/bt-blender/scripts/blender/uv_layout.py +555 -0
  47. package/skills/bt-blender/scripts/blender/vehicle_parts.py +370 -0
  48. package/skills/bt-blender/scripts/blender/view_consistency.py +133 -0
  49. package/skills/bt-blender/scripts/blender/world_gate.py +231 -0
  50. package/skills/bt-blender/scripts/bt-blender.mjs +333 -0
  51. package/skills/bt-blender/scripts/validate_gltf.mjs +204 -0
  52. package/skills/bt-execute/SKILL.md +2 -1
  53. package/skills/bt-gauntlet/SKILL.md +30 -20
  54. package/skills/bt-gauntlet/references/critic-rubrics.md +106 -7
  55. package/skills/bt-gauntlet/references/loop-templates.md +23 -3
  56. package/skills/bt-gauntlet/references/spec-composition.md +20 -1
  57. package/skills/bt-gauntlet/references/target-images.md +27 -0
  58. package/skills/bt-gauntlet/references/unity-pipeline.md +41 -4
  59. package/skills/bt-gauntlet/references/workspace.md +90 -6
  60. package/skills/bt-unwrap/scripts/blender/__pycache__/bt_unwrap.cpython-313.pyc +0 -0
  61. package/skills/bt-unwrap/scripts/blender/__pycache__/image_utils.cpython-313.pyc +0 -0
  62. package/skills/bt-unwrap/scripts/blender/__pycache__/mesh_tools.cpython-313.pyc +0 -0
  63. package/skills/bt-unwrap/scripts/blender/__pycache__/model_io.cpython-313.pyc +0 -0
  64. package/skills/bt-unwrap/scripts/blender/__pycache__/previews.cpython-313.pyc +0 -0
  65. package/skills/bt-unwrap/scripts/blender/__pycache__/rasterizer.cpython-313.pyc +0 -0
  66. package/skills/bt-unwrap/scripts/blender/__pycache__/reference_views.cpython-313.pyc +0 -0
  67. package/skills/bt-unwrap/scripts/blender/__pycache__/reference_warp.cpython-313.pyc +0 -0
  68. package/skills/bt-unwrap/scripts/blender/__pycache__/texture_bake.cpython-313.pyc +0 -0
  69. package/skills/bt-unwrap/scripts/blender/__pycache__/texture_compose.cpython-313.pyc +0 -0
  70. package/skills/bt-unwrap/scripts/blender/__pycache__/uv_layout.cpython-313.pyc +0 -0
@@ -0,0 +1,729 @@
1
+ """
2
+ qa_check -- asset QA gate: the defects that ship unnoticed from AI-built and hand-built models.
3
+
4
+ Checks the objects of ONE asset together (an island far from every other part is "floating"):
5
+ - z-fighting: coplanar, overlapping faces facing the same way (and back-to-back hidden faces);
6
+ - floating parts: islands not connected, through contact, to the main body (enclosed parts such as
7
+ eyes inside a head are reported separately);
8
+ - normals: closed parts that are inside out, and edges whose faces wind inconsistently (flipped faces);
9
+ - topology: non-manifold, boundary, degenerate, duplicate and loose geometry, n-gons;
10
+ - transforms: unapplied or negative scale;
11
+ - UVs: missing map, zero-area faces, overlap, out of range, on the active map or the one --uv-map names
12
+ (a lightmap UV1 is gated with --uv-map 1); --allow-uv-overlap lists objects whose map overlaps on
13
+ purpose (tiling or palette UV0), so their overlap is a warning;
14
+ - skin weights: unweighted vertices, more than four influences;
15
+ - materials: faces on empty or missing slots, unused slots, missing texture files, data maps (roughness,
16
+ metallic, normal) tagged sRGB, colour maps tagged Non-Color.
17
+ Each check is an error, a warning or skipped per profile; any error fails the gate (exit 1).
18
+
19
+ blender --background --factory-startup --python-exit-code 1 --python qa_check.py -- \
20
+ --model asset.blend [--objects Body Wheel] [--profile web|game|render|print]
21
+ [--allow-floating Decal GlowCard] [--uv-map UVLightmap|1] [--allow-uv-overlap Wall Floor]
22
+ [--plane-distance 0.001] [--contact-tolerance 0.002] [--no-modifiers] [--out qa.json]
23
+
24
+ Portions adapted from EL4CTEO/blender-skills (skills/blender-asset-qa/scripts/qa_check.py, commit e21818b)
25
+ -- Copyright (c) 2026 EL4CTEO, MIT License:
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in all
35
+ copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ SOFTWARE.
44
+
45
+ Fixed in this port:
46
+ - a cluster of detached parts that only touch each other was "attached" (each one touched something);
47
+ parts now have to connect to the main body through a contact graph;
48
+ - the duplicate-vertex count halved per-vertex hits, so three coincident vertices counted as one;
49
+ - the UV overlap raster counted a texel centre lying exactly on an edge shared by two faces as inside
50
+ both (every diagonal of a triangulated grid read as overlap); edges are now half-open;
51
+ - the enclosed-part parity test used one ray, which a hit on a shared edge counts twice; it is now a
52
+ majority of three rays;
53
+ - UV overlap was only ever a warning, even for game profiles where it breaks bakes and lightmaps;
54
+ severity now follows the profile, and a `web` profile was added;
55
+ - intended floaters (decals, glow cards) can be allowed by name instead of switching profile;
56
+ - a part whose nearby-contact search found a neighbour skipped the intersection test, so sibling parts
57
+ that touch each other and pierce the main body (branches of a tree) were all reported floating; every
58
+ part with triangles is now tested for intersection too;
59
+ - standalone: no shared helper module, the bt-blender result contract and exit codes.
60
+ """
61
+ import math
62
+ import os
63
+ import sys
64
+ from collections import Counter, defaultdict
65
+
66
+ sys.dont_write_bytecode = True
67
+ SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
68
+ if SCRIPT_DIRECTORY not in sys.path:
69
+ sys.path.insert(0, SCRIPT_DIRECTORY)
70
+
71
+ import bmesh # noqa: E402
72
+ import bpy # noqa: E402
73
+ import numpy as np # noqa: E402
74
+ from mathutils import Vector # noqa: E402
75
+ from mathutils.bvhtree import BVHTree # noqa: E402
76
+ from mathutils.kdtree import KDTree # noqa: E402
77
+
78
+ import tool_common # noqa: E402
79
+
80
+ TOOL_NAME = "qa-check"
81
+
82
+ ERROR, WARNING = "error", "warning"
83
+
84
+ # Severity of every check per profile (None skips it).
85
+ PROFILES = {
86
+ "web": {"zfighting": ERROR, "floating": ERROR, "inside_out": ERROR, "inconsistent_normals": ERROR,
87
+ "nonmanifold": WARNING, "boundary": WARNING, "degenerate": ERROR, "duplicates": WARNING,
88
+ "ngons": WARNING, "scale": ERROR, "uv": ERROR, "uv_overlap": ERROR, "weights": ERROR,
89
+ "materials": ERROR},
90
+ "game": {"zfighting": ERROR, "floating": ERROR, "inside_out": ERROR, "inconsistent_normals": ERROR,
91
+ "nonmanifold": WARNING, "boundary": None, "degenerate": ERROR, "duplicates": WARNING,
92
+ "ngons": WARNING, "scale": ERROR, "uv": ERROR, "uv_overlap": WARNING, "weights": ERROR,
93
+ "materials": ERROR},
94
+ "render": {"zfighting": ERROR, "floating": ERROR, "inside_out": WARNING, "inconsistent_normals": WARNING,
95
+ "nonmanifold": None, "boundary": None, "degenerate": WARNING, "duplicates": WARNING,
96
+ "ngons": None, "scale": WARNING, "uv": WARNING, "uv_overlap": WARNING, "weights": WARNING,
97
+ "materials": ERROR},
98
+ "print": {"zfighting": ERROR, "floating": ERROR, "inside_out": ERROR, "inconsistent_normals": ERROR,
99
+ "nonmanifold": ERROR, "boundary": ERROR, "degenerate": ERROR, "duplicates": ERROR,
100
+ "ngons": None, "scale": WARNING, "uv": None, "uv_overlap": None, "weights": None,
101
+ "materials": None},
102
+ }
103
+
104
+ # Option defaults: z-fighting plane distance and contact tolerance (metres), and the triangle count above
105
+ # which the pairwise z-fighting and floating checks are skipped.
106
+ DEFAULT_PLANE_DISTANCE = 0.001
107
+ DEFAULT_CONTACT_TOLERANCE = 0.002
108
+ DEFAULT_MAX_TRIANGLES = 300000
109
+
110
+ # An asset whose lowest point is further than this from z = 0 (metres) does not rest on the ground.
111
+ GROUND_TOLERANCE = 0.001
112
+
113
+ # Doubled UV areas below this count as zero-area faces; island volumes below minus this are inside out.
114
+ ZERO_UV_AREA = 1e-12
115
+ INSIDE_OUT_VOLUME = 1e-12
116
+
117
+ # Keeps the edge-crossing division finite for horizontal edges (which never span a cell centre).
118
+ DIVISION_GUARD = 1e-30
119
+
120
+ # Principled BSDF inputs and node types that read data, not colour: their images must be Non-Color.
121
+ DATA_INPUTS = {"Roughness", "Metallic", "Normal", "Alpha", "Specular IOR Level", "Coat Weight", "Coat Roughness",
122
+ "Transmission Weight", "Subsurface Weight", "Anisotropic", "Sheen Weight", "IOR"}
123
+ DATA_NODES = {"NORMAL_MAP", "BUMP", "DISPLACEMENT", "VECTOR_DISPLACEMENT"}
124
+
125
+ # How many nodes downstream an image's use is followed.
126
+ NODE_SEARCH_DEPTH = 4
127
+
128
+ # UV raster resolution (cells per side) and the largest face count rasterised before sampling.
129
+ UV_RASTER_SIZE = 128
130
+ UV_SAMPLE_FACES = 30000
131
+
132
+ # Deform weights at or below this do not count as an influence; scale this close to 1 counts as applied.
133
+ MINIMUM_DEFORM_WEIGHT = 1e-4
134
+ SCALE_TOLERANCE = 1e-4
135
+
136
+ # Z-fighting: triangles with a normal shorter than this are degenerate and skipped; each triangle is sampled
137
+ # at its centre and this far (0..1) towards each corner; at most this many pairs are listed per kind.
138
+ MINIMUM_NORMAL_LENGTH = 0.5
139
+ CORNER_SAMPLE_FRACTION = 0.6
140
+ MAX_REPORTED_PAIRS = 20
141
+
142
+ # How far outside an edge (in its plane) a point may lie and still count as inside the triangle.
143
+ INSIDE_TRIANGLE_TOLERANCE = 1e-9
144
+
145
+ # UV coordinates this far outside 0..1 count as out of range.
146
+ UV_RANGE_TOLERANCE = 1e-4
147
+
148
+ # UV overlap above this percent of the used area is reported.
149
+ UV_OVERLAP_PERCENT = 5.0
150
+
151
+ # Thresholds: degenerate face area (m^2), zero-length edge (m), coincident vertices (m), z-fight
152
+ # parallelism (normal dot product), and the vertex sample per island for contact queries.
153
+ DEGENERATE_AREA = 1e-10
154
+ ZERO_EDGE_LENGTH = 1e-7
155
+ DUPLICATE_DISTANCE = 1e-5
156
+ PARALLEL_DOT = 0.999
157
+ CONTACT_SAMPLES = 400
158
+
159
+ # Ray directions for the enclosed-part parity vote (deliberately off-axis), and the hit step.
160
+ PARITY_RAYS = [Vector(direction).normalized() for direction in
161
+ ((0.137, 0.271, 0.953), (-0.412, 0.135, -0.901), (0.577, -0.595, 0.559))]
162
+ RAY_STEP = 1e-5
163
+ MAX_RAY_HITS = 64
164
+
165
+
166
+ def build_parser() -> tool_common.ToolArgumentParser:
167
+ """The tool's command-line options."""
168
+ parser = tool_common.ToolArgumentParser(prog=TOOL_NAME, description=__doc__.strip().splitlines()[0])
169
+ parser.add_argument("--model", help="asset (.blend .glb .gltf .fbx .obj)")
170
+ parser.add_argument("--objects", nargs="*", help="objects of the asset (default every visible mesh)")
171
+ parser.add_argument("--profile", default="web", choices=sorted(PROFILES))
172
+ parser.add_argument("--plane-distance", type=float, default=DEFAULT_PLANE_DISTANCE,
173
+ help="z-fighting plane distance, metres")
174
+ parser.add_argument("--contact-tolerance", type=float, default=DEFAULT_CONTACT_TOLERANCE,
175
+ help="contact tolerance for detached parts, metres")
176
+ parser.add_argument("--allow-floating", nargs="*", default=[], help="objects whose parts may float")
177
+ parser.add_argument("--no-modifiers", action="store_true", help="check the base meshes, not the evaluated ones")
178
+ parser.add_argument("--no-uv", action="store_true", help="skip the UV checks")
179
+ parser.add_argument("--uv-map", help="UV map to check, by name or index (default the active map; "
180
+ "e.g. 1 for a lightmap UV1)")
181
+ parser.add_argument("--allow-uv-overlap", nargs="*", default=[],
182
+ help="objects whose UVs overlap on purpose (tiling or palette UV0): overlap is a warning")
183
+ parser.add_argument("--max-triangles", type=int, default=DEFAULT_MAX_TRIANGLES,
184
+ help="above this, z-fighting and floating checks are skipped")
185
+ parser.add_argument("--out", help="also write the report to this JSON file")
186
+ return parser
187
+
188
+
189
+ class Findings:
190
+ """Collects findings with the profile's severity for each check."""
191
+
192
+ def __init__(self, profile: str):
193
+ """
194
+ :param profile: Profile name from PROFILES.
195
+ """
196
+ self.severity = PROFILES[profile]
197
+ self.items = []
198
+
199
+ def add(self, check: str, message: str, severity=None) -> None:
200
+ """
201
+ Records a finding unless the profile skips the check.
202
+
203
+ :param check: Check key from the profile table.
204
+ :param message: Human-readable description.
205
+ :param severity: Force a severity instead of the profile's.
206
+ """
207
+ level = severity or self.severity.get(check)
208
+ if level is not None:
209
+ self.items.append({"check": check, "severity": level, "message": message})
210
+
211
+ def messages(self, level: str) -> list:
212
+ """Messages of one severity."""
213
+ return [item["message"] for item in self.items if item["severity"] == level]
214
+
215
+
216
+ def _downstream_uses(socket, depth: int = NODE_SEARCH_DEPTH) -> set:
217
+ """(node type, input name) pairs a node output reaches through up to `depth` nodes."""
218
+ uses = set()
219
+ for link in socket.links:
220
+ node = link.to_node
221
+ uses.add((node.type, link.to_socket.name))
222
+ if depth and node.type not in DATA_NODES and node.type != "BSDF_PRINCIPLED":
223
+ for output in node.outputs:
224
+ uses |= _downstream_uses(output, depth - 1)
225
+ return uses
226
+
227
+
228
+ def _image_node_issues(material, node) -> list:
229
+ """[(is_error, message)] for one image texture node."""
230
+ image = node.image
231
+ if image is None:
232
+ if node.outputs["Color"].is_linked or node.outputs["Alpha"].is_linked:
233
+ return [(False, f"{material.name}: image node {node.name!r} has no image")]
234
+ return []
235
+ issues = []
236
+ if image.source == "FILE" and not image.packed_file and not os.path.exists(bpy.path.abspath(image.filepath)):
237
+ issues.append((True, f"{material.name}: missing texture file {image.filepath!r}"))
238
+ uses = _downstream_uses(node.outputs["Color"])
239
+ data_uses = sorted({name for node_type, name in uses if node_type == "BSDF_PRINCIPLED" and name in DATA_INPUTS}
240
+ | {node_type.lower() for node_type, _ in uses if node_type in DATA_NODES})
241
+ if data_uses and not image.colorspace_settings.is_data:
242
+ issues.append((True, f"{material.name}: {image.name} feeds {data_uses} but is "
243
+ f"{image.colorspace_settings.name} (must be Non-Color)"))
244
+ if image.colorspace_settings.is_data and ("BSDF_PRINCIPLED", "Base Color") in uses:
245
+ issues.append((False, f"{material.name}: {image.name} is Non-Color but drives Base Color (washed out)"))
246
+ return issues
247
+
248
+
249
+ def material_issues(obj) -> list:
250
+ """
251
+ Material slot and texture problems of one object.
252
+
253
+ :param obj: Mesh object.
254
+ :returns: [(is_error, message)].
255
+ """
256
+ mesh, slots = obj.data, obj.material_slots
257
+ if not mesh.polygons:
258
+ return []
259
+ indices = np.empty(len(mesh.polygons), dtype=np.int32)
260
+ mesh.polygons.foreach_get("material_index", indices)
261
+ used = set(int(index) for index in np.unique(indices))
262
+ issues = []
263
+ empty = sorted(index for index in used if index >= len(slots) or slots[index].material is None)
264
+ if empty or not slots:
265
+ issues.append((True, f"{obj.name}: faces use empty or missing material slot(s) {empty or [0]} "
266
+ "(they render grey or untextured in engines)"))
267
+ unused = [slot.name or str(index) for index, slot in enumerate(slots) if index not in used]
268
+ if unused:
269
+ issues.append((False, f"{obj.name}: unused material slot(s) {unused} (extra draw calls in some exporters)"))
270
+ for index in sorted(used):
271
+ material = slots[index].material if index < len(slots) else None
272
+ if material is None or not material.node_tree:
273
+ continue
274
+ for node in material.node_tree.nodes:
275
+ if node.type == "TEX_IMAGE":
276
+ issues.extend(_image_node_issues(material, node))
277
+ return issues
278
+
279
+
280
+ def _world_bmesh(obj, use_modifiers: bool) -> bmesh.types.BMesh:
281
+ """The (evaluated) mesh in world space; a mirrored object's winding is flipped back as exporters do."""
282
+ edit_mesh = bmesh.new()
283
+ if use_modifiers:
284
+ edit_mesh.from_object(obj, bpy.context.evaluated_depsgraph_get())
285
+ else:
286
+ edit_mesh.from_mesh(obj.data)
287
+ edit_mesh.transform(obj.matrix_world)
288
+ if obj.matrix_world.determinant() < 0:
289
+ bmesh.ops.reverse_faces(edit_mesh, faces=edit_mesh.faces[:])
290
+ edit_mesh.verts.ensure_lookup_table()
291
+ edit_mesh.faces.ensure_lookup_table()
292
+ return edit_mesh
293
+
294
+
295
+ def _vertex_islands(edit_mesh) -> list:
296
+ """Connected-component id per vertex (union-find over edges)."""
297
+ parent = list(range(len(edit_mesh.verts)))
298
+
299
+ def find(index):
300
+ while parent[index] != index:
301
+ parent[index] = parent[parent[index]]
302
+ index = parent[index]
303
+ return index
304
+
305
+ for edge in edit_mesh.edges:
306
+ first, second = find(edge.verts[0].index), find(edge.verts[1].index)
307
+ if first != second:
308
+ parent[first] = second
309
+ roots = [find(index) for index in range(len(edit_mesh.verts))]
310
+ renumber = {root: number for number, root in enumerate(dict.fromkeys(roots))}
311
+ return [renumber[root] for root in roots]
312
+
313
+
314
+ def _duplicate_vertex_count(edit_mesh) -> int:
315
+ """Vertices that coincide with an earlier one (a cluster of n coincident vertices counts n - 1)."""
316
+ tree = KDTree(len(edit_mesh.verts))
317
+ for vertex in edit_mesh.verts:
318
+ tree.insert(vertex.co, vertex.index)
319
+ tree.balance()
320
+ duplicates = 0
321
+ for vertex in edit_mesh.verts:
322
+ if any(index < vertex.index for _, index, _ in tree.find_range(vertex.co, DUPLICATE_DISTANCE)):
323
+ duplicates += 1
324
+ return duplicates
325
+
326
+
327
+ def topology_metrics(edit_mesh) -> dict:
328
+ """Counts of the topology problems of one world-space bmesh."""
329
+ edge_face_counts = Counter(len(edge.link_faces) for edge in edit_mesh.edges)
330
+ directed = Counter((loop.vert.index, loop.link_loop_next.vert.index) for face in edit_mesh.faces for loop in face.loops)
331
+ return {"vertices": len(edit_mesh.verts), "faces": len(edit_mesh.faces),
332
+ "triangles": sum(len(face.verts) - 2 for face in edit_mesh.faces),
333
+ "ngons": sum(1 for face in edit_mesh.faces if len(face.verts) > 4),
334
+ "boundary_edges": edge_face_counts.get(1, 0),
335
+ "nonmanifold_edges": sum(count for faces, count in edge_face_counts.items() if faces > 2),
336
+ "wire_edges": edge_face_counts.get(0, 0),
337
+ "loose_vertices": sum(1 for vertex in edit_mesh.verts if not vertex.link_edges),
338
+ "degenerate_faces": sum(1 for face in edit_mesh.faces if face.calc_area() < DEGENERATE_AREA),
339
+ "zero_length_edges": sum(1 for edge in edit_mesh.edges if edge.calc_length() < ZERO_EDGE_LENGTH),
340
+ "inconsistent_normals_edges": sum(1 for count in directed.values() if count > 1),
341
+ "duplicate_vertices": _duplicate_vertex_count(edit_mesh)}
342
+
343
+
344
+ def _rasterise_uv_face(points: list, size: int):
345
+ """Cell range and inside mask of one UV polygon on the raster (half-open edges), or None."""
346
+ u_values, v_values = [point.x for point in points], [point.y for point in points]
347
+ u_start, u_end = max(0, int(min(u_values) * size)), min(size, int(max(u_values) * size) + 1)
348
+ v_start, v_end = max(0, int(min(v_values) * size)), min(size, int(max(v_values) * size) + 1)
349
+ if u_start >= u_end or v_start >= v_end:
350
+ return None
351
+ cell_x, cell_y = np.meshgrid((np.arange(u_start, u_end) + 0.5) / size, (np.arange(v_start, v_end) + 0.5) / size,
352
+ indexing="ij")
353
+ inside = np.zeros(cell_x.shape, dtype=bool)
354
+ previous = points[-1]
355
+ # Even-odd crossing test: a texel centre on an edge belongs to exactly one side, never to both faces.
356
+ for current in points:
357
+ spans = (current.y > cell_y) != (previous.y > cell_y)
358
+ crossing = (previous.x - current.x) * (cell_y - current.y) / (previous.y - current.y + DIVISION_GUARD) + current.x
359
+ inside ^= spans & (cell_x < crossing)
360
+ previous = current
361
+ return (u_start, u_end, v_start, v_end), inside
362
+
363
+
364
+ def _uv_layer_name(mesh, uv_map):
365
+ """The name of the UV map to check: the active one, or the one named or numbered by uv_map (None if absent)."""
366
+ if uv_map is None:
367
+ return mesh.uv_layers.active.name if mesh.uv_layers.active else mesh.uv_layers[0].name
368
+ if str(uv_map).isdigit():
369
+ index = int(uv_map)
370
+ return mesh.uv_layers[index].name if index < len(mesh.uv_layers) else None
371
+ return uv_map if uv_map in mesh.uv_layers else None
372
+
373
+
374
+ def uv_metrics(obj, uv_map=None) -> dict:
375
+ """
376
+ UV map statistics of the base mesh on a coarse raster: a cell is used when its centre lies in a face,
377
+ overlapped when it lies in two or more.
378
+
379
+ :param obj: Mesh object.
380
+ :param uv_map: UV map name or index (as a string or int), or None for the active map.
381
+ :returns: {"uv_maps"} plus "uv_map" and the out-of-range, zero-area, overlap and coverage figures when the
382
+ map exists, or "uv_map_missing" when the asked map does not.
383
+ """
384
+ mesh = obj.data
385
+ if not mesh.uv_layers:
386
+ return {"uv_maps": 0}
387
+ layer_name = _uv_layer_name(mesh, uv_map)
388
+ if layer_name is None:
389
+ return {"uv_maps": len(mesh.uv_layers), "uv_map_missing": str(uv_map)}
390
+ edit_mesh = bmesh.new()
391
+ edit_mesh.from_mesh(mesh)
392
+ layer = edit_mesh.loops.layers.uv[layer_name]
393
+ size = UV_RASTER_SIZE
394
+ owner = np.full((size, size), -1, dtype=np.int64)
395
+ overlapped = np.zeros((size, size), dtype=bool)
396
+ out_of_range = total = zero_area = 0
397
+ step = max(1, len(edit_mesh.faces) // UV_SAMPLE_FACES)
398
+ for face in list(edit_mesh.faces)[::step]:
399
+ points = [loop[layer].uv.copy() for loop in face.loops]
400
+ total += len(points)
401
+ low, high = -UV_RANGE_TOLERANCE, 1.0 + UV_RANGE_TOLERANCE
402
+ out_of_range += sum(1 for point in points if not (low <= point.x <= high and low <= point.y <= high))
403
+ doubled_area = sum(points[i].x * points[(i + 1) % len(points)].y - points[(i + 1) % len(points)].x * points[i].y
404
+ for i in range(len(points)))
405
+ if abs(doubled_area) < ZERO_UV_AREA:
406
+ zero_area += 1
407
+ continue
408
+ raster = _rasterise_uv_face(points, size)
409
+ if raster is None:
410
+ continue
411
+ (u_start, u_end, v_start, v_end), inside = raster
412
+ cells = (slice(u_start, u_end), slice(v_start, v_end))
413
+ window, overlap_window = owner[cells], overlapped[cells]
414
+ overlap_window |= inside & (window >= 0) & (window != face.index)
415
+ window[inside & (window < 0)] = face.index
416
+ edit_mesh.free()
417
+ used = int((owner >= 0).sum())
418
+ return {"uv_maps": len(mesh.uv_layers), "uv_map": layer_name,
419
+ "uv_out_of_range_percent": round(100.0 * out_of_range / max(total, 1), 2),
420
+ "uv_zero_area_faces": zero_area, "uv_overlap_percent": round(100.0 * int(overlapped.sum()) / max(used, 1), 2),
421
+ "uv_coverage_percent": round(100.0 * used / size / size, 1)}
422
+
423
+
424
+ def weight_metrics(obj) -> dict:
425
+ """Unweighted vertices and vertices over four deform influences, for armature-deformed meshes."""
426
+ armature = next((modifier for modifier in obj.modifiers if modifier.type == "ARMATURE" and modifier.object), None)
427
+ if not armature or not obj.vertex_groups:
428
+ return {}
429
+ deform_bones = {bone.name for bone in armature.object.data.bones if bone.use_deform}
430
+ deform_groups = {group.index for group in obj.vertex_groups if group.name in deform_bones}
431
+ unweighted = over_four = 0
432
+ for vertex in obj.data.vertices:
433
+ influences = [group for group in vertex.groups if group.group in deform_groups and group.weight > MINIMUM_DEFORM_WEIGHT]
434
+ unweighted += not influences
435
+ over_four += len(influences) > 4
436
+ return {"unweighted_vertices": unweighted, "vertices_over_4_influences": over_four}
437
+
438
+
439
+ def _report_object(obj, metrics: dict, findings: Findings, allow_uv_overlap: bool = False) -> None:
440
+ """Turns one object's metrics into findings; with allow_uv_overlap its UV overlap is only a warning."""
441
+ name = obj.name
442
+ if not metrics["faces"]:
443
+ findings.add("degenerate", f"{name}: mesh has no faces", ERROR)
444
+ if metrics["inside_out_islands"]:
445
+ findings.add("inside_out", f"{name}: {metrics['inside_out_islands']} closed part(s) with normals pointing inward")
446
+ if metrics["inconsistent_normals_edges"]:
447
+ findings.add("inconsistent_normals", f"{name}: {metrics['inconsistent_normals_edges']} edges between faces "
448
+ "with opposite winding (flipped faces)")
449
+ if metrics["nonmanifold_edges"] or metrics["wire_edges"]:
450
+ findings.add("nonmanifold", f"{name}: non-manifold edges={metrics['nonmanifold_edges']} wire={metrics['wire_edges']}")
451
+ if metrics["boundary_edges"]:
452
+ findings.add("boundary", f"{name}: {metrics['boundary_edges']} open boundary edges (not watertight)")
453
+ if metrics["degenerate_faces"] or metrics["zero_length_edges"]:
454
+ findings.add("degenerate", f"{name}: degenerate faces={metrics['degenerate_faces']} "
455
+ f"zero-length edges={metrics['zero_length_edges']}")
456
+ if metrics["duplicate_vertices"] or metrics["loose_vertices"]:
457
+ findings.add("duplicates", f"{name}: duplicate vertices={metrics['duplicate_vertices']} "
458
+ f"loose vertices={metrics['loose_vertices']}")
459
+ if metrics["ngons"]:
460
+ findings.add("ngons", f"{name}: {metrics['ngons']} n-gons")
461
+ scale = metrics["scale"]
462
+ if any(abs(value - 1.0) > SCALE_TOLERANCE for value in scale):
463
+ findings.add("scale", f"{name}: unapplied scale {scale}")
464
+ if scale[0] * scale[1] * scale[2] < 0:
465
+ findings.add("scale", f"{name}: negative scale (flips normals on export)", ERROR)
466
+ if metrics.get("unweighted_vertices"):
467
+ findings.add("weights", f"{name}: {metrics['unweighted_vertices']} vertices with no deform weights")
468
+ if metrics.get("vertices_over_4_influences"):
469
+ findings.add("weights", f"{name}: {metrics['vertices_over_4_influences']} vertices with more than 4 bone influences")
470
+ if "uv_maps" not in metrics:
471
+ return
472
+ if metrics["uv_maps"] == 0:
473
+ findings.add("uv", f"{name}: no UV map")
474
+ return
475
+ if "uv_map_missing" in metrics:
476
+ findings.add("uv", f"{name}: no UV map '{metrics['uv_map_missing']}' ({metrics['uv_maps']} map(s))")
477
+ return
478
+ if metrics["uv_zero_area_faces"]:
479
+ findings.add("uv", f"{name}: {metrics['uv_zero_area_faces']} zero-area UV faces")
480
+ if metrics["uv_overlap_percent"] > UV_OVERLAP_PERCENT:
481
+ allowed = " (allowed: --allow-uv-overlap)" if allow_uv_overlap else ""
482
+ findings.add("uv_overlap", f"{name}: ~{metrics['uv_overlap_percent']}% of {metrics['uv_map']} overlaps "
483
+ f"(only fine when mirrored or stacked on purpose; bakes and lightmaps break){allowed}",
484
+ WARNING if allow_uv_overlap else None)
485
+
486
+
487
+ def _closed_island_volumes(edit_mesh, islands: list) -> tuple:
488
+ """Signed volume and closedness per island, each volume taken about a point of its own island."""
489
+ volume, closed = defaultdict(float), defaultdict(lambda: True)
490
+ for edge in edit_mesh.edges:
491
+ if len(edge.link_faces) != 2:
492
+ closed[islands[edge.verts[0].index]] = False
493
+ # A volume about the world origin cancels in float32 for small parts far from it (3 mm parts 2 m out
494
+ # read inside out), so each island's volume is taken about one of its own vertices.
495
+ reference = {}
496
+ for vertex in edit_mesh.verts:
497
+ reference.setdefault(islands[vertex.index], vertex.co.copy())
498
+ triangulated = edit_mesh.copy()
499
+ bmesh.ops.triangulate(triangulated, faces=triangulated.faces[:])
500
+ for face in triangulated.faces:
501
+ island = islands[face.verts[0].index]
502
+ first, second, third = (vertex.co - reference[island] for vertex in face.verts)
503
+ volume[island] += first.dot(second.cross(third)) / 6.0
504
+ return volume, closed, triangulated
505
+
506
+
507
+ def gather(objects: list, use_modifiers: bool, uv: bool, findings: Findings, uv_map=None,
508
+ allow_uv_overlap=()) -> dict:
509
+ """
510
+ Measures every object and collects the world-space triangles and islands of the whole asset.
511
+
512
+ :param uv_map: UV map to check, by name or index (None: the active map).
513
+ :param allow_uv_overlap: Names of objects whose UV overlap is intended (reported as a warning).
514
+ :returns: {"objects": per-object metrics, "vertices", "triangles", "triangle_owners", "islands", "lowest_z"}.
515
+ """
516
+ vertices, triangles, triangle_owners, island_info, per_object = [], [], [], {}, {}
517
+ lowest = math.inf
518
+ for object_index, obj in enumerate(objects):
519
+ edit_mesh = _world_bmesh(obj, use_modifiers)
520
+ islands = _vertex_islands(edit_mesh)
521
+ island_count = max(islands) + 1 if islands else 0
522
+ base_vertex, base_island = len(vertices), len(island_info)
523
+ vertices.extend(vertex.co.copy() for vertex in edit_mesh.verts)
524
+ if edit_mesh.verts:
525
+ lowest = min(lowest, min(vertex.co.z for vertex in edit_mesh.verts))
526
+ metrics = topology_metrics(edit_mesh)
527
+ metrics["islands"] = island_count
528
+ volume, closed, triangulated = _closed_island_volumes(edit_mesh, islands)
529
+ for face in triangulated.faces:
530
+ triangles.append(tuple(base_vertex + vertex.index for vertex in face.verts))
531
+ triangle_owners.append((object_index, base_island + islands[face.verts[0].index], face.normal.copy()))
532
+ triangulated.free()
533
+ metrics["inside_out_islands"] = sum(1 for island in range(island_count)
534
+ if closed[island] and volume[island] < -INSIDE_OUT_VOLUME)
535
+ members = defaultdict(list)
536
+ for vertex_index, island in enumerate(islands):
537
+ members[island].append(vertex_index)
538
+ for island, indices in members.items():
539
+ points = np.array([tuple(edit_mesh.verts[index].co) for index in indices])
540
+ low, high = points.min(axis=0), points.max(axis=0)
541
+ island_info[base_island + island] = {"object": obj.name, "vertices": [base_vertex + index for index in indices],
542
+ "center": Vector((low + high) / 2.0),
543
+ "size": float(np.linalg.norm(high - low)), "triangles": []}
544
+ edit_mesh.free()
545
+ metrics["scale"] = [round(value, 4) for value in obj.scale]
546
+ metrics["materials"] = len(obj.material_slots)
547
+ for is_error, message in material_issues(obj):
548
+ findings.add("materials", message, None if is_error else WARNING)
549
+ metrics.update(weight_metrics(obj))
550
+ if uv:
551
+ metrics.update(uv_metrics(obj, uv_map))
552
+ _report_object(obj, metrics, findings, obj.name in allow_uv_overlap)
553
+ per_object[obj.name] = metrics
554
+ for triangle_index, (_, island, _) in enumerate(triangle_owners):
555
+ island_info[island]["triangles"].append(triangle_index)
556
+ return {"objects": per_object, "vertices": vertices, "triangles": triangles, "triangle_owners": triangle_owners,
557
+ "islands": island_info,
558
+ "lowest_z": lowest}
559
+
560
+
561
+ def _point_in_triangle(point, first, second, third, normal) -> bool:
562
+ """Whether a point (already on the triangle's plane) lies inside it."""
563
+ for start, end in ((first, second), (second, third), (third, first)):
564
+ if (end - start).cross(point - start).dot(normal) < -INSIDE_TRIANGLE_TOLERANCE:
565
+ return False
566
+ return True
567
+
568
+
569
+ def find_zfighting(data: dict, triangle_tree: BVHTree, objects: list, plane_distance: float) -> tuple:
570
+ """
571
+ Coplanar overlapping triangle pairs within `plane_distance`: same-facing pairs z-fight, opposite-facing pairs are
572
+ hidden back-to-back faces.
573
+
574
+ :returns: (z-fighting summary, back-to-back summary), each [{"where", "triangle_pairs"}].
575
+ """
576
+ vertices, triangles, triangle_owners = data["vertices"], data["triangles"], data["triangle_owners"]
577
+ vertex_sets = [set(triangle) for triangle in triangles]
578
+ fighting, back_to_back = set(), set()
579
+ for triangle_index, triangle in enumerate(triangles):
580
+ first, second, third = (vertices[index] for index in triangle)
581
+ normal = triangle_owners[triangle_index][2]
582
+ if normal.length < MINIMUM_NORMAL_LENGTH:
583
+ continue
584
+ center = (first + second + third) / 3.0
585
+ samples = [center] + [center.lerp(corner, CORNER_SAMPLE_FRACTION) for corner in (first, second, third)]
586
+ for sample in samples:
587
+ for _, _, other, _ in triangle_tree.find_nearest_range(sample, plane_distance):
588
+ if other is None or other == triangle_index or vertex_sets[triangle_index] & vertex_sets[other]:
589
+ continue
590
+ other_normal = triangle_owners[other][2]
591
+ alignment = normal.dot(other_normal)
592
+ if abs(alignment) < PARALLEL_DOT:
593
+ continue
594
+ corners = [vertices[index] for index in triangles[other]]
595
+ projected = sample - other_normal * other_normal.dot(sample - corners[0])
596
+ if _point_in_triangle(projected, *corners, other_normal):
597
+ pair = (min(triangle_index, other), max(triangle_index, other))
598
+ (fighting if alignment > 0 else back_to_back).add(pair)
599
+
600
+ def describe(pairs):
601
+ counts = Counter()
602
+ for first_index, second_index in pairs:
603
+ first_name = objects[triangle_owners[first_index][0]].name
604
+ second_name = objects[triangle_owners[second_index][0]].name
605
+ counts[f"{first_name}<->{second_name}" if first_name != second_name else first_name] += 1
606
+ return [{"where": where, "triangle_pairs": count} for where, count in counts.most_common(MAX_REPORTED_PAIRS)]
607
+
608
+ return describe(fighting), describe(back_to_back)
609
+
610
+
611
+ def _contact_graph(data: dict, triangle_tree: BVHTree, tolerance: float) -> dict:
612
+ """
613
+ Island -> set of islands it touches or intersects. Both tests run for every island: a part that touches
614
+ one neighbour can still be joined to the body only by intersecting it (two branches touching each other
615
+ and both sunk into the trunk), so finding a contact must not skip the intersection test.
616
+ """
617
+ vertices, triangles = data["vertices"], data["triangles"]
618
+ triangle_island = [meta[1] for meta in data["triangle_owners"]]
619
+ neighbours = defaultdict(set)
620
+ for island, info in data["islands"].items():
621
+ island_vertices = info["vertices"]
622
+ for vertex_index in island_vertices[::max(1, len(island_vertices) // CONTACT_SAMPLES)]:
623
+ for _, _, triangle, _ in triangle_tree.find_nearest_range(vertices[vertex_index], tolerance):
624
+ if triangle is not None and triangle_island[triangle] != island:
625
+ neighbours[island].add(triangle_island[triangle])
626
+ neighbours[triangle_island[triangle]].add(island)
627
+ if not info["triangles"]:
628
+ continue
629
+ own_tree = BVHTree.FromPolygons(vertices, [triangles[triangle] for triangle in info["triangles"]], epsilon=0.0)
630
+ for _, other in own_tree.overlap(triangle_tree):
631
+ if triangle_island[other] != island:
632
+ neighbours[island].add(triangle_island[other])
633
+ neighbours[triangle_island[other]].add(island)
634
+ return neighbours
635
+
636
+
637
+ def _is_enclosed(info: dict, triangle_tree: BVHTree, triangle_island: list, island: int) -> bool:
638
+ """Majority vote of three parity rays from the island's centre through the other islands."""
639
+ votes = 0
640
+ for direction in PARITY_RAYS:
641
+ hits, origin = 0, info["center"].copy()
642
+ for _ in range(MAX_RAY_HITS):
643
+ location, _, triangle, _ = triangle_tree.ray_cast(origin, direction)
644
+ if location is None:
645
+ break
646
+ if triangle_island[triangle] != island:
647
+ hits += 1
648
+ origin = location + direction * RAY_STEP
649
+ votes += hits % 2
650
+ return votes >= 2
651
+
652
+
653
+ def find_floating(data: dict, triangle_tree: BVHTree, tolerance: float, allowed: set) -> tuple:
654
+ """
655
+ Islands not connected to the main body (the largest island) through the contact graph, split into
656
+ floating parts and parts enclosed inside another closed part.
657
+
658
+ :returns: (floating, enclosed) lists of {"object", "island_vertices", "center"}.
659
+ """
660
+ islands = data["islands"]
661
+ if len(islands) < 2:
662
+ return [], []
663
+ neighbours = _contact_graph(data, triangle_tree, tolerance)
664
+ main_body = max(islands, key=lambda island: islands[island]["size"])
665
+ connected, frontier = {main_body}, [main_body]
666
+ while frontier:
667
+ for neighbour in neighbours[frontier.pop()]:
668
+ if neighbour not in connected:
669
+ connected.add(neighbour)
670
+ frontier.append(neighbour)
671
+ triangle_island = [meta[1] for meta in data["triangle_owners"]]
672
+ floating, enclosed = [], []
673
+ for island, info in islands.items():
674
+ if island in connected or info["object"] in allowed:
675
+ continue
676
+ record = {"object": info["object"], "island_vertices": len(info["vertices"]),
677
+ "center": [round(value, 4) for value in info["center"]]}
678
+ (enclosed if _is_enclosed(info, triangle_tree, triangle_island, island) else floating).append(record)
679
+ return floating, enclosed
680
+
681
+
682
+ def run(options) -> dict:
683
+ """
684
+ Runs every check on the asset.
685
+
686
+ :param options: Parsed options.
687
+ :returns: The QA report.
688
+ """
689
+ tool_common.load_model(options.model)
690
+ objects = tool_common.resolve_objects(options.objects)
691
+ findings = Findings(options.profile)
692
+ data = gather(objects, not options.no_modifiers, not options.no_uv, findings, options.uv_map,
693
+ set(options.allow_uv_overlap))
694
+ report = {"profile": options.profile, "objects": data["objects"], "zfighting": [], "back_to_back": [],
695
+ "floating": [], "enclosed": [], "skipped": []}
696
+ if len(data["triangles"]) > options.max_triangles:
697
+ report["skipped"] = ["zfighting", "floating"]
698
+ findings.add("zfighting", f"{len(data['triangles'])} triangles > --max-triangles {options.max_triangles}: "
699
+ "z-fighting and floating checks skipped", WARNING)
700
+ elif data["triangles"]:
701
+ triangle_tree = BVHTree.FromPolygons(data["vertices"], data["triangles"], epsilon=0.0)
702
+ report["zfighting"], report["back_to_back"] = find_zfighting(data, triangle_tree, objects, options.plane_distance)
703
+ for entry in report["zfighting"]:
704
+ findings.add("zfighting", f"z-fighting: {entry['where']} "
705
+ f"({entry['triangle_pairs']} overlapping coplanar triangle pairs)")
706
+ for entry in report["back_to_back"]:
707
+ findings.add("zfighting", f"hidden back-to-back faces: {entry['where']} ({entry['triangle_pairs']} pairs); "
708
+ "delete them to save triangles", WARNING)
709
+ report["floating"], report["enclosed"] = find_floating(data, triangle_tree, options.contact_tolerance,
710
+ set(options.allow_floating))
711
+ for part in report["floating"]:
712
+ findings.add("floating", f"floating part in {part['object']} "
713
+ f"({part['island_vertices']} vertices at {part['center']})")
714
+ if report["enclosed"]:
715
+ findings.add("floating", f"{len(report['enclosed'])} part(s) fully enclosed, not touching (eyes, internals?): "
716
+ f"{sorted({part['object'] for part in report['enclosed']})[:5]}", WARNING)
717
+ lowest = None if data["lowest_z"] == math.inf else round(data["lowest_z"], 4)
718
+ report["ground_z"] = lowest
719
+ if lowest is not None and abs(lowest) > max(options.contact_tolerance, GROUND_TOLERANCE):
720
+ findings.add("scale", f"lowest point z={lowest}: the asset does not rest on the ground plane z=0", WARNING)
721
+ report.update({"pass": not findings.messages(ERROR), "errors": findings.messages(ERROR),
722
+ "warnings": findings.messages(WARNING), "findings": findings.items})
723
+ if options.out:
724
+ report["report_json"] = tool_common.write_json(options.out, report)
725
+ return report
726
+
727
+
728
+ if __name__ == "__main__":
729
+ tool_common.run_tool(TOOL_NAME, build_parser(), run)