Skip to content

Commit deb4b5d

Browse files
authored
[OoT] Fix include reading for DL imports (Fast-64#691)
1 parent d517bc4 commit deb4b5d

5 files changed

Lines changed: 26 additions & 8 deletions

File tree

fast64_internal/z64/animation/importer/functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def ootImportNonLinkAnimationC(armatureObj, filepath, animName, actorScale, isCu
6969
animData = getImportData([filepath])
7070
if not isCustomImport:
7171
basePath = bpy.path.abspath(bpy.context.scene.ootDecompPath)
72-
animData = ootGetIncludedAssetData(basePath, [filepath], animData) + animData
72+
animData = ootGetIncludedAssetData([basePath], [filepath], animData) + animData
7373

7474
matchResult = re.search(re.escape(animName) + r"\s*=\s*\{(.*?)\}\s*;", animData, re.DOTALL | re.MULTILINE)
7575

@@ -195,8 +195,8 @@ def ootImportLinkAnimationC(
195195
animData = getImportData([animFilepath])
196196
if not isCustomImport:
197197
basePath = bpy.path.abspath(bpy.context.scene.ootDecompPath)
198-
animHeaderData = ootGetIncludedAssetData(basePath, [animHeaderFilepath], animHeaderData) + animHeaderData
199-
animData = ootGetIncludedAssetData(basePath, [animFilepath], animData) + animData
198+
animHeaderData = ootGetIncludedAssetData([basePath], [animHeaderFilepath], animHeaderData) + animHeaderData
199+
animData = ootGetIncludedAssetData([basePath], [animFilepath], animData) + animData
200200

201201
matchResult = re.search(
202202
re.escape(animHeaderName) + r"\s*=\s*\{(.*?)\}\s*;", animHeaderData, re.DOTALL | re.MULTILINE

fast64_internal/z64/f3d/operators.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,17 @@ def execute(self, context):
172172

173173
scale = None
174174
if not isCustomImport:
175-
filedata = ootGetIncludedAssetData(basePath, paths, filedata) + filedata
175+
filedata = (
176+
ootGetIncludedAssetData(
177+
[
178+
basePath,
179+
str(Path(basePath) / context.scene.fast64.oot.get_extracted_path()),
180+
],
181+
paths,
182+
filedata,
183+
)
184+
+ filedata
185+
)
176186

177187
if overlayName is not None:
178188
ootReadTextureArrays(basePath, overlayName, name, f3dContext, False, flipbookArrayIndex2D)

fast64_internal/z64/model_classes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,23 @@
4242

4343

4444
# read included asset data
45-
def ootGetIncludedAssetData(basePath: str, currentPaths: list[str], data: str) -> str:
45+
def ootGetIncludedAssetData(basePaths: list[str], currentPaths: list[str], data: str) -> str:
4646
includeData = ""
4747
searchedPaths = currentPaths[:]
4848

4949
print("Included paths:")
5050

5151
# search assets
5252
for includeMatch in re.finditer(r"\#include\s*\"(assets/objects/(.*?)\.h)\"", data):
53-
h_p = Path(basePath) / includeMatch.group(1)
53+
h_p = None
54+
for basePath in basePaths:
55+
candidate_h_p = Path(basePath) / includeMatch.group(1)
56+
if candidate_h_p.exists():
57+
h_p = candidate_h_p
58+
break
59+
if h_p is None:
60+
print("Could not find included file:", includeMatch.group(1))
61+
continue
5462
print("", str(h_p))
5563
includeData += getImportData([str(h_p)]) + "\n"
5664
for path_p in h_p.parent.glob("*.c"):

fast64_internal/z64/skeleton/importer/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def ootImportSkeletonC(basePath: str, importSettings: OOTSkeletonImportSettings)
316316

317317
skeletonData = getImportData(filepaths)
318318
if overlayName is not None or isLink:
319-
skeletonData = ootGetIncludedAssetData(basePath, filepaths, skeletonData) + skeletonData
319+
skeletonData = ootGetIncludedAssetData([basePath], filepaths, skeletonData) + skeletonData
320320

321321
skel_info = ootGetSkeleton(skeletonData, skeletonName, False)
322322
assert skel_info is not None

fast64_internal/z64/texture_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def ootReadTextureArrays(
2929
else:
3030
actorData = ootGetLinkData(basePath)
3131
currentPaths = [os.path.join(basePath, f"src/code/z_player_lib.c")]
32-
actorData = ootGetIncludedAssetData(basePath, currentPaths, actorData) + actorData
32+
actorData = ootGetIncludedAssetData([basePath], currentPaths, actorData) + actorData
3333

3434
actorData = removeComments(actorData)
3535

0 commit comments

Comments
 (0)