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>
71 lines
2.8 KiB
Python
71 lines
2.8 KiB
Python
"""Re-import the os_decor FBX files and print per-object origin / bounds (Unity space) / tris / materials,
|
|
check required named children, and check tri budgets.
|
|
Run: blender -b --factory-startup --python ArtSource/Blender/scripts/verify_os_decor.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_Decor_Lamp": ["Bulb"],
|
|
"SM_Decor_Palm": [],
|
|
"SM_Decor_Bench": [],
|
|
"SM_Decor_Umbrella": [],
|
|
"SM_Decor_Flag": ["Cloth"],
|
|
"SM_Decor_Dish": ["Dish"],
|
|
"SM_Decor_Crates": [],
|
|
"SM_Decor_Lifebuoy": [],
|
|
"SM_Decor_Grill": [],
|
|
"SM_Decor_Hammock": [],
|
|
"SM_Decor_Beacon": ["Light"],
|
|
"SM_Decor_Sofa": [],
|
|
"SM_Decor_Vending": [],
|
|
"SM_Decor_Pool": ["Water"],
|
|
"SM_Decor_Gnome": [],
|
|
"SM_Spire_A": [],
|
|
"SM_Spire_B": [],
|
|
"SM_Spire_C": [],
|
|
"SM_Wreck_Ship": [],
|
|
"SM_Wreck_Probe": [],
|
|
"SM_Buoy": ["Light"],
|
|
}
|
|
BUDGET = {"SM_Spire_A": 12000, "SM_Spire_B": 12000, "SM_Spire_C": 12000, "SM_Wreck_Ship": 25000, "SM_Wreck_Probe": 10000}
|
|
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
|
|
gmn = [1e9] * 3; gmx = [-1e9] * 3
|
|
rows = []
|
|
found = set()
|
|
for o in sorted(bpy.context.scene.objects, key=lambda o: o.name):
|
|
if o.type != "MESH":
|
|
continue
|
|
found.add(o.name)
|
|
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)]
|
|
gmn = [min(a, b) for a, b in zip(gmn, mn)]; gmx = [max(a, b) for a, b in zip(gmx, mx)]
|
|
org = U(o.matrix_world.translation)
|
|
mats = ",".join(sorted({m.name for m in o.data.materials if m}))
|
|
uv = "uv" if o.data.uv_layers else "NO-UV"
|
|
rows.append(f" {o.name:<18} origin({org[0]:.3f},{org[1]:.3f},{org[2]:.3f}) x[{mn[0]:.2f},{mx[0]:.2f}] y[{mn[1]:.2f},{mx[1]:.2f}] z[{mn[2]:.2f},{mx[2]:.2f}] tris={tris} {uv} [{mats}]")
|
|
missing = [r for r in REQ.get(n, []) if r not in found]
|
|
budget = BUDGET.get(n, 4000)
|
|
over = total > budget
|
|
bad += len(missing) + (1 if over else 0)
|
|
size = [gmx[i] - gmn[i] for i in range(3)]
|
|
print(f"OSD|{n}|tris={total}/{budget}{' OVER' if over else ''}|size {size[0]:.2f} x {size[1]:.2f} x {size[2]:.2f} m (UnityXYZ)|"
|
|
f"y[{gmn[1]:.2f},{gmx[1]:.2f}]|missing={missing or 'none'}")
|
|
for r in rows:
|
|
print(r)
|
|
print(f"OSD|RESULT|{'OK' if bad == 0 else 'PROBLEMS %d' % bad}")
|