Bump engine submodule and fix signed integers normalisation.

This commit is contained in:
Roz K 2023-01-04 15:26:05 +01:00
parent ccc168c896
commit 4783f0ba2d
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
2 changed files with 6 additions and 3 deletions

2
engine

@ -1 +1 @@
Subproject commit 59d13684be90b9f942e68b478ab60755b528c8f5 Subproject commit f463db316fc9eae9f26a83605d1c05f662b6e7de

View File

@ -219,9 +219,12 @@ class ObjArchive(Archive):
assert name not in self.vertices_db.keys() assert name not in self.vertices_db.keys()
#TODO: move to math #TODO: move to math
def pack_10(_x): 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): 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): def pack_vertex(_px, _py, _pz, _nx, _ny, _nz, _s, _t, _tl):
n = (pack_10(_nz) << 20) | (pack_10(_ny) << 10) | pack_10(_nx) n = (pack_10(_nz) << 20) | (pack_10(_ny) << 10) | pack_10(_nx)
t = ((_tl & 1023) << 20) | (pack_u10(_t) << 10) | pack_u10(_s) t = ((_tl & 1023) << 20) | (pack_u10(_t) << 10) | pack_u10(_s)