From f64e672404b87b2d983a1ee2eb256db077efe2d2 Mon Sep 17 00:00:00 2001 From: kurethedead Date: Sat, 20 Feb 2021 08:19:42 -0800 Subject: [PATCH] Fixed issues with bit packing OOT collision values. --- fast64_internal/oot/oot_collision.py | 8 ++++---- fast64_internal/oot/oot_utility.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fast64_internal/oot/oot_collision.py b/fast64_internal/oot/oot_collision.py index 1301f3e..1ef6ad4 100644 --- a/fast64_internal/oot/oot_collision.py +++ b/fast64_internal/oot/oot_collision.py @@ -215,7 +215,7 @@ class OOTPolygonType: (self.exitID << 8) |\ (self.cameraID << 0) - return convertIntTo2sComplement(value, 4) + return convertIntTo2sComplement(value, 4, False) def convertLow(self): value = ((1 if self.isWallDamage else 0) << 27) |\ @@ -227,7 +227,7 @@ class OOTPolygonType: (int(self.terrain, 16) << 4) |\ (int(self.sound, 16) << 0) - return convertIntTo2sComplement(value, 4) + return convertIntTo2sComplement(value, 4, False) class OOTCollision: def __init__(self, ownerName): @@ -303,7 +303,7 @@ class OOTWaterBox(BoxEmpty): value = (int(self.roomIndex) << 13) |\ (self.lightingSetting << 8) |\ (self.cameraSetting << 0) - return convertIntTo2sComplement(value, 4) + return convertIntTo2sComplement(value, 4, False) class OOTCameraData: def __init__(self, ownerName): @@ -526,7 +526,7 @@ def addCollisionTriangles(obj, collisionDict, includeChildren, transformMatrix, faceNormal[0] * planePoint[0] + \ faceNormal[1] * planePoint[1] + \ faceNormal[2] * planePoint[2]))) - distance = convertIntTo2sComplement(distance, 2) + distance = convertIntTo2sComplement(distance, 2, True) nx = (y2 - y1) * (z3 - z2) - (z2 - z1) * (y3 - y2) ny = (z2 - z1) * (x3 - x2) - (x2 - x1) * (z3 - z2) diff --git a/fast64_internal/oot/oot_utility.py b/fast64_internal/oot/oot_utility.py index c284cce..701522c 100644 --- a/fast64_internal/oot/oot_utility.py +++ b/fast64_internal/oot/oot_utility.py @@ -232,8 +232,8 @@ def getCustomProperty(data, prop): value = getattr(data, prop) return value if value != "Custom" else getattr(data, prop + str("Custom")) -def convertIntTo2sComplement(value, length): - return int.from_bytes(int(round(value)).to_bytes(length, 'big', signed = True), 'big') +def convertIntTo2sComplement(value, length, signed): + return int.from_bytes(int(round(value)).to_bytes(length, 'big', signed = signed), 'big') def drawEnumWithCustom(panel, data, attribute, name, customName): prop_split(panel, data, attribute, name)