From 4783f0ba2de5d899bb2e3b3b41fb09cdf22ba8b7 Mon Sep 17 00:00:00 2001 From: Roz K Date: Wed, 4 Jan 2023 15:26:05 +0100 Subject: [PATCH] Bump engine submodule and fix signed integers normalisation. --- engine | 2 +- game/obj2rkar.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engine b/engine index 59d1368..f463db3 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit 59d13684be90b9f942e68b478ab60755b528c8f5 +Subproject commit f463db316fc9eae9f26a83605d1c05f662b6e7de diff --git a/game/obj2rkar.py b/game/obj2rkar.py index 433b31c..9199847 100644 --- a/game/obj2rkar.py +++ b/game/obj2rkar.py @@ -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)