From 6f08c20cf0830f626261f66097f33b1cceba10b3 Mon Sep 17 00:00:00 2001 From: s4Ys369 Date: Thu, 12 Sep 2024 09:21:57 -0400 Subject: [PATCH 1/3] [SM64] fix Whirlpool Object export for decomp/ultrasm64 --- fast64_internal/sm64/sm64_constants.py | 8 ++++ fast64_internal/sm64/sm64_objects.py | 56 +++++++++++++++++++------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/fast64_internal/sm64/sm64_constants.py b/fast64_internal/sm64/sm64_constants.py index fd1893770..9ee19779b 100644 --- a/fast64_internal/sm64/sm64_constants.py +++ b/fast64_internal/sm64/sm64_constants.py @@ -1762,6 +1762,14 @@ def __init__(self, geoAddr, level, switchDict): ("macro_yellow_coin_2", "Yellow Coin 2", "Yellow Coin 2"), ] +enumWhirlpoolConditions = [ + ("Custom", "Custom", "Custom"), + ("0", "Always on", "Always on"), + ("1", "Pre Bowser 2", "Checks if Key 2 has not been collected"), + ("2", "Post Bowser 2", "Checks if Key 2 has been collected and used"), + ("3", "Not Act 1", "Only spawns if the current act >= 2"), +] + enumBehaviorMacros = [ ("Custom", "Custom", ""), ("BEGIN", "BEGIN", "Starts the behavior, places it in a specific group"), diff --git a/fast64_internal/sm64/sm64_objects.py b/fast64_internal/sm64/sm64_objects.py index 951e8bcc5..e3805d488 100644 --- a/fast64_internal/sm64/sm64_objects.py +++ b/fast64_internal/sm64/sm64_objects.py @@ -34,6 +34,7 @@ enumLevelNames, enumModelIDs, enumMacrosNames, + enumWhirlpoolConditions, enumSpecialsNames, enumBehaviourPresets, enumBehaviorMacros, @@ -136,7 +137,7 @@ ("ENVFX_SNOW_BLIZZARD", "Blizzard", "Unused"), ("ENVFX_FLOWERS", "Flowers", "Unused"), ("ENVFX_LAVA_BUBBLES", "Lava Bubbles", "Used in LLL, BitFS, Bowser 2"), - ("ENVFX_WHIRLPOOL_BUBBLES", "Whirpool Bubbles", "Used in DDD where whirpool is"), + ("ENVFX_WHIRLPOOL_BUBBLES", "Whirlpool Bubbles", "Used in DDD where whirlpool is"), ("ENVFX_JETSTREAM_BUBBLES", "Jetstream Bubbles", "Used in JRB, DDD where jetstream is"), ] @@ -341,7 +342,7 @@ def to_c(self): ) -class SM64_Whirpool: +class SM64_Whirlpool: def __init__(self, index, condition, strength, position): self.index = index self.condition = condition @@ -351,7 +352,7 @@ def __init__(self, index, condition, strength, position): def to_c(self): return ( - "WHIRPOOL(" + "WHIRLPOOL(" + str(self.index) + ", " + str(self.condition) @@ -852,9 +853,10 @@ def process_sm64_objects(obj, area, rootMatrix, transformMatrix, specialsOnly): area.mario_start = mario_start elif obj.sm64_obj_type == "Trajectory": pass - elif obj.sm64_obj_type == "Whirpool": + elif obj.sm64_obj_type == "Whirlpool": + condition = obj.sm64_whirlpool_enum if obj.sm64_whirlpool_enum != "Custom" else obj.sm64_obj_preset area.objects.append( - SM64_Whirpool(obj.whirlpool_index, obj.whirpool_condition, obj.whirpool_strength, translation) + SM64_Whirlpool(obj.whirlpool_index, condition, obj.whirlpool_strength, translation) ) elif obj.sm64_obj_type == "Camera Volume": checkIdentityRotation(obj, rotation.to_quaternion(), True) @@ -1049,6 +1051,25 @@ def invoke(self, context, event): return {"RUNNING_MODAL"} +class SearchWhirlpoolEnumOperator(bpy.types.Operator): + bl_idname = "object.search_whirlpool_enum_operator" + bl_label = "Search Whirlpool Conditions" + bl_property = "sm64_whirlpool_enum" + bl_options = {"REGISTER", "UNDO"} + + sm64_whirlpool_enum: bpy.props.EnumProperty(items=enumWhirlpoolConditions) + + def execute(self, context): + context.object.sm64_whirlpool_enum = self.sm64_whirlpool_enum + bpy.context.region.tag_redraw() + self.report({"INFO"}, "Selected: " + self.sm64_whirlpool_enum) + return {"FINISHED"} + + def invoke(self, context, event): + context.window_manager.invoke_search_popup(self) + return {"RUNNING_MODAL"} + + class SearchSpecialEnumOperator(bpy.types.Operator): bl_idname = "object.search_special_enum_operator" bl_label = "Search Specials" @@ -1222,9 +1243,14 @@ def draw(self, context): pass elif obj.sm64_obj_type == "Whirlpool": - prop_split(box, obj, "whirpool_index", "Index") - prop_split(box, obj, "whirpool_condition", "Condition") - prop_split(box, obj, "whirpool_strength", "Strength") + prop_split(box, obj, "sm64_whirlpool_enum", "Condition") + if obj.sm64_whirlpool_enum == "Custom": + prop_split(box, obj, "sm64_obj_preset", "Condition Name") + box.operator(SearchWhirlpoolEnumOperator.bl_idname, icon="VIEWZOOM") + box.box().label(text="Whirlpool conditions defined in include/level_commands.h.") + prop_split(box, obj, "whirlpool_index", "Index") + prop_split(box, obj, "whirlpool_strength", "Strength") + box.box().label(text="Negative strength pushs, positive strength pulls.") pass elif obj.sm64_obj_type == "Water Box": @@ -2806,6 +2832,7 @@ def upgrade_changed_props(): SearchBehaviourEnumOperator, SearchSpecialEnumOperator, SearchMacroEnumOperator, + SearchWhirlpoolEnumOperator, StarGetCutscenesProperty, PuppycamProperty, PuppycamSetupCamera, @@ -2878,9 +2905,10 @@ def sm64_obj_register(): bpy.types.Object.sm64_obj_mario_start_area = bpy.props.StringProperty(name="Area", default="0x01") - bpy.types.Object.whirpool_index = bpy.props.StringProperty(name="Index", default="0") - bpy.types.Object.whirpool_condition = bpy.props.StringProperty(name="Condition", default="3") - bpy.types.Object.whirpool_strength = bpy.props.StringProperty(name="Strength", default="-30") + bpy.types.Object.whirlpool_index = bpy.props.StringProperty(name="Index", default="0") + bpy.types.Object.sm64_whirlpool_enum = bpy.props.EnumProperty(name="Condition", items=enumWhirlpoolConditions) + bpy.types.Object.whirlpool_strength = bpy.props.StringProperty(name="Strength", default="20") + bpy.types.Object.waterBoxType = bpy.props.EnumProperty( name="Water Box Type", items=enumWaterBoxType, default="Water" ) @@ -3016,6 +3044,7 @@ def sm64_obj_unregister(): del bpy.types.Object.sm64_macro_enum del bpy.types.Object.sm64_special_enum del bpy.types.Object.sm64_behaviour_enum + del bpy.types.Object.sm64_whirlpool_enum # del bpy.types.Object.sm64_model # del bpy.types.Object.sm64_macro @@ -3027,9 +3056,8 @@ def sm64_obj_unregister(): del bpy.types.Object.sm64_obj_preset del bpy.types.Object.sm64_obj_behaviour - del bpy.types.Object.whirpool_index - del bpy.types.Object.whirpool_condition - del bpy.types.Object.whirpool_strength + del bpy.types.Object.whirlpool_index + del bpy.types.Object.whirlpool_strength del bpy.types.Object.waterBoxType From 3cfbdd519f3e45c042fa9682cda5e9ef50e71e8f Mon Sep 17 00:00:00 2001 From: s4Ys369 Date: Thu, 12 Sep 2024 09:40:19 -0400 Subject: [PATCH 2/3] black fix --- fast64_internal/sm64/sm64_objects.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fast64_internal/sm64/sm64_objects.py b/fast64_internal/sm64/sm64_objects.py index e3805d488..ebcab84be 100644 --- a/fast64_internal/sm64/sm64_objects.py +++ b/fast64_internal/sm64/sm64_objects.py @@ -855,9 +855,7 @@ def process_sm64_objects(obj, area, rootMatrix, transformMatrix, specialsOnly): pass elif obj.sm64_obj_type == "Whirlpool": condition = obj.sm64_whirlpool_enum if obj.sm64_whirlpool_enum != "Custom" else obj.sm64_obj_preset - area.objects.append( - SM64_Whirlpool(obj.whirlpool_index, condition, obj.whirlpool_strength, translation) - ) + area.objects.append(SM64_Whirlpool(obj.whirlpool_index, condition, obj.whirlpool_strength, translation)) elif obj.sm64_obj_type == "Camera Volume": checkIdentityRotation(obj, rotation.to_quaternion(), True) if obj.cameraVolumeGlobal: From 904608dce52a2e67137c6e885a629fb67715d818 Mon Sep 17 00:00:00 2001 From: s4Ys369 Date: Fri, 13 Sep 2024 07:37:18 -0400 Subject: [PATCH 3/3] Remove search option --- fast64_internal/sm64/sm64_objects.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/fast64_internal/sm64/sm64_objects.py b/fast64_internal/sm64/sm64_objects.py index ebcab84be..6e0ee4801 100644 --- a/fast64_internal/sm64/sm64_objects.py +++ b/fast64_internal/sm64/sm64_objects.py @@ -1049,25 +1049,6 @@ def invoke(self, context, event): return {"RUNNING_MODAL"} -class SearchWhirlpoolEnumOperator(bpy.types.Operator): - bl_idname = "object.search_whirlpool_enum_operator" - bl_label = "Search Whirlpool Conditions" - bl_property = "sm64_whirlpool_enum" - bl_options = {"REGISTER", "UNDO"} - - sm64_whirlpool_enum: bpy.props.EnumProperty(items=enumWhirlpoolConditions) - - def execute(self, context): - context.object.sm64_whirlpool_enum = self.sm64_whirlpool_enum - bpy.context.region.tag_redraw() - self.report({"INFO"}, "Selected: " + self.sm64_whirlpool_enum) - return {"FINISHED"} - - def invoke(self, context, event): - context.window_manager.invoke_search_popup(self) - return {"RUNNING_MODAL"} - - class SearchSpecialEnumOperator(bpy.types.Operator): bl_idname = "object.search_special_enum_operator" bl_label = "Search Specials" @@ -1244,7 +1225,6 @@ def draw(self, context): prop_split(box, obj, "sm64_whirlpool_enum", "Condition") if obj.sm64_whirlpool_enum == "Custom": prop_split(box, obj, "sm64_obj_preset", "Condition Name") - box.operator(SearchWhirlpoolEnumOperator.bl_idname, icon="VIEWZOOM") box.box().label(text="Whirlpool conditions defined in include/level_commands.h.") prop_split(box, obj, "whirlpool_index", "Index") prop_split(box, obj, "whirlpool_strength", "Strength") @@ -2830,7 +2810,6 @@ def upgrade_changed_props(): SearchBehaviourEnumOperator, SearchSpecialEnumOperator, SearchMacroEnumOperator, - SearchWhirlpoolEnumOperator, StarGetCutscenesProperty, PuppycamProperty, PuppycamSetupCamera,