mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-19 05:23:00 +01:00
Updated meshoptimizer.
This commit is contained in:
12
3rdparty/meshoptimizer/src/quantization.cpp
vendored
12
3rdparty/meshoptimizer/src/quantization.cpp
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user