Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OOT DL importer: DL import from models with skeletons frequently fails with "list index out of range" #15

Open
raknaar opened this issue May 23, 2023 · 2 comments

Comments

@raknaar
Copy link

raknaar commented May 23, 2023

Blender 3.3.5
oot_model_classes.py", line 425, in setCurrentTransform
self.currentTransformName = self.getLimbName(self.dlList[int(int(name[4:], 16) / MTX_SIZE)].limbIndex)
IndexError: list index out of range

Traceback (most recent call last):
File "Blender\3.3\scripts\addons\fast64-main\fast64_internal\oot\oot_f3d_writer.py", line 541, in execute
obj = importMeshC(
File "Blender\3.3\scripts\addons\fast64-main\fast64_internal\f3d\f3d_parser.py", line 2166, in importMeshC
parseF3D(data, name, transformMatrix, name, name, "oot", drawLayer, f3dContext, True)
File "Blender\3.3\scripts\addons\fast64-main\fast64_internal\f3d\f3d_parser.py", line 1838, in parseF3D
f3dContext.processCommands(dlData, processedDLName, dlCommands)
File "Blender\3.3\scripts\addons\fast64-main\fast64_internal\f3d\f3d_parser.py", line 1502, in processCommands
self.setCurrentTransform(command.params[0])
File "Blender\3.3\scripts\addons\fast64-main\fast64_internal\oot\oot_model_classes.py", line 425, in setCurrentTransform
self.currentTransformName = self.getLimbName(self.dlList[int(int(name[4:], 16) / MTX_SIZE)].limbIndex)
IndexError: list index out of range

Examples of affected displaylist:

Object_skj: gSkullKidRightUpperLegDL gSkullKidRightLowerLegDL gSkullKidLeftFootDL

object_ge1: gGerudoWhiteRightUpperArmDL

@raknaar
Copy link
Author

raknaar commented May 24, 2023

I believe I've found a fix from the main non-SoH version of Fast64 that this one diverged from, and it seems to be working.

the problem is at line 423-425 in fast64_internal\oot\oot_model_classes.py

"def setCurrentTransform(self, name):
if name[:4].lower() == "0x0d":
self.currentTransformName = self.getLimbName(self.dlList[int(int(name[4:], 16) / MTX_SIZE)].limbIndex)"

In the main non-SoH version this seems to be fixed as:

def setCurrentTransform(self, name, flagList="G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW"):
if name[:4].lower() == "0x0d":
# This code is for skeletons
index = int(int(name[4:], 16) / MTX_SIZE)
if index < len(self.dlList):
transformName = self.getLimbName(self.dlList[index].limbIndex)

My attempt at porting this that seems to work:

def setCurrentTransform(self, name):
if name[:4].lower() == "0x0d":
index = int(int(name[4:], 16) / MTX_SIZE)
if index < len(self.dlList):
self.currentTransformName = self.getLimbName(self.dlList[index].limbIndex)

@raknaar
Copy link
Author

raknaar commented May 25, 2023

I did some more testing and although this does workaround the error and allow DLs to import, there is a possibly unrelated problem causing some of the verts to be importing with wrong positions or linked to the wrong bones. It's very possible that these new problems are unrelated to this fix, but I'm not sure if this workaround is a good idea for SoH Fast64 or not, since the Fast64 version the fix came from has changed so much from the SoH version, and the fix may or may not rely on any of those many changes.
It's basically just checking that the calculated index isn't longer than len(self.dlist) before attempting to access that index.
It's very possible this is a valid fix and those other problems are unrelated, however it's also very possible that porting a fix from another heavily changed Fast64 fork without fully understanding the implications is a bad idea.
I really hope any of this info can be helpful to anyone more experienced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant