Updated meshoptimizer.

This commit is contained in:
Бранимир Караџић
2023-12-22 18:14:49 -08:00
parent f07a164880
commit 9640d461ac
2 changed files with 13 additions and 12 deletions

View File

@@ -3,9 +3,15 @@
#include <assert.h>
union FloatBits
{
float f;
unsigned int ui;
};
unsigned short meshopt_quantizeHalf(float v)
{
union { float f; unsigned int ui; } u = {v};
FloatBits u = {v};
unsigned int ui = u.ui;
int s = (ui >> 16) & 0x8000;
@@ -30,7 +36,7 @@ float meshopt_quantizeFloat(float v, int N)
{
assert(N >= 0 && N <= 23);
union { float f; unsigned int ui; } u = {v};
FloatBits u = {v};
unsigned int ui = u.ui;
const int mask = (1 << (23 - N)) - 1;
@@ -64,7 +70,7 @@ float meshopt_dequantizeHalf(unsigned short h)
// 112 is an exponent bias fixup; since we already applied it once, applying it twice converts 31 to 255
r += (em >= (31 << 10)) ? (112 << 23) : 0;
union { float f; unsigned int ui; } u;
FloatBits u;
u.ui = s | r;
return u.f;
}