1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Update meshoptimizer to 0.22

The Godot-specific patch is just a single line now; removing this patch
will likely require adjusting Godot importer code to handle error limits
better.

This also adds new SIMPLIFY_ options; Godot is currently not using any
of these but might use SIMPLIFY_PRUNE and SIMPLIFY_SPARSE in the future.
This commit is contained in:
Arseny Kapoulkine
2024-10-25 10:41:51 -07:00
parent 1015a481ff
commit e2cc0e484e
18 changed files with 1021 additions and 273 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;
}