diff --git a/fast64_internal/sm64/sm64_geolayout_classes.py b/fast64_internal/sm64/sm64_geolayout_classes.py index 1118cf79e..e495b69b1 100644 --- a/fast64_internal/sm64/sm64_geolayout_classes.py +++ b/fast64_internal/sm64/sm64_geolayout_classes.py @@ -295,7 +295,7 @@ def c_func_macro(self, base_cmd: str, *args: str): all_args = list(args) if self.hasDL: all_args.append(self.get_dl_name()) - return f'{self.get_c_func_macro(base_cmd)}({", ".join(all_args)}),' + return f'{self.get_c_func_macro(base_cmd)}({", ".join(all_args)})' class TransformNode: @@ -380,9 +380,9 @@ def to_binary(self, segmentData): def to_c(self, depth): if self.node is not None: - nodeC = self.node.to_c() + nodeC = self.node.to_c(depth) if nodeC is not None: # Should only be the case for DisplayListNode with no DL - data = depth * "\t" + self.node.to_c() + "\n" + data = depth * "\t" + f"{nodeC},\n" else: data = "" else: @@ -464,9 +464,9 @@ def to_binary(self, segmentData): command.extend(startAddress) return command - def to_c(self): + def to_c(self, _depth=0): geo_name = self.geoRef or self.geolayout.name - return "GEO_BRANCH(" + ("1, " if self.storeReturn else "0, ") + geo_name + ")," + return "GEO_BRANCH(" + ("1, " if self.storeReturn else "0, ") + geo_name + ")" class GeoLayoutBleed(BleedGraphics): @@ -531,8 +531,8 @@ def to_binary(self, segmentData): addFuncAddress(command, self.geo_func) return command - def to_c(self): - return "GEO_ASM(" + str(self.func_param) + ", " + convert_addr_to_func(self.geo_func) + ")," + def to_c(self, _depth=0): + return "GEO_ASM(" + str(self.func_param) + ", " + convert_addr_to_func(self.geo_func) + ")" class HeldObjectNode: @@ -551,7 +551,7 @@ def to_binary(self, segmentData): addFuncAddress(command, self.geo_func) return command - def to_c(self): + def to_c(self, _depth=0): return ( "GEO_HELD_OBJECT(0, " + str(convertFloatToShort(self.translate[0])) @@ -561,7 +561,7 @@ def to_c(self): + str(convertFloatToShort(self.translate[2])) + ", " + convert_addr_to_func(self.geo_func) - + ")," + + ")" ) @@ -576,8 +576,8 @@ def to_binary(self, segmentData): command = bytearray([GEO_START, 0x00, 0x00, 0x00]) return command - def to_c(self): - return "GEO_NODE_START()," + def to_c(self, _depth=0): + return "GEO_NODE_START()" class EndNode: @@ -591,8 +591,8 @@ def to_binary(self, segmentData): command = bytearray([GEO_END, 0x00, 0x00, 0x00]) return command - def to_c(self): - return "GEO_END()," + def to_c(self, _depth=0): + return "GEO_END()" # Geolayout node hierarchy is first generated without material/draw layer @@ -616,8 +616,8 @@ def to_binary(self, segmentData): addFuncAddress(command, self.switchFunc) return command - def to_c(self): - return "GEO_SWITCH_CASE(" + str(self.defaultCase) + ", " + convert_addr_to_func(self.switchFunc) + ")," + def to_c(self, _depth=0): + return "GEO_SWITCH_CASE(" + str(self.defaultCase) + ", " + convert_addr_to_func(self.switchFunc) + ")" class TranslateRotateNode(BaseDisplayListNode): @@ -688,7 +688,7 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): if self.fieldLayout == 0: return self.c_func_macro( "GEO_TRANSLATE_ROTATE", @@ -755,7 +755,7 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): return self.c_func_macro( "GEO_TRANSLATE_NODE", getDrawLayerName(self.drawLayer), @@ -798,7 +798,7 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): return self.c_func_macro( "GEO_ROTATION_NODE", getDrawLayerName(self.drawLayer), @@ -840,7 +840,7 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): return self.c_func_macro( "GEO_BILLBOARD_WITH_PARAMS", getDrawLayerName(self.drawLayer), @@ -875,11 +875,11 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): if not self.hasDL: return None args = [getDrawLayerName(self.drawLayer), self.get_dl_name()] - return f"GEO_DISPLAY_LIST({join_c_args(args)})," + return f"GEO_DISPLAY_LIST({join_c_args(args)})" class ShadowNode: @@ -899,9 +899,9 @@ def to_binary(self, segmentData): command.extend(self.shadowScale.to_bytes(2, "big")) return command - def to_c(self): + def to_c(self, _depth=0): return ( - "GEO_SHADOW(" + str(self.shadowType) + ", " + str(self.shadowSolidity) + ", " + str(self.shadowScale) + ")," + "GEO_SHADOW(" + str(self.shadowType) + ", " + str(self.shadowSolidity) + ", " + str(self.shadowScale) + ")" ) @@ -933,7 +933,7 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): return self.c_func_macro( "GEO_SCALE", getDrawLayerName(self.drawLayer), str(int(round(self.scaleValue * 0x10000))) ) @@ -952,12 +952,12 @@ def to_binary(self, segmentData): command.extend(convertFloatToShort(self.cullingRadius).to_bytes(2, "big")) return command - def to_c(self): + def to_c(self, _depth=0): cullingRadius = convertFloatToShort(self.cullingRadius) # if abs(cullingRadius) > 2**15 - 1: # raise PluginError("A render area node has a culling radius that does not fit an s16.\n Radius is " +\ # str(cullingRadius) + ' when converted to SM64 units.') - return "GEO_CULLING_RADIUS(" + str(convertFloatToShort(self.cullingRadius)) + ")," + return "GEO_CULLING_RADIUS(" + str(convertFloatToShort(self.cullingRadius)) + ")" class RenderRangeNode: @@ -975,13 +975,13 @@ def to_binary(self, segmentData): command.extend(convertFloatToShort(self.maxDist).to_bytes(2, "big")) return command - def to_c(self): + def to_c(self, _depth=0): minDist = convertFloatToShort(self.minDist) maxDist = convertFloatToShort(self.maxDist) # if (abs(minDist) > 2**15 - 1) or (abs(maxDist) > 2**15 - 1): # raise PluginError("A render range (LOD) node has a range that does not fit an s16.\n Range is " +\ # str(minDist) + ', ' + str(maxDist) + ' when converted to SM64 units.') - return "GEO_RENDER_RANGE(" + str(minDist) + ", " + str(maxDist) + ")," + return "GEO_RENDER_RANGE(" + str(minDist) + ", " + str(maxDist) + ")" class DisplayListWithOffsetNode(BaseDisplayListNode): @@ -1012,7 +1012,7 @@ def to_binary(self, segmentData): command.extend(bytearray([0x00] * 4)) return command - def to_c(self): + def to_c(self, _depth=0): args = [ getDrawLayerName(self.drawLayer), str(convertFloatToShort(self.translate[0])), @@ -1020,7 +1020,7 @@ def to_c(self): str(convertFloatToShort(self.translate[2])), self.get_dl_name(), # This node requires 'NULL' if there is no DL ] - return f"GEO_ANIMATED_PART({join_c_args(args)})," + return f"GEO_ANIMATED_PART({join_c_args(args)})" class ScreenAreaNode: @@ -1046,10 +1046,10 @@ def to_binary(self, segmentData): command.extend(dimensions[1].to_bytes(2, "big", signed=True)) return command - def to_c(self): + def to_c(self, _depth=0): if self.useDefaults: return ( - "GEO_NODE_SCREEN_AREA(10, " + "SCREEN_WIDTH/2, SCREEN_HEIGHT/2, " + "SCREEN_WIDTH/2, SCREEN_HEIGHT/2)," + "GEO_NODE_SCREEN_AREA(10, " + "SCREEN_WIDTH/2, SCREEN_HEIGHT/2, " + "SCREEN_WIDTH/2, SCREEN_HEIGHT/2)" ) else: return ( @@ -1063,7 +1063,7 @@ def to_c(self): + str(self.dimensions[0]) + ", " + str(self.dimensions[1]) - + ")," + + ")" ) @@ -1081,8 +1081,8 @@ def to_binary(self, segmentData): command.extend(bytearray(pack(">f", self.scale))) return command - def to_c(self): - return "GEO_NODE_ORTHO(" + format(self.scale, ".4f") + ")," + def to_c(self, _depth=0): + return "GEO_NODE_ORTHO(" + format(self.scale, ".4f") + ")" class FrustumNode: @@ -1106,9 +1106,9 @@ def to_binary(self, segmentData): command.extend(bytes.fromhex("8029AA3C")) return command - def to_c(self): + def to_c(self, _depth=0): if not self.useFunc: - return "GEO_CAMERA_FRUSTUM(" + format(self.fov, ".4f") + ", " + str(self.near) + ", " + str(self.far) + ")," + return "GEO_CAMERA_FRUSTUM(" + format(self.fov, ".4f") + ", " + str(self.near) + ", " + str(self.far) + ")" else: return ( "GEO_CAMERA_FRUSTUM_WITH_FUNC(" @@ -1117,7 +1117,7 @@ def to_c(self): + str(self.near) + ", " + str(self.far) - + ", geo_camera_fov)," + + ", geo_camera_fov)" ) @@ -1133,8 +1133,8 @@ def to_binary(self, segmentData): command = bytearray([GEO_SET_Z_BUF, 0x01 if self.enable else 0x00, 0x00, 0x00]) return command - def to_c(self): - return "GEO_ZBUFFER(" + ("1" if self.enable else "0") + ")," + def to_c(self, _depth=0): + return "GEO_ZBUFFER(" + ("1" if self.enable else "0") + ")" class CameraNode: @@ -1160,7 +1160,7 @@ def to_binary(self, segmentData): addFuncAddress(command, self.geo_func) return command - def to_c(self): + def to_c(self, _depth=0): return ( "GEO_CAMERA(" + str(self.camType) @@ -1178,7 +1178,7 @@ def to_c(self): + str(self.lookAt[2]) + ", " + convert_addr_to_func(self.geo_func) - + ")," + + ")" ) @@ -1194,8 +1194,8 @@ def to_binary(self, segmentData): command = bytearray([GEO_SETUP_OBJ_RENDER, 0x00, 0x00, 0x00]) return command - def to_c(self): - return "GEO_RENDER_OBJ()," + def to_c(self, _depth=0): + return "GEO_RENDER_OBJ()" class BackgroundNode: @@ -1217,11 +1217,11 @@ def to_binary(self, segmentData): addFuncAddress(command, self.geo_func) return command - def to_c(self): + def to_c(self, _depth=0): if self.isColor: - return "GEO_BACKGROUND_COLOR(0x" + format(self.backgroundValue, "04x").upper() + ")," + return "GEO_BACKGROUND_COLOR(0x" + format(self.backgroundValue, "04x").upper() + ")" else: - return "GEO_BACKGROUND(" + str(self.backgroundValue) + ", " + convert_addr_to_func(self.geo_func) + ")," + return "GEO_BACKGROUND(" + str(self.backgroundValue) + ", " + convert_addr_to_func(self.geo_func) + ")" class CustomNode: @@ -1236,8 +1236,8 @@ def size(self): def to_binary(self, segmentData): raise PluginError("Custom Geo Nodes are not supported for binary exports.") - def to_c(self): - return f"{self.command}({self.args})," + def to_c(self, _depth=0): + return f"{self.command}({self.args})" class CustomAnimatedNode(BaseDisplayListNode): @@ -1262,7 +1262,7 @@ def get_ptr_offsets(self): def to_binary(self, segmentData): raise PluginError("Custom Geo Nodes are not supported for binary exports.") - def to_c(self): + def to_c(self, _depth=0): args = [ getDrawLayerName(self.drawLayer), str(convertFloatToShort(self.translate[0])), @@ -1271,7 +1271,7 @@ def to_c(self): *(str(radians_to_s16(r)) for r in self.rotate.to_euler("XYZ")), self.get_dl_name(), # This node requires 'NULL' if there is no DL ] - return f"{self.command}({join_c_args(args)})," + return f"{self.command}({join_c_args(args)})" nodeGroupClasses = [