From 58905b5adcaece679d3cf3aaf198df4feab84ee1 Mon Sep 17 00:00:00 2001 From: kurethedead Date: Sun, 29 Nov 2020 23:54:18 -0800 Subject: [PATCH] Fixed upside down exports in Blender 2.91 --- fast64_internal/utility.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fast64_internal/utility.py b/fast64_internal/utility.py index 6025439..ead26f8 100644 --- a/fast64_internal/utility.py +++ b/fast64_internal/utility.py @@ -451,6 +451,13 @@ def colorTo16bitRGBA(color): return (r << 11) | (g << 6) | (b << 1) | a +# On 2.83/2.91 the rotate operator rotates in the opposite direction (???) +def getDirectionGivenAppVersion(): + if bpy.app.version[1] == 83 or bpy.app.version[1] == 91: + return -1 + else: + return 1 + def applyRotation(objList, angle, axis): bpy.context.scene.tool_settings.use_transform_data_origin = False bpy.context.scene.tool_settings.use_transform_pivot_point_align = False @@ -461,16 +468,15 @@ def applyRotation(objList, angle, axis): obj.select_set(True) bpy.context.view_layer.objects.active = objList[0] - # On 2.83 this operator rotates in the opposite direction (???) - direction = 1 if bpy.app.version[1] != 83 else -1 + direction = getDirectionGivenAppVersion() bpy.ops.transform.rotate(value = direction * angle, orient_axis = axis, orient_type='GLOBAL') bpy.ops.object.transform_apply(location = False, rotation = True, scale = True, properties = False) def doRotation(angle, axis): - direction = 1 if bpy.app.version[1] != 83 else -1 - bpy.ops.transform.rotate(value = direction * angle, orient_axis = axis) + direction = getDirectionGivenAppVersion() + bpy.ops.transform.rotate(value = direction * angle, orient_axis = axis, orient_type='GLOBAL') def getAddressFromRAMAddress(RAMAddress): addr = RAMAddress - 0x80000000