Skip to content

Commit

Permalink
[SM64] add depth arg to level and collision objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Oct 8, 2024
1 parent e643c77 commit abe037e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
7 changes: 2 additions & 5 deletions fast64_internal/sm64/sm64_collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,11 @@ def to_c(self):
if len(self.specials) > 0:
data.source += "\tCOL_SPECIAL_INIT(" + str(len(self.specials)) + "),\n"
for special in self.specials:
if isinstance(special, CustomCmd):
data.source += "\t" + special.to_c("\t") + ",\n"
continue
data.source += "\t" + special.to_c() + ",\n"
data.source += "\t" + special.to_c(1) + ",\n"
if len(self.water_boxes) > 0:
data.source += "\tCOL_WATER_BOX_INIT(" + str(len(self.water_boxes)) + "),\n"
for waterBox in self.water_boxes:
data.source += "\t" + waterBox.to_c()
data.source += "\t" + waterBox.to_c(1)
data.source += "\tCOL_END()\n" + "};\n"
return data

Expand Down
35 changes: 16 additions & 19 deletions fast64_internal/sm64/sm64_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def __init__(self, model, position, rotation, behaviour, bparam, acts, name):
self.rotation = rotation
self.name = name # to sort by when exporting

def to_c(self):
def to_c(self, depth=0):
if self.acts == 0x1F:
return (
"OBJECT("
Expand Down Expand Up @@ -356,7 +356,7 @@ def __init__(self, index, condition, strength, position):
self.position = position
self.name = "whirlpool" # for sorting

def to_c(self):
def to_c(self, depth=0):
return (
"WHIRPOOL("
+ str(self.index)
Expand All @@ -381,7 +381,7 @@ def __init__(self, preset, position, rotation, bparam):
self.position = position
self.rotation = rotation

def to_c(self):
def to_c(self, depth=0):
if self.bparam is None:
return (
"MACRO_OBJECT("
Expand Down Expand Up @@ -433,7 +433,7 @@ def to_binary(self):
data.extend(int(self.bparam).to_bytes(2, "big"))
return data

def to_c(self):
def to_c(self, depth=0):
if self.rotation is None:
return (
"SPECIAL_OBJECT("
Expand Down Expand Up @@ -485,7 +485,7 @@ def __init__(self, area, position, rotation):
self.rotation = rotation
self.name = "Mario" # for sorting

def to_c(self):
def to_c(self, depth=0):
return (
"MARIO_POS("
+ str(self.area)
Expand Down Expand Up @@ -533,10 +533,7 @@ def to_c_script(self, includeRooms, persistentBlockString: str = ""):
data += "\t\t" + warpNode + ",\n"
# export objects in name order
for obj in sorted(self.objects, key=(lambda obj: obj.name)):
if isinstance(obj, CustomCmd):
data += "\t\t" + obj.to_c("\t\t") + ",\n"
continue
data += "\t\t" + obj.to_c() + ",\n"
data += "\t\t" + obj.to_c(2) + ",\n"
data += "\t\tTERRAIN(" + self.collision.name + "),\n"
if includeRooms:
data += "\t\tROOMS(" + self.collision.rooms_name() + "),\n"
Expand All @@ -557,21 +554,21 @@ def to_c_macros(self):
data.header = "extern const MacroObject " + self.macros_name() + "[];\n"
data.source += "const MacroObject " + self.macros_name() + "[] = {\n"
for macro in self.macros:
data.source += "\t" + macro.to_c() + ",\n"
data.source += "\t" + macro.to_c(1) + ",\n"
data.source += "\tMACRO_OBJECT_END(),\n};\n\n"

return data

def to_c_camera_volumes(self):
data = ""
for camVolume in self.cameraVolumes:
data += "\t" + camVolume.to_c() + "\n"
data += "\t" + camVolume.to_c(1) + ",\n"
return data

def to_c_puppycam_volumes(self):
data = ""
for puppycamVolume in self.puppycamVolumes:
data += "\t" + puppycamVolume.to_c() + "\n"
data += "\t" + puppycamVolume.to_c(1) + ",\n"
return data

def hasCutsceneSpline(self):
Expand Down Expand Up @@ -608,7 +605,7 @@ def to_binary(self):
data.extend(int(round(self.height)).to_bytes(2, "big", signed=True))
return data

def to_c(self):
def to_c(self, depth=0):
data = (
"COL_WATER_BOX("
+ ("0x00" if self.waterBoxType == "Water" else "0x32")
Expand All @@ -622,7 +619,7 @@ def to_c(self):
+ str(int(round(self.high[1])))
+ ", "
+ str(int(round(self.height)))
+ "),\n"
+ ")"
)
return data

Expand All @@ -640,7 +637,7 @@ def __init__(self, area, functionName, position, rotation, scale, emptyScale):
def to_binary(self):
raise PluginError("Binary exporting not implemented for camera volumens.")

def to_c(self):
def to_c(self, depth=0):
data = (
"{"
+ str(self.area)
Expand All @@ -660,7 +657,7 @@ def to_c(self):
+ str(int(round(self.scale[2])))
+ ", "
+ str(convertRadiansToS16(self.rotation[1]))
+ "},"
+ "}"
)
return data

Expand Down Expand Up @@ -693,7 +690,7 @@ def __init__(self, area, level, permaswap, functionName, position, scale, emptyS
def to_binary(self):
raise PluginError("Binary exporting not implemented for puppycam volumes.")

def to_c(self):
def to_c(self, depth=0):
data = (
"{"
+ str(self.level)
Expand Down Expand Up @@ -729,7 +726,7 @@ def to_c(self):
+ str(int(round(self.camFocus[1])))
+ ", "
+ str(int(round(self.camFocus[2])))
+ "},"
+ "}"
)
return data

Expand Down Expand Up @@ -2436,7 +2433,7 @@ def calc_offsets_from_objects(self, reverse=False):
ret.z = int(round(-difference.y * bpy.context.scene.blenderF3DScale))
return ret

def to_c(self):
def to_c(self, depth=0):
if self.warpType == "Instant":
offset = Vector()

Expand Down

0 comments on commit abe037e

Please sign in to comment.