Bump engine submodule and fix signed integers normalisation.

This commit is contained in:
2023-01-04 15:26:05 +01:00
parent ccc168c896
commit 4783f0ba2d
2 changed files with 6 additions and 3 deletions

2
engine

Submodule engine updated: 59d13684be...f463db316f

View File

@ -219,9 +219,12 @@ class ObjArchive(Archive):
assert name not in self.vertices_db.keys()
#TODO: move to math
def pack_10(_x):
return round(_x * (512.0 if _x < 0.0 else 511.0)) & 1023
assert _x >= -1.0 and _x <= 1.0
return round(_x * 511.0) & 1023
# return ((round(_x * 1023.0) - 1) // 2) & 1023
def pack_u10(_x):
return round(_x * 1023.0) & 1023
assert _x >= 0.0 and _x <= 1.0
return round(_x * 1023.0)
def pack_vertex(_px, _py, _pz, _nx, _ny, _nz, _s, _t, _tl):
n = (pack_10(_nz) << 20) | (pack_10(_ny) << 10) | pack_10(_nx)
t = ((_tl & 1023) << 20) | (pack_u10(_t) << 10) | pack_u10(_s)