Skip to content

Commit

Permalink
First pass
Browse files Browse the repository at this point in the history
There seems to be something wrong with reverts still, will investigate
  • Loading branch information
Lilaa3 committed Aug 15, 2024
1 parent 672eda3 commit d5e18ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
21 changes: 11 additions & 10 deletions fast64_internal/sm64/sm64_geolayout_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -351,9 +352,9 @@ def has_data(self):
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()
size += 8 # node open/close
for child in self.children:
size += child.size()

return size

Expand All @@ -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.")
Expand Down Expand Up @@ -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.")
Expand Down
6 changes: 4 additions & 2 deletions fast64_internal/sm64/sm64_geolayout_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.")
Expand Down

0 comments on commit d5e18ea

Please sign in to comment.