15# define M_PI_F (3.1415926535897932f)
22 return fabsf(fX) > FLT_MIN;
28 assert((vert & 0x3) == vert);
29 return (face << 2) | (vert & 0x3);
41 const float f =
fabsf(x);
43 const float m = (f < 1.0f) ? 1.0f - (1.0f - f) : 1.0f;
51 const float a =
sqrtf(1.0f - m) *
52 (1.5707963267f + m * (-0.213300989f + m * (0.077980478f + m * -0.02164095f)));
53 return x < 0 ?
M_PI_F - a : a;
58 return (x << k) | (x >> (32 - k));
64 a =
b = c = 0xdeadbeef + (2 << 2) + 13;
71 a = (a ^ c) -
rotl(c, 11);
80 return (x * 73856093) ^ (y * 19349663) ^ (
z * 83492791);
85 return *((
uint *)(&
v));
90 return *((
float *)(&
v));
105template<
typename T,
typename KeyGetter>
106void radixsort(std::vector<T> &data, std::vector<T> &data2, KeyGetter getKey)
108 typedef decltype(getKey(data[0])) key_t;
109 constexpr size_t datasize =
sizeof(key_t);
110 static_assert(datasize % 2 == 0);
111 static_assert(std::is_integral<key_t>::value);
113 uint bins[datasize][257] = {{0}};
116 for (
const T &item :
data) {
117 key_t key = getKey(item);
118 for (
uint pass = 0; pass < datasize; pass++)
119 bins[pass][((key >> (8 * pass)) & 0xff) + 1]++;
123 for (
uint pass = 0; pass < datasize; pass++) {
124 for (
uint i = 2; i < 256; i++) {
125 bins[pass][i] += bins[pass][i - 1];
130 for (
uint pass = 0; pass < datasize; pass++, shift += 8) {
132 for (
const T &item :
data) {
133 uint pos = bins[pass][(getKey(item) >> shift) & 0xff]++;
138 std::swap(data, data2);
148 std::atomic<uint32_t> *atomic_val =
reinterpret_cast<std::atomic<uint32_t> *
>(val);
150 uint32_t old_v = atomic_val->load();
152 if (atomic_val->compare_exchange_weak(old_v, new_v)) {
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
local_group_size(16, 16) .push_constant(Type b
static uint hash_uint3(uint kx, uint ky, uint kz)
static uint pack_index(const uint face, const uint vert)
bool not_zero(const float fX)
static uint float_as_uint(const float v)
static uint hash_float3_fast(const float x, const float y, const float z)
static void unpack_index(uint &face, uint &vert, const uint indexIn)
static uint rotl(uint x, uint k)
static uint hash_float3x3(const float3 &x, const float3 &y, const float3 &z)
static void float_add_atomic(float *val, float add)
static float uint_as_float(const uint v)
void radixsort(std::vector< T > &data, std::vector< T > &data2, KeyGetter getKey)
static uint hash_uint3_fast(const uint x, const uint y, const uint z)
float fast_acosf(float x)