Files
NiemandKG d1c3761e58 Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:44:40 +06:00

48 lines
1.9 KiB
Python

"""Print object names / unity-space bounds / tris / materials of FBX files (re-imported), optionally vs an old copy.
Run: blender -b --factory-startup --python verify_v3.py -- [--old <dir>] Name1 Name2 ...
"""
import bpy, os, sys
from mathutils import Vector
d = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "Assets", "Art", "Models"))
args = sys.argv[sys.argv.index("--") + 1:]
old = None
if args and args[0] == "--old":
old, args = args[1], args[2:]
def measure(path):
bpy.ops.wm.read_factory_settings(use_empty=True)
bpy.ops.import_scene.fbx(filepath=path)
bpy.context.view_layer.update()
mn = Vector((1e9,) * 3); mx = Vector((-1e9,) * 3); tris = 0; kids = []; mats = set()
for o in bpy.context.scene.objects:
if o.type != "MESH":
continue
ot = sum(len(f.vertices) - 2 for f in o.data.polygons)
tris += ot
p = o.matrix_world.translation
kids.append(f"{o.name}[{ot}]@({-p.x:.2f},{p.z:.2f},{-p.y:.2f})")
for m in o.data.materials:
if m:
mats.add(m.name)
for v in o.data.vertices:
w = o.matrix_world @ v.co
mn = Vector(map(min, mn, w)); mx = Vector(map(max, mx, w))
# unity space: x = -bx, y = bz, z = -by
b = (-mx.x, -mn.x, mn.z, mx.z, -mx.y, -mn.y)
return tris, b, sorted(kids), sorted(mats)
def fmt(b):
return f"x[{b[0]:.3f},{b[1]:.3f}] y[{b[2]:.3f},{b[3]:.3f}] z[{b[4]:.3f},{b[5]:.3f}] size({b[1]-b[0]:.2f}x{b[3]-b[2]:.2f}x{b[5]-b[4]:.2f})"
for n in args:
tris, b, kids, mats = measure(os.path.join(d, n + ".fbx"))
print(f"V3|{n}|tris={tris}|{fmt(b)}|{' '.join(kids)}|{','.join(mats)}")
if old and os.path.exists(os.path.join(old, n + ".fbx")):
ot, ob, ok, _ = measure(os.path.join(old, n + ".fbx"))
dev = max(abs(a - c) for a, c in zip(b, ob))
print(f"OLD|{n}|tris={ot}|{fmt(ob)}|{' '.join(ok)}|max bound delta={dev * 100:.1f} cm")