MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / flatten_includes

Function flatten_includes

Scripts/clean_meshes.py:203–217  ·  view source on GitHub ↗

Resolve every into a single self-contained tree. gym-aloha (and many MJCF models) split a robot across fragments rooted in , including files referenced from inside . Unreal's importer must see one flat document so all /<compi

(root, root_dir: Path)

Source from the content-addressed store, hash-verified

201 return
202 visited.add(inc_path)
203 inc_root = ET.parse(str(inc_path)).getroot()
204 inc_dir = inc_path.parent
205 imd, itxd, iad = _compiler_dirs(inc_root)
206 # Splice the included root's children directly into the current parent.
207 for child in list(inc_root):
208 _append_expanded(out_parent, child, inc_dir, root_dir, imd, itxd, iad, visited)
209 return
210
211 # Regular element: shallow-copy attributes, then recurse into children.
212 new_elem = ET.SubElement(out_parent, elem.tag, dict(elem.attrib))
213 new_elem.text = elem.text
214 new_elem.tail = elem.tail
215
216 if elem.tag in _ASSET_FILE_TAGS:
217 _rewrite_asset_path(new_elem, src_dir, root_dir, meshdir, texturedir, assetdir)
218 elif elem.tag == "compiler":
219 # Paths are now baked into each file=, so clear the dir prefixes.
220 for attr in ("meshdir", "texturedir", "assetdir"):

Callers 1

process_xmlFunction · 0.85

Calls 2

_compiler_dirsFunction · 0.85
_append_expandedFunction · 0.85

Tested by

no test coverage detected