From d37ce933b89a59548fce436ef22b1ced53fd2a32 Mon Sep 17 00:00:00 2001 From: Lila Date: Thu, 15 Aug 2024 19:05:20 +0100 Subject: [PATCH 1/3] First pass There seems to be something wrong with reverts still, will investigate --- .../sm64/sm64_geolayout_classes.py | 19 ++++++++++--------- fast64_internal/sm64/sm64_geolayout_writer.py | 6 ++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/fast64_internal/sm64/sm64_geolayout_classes.py b/fast64_internal/sm64/sm64_geolayout_classes.py index a0e82306e..a4f30ea2b 100644 --- a/fast64_internal/sm64/sm64_geolayout_classes.py +++ b/fast64_internal/sm64/sm64_geolayout_classes.py @@ -272,8 +272,9 @@ class BaseDisplayListNode: bleed_independently = False # base behavior, can be changed with obj boolProp def get_dl_address(self): - if self.hasDL and (self.dlRef or self.DLmicrocode is not None): - return self.dlRef or self.DLmicrocode.startAddress + assert self.dlRef is None, "dlRef not implemented in binary" + if self.hasDL and self.DLmicrocode is not None: + return self.DLmicrocode.startAddress return None def get_dl_name(self): @@ -352,8 +353,8 @@ def size(self): size = self.node.size() if self.node is not None else 0 if len(self.children) > 0 and type(self.node) in nodeGroupClasses: size += 8 # node open/close - for child in self.children: - size += child.size() + for child in self.children: + size += child.size() return size @@ -368,11 +369,11 @@ def to_binary(self, segmentData): if type(self.node) is FunctionNode: raise PluginError("An FunctionNode cannot have children.") - if data[0] in nodeGroupCmds: + if type(self.node) in nodeGroupClasses: data.extend(bytearray([GEO_NODE_OPEN, 0x00, 0x00, 0x00])) for child in self.children: data.extend(child.to_binary(segmentData)) - if data[0] in nodeGroupCmds: + if type(self.node) in nodeGroupClasses: data.extend(bytearray([GEO_NODE_CLOSE, 0x00, 0x00, 0x00])) elif type(self.node) is SwitchNode: raise PluginError("A switch bone must have at least one child bone.") @@ -411,11 +412,11 @@ def toTextDump(self, nodeLevel, segmentData): data += "\n" if len(self.children) > 0: - if len(command) == 0 or command[0] in nodeGroupCmds: + if type(self.node) in nodeGroupClasses: data += "\t" * nodeLevel + "04 00 00 00\n" for child in self.children: - data += child.toTextDump(nodeLevel + 1, segmentData) - if len(command) == 0 or command[0] in nodeGroupCmds: + data += child.toTextDump(nodeLevel + (1 if type(self.node) in nodeGroupClasses else 0), segmentData) + if type(self.node) in nodeGroupClasses: data += "\t" * nodeLevel + "05 00 00 00\n" elif type(self.node) is SwitchNode: raise PluginError("A switch bone must have at least one child bone.") diff --git a/fast64_internal/sm64/sm64_geolayout_writer.py b/fast64_internal/sm64/sm64_geolayout_writer.py index a0a2f1aab..c7d7aacd5 100644 --- a/fast64_internal/sm64/sm64_geolayout_writer.py +++ b/fast64_internal/sm64/sm64_geolayout_writer.py @@ -1534,7 +1534,8 @@ def processMesh( if len(src_meshes): fMeshes = {} - node.dlRef = src_meshes[0]["name"] + if useGeoEmpty: + node.dlRef = src_meshes[0]["name"] node.drawLayer = src_meshes[0]["layer"] processed_inline_geo = True @@ -1559,7 +1560,8 @@ def processMesh( temp_obj["src_meshes"] = [ ({"name": fMesh.draw.name, "layer": drawLayer}) for drawLayer, fMesh in fMeshes.items() ] - node.dlRef = temp_obj["src_meshes"][0]["name"] + if useGeoEmpty: + node.dlRef = temp_obj["src_meshes"][0]["name"] else: # TODO: Display warning to the user that there is an object that doesn't have polygons print("Object", obj.original_name, "does not have any polygons.") From b42def1934df84dec1c76bb4c4c5ff8573ab8b6e Mon Sep 17 00:00:00 2001 From: Lila Date: Thu, 15 Aug 2024 19:53:10 +0100 Subject: [PATCH 2/3] =?UTF-8?q?currently=20hasn=C2=B4t=20caused=20a=20bug?= =?UTF-8?q?=20but=20update=20this=20to=20be=20sure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fast64_internal/f3d/f3d_gbi.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fast64_internal/f3d/f3d_gbi.py b/fast64_internal/f3d/f3d_gbi.py index 4c129acc3..903058c63 100644 --- a/fast64_internal/f3d/f3d_gbi.py +++ b/fast64_internal/f3d/f3d_gbi.py @@ -3054,15 +3054,17 @@ def get_ptr_addresses(self, f3d): return addresses def set_addr(self, startAddress, f3d): - addrRange = self.material.set_addr(startAddress, f3d) - startAddress = addrRange[0] - if self.revert is not None: + addrRange = (startAddress, startAddress) + if self.material.tag.Export: + addrRange = self.material.set_addr(addrRange[1], f3d) + if self.revert is not None and self.revert.tag.Export: addrRange = self.revert.set_addr(addrRange[1], f3d) return startAddress, addrRange[1] def save_binary(self, romfile, f3d, segments): - self.material.save_binary(romfile, f3d, segments) - if self.revert is not None: + if self.material.tag.Export: + self.material.save_binary(romfile, f3d, segments) + if self.revert is not None and self.revert.tag.Export: self.revert.save_binary(romfile, f3d, segments) def to_c(self, f3d): From b449946746904bd7bf0522831a8e3cd826d34c62 Mon Sep 17 00:00:00 2001 From: Lila Date: Thu, 15 Aug 2024 21:01:57 +0100 Subject: [PATCH 3/3] another similar issue --- fast64_internal/f3d/f3d_gbi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fast64_internal/f3d/f3d_gbi.py b/fast64_internal/f3d/f3d_gbi.py index 903058c63..d0df9f46f 100644 --- a/fast64_internal/f3d/f3d_gbi.py +++ b/fast64_internal/f3d/f3d_gbi.py @@ -2940,14 +2940,17 @@ def get_ptr_addresses(self, f3d): return self.triList.get_ptr_addresses(f3d) def set_addr(self, startAddress, f3d): - addrRange = self.triList.set_addr(startAddress, f3d) + addrRange = (startAddress, startAddress) + if self.triList.tag.Export: + addrRange = self.triList.set_addr(startAddress, f3d) addrRange = self.vertexList.set_addr(addrRange[1]) return startAddress, addrRange[1] def save_binary(self, romfile, f3d, segments): for celTriList in self.celTriLists: celTriList.save_binary(romfile, f3d, segments) - self.triList.save_binary(romfile, f3d, segments) + if self.triList.tag.Export: + self.triList.save_binary(romfile, f3d, segments) self.vertexList.save_binary(romfile) def to_c(self, f3d, gfxFormatter):