Fixed bugs in compression logic.

master
TigerKat 4 years ago
parent 749bc7577b
commit cffe622ef2

@ -26,12 +26,12 @@ def compressQuaternion_5Byte(quat):
for i in range(4):
if i == missing:
continue
v = int(math.round(q[i] / MAX_5_BYTE_QUATERNION * 2048))
v = int(math.floor(0.5 + q[i] / MAX_5_BYTE_QUATERNION * 2048))
if v < -2048:
v = -2048
elif v > 2047:
v = 2047
d.append(q[i] * 2048)
d.append(v + 2048)
v = (
(missing << 36) |
(d[0] << 24) |
@ -40,7 +40,7 @@ def compressQuaternion_5Byte(quat):
)
s = struct.pack("<Q", v)
#Return with the top most byte first, but remaining bytes in little endian order.
return s[4] + s[0:4]
return s[4:5] + s[0:4]
def decompressQuaternion_5Byte(data):
#Source data has the top most byte first, but remaining bytes are little endian.
@ -79,10 +79,10 @@ def decompressQuaternion_5Byte(data):
def compressQuaternion_8Byte(quat):
return struct.pack("<hhhh",
int(floor(0.5 + quat[0] * SCALE_8_BYTE_QUATERNION_COMPRESS)),
int(floor(0.5 + quat[1] * SCALE_8_BYTE_QUATERNION_COMPRESS)),
int(floor(0.5 + quat[2] * SCALE_8_BYTE_QUATERNION_COMPRESS)),
int(floor(0.5 + quat[3] * SCALE_8_BYTE_QUATERNION_COMPRESS))
int(math.floor(0.5 + quat[0] * SCALE_8_BYTE_QUATERNION_COMPRESS)),
int(math.floor(0.5 + quat[1] * SCALE_8_BYTE_QUATERNION_COMPRESS)),
int(math.floor(0.5 + quat[2] * SCALE_8_BYTE_QUATERNION_COMPRESS)),
int(math.floor(0.5 + quat[3] * SCALE_8_BYTE_QUATERNION_COMPRESS))
)
def decompressQuaternion_8Byte(data):
@ -97,9 +97,9 @@ def decompressQuaternion_8Byte(data):
def compressVector3_6Byte(vec):
return struct.pack("<hhh",
int(floor(0.5 + vec[0] * SCALE_6_BYTE_VECTOR3_COMPRESS)),
int(floor(0.5 + vec[1] * SCALE_6_BYTE_VECTOR3_COMPRESS)),
int(floor(0.5 + vec[2] * SCALE_6_BYTE_VECTOR3_COMPRESS))
int(math.floor(0.5 + vec[0] * SCALE_6_BYTE_VECTOR3_COMPRESS)),
int(math.floor(0.5 + vec[1] * SCALE_6_BYTE_VECTOR3_COMPRESS)),
int(math.floor(0.5 + vec[2] * SCALE_6_BYTE_VECTOR3_COMPRESS))
)
def decompressVector3_6Byte(data):

Loading…
Cancel
Save