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>
64 lines
3.3 KiB
Python
64 lines
3.3 KiB
Python
"""Re-import the os_crew FBX files in a fresh scene and print objects / bones / parents / tri counts / materials,
|
|
and check the manifest names (meshes, empties, bones) exist.
|
|
Run: blender -b --factory-startup --python verify_os_crew.py -- [names]"""
|
|
import bpy, os, sys
|
|
|
|
d = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "Assets", "Art", "Models"))
|
|
REQ = {
|
|
"SM_Crew": dict(objs=["Rig", "CrewBody", "Vest", "Helmet", "Lamp", "Backpack", "TankFill", "Boot_L", "Boot_R"],
|
|
bones=["Root", "Body", "Leg_L", "Leg_R", "Arm_L", "Arm_R"], max_tris=25000),
|
|
"SM_Glove_R": dict(objs=["Glove"], max_tris=8000),
|
|
"SM_Glove_L": dict(objs=["Glove"], max_tris=8000),
|
|
"SM_Tool_HandPump": dict(objs=["Body", "Plunger", "Nozzle"], max_tris=8000),
|
|
"SM_Tool_SlurpGun": dict(objs=["Body", "Fill", "Fan", "Nozzle"], max_tris=8000),
|
|
"SM_Tool_HydroCannon": dict(objs=["Body", "Fan", "Nozzle"], max_tris=8000),
|
|
"SM_Tool_MegaSiphon": dict(objs=["Body", "Ring1", "Ring2", "Nozzle"], max_tris=8000),
|
|
}
|
|
names = (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []) or list(REQ)
|
|
|
|
|
|
def U(v): # blender -> unity
|
|
return (-v.x, v.z, -v.y)
|
|
|
|
|
|
bad = 0
|
|
for n in names:
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
bpy.ops.import_scene.fbx(filepath=os.path.join(d, n + ".fbx"))
|
|
bpy.context.view_layer.update()
|
|
total = 0
|
|
found, bones = set(), []
|
|
rows = []
|
|
for o in sorted(bpy.context.scene.objects, key=lambda o: o.name):
|
|
found.add(o.name)
|
|
par = (o.parent.name + (":" + o.parent_bone if o.parent_type == "BONE" else "")) if o.parent else "-"
|
|
org = U(o.matrix_world.translation)
|
|
if o.type == "ARMATURE":
|
|
for b in o.data.bones:
|
|
bones.append(b.name)
|
|
h = U(o.matrix_world @ b.head_local)
|
|
rows.append(f" bone {b.name:<7} parent={b.parent.name if b.parent else '-':<5} head(unity)=({h[0]:.3f},{h[1]:.3f},{h[2]:.3f})")
|
|
rows.append(f" {o.name:<10} ARMATURE parent={par}")
|
|
continue
|
|
if o.type != "MESH":
|
|
rows.append(f" {o.name:<10} {o.type} parent={par} origin(unity)=({org[0]:.3f},{org[1]:.3f},{org[2]:.3f})")
|
|
continue
|
|
tris = sum(len(f.vertices) - 2 for f in o.data.polygons)
|
|
total += tris
|
|
pts = [U(o.matrix_world @ v.co) for v in o.data.vertices]
|
|
mn = [min(p[i] for p in pts) for i in range(3)]
|
|
mx = [max(p[i] for p in pts) for i in range(3)]
|
|
mats = ",".join(m.name for m in o.data.materials if m)
|
|
vg = ",".join(g.name for g in o.vertex_groups)
|
|
skin = "skinned[" + vg + "]" if any(md.type == "ARMATURE" for md in o.modifiers) else "rigid"
|
|
rows.append(f" {o.name:<10} parent={par:<9} origin(unity)=({org[0]:.3f},{org[1]:.3f},{org[2]:.3f}) "
|
|
f"y[{mn[1]:.3f},{mx[1]:.3f}] z[{mn[2]:.3f},{mx[2]:.3f}] tris={tris} {skin} [{mats}]")
|
|
req = REQ.get(n, {})
|
|
missing = [r for r in req.get("objs", []) if r not in found] + [b for b in req.get("bones", []) if b not in bones]
|
|
over = total > req.get("max_tris", 10 ** 9)
|
|
bad += len(missing) + int(over)
|
|
print(f"CREW|{n}|tris={total}{' OVER BUDGET' if over else ''}|missing={missing or 'none'}")
|
|
for r in rows:
|
|
print(r)
|
|
print(f"CREW|RESULT|{'OK' if bad == 0 else 'PROBLEMS %d' % bad}")
|