Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions fast64_internal/z64/f3d/operators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bpy
import os
from pathlib import Path
import mathutils

from bpy.types import Operator
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
38 changes: 23 additions & 15 deletions fast64_internal/z64/model_classes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bpy
import os
from pathlib import Path
import re
import mathutils

Expand Down Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions fast64_internal/z64/skeleton/importer/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down