summaryrefslogtreecommitdiffstats
path: root/thirdparty/meshoptimizer/quantization.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/meshoptimizer/quantization.cpp')
-rw-r--r--thirdparty/meshoptimizer/quantization.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/thirdparty/meshoptimizer/quantization.cpp b/thirdparty/meshoptimizer/quantization.cpp
index 09a314d602..149835f501 100644
--- a/thirdparty/meshoptimizer/quantization.cpp
+++ b/thirdparty/meshoptimizer/quantization.cpp
@@ -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;
}