From 2c03117438f3e99c782c25ce070a443d2d70c1ae Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:32:55 +0100 Subject: [PATCH 1/6] fix door upgrade issues --- fast64_internal/oot/oot_upgrade.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fast64_internal/oot/oot_upgrade.py b/fast64_internal/oot/oot_upgrade.py index b3dfd90de..cf604f606 100644 --- a/fast64_internal/oot/oot_upgrade.py +++ b/fast64_internal/oot/oot_upgrade.py @@ -1,3 +1,5 @@ +import bpy + from dataclasses import dataclass from typing import TYPE_CHECKING from bpy.types import Object, CollectionProperty @@ -313,10 +315,11 @@ def upgradeActors(actorObj: Object): break elif actorObj.ootEmptyType == "Transition Actor": transActorProp = actorObj.ootTransitionActorProperty - transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False - del actorObj["ootTransitionActorProperty"]["dontTransition"] + if "dontTransition" in transActorProp: + transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False + del actorObj["ootTransitionActorProperty"]["dontTransition"] - if transActorProp.isRoomTransition: + if "roomIndex" in transActorProp: for obj in bpy.data.objects: if obj.type == "EMPTY": if obj.ootEmptyType == "Room": From 93849c1b0d8ee3e01eb472ed2087d7c74cc79c59 Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:54:05 +0100 Subject: [PATCH 2/6] fixed index issues --- fast64_internal/oot/oot_upgrade.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fast64_internal/oot/oot_upgrade.py b/fast64_internal/oot/oot_upgrade.py index cf604f606..2a9427dfa 100644 --- a/fast64_internal/oot/oot_upgrade.py +++ b/fast64_internal/oot/oot_upgrade.py @@ -319,13 +319,16 @@ def upgradeActors(actorObj: Object): transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False del actorObj["ootTransitionActorProperty"]["dontTransition"] - if "roomIndex" in transActorProp: + for obj in bpy.data.objects: + if obj.type == "EMPTY": + if obj.ootEmptyType == "Room": + if actorObj in obj.children_recursive: + transActorProp.fromRoom = obj + + if "roomIndex" in transActorProp and transActorProp.fromRoom is not None: for obj in bpy.data.objects: - if obj.type == "EMPTY": - if obj.ootEmptyType == "Room": - if actorObj in obj.children_recursive: - transActorProp.fromRoom = obj - - if obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"]: - transActorProp.toRoom = obj - del actorObj["ootTransitionActorProperty"]["roomIndex"] + if obj.name != transActorProp.fromRoom.name and obj.type == "EMPTY" and obj.ootEmptyType == "Room": + if obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"]: + transActorProp.toRoom = obj + del actorObj["ootTransitionActorProperty"]["roomIndex"] + break From e671ee57b17eccdfe40765d05f907490c010e231 Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:56:38 +0100 Subject: [PATCH 3/6] minor code improvements --- fast64_internal/oot/oot_upgrade.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fast64_internal/oot/oot_upgrade.py b/fast64_internal/oot/oot_upgrade.py index 2a9427dfa..c9005dad4 100644 --- a/fast64_internal/oot/oot_upgrade.py +++ b/fast64_internal/oot/oot_upgrade.py @@ -320,15 +320,18 @@ def upgradeActors(actorObj: Object): del actorObj["ootTransitionActorProperty"]["dontTransition"] for obj in bpy.data.objects: - if obj.type == "EMPTY": - if obj.ootEmptyType == "Room": - if actorObj in obj.children_recursive: - transActorProp.fromRoom = obj + if obj.type == "EMPTY" and obj.ootEmptyType == "Room" and actorObj in obj.children_recursive: + transActorProp.fromRoom = obj + break if "roomIndex" in transActorProp and transActorProp.fromRoom is not None: for obj in bpy.data.objects: - if obj.name != transActorProp.fromRoom.name and obj.type == "EMPTY" and obj.ootEmptyType == "Room": - if obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"]: - transActorProp.toRoom = obj - del actorObj["ootTransitionActorProperty"]["roomIndex"] - break + if ( + obj.name != transActorProp.fromRoom.name + and obj.type == "EMPTY" + and obj.ootEmptyType == "Room" + and obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"] + ): + transActorProp.toRoom = obj + del actorObj["ootTransitionActorProperty"]["roomIndex"] + break From fb2cba93a32de7a7d2ab195446a53b152f71a441 Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Mon, 22 Jan 2024 02:30:12 +0100 Subject: [PATCH 4/6] check if any old props is present --- fast64_internal/oot/oot_upgrade.py | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fast64_internal/oot/oot_upgrade.py b/fast64_internal/oot/oot_upgrade.py index c9005dad4..bf260fbab 100644 --- a/fast64_internal/oot/oot_upgrade.py +++ b/fast64_internal/oot/oot_upgrade.py @@ -315,23 +315,23 @@ def upgradeActors(actorObj: Object): break elif actorObj.ootEmptyType == "Transition Actor": transActorProp = actorObj.ootTransitionActorProperty - if "dontTransition" in transActorProp: - transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False - del actorObj["ootTransitionActorProperty"]["dontTransition"] - - for obj in bpy.data.objects: - if obj.type == "EMPTY" and obj.ootEmptyType == "Room" and actorObj in obj.children_recursive: - transActorProp.fromRoom = obj - break - - if "roomIndex" in transActorProp and transActorProp.fromRoom is not None: + if "dontTransition" in transActorProp or "roomIndex" in transActorProp: for obj in bpy.data.objects: - if ( - obj.name != transActorProp.fromRoom.name - and obj.type == "EMPTY" - and obj.ootEmptyType == "Room" - and obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"] - ): - transActorProp.toRoom = obj - del actorObj["ootTransitionActorProperty"]["roomIndex"] + if obj.type == "EMPTY" and obj.ootEmptyType == "Room" and actorObj in obj.children_recursive: + transActorProp.fromRoom = obj break + + if "dontTransition" in transActorProp: + transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False + del actorObj["ootTransitionActorProperty"]["dontTransition"] + elif transActorProp.fromRoom is not None: + for obj in bpy.data.objects: + if ( + obj.name != transActorProp.fromRoom.name + and obj.type == "EMPTY" + and obj.ootEmptyType == "Room" + and obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"] + ): + transActorProp.toRoom = obj + del actorObj["ootTransitionActorProperty"]["roomIndex"] + break From 9b17409b718368a0d2ef3ac7be1382131bd91ef3 Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Mon, 22 Jan 2024 02:36:20 +0100 Subject: [PATCH 5/6] review --- fast64_internal/oot/oot_upgrade.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fast64_internal/oot/oot_upgrade.py b/fast64_internal/oot/oot_upgrade.py index bf260fbab..226e03f08 100644 --- a/fast64_internal/oot/oot_upgrade.py +++ b/fast64_internal/oot/oot_upgrade.py @@ -322,16 +322,16 @@ def upgradeActors(actorObj: Object): break if "dontTransition" in transActorProp: - transActorProp.isRoomTransition = actorObj["ootTransitionActorProperty"]["dontTransition"] == False - del actorObj["ootTransitionActorProperty"]["dontTransition"] + transActorProp.isRoomTransition = transActorProp["dontTransition"] == False + del transActorProp["dontTransition"] elif transActorProp.fromRoom is not None: for obj in bpy.data.objects: if ( - obj.name != transActorProp.fromRoom.name + obj != transActorProp.fromRoom and obj.type == "EMPTY" and obj.ootEmptyType == "Room" - and obj.ootRoomHeader.roomIndex == actorObj["ootTransitionActorProperty"]["roomIndex"] + and obj.ootRoomHeader.roomIndex == transActorProp["roomIndex"] ): transActorProp.toRoom = obj - del actorObj["ootTransitionActorProperty"]["roomIndex"] + del transActorProp["roomIndex"] break From 59cbc3e87ad70713521d122ad03064169690d5c3 Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Fri, 26 Jan 2024 02:28:55 +0100 Subject: [PATCH 6/6] proper fix --- fast64_internal/oot/oot_upgrade.py | 46 +++++++++++++++++++----------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/fast64_internal/oot/oot_upgrade.py b/fast64_internal/oot/oot_upgrade.py index 226e03f08..e0b893b57 100644 --- a/fast64_internal/oot/oot_upgrade.py +++ b/fast64_internal/oot/oot_upgrade.py @@ -314,24 +314,36 @@ def upgradeActors(actorObj: Object): entranceProp.tiedRoom = obj break elif actorObj.ootEmptyType == "Transition Actor": + # get room parent + roomParent = None + for obj in bpy.data.objects: + if obj.type == "EMPTY" and obj.ootEmptyType == "Room" and actorObj in obj.children_recursive: + roomParent = obj + break + + # if it's ``None`` then this door actor is not parented to a room + if roomParent is None: + print("WARNING: Ignoring Door Actor not parented to a room") + return + transActorProp = actorObj.ootTransitionActorProperty if "dontTransition" in transActorProp or "roomIndex" in transActorProp: + # look for old data since we don't want to overwrite newer existing data + transActorProp.fromRoom = roomParent + + # upgrade old props if present + if "dontTransition" in transActorProp: + transActorProp.isRoomTransition = transActorProp["dontTransition"] == False + del transActorProp["dontTransition"] + + if "roomIndex" in transActorProp: for obj in bpy.data.objects: - if obj.type == "EMPTY" and obj.ootEmptyType == "Room" and actorObj in obj.children_recursive: - transActorProp.fromRoom = obj + if ( + obj != transActorProp.fromRoom + and obj.type == "EMPTY" + and obj.ootEmptyType == "Room" + and obj.ootRoomHeader.roomIndex == transActorProp["roomIndex"] + ): + transActorProp.toRoom = obj + del transActorProp["roomIndex"] break - - if "dontTransition" in transActorProp: - transActorProp.isRoomTransition = transActorProp["dontTransition"] == False - del transActorProp["dontTransition"] - elif transActorProp.fromRoom is not None: - for obj in bpy.data.objects: - if ( - obj != transActorProp.fromRoom - and obj.type == "EMPTY" - and obj.ootEmptyType == "Room" - and obj.ootRoomHeader.roomIndex == transActorProp["roomIndex"] - ): - transActorProp.toRoom = obj - del transActorProp["roomIndex"] - break