diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 6b1acc8d1c..730df36cf3 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -96,7 +96,8 @@ jobs: make check.smoke make check.vr make check.air - make check.upload + # 只在手动触发时上传 + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then make check.upload; fi shell: bash diff --git a/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Scripts/clean_meshes.py b/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Scripts/clean_meshes.py index 989de41c04..86a9064fbf 100644 --- a/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Scripts/clean_meshes.py +++ b/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Scripts/clean_meshes.py @@ -21,22 +21,23 @@ # CoACD (MIT), and libzmq (MPL 2.0). See ThirdPartyNotices.txt for details. """ -Prepare MuJoCo MJCF meshes for Unreal import. +准备 MuJoCo MJCF 网格以供 Unreal 导入。 -Parses an MJCF XML, converts all referenced meshes (OBJ, STL) to GLB, -resolves naming conflicts (e.g., link1.obj and link1.stl both becoming link1.glb), -and writes an updated XML ready for drag-and-drop import into Unreal. +解析 MJCF XML(展开 文件),将所有引用的网格文件(OBJ、STL)转换为 GLB 格式, +解决命名冲突(例如 link1.obj 和 link1.stl 均被转为 link1.glb),并生成更新后的 XML 文件, +可直接拖拽导入 Unreal. -Installation: +安装: pip install trimesh numpy -Usage: +用法: python clean_meshes_trimesh.py -Example: +示例: python clean_meshes_trimesh.py "path/to/mujoco_menagerie/franka_emika_panda/panda.xml" """ + import trimesh import numpy as np from pathlib import Path @@ -46,14 +47,14 @@ def clean_mesh(mesh): - """Clean up a mesh using trimesh.""" + """使用 trimesh 清理网格。""" print(f" Original: {len(mesh.vertices)} vertices, {len(mesh.faces)} faces") mesh.merge_vertices(merge_tex=False, merge_norm=False) mesh.remove_unreferenced_vertices() mesh.fix_normals() - # Rotate -90 degrees around X for GLTF Y-up -> Unreal Z-up + # 绕 X 轴旋转 -90 度,将 GLTF 的 Y 轴向上坐标系转换为 Unreal 的 Z 轴向上坐标系 rotation_matrix = trimesh.transformations.rotation_matrix(-np.radians(90), [1, 0, 0]) mesh.apply_transform(rotation_matrix) @@ -62,7 +63,7 @@ def clean_mesh(mesh): def convert_mesh(input_path: Path, output_path: Path) -> bool: - """Convert a single mesh file to GLB.""" + """将单个网格文件转换为 GLB。""" print(f"\n Converting: {input_path.name} -> {output_path.name}") try: @@ -74,9 +75,9 @@ def convert_mesh(input_path: Path, output_path: Path) -> bool: cleaned_mesh = clean_mesh(mesh) - # Strip embedded materials/textures to prevent Unreal's Interchange importer - # from creating a Texture2D instead of a StaticMesh. - # Preserve UV coordinates so textures can be applied via material instances. + # 剥离内嵌的材质/纹理,防止 Unreal 的 Interchange 导入器 + # 将其创建为 Texture2D 而不是 StaticMesh。 + # 保留 UV 坐标,以便之后通过材质实例来应用纹理。 if hasattr(cleaned_mesh.visual, 'uv') and cleaned_mesh.visual.uv is not None: uv = cleaned_mesh.visual.uv.copy() cleaned_mesh.visual = trimesh.visual.TextureVisuals(uv=uv) @@ -104,7 +105,7 @@ def convert_mesh(input_path: Path, output_path: Path) -> bool: def process_xml(xml_path: Path): - """Parse MJCF XML, convert meshes, resolve conflicts, write updated XML.""" + """解析MJCF XML,转换网格,解决冲突,生成更新后的XML。""" if not xml_path.exists(): print(f"Error: XML file not found: {xml_path}") @@ -116,24 +117,79 @@ def process_xml(xml_path: Path): print(f"Dir: {xml_dir}") print("=" * 60) - # Parse XML + # ET.parse() 打开文件并解析整个 XML,返回一个 ElementTree 对象。 + # tree.getroot() 取出根元素。对于 MJCF 文件,根就是 标签。 tree = ET.parse(str(xml_path)) root = tree.getroot() - # Find meshdir from compiler + # 从 元素中查找 meshdir 属性 meshdir = "" for compiler in root.iter("compiler"): md = compiler.get("meshdir", "") if md: meshdir = md + # Path 的 / 运算符是路径拼接,不是算术除法。 mesh_base = xml_dir / meshdir if meshdir else xml_dir print(f"Mesh directory: {mesh_base}") - # Collect all mesh elements - mesh_elements = list(root.iter("mesh")) - - # Also convert meshes referenced by + # ------------------------------------------------------------------ + # 收集网格,递归展开 + # 相对的网格路径会相对于声明它们的文件所在目录进行解析(即 MuJoCo 的解析方式)。 + # 具有优先权,且相对于主 XML 目录。 + # ------------------------------------------------------------------ + mesh_elements = [] # (mesh_element, source_path) 列表 + # 递归展开 时的**“已访问文件”集合**,用来防止死循环和重复解析 + seen_includes = {xml_path.resolve()} + + # 递归函数:从给定节点收集网格和 ,并解析包含的文件 + def collect_from_include(node_root: ET.Element, owner_dir: Path): + base_dir = mesh_base if meshdir else owner_dir + + for mesh_el in node_root.iter("mesh"): + file_attr = mesh_el.get("file") + if not file_attr: + continue + + # 确保显式名称属性存在——如果省略,MuJoCo 默认使用文件名前缀。 + # 在更改文件属性之前,我们必须保留它。 + if mesh_el.get("name") is None: + implicit_name = Path(file_attr).stem + mesh_el.set("name", implicit_name) + print(f" Set explicit name='{implicit_name}' on mesh with file='{file_attr}'") + + # 添加网格条目:包括 mesh 元素和源文件路径 + mesh_elements.append((mesh_el, base_dir / file_attr)) + + for include_el in node_root.iter("include"): + file_attr = include_el.get("file") + if not file_attr: + continue + # resolve() 是 pathlib.Path 的方法:把路径规范化成唯一的绝对路径。 + # 它做三件事: + # 1.变成绝对路径(相对路径拼上当前工作目录) + # 2.消掉 . 和 ..(纯字符串/路径层面的规整) + # 3.解析符号链接(symlink 指向哪,就得到真实路径) + include_path = (owner_dir / file_attr).resolve() + if include_path in seen_includes: + continue + seen_includes.add(include_path) + if not include_path.exists(): + print(f" x Included file not found: {include_path}") + continue + print(f" Expanding include: {include_path}") + try: + # 得到include的文件中的根节点 + include_root = ET.parse(str(include_path)).getroot() + except ET.ParseError as e: + print(f" x Failed to parse {include_path}: {e}") + continue + # 再看include文件中的 ,递归展开 + collect_from_include(include_root, include_path.parent) + + collect_from_include(root, xml_dir) + + # 转换由 引用的网格(也包括来自 include 文件的网格)。 for flexcomp in root.iter("flexcomp"): file_attr = flexcomp.get("file") if file_attr: @@ -148,77 +204,63 @@ def process_xml(xml_path: Path): print(f"Found {len(mesh_elements)} mesh assets in XML\n") - # Phase 1: Plan output filenames, detect conflicts - # Map: glb_stem -> list of (mesh_element, source_path) + # 阶段 1:规划输出文件名,检测冲突。 + # 映射:glb_stem -> (mesh_element, source_path) 列表 stem_usage = {} - for mesh_el in mesh_elements: - file_attr = mesh_el.get("file") - if not file_attr: - continue - - source_path = mesh_base / file_attr - glb_stem = source_path.stem # e.g., "link1" from "link1.stl" - - # Ensure explicit name attribute exists — MuJoCo defaults to filename stem - # if omitted. We must preserve it before changing the file attribute. - if mesh_el.get("name") is None: - implicit_name = Path(file_attr).stem - mesh_el.set("name", implicit_name) - print(f" Set explicit name='{implicit_name}' on mesh with file='{file_attr}'") - + for mesh_el, source_path in mesh_elements: + glb_stem = source_path.stem # 例如,从 "/…/assets/geometry/link1.stl" 得到 "link1" if glb_stem not in stem_usage: stem_usage[glb_stem] = [] stem_usage[glb_stem].append((mesh_el, source_path)) - # Phase 2: Assign unique output names and resolve conflicts - # For each mesh: keep the original format (OBJ/STL) in the XML (MuJoCo needs it), - # but rename conflicting files so their stems are unique. Then convert each to GLB - # alongside — Unreal's importer will find the GLB via "higher priority" fallback. - # - # output_plan: list of (mesh_element, source_path, renamed_source_path, output_glb_path, new_file_attr) + # 阶段 2:分配唯一的输出名称并解决冲突 + # 对于每个网格:在 XML 中保留原始格式(OBJ/STL)(MuJoCo 需要它), + # 但重命名冲突的文件,使其文件名主干唯一。然后将每个网格一并转换为 GLB—— + # Unreal 的导入器会通过“更高优先级”的回退机制找到 GLB。 + # output_plan:由 (mesh_el, original_source, actual_source, output_glb) 组成的列表 import shutil output_plan = [] conflicts_found = 0 for glb_stem, entries in stem_usage.items(): if len(entries) == 1: - # No conflict + # 无冲突 mesh_el, source_path = entries[0] output_glb = source_path.with_suffix(".glb") - # file attr stays unchanged in the XML + # XML 中的 file 属性保持不变 output_plan.append((mesh_el, source_path, source_path, output_glb)) else: - # Conflict — multiple source files share the same stem + # 冲突——多个源文件共用同一主干名 conflicts_found += len(entries) - 1 print(f" CONFLICT: {len(entries)} files map to stem '{glb_stem}':") for i, (mesh_el, source_path) in enumerate(entries): mesh_name = mesh_el.get("name", "?") print(f" [{i}] mesh name='{mesh_name}' <- {source_path.name}") - # First one keeps original name, rest get a counter suffix + # 第一个保留原始名称,其余添加计数后缀 for i, (mesh_el, source_path) in enumerate(entries): if i == 0: - # No rename needed + # 无需重命名 output_glb = source_path.with_suffix(".glb") output_plan.append((mesh_el, source_path, source_path, output_glb)) else: - # Rename: link1.stl -> link1_1.stl, link1_1.glb - # Save to meshdir root (not the source subdirectory) so the - # XML file attribute stays a simple filename relative to meshdir. + # 重命名:link1.stl -> link1_1.stl,link1_1.glb + # 保存到 meshdir 根目录(而不是源文件所在子目录), + # 这样 XML 的 file 属性可以保持为相对于 meshdir 的简单文件名。 new_stem = f"{glb_stem}_{i}" ext = source_path.suffix # .stl, .obj, etc. renamed_source = mesh_base / f"{new_stem}{ext}" output_glb = mesh_base / f"{new_stem}.glb" - # Update XML file attribute (relative to meshdir) + # 更新 XML 的 file 属性(相对于 meshdir) new_file_attr = f"{new_stem}{ext}" mesh_el.set("file", new_file_attr) mesh_name = mesh_el.get("name", "?") print(f" -> Renaming '{mesh_name}': {source_path.name} -> {new_stem}{ext}") - # Copy the source file to the new name + # 将源文件复制到新名称 if not source_path.exists(): print(f" x Source file missing: {source_path} — skipping") continue @@ -231,7 +273,7 @@ def process_xml(xml_path: Path): print(f"\n{len(output_plan)} meshes to convert, {conflicts_found} naming conflicts resolved") print("=" * 60) - # Phase 3: Convert meshes to GLB (alongside the originals) + # 阶段 3:将网格转换为 GLB(与原文件放在同一目录) success_count = 0 for mesh_el, original_source, actual_source, output_glb in output_plan: mesh_name = mesh_el.get("name", "?") @@ -240,7 +282,7 @@ def process_xml(xml_path: Path): print(f"\n x Source not found: {actual_source}") continue - # Skip if GLB already exists and is newer than source + # 如果 GLB 已存在且比源文件新,则跳过 if output_glb.exists() and output_glb.stat().st_mtime > actual_source.stat().st_mtime: print(f"\n Skipping '{mesh_name}' (GLB up to date): {output_glb.name}") success_count += 1 @@ -252,7 +294,7 @@ def process_xml(xml_path: Path): else: print(f" x FAILED to convert {actual_source.name}") - # Phase 4: Write updated XML + # 阶段 4:写出更新后的 XML output_xml = xml_path.parent / f"{xml_path.stem}_ue.xml" tree.write(str(output_xml), encoding="unicode", xml_declaration=True) diff --git a/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MjPythonHelper.cpp b/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MjPythonHelper.cpp index 3b11adb09f..fffb5b7209 100644 --- a/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MjPythonHelper.cpp +++ b/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MjPythonHelper.cpp @@ -68,7 +68,7 @@ FString FMjPythonHelper::GetStoredPythonOverride() FString FileContent; if (!FFileHelper::LoadFileToString(FileContent, *IniPath)) return FString(); - // Parse simple INI: look for PythonPath= line + // 解析简单的 INI 文件:查找 PythonPath= 行 TArray Lines; FileContent.ParseIntoArrayLines(Lines); for (const FString& Line : Lines) @@ -101,21 +101,21 @@ void FMjPythonHelper::StorePythonOverride(const FString& PythonPath) FString FMjPythonHelper::ResolvePythonPath() { - // 1. Check user override + // 1. 检查用户覆盖设置 FString Override = GetStoredPythonOverride(); if (!Override.IsEmpty() && FPaths::FileExists(Override)) { return Override; } - // 2. Fall back to UE's bundled Python + // 2. 回退到 UE 内置的 Python FString Bundled = GetUEBundledPythonPath(); if (FPaths::FileExists(Bundled)) { return Bundled; } - // 3. Try system PATH as last resort + // 3. 尝试使用 PATH 系统作为最后手段 return TEXT("python"); } @@ -179,36 +179,37 @@ bool FMjPythonHelper::InstallPythonPackages(const FString& PythonPath, FString& FString FMjPythonHelper::EnsurePythonReady(bool& bOutCancelled) { bOutCancelled = false; + // 这台机器上还没有保存过 Python 解释器路径配置 bool bNeedsFirstTimeSetup = GetStoredPythonOverride().IsEmpty(); FString PythonPath = ResolvePythonPath(); bool bIsUEBundled = (PythonPath == GetUEBundledPythonPath()); - // Validate the resolved Python + // 验证已解析的 Python if (!ValidatePythonBinary(PythonPath)) { - FText Title = FText::FromString(TEXT("Python Interpreter Not Found")); + FText Title = FText::FromString(TEXT("未找到 Python 解释器")); FText Message = FText::FromString(FString::Printf( - TEXT("URLab uses Python to preprocess mesh files during MJCF import.\n\n") - TEXT("This is needed because Unreal Engine does not natively support all mesh formats ") - TEXT("used by MuJoCo (e.g. STL, OBJ with certain features). The preprocessing step ") - TEXT("converts meshes to a compatible format and resolves asset conflicts.\n\n") - TEXT("Could not find a valid Python interpreter at:\n%s\n\n") - TEXT("Click 'Yes' to browse for your Python interpreter, or 'Cancel' to cancel the import."), + TEXT("URLab 在 MJCF 导入过程中使用 Python 对网格文件进行预处理。\n\n") + TEXT("这是因为 Unreal Engine 原生不支持 MuJoCo 使用的所有网格格式") + TEXT("(例如 STL、某些带特殊特性的 OBJ)。预处理步骤会把网格转换为") + TEXT("兼容格式,并解决资产命名冲突。\n\n") + TEXT("在以下路径未找到有效的 Python 解释器:\n%s\n\n") + TEXT("点击“是”浏览选择 Python 解释器,或点击“取消”取消本次导入。"), *PythonPath)); - // EAppReturnType::Type Result = FMessageDialog::Open(EAppMsgType::YesNoCancel, Message, Title); - // if (Result == EAppReturnType::Cancel) - // { - // bOutCancelled = true; - // return FString(); - // } - // if (Result == EAppReturnType::No) - // { - // return FString(); // Skip preprocessing - // } - - // Browse for Python + EAppReturnType::Type Result = FMessageDialog::Open(EAppMsgType::YesNoCancel, Message, &Title); + if (Result == EAppReturnType::Cancel) + { + bOutCancelled = true; + return FString(); + } + if (Result == EAppReturnType::No) + { + return FString(); // 跳过预处理 + } + + // 浏览 Python PythonPath = BrowseForPython(); if (PythonPath.IsEmpty()) { @@ -218,113 +219,116 @@ FString FMjPythonHelper::EnsurePythonReady(bool& bOutCancelled) bIsUEBundled = false; } - // Show package dialog if packages are missing or first-time setup + // 如果缺少软件包或首次设置,显示软件包对话框 if (!CheckPythonPackages(PythonPath) || bNeedsFirstTimeSetup) { FString EnvLabel = bIsUEBundled - ? TEXT("Unreal Engine's bundled Python") - : FString::Printf(TEXT("your selected Python at:\n%s"), *PythonPath); + ? TEXT("Unreal Engine 自带的 Python 环境") + : FString::Printf(TEXT("你选择的 Python:\n%s"), *PythonPath); bool bPackagesPresent = CheckPythonPackages(PythonPath); FText Title = FText::FromString(bPackagesPresent - ? TEXT("Python Setup") - : TEXT("Python Packages Required")); + ? TEXT("Python 环境设置") + : TEXT("需要安装 Python 软件包")); // Button mapping: Yes = proceed, No = browse for different Python, Cancel = abort import FString MessageStr; if (bPackagesPresent) { MessageStr = FString::Printf( - TEXT("URLab uses Python to preprocess mesh files during MJCF import.\n\n") - TEXT("Required packages are already installed in %s.\n\n") - TEXT("Click 'Yes' to use this Python, 'No' to choose a different interpreter, ") - TEXT("or 'Cancel' to cancel the import."), + TEXT("URLab 在 MJCF 导入过程中使用 Python 对网格文件进行预处理。\n\n") + TEXT("所需软件包已在 %s 中安装。\n\n") + TEXT("点击“是”使用此 Python,点击“否”选择其他解释器,") + TEXT("或点击“取消”取消导入。"), *EnvLabel); } else { MessageStr = FString::Printf( - TEXT("URLab needs the 'trimesh', 'numpy', and 'scipy' Python packages to preprocess mesh files.\n\n") - TEXT("Unreal Engine does not natively support all mesh formats used by MuJoCo, ") - TEXT("so these packages are used to convert and prepare meshes for import.\n\n") - TEXT("These will be installed to %s.\n\n") - TEXT("Install now?\n\n") - TEXT("Note: The editor will be unresponsive during installation. ") - TEXT("This may take a minute.\n\n") - TEXT("Alternatively, you can install these manually in your preferred Python environment:\n") + TEXT("URLab 需要 'trimesh'、'numpy'、'scipy' 这些 Python 软件包来预处理网格文件。\n\n") + TEXT("Unreal Engine 原生不支持 MuJoCo 使用的所有网格格式,") + TEXT("因此需要这些软件包来转换并准备要导入的网格。\n\n") + TEXT("这些软件包将安装到:%s\n\n") + TEXT("现在安装吗?\n\n") + TEXT("注意:安装期间编辑器会暂时无响应,") + TEXT("可能需要几分钟左右。\n\n") + TEXT("你也可以在自己的 Python 环境中手动安装:\n") TEXT(" -m pip install trimesh numpy scipy\n") - TEXT("Then set the path in Config/LocalUnrealRoboticsLab.ini in the plugin directory.\n\n") - TEXT("Click 'Yes' to install, 'No' to choose a different interpreter, ") - TEXT("or 'Cancel' to cancel the import."), + TEXT("然后在插件目录的 Config/LocalUnrealRoboticsLab.ini 中设置解释器路径。\n\n") + TEXT("点击“是”开始安装,点击“否”选择其他解释器,") + TEXT("或点击“取消”取消导入。"), *EnvLabel); } - // EAppReturnType::Type Result; // = FMessageDialog::Open(EAppMsgType::YesNoCancel, - // FText::FromString(MessageStr), Title); - - // if (Result == EAppReturnType::Cancel) - // { - // bOutCancelled = true; - // return FString(); - // } - // else if (Result == EAppReturnType::No) - // { - // PythonPath = BrowseForPython(); - // if (PythonPath.IsEmpty()) - // { - // bOutCancelled = true; - // return FString(); - // } -// - // // Re-check packages with new Python - // if (CheckPythonPackages(PythonPath)) - // { - // UE_LOG(LogURLabEditor, Log, TEXT("[Python] Packages already available in selected Python.")); - // StorePythonOverride(PythonPath); - // return PythonPath; - // } -// - // bPackagesPresent = false; -// - // // Ask to install for the new Python - // FText InstallMsg = FText::FromString(FString::Printf( - // TEXT("Install 'trimesh', 'numpy', and 'scipy' to:\n%s?\n\n") - // TEXT("The editor will be unresponsive during installation.\n\n") - // TEXT("Click 'Cancel' to cancel the import."), *PythonPath)); - // // if (FMessageDialog::Open(EAppMsgType::OkCancel, InstallMsg, Title) == EAppReturnType::Cancel) - // // { - // // bOutCancelled = true; - // // return FString(); - // // } - // } - - // Install packages if not already present + EAppReturnType::Type Result = FMessageDialog::Open(EAppMsgType::YesNoCancel, + FText::FromString(MessageStr), &Title); + + if (Result == EAppReturnType::Cancel) + { + bOutCancelled = true; + return FString(); + } + else if (Result == EAppReturnType::No) + { + PythonPath = BrowseForPython(); + if (PythonPath.IsEmpty()) + { + bOutCancelled = true; + return FString(); + } + + // Re-check packages with new Python + if (CheckPythonPackages(PythonPath)) + { + UE_LOG(LogURLabEditor, Log, TEXT("[Python] Packages already available in selected Python.")); + StorePythonOverride(PythonPath); + return PythonPath; + } + + bPackagesPresent = false; + + // Ask to install for the new Python + FText InstallMsg = FText::FromString(FString::Printf( + TEXT("将 'trimesh'、'numpy'、'scipy' 安装到:\n%s?\n\n") + TEXT("安装期间编辑器会暂时无响应。\n\n") + TEXT("点击“取消”将取消本次导入。"), *PythonPath)); + if (FMessageDialog::Open(EAppMsgType::OkCancel, InstallMsg, &Title) == EAppReturnType::Cancel) + { + bOutCancelled = true; + return FString(); + } + } + + // 如果尚未安装,请安装相关软件包 if (!bPackagesPresent) { FString InstallLog; + const FText FailureTitle = FText::FromString(TEXT("软件包安装失败")); if (!InstallPythonPackages(PythonPath, InstallLog)) { - // FMessageDialog::Open(EAppMsgType::Ok, - // FText::FromString(FString::Printf( - // TEXT("Failed to install packages. You can install them manually by running:\n\n") - // TEXT("%s -m pip install trimesh numpy scipy\n\n") - // TEXT("Error log:\n%s"), - // *PythonPath, *InstallLog)), - // FText::FromString(TEXT("Package Install Failed"))); + FMessageDialog::Open(EAppMsgType::Ok, + FText::FromString(FString::Printf( + TEXT("软件包安装失败。你可以手动运行以下命令安装:\n\n") + TEXT("%s -m pip install trimesh numpy scipy\n\n") + TEXT("错误日志:\n%s"), + *PythonPath, *InstallLog)), + &FailureTitle); return FString(); } if (!CheckPythonPackages(PythonPath)) { - // FMessageDialog::Open(EAppMsgType::Ok, - // FText::FromString(TEXT("Packages were installed but still cannot be imported. Check your Python environment.")), - // FText::FromString(TEXT("Package Verification Failed"))); + const FText VerifyTitle = FText::FromString(TEXT("软件包验证失败")); + FMessageDialog::Open(EAppMsgType::Ok, + FText::FromString(TEXT("软件包已安装,但仍然无法导入。请检查你的 Python 环境。")), + &VerifyTitle); return FString(); } } } + // 把当前选定的 Python 解释器绝对路径保存成本机配置,供下次导入直接复用。 StorePythonOverride(PythonPath); UE_LOG(LogURLabEditor, Log, TEXT("[Python] Ready: %s"), *PythonPath); return PythonPath; @@ -338,13 +342,13 @@ FString FMjPythonHelper::BrowseForPython() { DesktopPlatform->OpenFileDialog( FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr), - TEXT("Select Python Interpreter"), + TEXT("选择 Python 解释器"), TEXT(""), TEXT(""), #if PLATFORM_WINDOWS - TEXT("Python Executable (*.exe)|*.exe"), + TEXT("Python 可执行文件 (*.exe)|*.exe"), #else - TEXT("All Files (*)|*"), + TEXT("所有文件 (*)|*"), #endif 0, OutFiles); } @@ -354,9 +358,10 @@ FString FMjPythonHelper::BrowseForPython() FString PythonPath = OutFiles[0]; if (!ValidatePythonBinary(PythonPath)) { - // FMessageDialog::Open(EAppMsgType::Ok, - // FText::FromString(FString::Printf(TEXT("'%s' is not a valid Python interpreter."), *PythonPath)), - // FText::FromString(TEXT("Invalid Python"))); + const FText Title = FText::FromString(TEXT("无效的 Python")); + FMessageDialog::Open(EAppMsgType::Ok, + FText::FromString(FString::Printf(TEXT("“%s”不是有效的 Python 解释器。"), *PythonPath)), + &Title); return FString(); } diff --git a/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MujocoMeshImporter.cpp b/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MujocoMeshImporter.cpp index cd56e5d92d..cad2b0bfd8 100644 --- a/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MujocoMeshImporter.cpp +++ b/Unreal/CarlaUE4/Plugins/UnrealRoboticsLab/Source/URLabEditor/Private/MujocoMeshImporter.cpp @@ -205,6 +205,13 @@ UStaticMesh* UMujocoGenerationAction::AttemptMeshImport(const FString& SourcePat { if (Obj) ImportedAssets.Add(Obj); } + for (const FString& ObjectPath : ImportTask->ImportedObjectPaths) + { + if (UObject* ImportedObject = LoadObject(nullptr, *ObjectPath)) + { + ImportedAssets.AddUnique(ImportedObject); + } + } // 记录所有导入的资产以进行调试 UE_LOG(LogURLabEditor, Log, TEXT("[ImportSingleMesh] Import returned %d objects:"), ImportedAssets.Num()); diff --git a/Util/download_from_git.py b/Util/download_from_git.py index c6275ff0b2..30b82024c7 100644 --- a/Util/download_from_git.py +++ b/Util/download_from_git.py @@ -551,12 +551,9 @@ def remove_readonly(func, path, _): commit_msg = f"{latest_file_name} - upload chunk {idx}/{total_chunks}" repo.repo.git.commit("-m", commit_msg) - # 3. 执行推送。结合上文可能有 reset_hard,首个包强制覆盖,后续包常规追加 + # 3. 执行推送。 try: - if idx == 1: - repo.repo.git.push(force=True) - else: - repo.repo.git.push() + repo.repo.git.push() print(f"Chunk {idx} successfully pushed.") except Exception as e: print(f"Failed to push chunk {idx}. Error: {e}")