One directory with sixty scripts stopped being navigable, and the grouping is also the sandbox boundary:
Tools/unreal/ commandlets and the two map builders, with ue_common.py and ue_placement.py as the
shared imports (they need the engine)
Tools/blender/ builders, exporters, the FBX preset, the MPFB character pipeline, blender_screenshots
(they need the Blender Flatpak)
Tools/review/ the visual loop: render_screenshots.sh, judge_screenshot.py, hero_compare.py,
build_comparison_md.py, e2e_asset_check.py, hero_iterate.sh, visual_loop.py,
visual_targets.json
Tools/gen/ image and texture generation: the ComfyUI driver, deterministic texture writers,
reference fetching
Tools/input/ OS-level input injection
root _common.py, check-lfs.sh, addon_compat_probe.py, sibling_asset_audit.py, tests/
Every moved script now resolves the repository root as ../.. and puts the tools root plus its siblings on
sys.path, so 'import ue_common' still works from unreal/. The test suite bootstrap does the same for the five
folders. render_screenshots.sh takes the folder as a third argument to run_cmdlet, and the e2e driver,
hero_iterate.sh and the comparison generator were repointed.
51 README rows now link to their new location, the README gains a Layout section naming each folder's
sandbox, and the architecture notes and Blender README follow the moves.
Verified: 108 tests pass, prettier is clean, judge_screenshot.py and hero_compare.py run from their new
homes, and the e2e run was aborted mid-way (it had been rebuilding an empty DemoMap for 15 minutes) and is
being rerun against the new layout.
128 lines
5.3 KiB
Python
128 lines
5.3 KiB
Python
# Import the Blender site meshes (terrain, road, sidewalks, kerbs) into Unreal.
|
|
#
|
|
# blender ... --python Art/blender/site/export_site_fbx.py -- --out /tmp/gigline/site
|
|
# <engine>/.../UnrealEditor-Cmd <uproject> -run=pythonscript \
|
|
# -script=<repo>/Tools/unreal/ue_import_site.py -nullrhi -unattended -nopause -stdout
|
|
#
|
|
# Each mesh is a separate FBX because they carry different materials and want
|
|
# different collision settings (terrain and street are walkable surfaces).
|
|
# Destination: /Game/Hollywood/Site/<name>.
|
|
#
|
|
# Y-axis note: the FBX preset maps Blender +Y (north) to Unreal -Y, so the site
|
|
# arrives in the same frame as the hero facade. Nothing is mirrored here.
|
|
|
|
import glob
|
|
import os
|
|
|
|
import unreal
|
|
|
|
SRC = "/tmp/gigline/site"
|
|
DEST = "/Game/Hollywood/Site"
|
|
RESULT = "/tmp/gigline/site-import.txt"
|
|
lines = []
|
|
|
|
|
|
def log(msg):
|
|
lines.append(str(msg))
|
|
unreal.log(str(msg))
|
|
|
|
|
|
def import_fbx(path, name, collision="complex"):
|
|
# 5.8 note: there is no FBX import 'no collision' switch exposed to Python;
|
|
# a default import simply generates no collision primitives, so collision="none"
|
|
# means: skip the trace-flag step below and leave the body setup empty.
|
|
task = unreal.AssetImportTask()
|
|
task.filename = path
|
|
task.destination_path = DEST
|
|
task.destination_name = name
|
|
task.automated = True
|
|
task.save = True
|
|
task.replace_existing = True
|
|
|
|
ui = unreal.FbxImportUI()
|
|
ui.import_mesh = True
|
|
ui.import_materials = True
|
|
ui.import_textures = False
|
|
ui.import_as_skeletal = False
|
|
smd = ui.static_mesh_import_data
|
|
smd.import_uniform_scale = 1.0
|
|
smd.combine_meshes = True
|
|
smd.convert_scene_unit = False
|
|
smd.force_front_x_axis = False
|
|
smd.normal_import_method = unreal.FBXNormalImportMethod.FBXNIM_IMPORT_NORMALS
|
|
# Generate collision at import. A default FBX static-mesh import creates NO
|
|
# collision primitives, so CTF_USE_COMPLEX_AS_SIMPLE later has nothing to use
|
|
# and the player falls through the walkable surfaces (observed at runtime:
|
|
# ground trace under the spawn hits nothing). auto_generate_collision bakes
|
|
# collision geometry into the mesh so the walkable plane actually blocks.
|
|
smd.auto_generate_collision = True
|
|
task.options = ui
|
|
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
|
|
|
mesh = unreal.EditorAssetLibrary.load_asset(f"{DEST}/{name}")
|
|
if mesh is None:
|
|
log(f"MISSING after import: {DEST}/{name}")
|
|
return
|
|
# Collision is requested at import time so the 0.1.0 walkability check has
|
|
# something to stand on. Terrain and street get complex-as-simple: a simple
|
|
# hull would ramp straight over the kerbs.
|
|
#
|
|
# UE 5.8 exposes this only through the body setup's trace flag (the mesh itself
|
|
# has no trace-flag property, and the subsystem has no setter in Python), so
|
|
# the import path sets the body setup's trace flag, then verifies it by reading
|
|
# it back.
|
|
if collision == "none":
|
|
box = mesh.get_bounding_box()
|
|
mn, mx = box.min, box.max
|
|
log(f"{name:18} import ok size=({mx.x - mn.x:.0f}, {mx.y - mn.y:.0f}, {mx.z - mn.z:.0f}) cm "
|
|
f"min_z={mn.z:.1f} collision=none")
|
|
return
|
|
# Walkable surfaces block with SIMPLE + COMPLEX collision so the player's
|
|
# capsule always has ground: CFG_USE_SIMPLE_AND_COMPLEX uses the auto-
|
|
# generated simple collision AND the mesh triangles. (Complex-as-simple
|
|
# alone only worked if the mesh carried complex collision, which a default
|
|
# FBX static-mesh import does not.)
|
|
trace = unreal.CollisionTraceFlag.CTF_USE_SIMPLE_AND_COMPLEX
|
|
try:
|
|
body = mesh.get_editor_property("body_setup")
|
|
body.set_editor_property("collision_trace_flag", trace)
|
|
mesh.set_editor_property("body_setup", body)
|
|
except Exception as exc: # noqa: BLE001 - report, do not fail the whole import
|
|
log(f"{name}: could not set trace flag ({exc}); leaving the default")
|
|
box = mesh.get_bounding_box()
|
|
mn, mx = box.min, box.max
|
|
log(f"{name:18} import ok size=({mx.x - mn.x:.0f}, {mx.y - mn.y:.0f}, {mx.z - mn.z:.0f}) cm "
|
|
f"min_z={mn.z:.1f} collision={collision}")
|
|
|
|
|
|
def main():
|
|
files = sorted(glob.glob(os.path.join(SRC, "*.fbx")))
|
|
if not files:
|
|
log(f"no FBX in {SRC}; run Art/blender/site/export_site_fbx.py first")
|
|
return
|
|
for path in files:
|
|
stem = os.path.splitext(os.path.basename(path))[0]
|
|
# Crossing markings are paint on the road surface — no collision at all,
|
|
# so the player never stands on a 1 cm lip at the band edges.
|
|
if stem == "Crossing_Markings":
|
|
import_fbx(path, stem, "none")
|
|
continue
|
|
# Segmented ground surfaces keep their names with a numeric suffix; both the base
|
|
# names and the slices want the same walkable collision.
|
|
walkable = ("Terrain_DEM", "Road_Hollywood", "Road_Hollywood_",
|
|
"Sidewalk_South", "Sidewalk_North", "Kerb_South", "Kerb_North")
|
|
collision = "complex" if any(stem.startswith(w) for w in walkable) else "simple"
|
|
import_fbx(path, stem, collision)
|
|
unreal.EditorLoadingAndSavingUtils.save_dirty_packages(True, True)
|
|
|
|
|
|
try:
|
|
main()
|
|
except Exception as exc: # noqa: BLE001
|
|
import traceback
|
|
log(f"FAILED: {type(exc).__name__}: {exc}")
|
|
log(traceback.format_exc())
|
|
|
|
with open(RESULT, "w") as f:
|
|
f.write("\n".join(lines) + "\n")
|