From 36d34ff6f726bb8bcb99ccab75f005f154500889 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sun, 8 Mar 2026 10:09:22 +0100 Subject: [PATCH 1/2] Fix DL importer for importing committed assets --- fast64_internal/z64/f3d/operators.py | 23 +++++++++++++---- fast64_internal/z64/model_classes.py | 38 +++++++++++++++++----------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/fast64_internal/z64/f3d/operators.py b/fast64_internal/z64/f3d/operators.py index 533b29bbe..7d0118836 100644 --- a/fast64_internal/z64/f3d/operators.py +++ b/fast64_internal/z64/f3d/operators.py @@ -1,5 +1,6 @@ import bpy import os +from pathlib import Path import mathutils from bpy.types import Operator @@ -127,7 +128,7 @@ def execute(self, context): try: settings: OOTDLImportSettings = context.scene.fast64.oot.DLImportSettings name = settings.name - folderName = settings.folder + folderName: str = settings.folder importPath = abspath(settings.customPath) isCustomImport = settings.isCustom basePath = abspath(context.scene.ootDecompPath) if not isCustomImport else os.path.dirname(importPath) @@ -138,10 +139,22 @@ def execute(self, context): flipbookUses2DArray = settings.flipbookUses2DArray flipbookArrayIndex2D = settings.flipbookArrayIndex2D if flipbookUses2DArray else None - paths = [ - ootGetObjectPath(isCustomImport, importPath, folderName, True), - ootGetObjectHeaderPath(isCustomImport, importPath, folderName, True), - ] + paths = None + + # Check if folderName exists under assets/objects (if it is committed) + if not isCustomImport: + assets_folder = Path(abspath(context.scene.ootDecompPath)) / "assets" / "objects" / folderName + if assets_folder.exists(): + paths = list(map(str, assets_folder.glob("*.[ch]"))) + if not paths: + paths = None + + # Otherwise search in extracted/ + if paths is None: + paths = [ + ootGetObjectPath(isCustomImport, importPath, folderName, True), + ootGetObjectHeaderPath(isCustomImport, importPath, folderName, True), + ] filedata = getImportData(paths) f3dContext = OOTF3DContext(get_F3D_GBI(), [name], basePath) diff --git a/fast64_internal/z64/model_classes.py b/fast64_internal/z64/model_classes.py index 0d676e905..7a006ae01 100644 --- a/fast64_internal/z64/model_classes.py +++ b/fast64_internal/z64/model_classes.py @@ -1,5 +1,6 @@ import bpy import os +from pathlib import Path import re import mathutils @@ -48,22 +49,29 @@ def ootGetIncludedAssetData(basePath: str, currentPaths: list[str], data: str) - print("Included paths:") # search assets - for includeMatch in re.finditer(r"\#include\s*\"(assets/objects/(.*?))\.h\"", data): - path = os.path.join(basePath, includeMatch.group(1) + ".c") - if path in searchedPaths: - continue - searchedPaths.append(path) - subIncludeData = getImportData([path]) + "\n" - includeData += subIncludeData - print(path) - - for subIncludeMatch in re.finditer(r"\#include\s*\"(((?![/\"]).)*)\.c\"", subIncludeData): - subPath = os.path.join(os.path.dirname(path), subIncludeMatch.group(1) + ".c") - if subPath in searchedPaths: + for includeMatch in re.finditer(r"\#include\s*\"(assets/objects/(.*?)\.h)\"", data): + h_p = Path(basePath) / includeMatch.group(1) + print("", str(h_p)) + includeData += getImportData([str(h_p)]) + "\n" + for path_p in h_p.parent.glob("*.c"): + path = str(path_p) + if path in searchedPaths: continue - searchedPaths.append(subPath) - print(subPath) - includeData += getImportData([subPath]) + "\n" + searchedPaths.append(path) + subIncludeData = getImportData([path]) + "\n" + includeData += subIncludeData + print(" ", path) + + for subIncludeMatch in re.finditer(r"\#include\s*\"(((?![/\"]).)*\.[ch])\"", subIncludeData): + sub_inc_p = Path(path).parent / subIncludeMatch.group(1) + subPath = str(sub_inc_p) + if subPath in searchedPaths: + continue + searchedPaths.append(subPath) + print(" ", subPath) + includeData += getImportData([subPath]) + "\n" + + print("More included paths:") # search same directory c includes, both in current path and in included object files # these are usually fast64 exported files From 5b138d535e8fc32e479a60b947ba293125d67b00 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sun, 8 Mar 2026 10:09:31 +0100 Subject: [PATCH 2/2] Fix skeleton importer for importing committed assets --- .../z64/skeleton/importer/functions.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/fast64_internal/z64/skeleton/importer/functions.py b/fast64_internal/z64/skeleton/importer/functions.py index 757ebe47c..3197e73a1 100644 --- a/fast64_internal/z64/skeleton/importer/functions.py +++ b/fast64_internal/z64/skeleton/importer/functions.py @@ -267,10 +267,21 @@ def ootImportSkeletonC(basePath: str, importSettings: OOTSkeletonImportSettings) isLink = False restPoseData = None - filepaths = [ - ootGetObjectPath(isCustomImport, importPath, folderName, True), - ootGetObjectHeaderPath(isCustomImport, importPath, folderName, True), - ] + filepaths = None + + # Check if folderName exists under assets/objects (if it is committed) + if not isCustomImport: + assets_folder = Path(bpy.path.abspath(bpy.context.scene.ootDecompPath)) / "assets" / "objects" / folderName + if assets_folder.exists(): + filepaths = list(map(str, assets_folder.glob("*.[ch]"))) + if not filepaths: + filepaths = None + + if filepaths is None: + filepaths = [ + ootGetObjectPath(isCustomImport, importPath, folderName, True), + ootGetObjectHeaderPath(isCustomImport, importPath, folderName, True), + ] if isLink: filepaths.append(ootGetObjectPath(isCustomImport, "", "gameplay_keep", True))