28#define BT_BULLET_VERSION 289
37 #ifdef BT_USE_DOUBLE_PRECISION
57#define BT_NOT_EMPTY_FILE_CAT_II(p, res) res
58#define BT_NOT_EMPTY_FILE_CAT_I(a, b) BT_NOT_EMPTY_FILE_CAT_II(~, a##b)
59#define BT_NOT_EMPTY_FILE_CAT(a, b) BT_NOT_EMPTY_FILE_CAT_I(a, b)
60#define BT_NOT_EMPTY_FILE \
63 char BT_NOT_EMPTY_FILE_CAT(NoEmptyFileDummy, __COUNTER__); \
66#define BT_NOT_EMPTY_FILE
71#if defined(DEBUG) || defined (_DEBUG)
77 #define SIMD_FORCE_INLINE __inline__ __attribute__((always_inline))
78 #define ATTRIBUTE_ALIGNED16(a) a __attribute__((aligned(16)))
79 #define ATTRIBUTE_ALIGNED64(a) a __attribute__((aligned(64)))
80 #define ATTRIBUTE_ALIGNED128(a) a __attribute__((aligned(128)))
81 #elif ( defined(_MSC_VER) && _MSC_VER < 1300 )
82 #define SIMD_FORCE_INLINE inline
83 #define ATTRIBUTE_ALIGNED16(a) a
84 #define ATTRIBUTE_ALIGNED64(a) a
85 #define ATTRIBUTE_ALIGNED128(a) a
87 #define SIMD_FORCE_INLINE __forceinline
88 #define ATTRIBUTE_ALIGNED16(a) __declspec() a
89 #define ATTRIBUTE_ALIGNED64(a) __declspec() a
90 #define ATTRIBUTE_ALIGNED128(a) __declspec () a
93 #pragma warning(disable : 4324)
95 #pragma warning(disable:4996)
98 #define SIMD_FORCE_INLINE __forceinline
99 #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
100 #define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a
101 #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
103 #define BT_USE_VMX128
105 #include <ppcintrinsics.h>
106 #define BT_HAVE_NATIVE_FSEL
107 #define btFsel(a,b,c) __fsel((a),(b),(c))
112#elif (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))
115#define __BT_DISABLE_SSE__
117#ifndef __BT_DISABLE_SSE__
119 #define BT_USE_SIMD_VECTOR3
125#if (_MSC_FULL_VER >= 170050727)
126 #define BT_ALLOW_SSE4
137 #include <emmintrin.h>
147 #define btAssert(x) { if(!(x)){printf("Assert " __FILE__ ":%u (%s)\n", __LINE__, #x);__debugbreak(); }}
150 #define btAssert assert
156 #define btFullAssert(x)
158 #define btLikely(_c) _c
159 #define btUnlikely(_c) _c
163 #if defined (__CELLOS_LV2__)
164 #define SIMD_FORCE_INLINE inline __attribute__((always_inline))
165 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
166 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
167 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
173 #include <spu_printf.h>
174 #define printf spu_printf
175 #define btAssert(x) {if(!(x)){printf("Assert " __FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}
177 #define btAssert assert
184 #define btFullAssert(x)
186 #define btLikely(_c) _c
187 #define btUnlikely(_c) _c
193 #define SIMD_FORCE_INLINE __inline
194 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
195 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
196 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
201 #define btAssert assert
206 #define btFullAssert(x)
209 #define btLikely(_c) __builtin_expect((_c), 1)
210 #define btUnlikely(_c) __builtin_expect((_c), 0)
216 #if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION)))
217 #if defined (__i386__) || defined (__x86_64__)
218 #define BT_USE_SIMD_VECTOR3
222 #define BT_USE_SSE_IN_API
225 #if defined (__SSE4_1__)
226 #include <smmintrin.h>
227 #elif defined (__SSSE3__)
228 #include <tmmintrin.h>
229 #elif defined (__SSE3__)
230 #include <pmmintrin.h>
232 #include <emmintrin.h>
235 #elif defined( __ARM_NEON__ )
237 #define BT_USE_NEON 1
238 #define BT_USE_SIMD_VECTOR3
240 #if defined BT_USE_NEON && defined (__clang__)
241 #include <arm_neon.h>
246 #define SIMD_FORCE_INLINE inline __attribute__ ((always_inline))
248 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
249 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
250 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
255 #if defined(DEBUG) || defined (_DEBUG)
256 #if defined (__i386__) || defined (__x86_64__)
262 printf("Assert %s in line %d, file %s\n",#x, __LINE__, __FILE__);\
263 asm volatile ("int3");\
267 #define btAssert assert
274 #define btFullAssert(x)
275 #define btLikely(_c) _c
276 #define btUnlikely(_c) _c
280 #define SIMD_FORCE_INLINE inline
285 #define ATTRIBUTE_ALIGNED16(a) a
286 #define ATTRIBUTE_ALIGNED64(a) a
287 #define ATTRIBUTE_ALIGNED128(a) a
292 #if defined(DEBUG) || defined (_DEBUG)
293 #define btAssert assert
299 #define btFullAssert(x)
300 #define btLikely(_c) _c
301 #define btUnlikely(_c) _c
309#if defined(BT_USE_DOUBLE_PRECISION)
312 #define BT_LARGE_FLOAT 1e30
316 #define BT_LARGE_FLOAT 1e18f
320 typedef __m128 btSimdFloat4;
323#if defined(BT_USE_SSE)
328 static int btNanMask = 0x7F800001;
329 #define BT_NAN (*(float *)&btNanMask)
334 #define BT_INFINITY (*(float *)&btInfinityMask)
344 #ifndef BT_NO_SIMD_OPERATOR_OVERLOADS
345 inline __m128
operator+(
const __m128 A,
const __m128
B)
347 return _mm_add_ps(A,
B);
350 inline __m128
operator-(
const __m128 A,
const __m128
B)
352 return _mm_sub_ps(A,
B);
355 inline __m128
operator*(
const __m128 A,
const __m128
B)
357 return _mm_mul_ps(A,
B);
361 #define btCastfTo128i(a) (_mm_castps_si128(a))
362 #define btCastfTo128d(a) (_mm_castps_pd(a))
363 #define btCastiTo128f(a) (_mm_castsi128_ps(a))
364 #define btCastdTo128f(a) (_mm_castpd_ps(a))
365 #define btCastdTo128i(a) (_mm_castpd_si128(a))
366 #define btAssign128(r0, r1, r2, r3) _mm_setr_ps(r0, r1, r2, r3)
370 #define btCastfTo128i(a) ((__m128i)(a))
371 #define btCastfTo128d(a) ((__m128d)(a))
372 #define btCastiTo128f(a) ((__m128)(a))
373 #define btCastdTo128f(a) ((__m128)(a))
374 #define btCastdTo128i(a) ((__m128i)(a))
375 #define btAssign128(r0, r1, r2, r3) \
376 (__m128) { r0, r1, r2, r3 }
377 #define BT_INFINITY INFINITY
383 #include <arm_neon.h>
385 typedef float32x4_t btSimdFloat4;
386 #define BT_INFINITY INFINITY
388 #define btAssign128(r0, r1, r2, r3) \
389 (float32x4_t) { r0, r1, r2, r3 }
405 #define BT_INFINITY (btInfinityMask.mask)
416 #include <arm_neon.h>
418 typedef float32x4_t btSimdFloat4;
419 #define BT_INFINITY INFINITY
421 #define btAssign128(r0, r1, r2, r3) \
422 (float32x4_t) { r0, r1, r2, r3 }
425#define BT_DECLARE_ALIGNED_ALLOCATOR() \
426 SIMD_FORCE_INLINE void *operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes, 16); } \
427 SIMD_FORCE_INLINE void operator delete(void *ptr) { btAlignedFree(ptr); } \
428 SIMD_FORCE_INLINE void *operator new(size_t, void *ptr) { return ptr; } \
429 SIMD_FORCE_INLINE void operator delete(void *, void *) {} \
430 SIMD_FORCE_INLINE void *operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes, 16); } \
431 SIMD_FORCE_INLINE void operator delete[](void *ptr) { btAlignedFree(ptr); } \
432 SIMD_FORCE_INLINE void *operator new[](size_t, void *ptr) { return ptr; } \
433 SIMD_FORCE_INLINE void operator delete[](void *, void *) {}
435#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
468 #ifdef USE_APPROXIMATION
470 float xhalf = 0.5f *
y;
472 i = 0x5f375a86 - (i >> 1);
474 y = y * (1.5f - xhalf * y *
y);
475 y = y * (1.5f - xhalf * y *
y);
476 y = y * (1.5f - xhalf * y *
y);
481 unsigned long *tfptr = ((
unsigned long *)&tempf) + 1;
483 *tfptr = (0xbfcdd90a - *tfptr) >> 1;
526#define SIMD_PI btScalar(3.1415926535897932384626433832795029)
527#define SIMD_2_PI (btScalar(2.0) * SIMD_PI)
528#define SIMD_HALF_PI (SIMD_PI * btScalar(0.5))
529#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))
530#define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI)
531#define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490)
532#define btRecipSqrt(x) ((btScalar)(btScalar(1.0) / btSqrt(btScalar(x))))
533#define btRecip(x) (btScalar(1.0) / btScalar(x))
535#ifdef BT_USE_DOUBLE_PRECISION
536 #define SIMD_EPSILON DBL_EPSILON
537 #define SIMD_INFINITY DBL_MAX
543 #define SIMD_EPSILON FLT_EPSILON
544 #define SIMD_INFINITY FLT_MAX
561 btScalar r = (x - abs_y) / (x + abs_y);
562 angle = coeff_1 - coeff_1 * r;
566 btScalar r = (x + abs_y) / (abs_y - x);
567 angle = coeff_2 - coeff_1 * r;
576 return (((a) <=
eps) && !((a) < -
eps));
580 return (!((a) <=
eps));
591#define BT_DECLARE_HANDLE(name) \
592 typedef struct name##__ \
600 return a >= 0 ?
b : c;
603#define btFsels(a, b, c) (btScalar) btFsel(a, b, c)
608 const char *p = (
const char *)&i;
623 unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
624 unsigned testEqz = ~testNz;
625 return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
629 unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
630 unsigned testEqz = ~testNz;
631 return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
635#ifdef BT_HAVE_NATIVE_FSEL
636 return (
float)
btFsel((
btScalar)condition -
btScalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
638 return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero;
653 return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24));
658 return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
680 unsigned char *dst = (
unsigned char *)&a;
681 unsigned char *src = (
unsigned char *)&d;
694 unsigned char *src = (
unsigned char *)&a;
695 unsigned char *dst = (
unsigned char *)&d;
708 unsigned char *src = (
unsigned char *)&d;
724 unsigned char *dst = (
unsigned char *)&d;
788 else if (angleInRadians >
SIMD_PI)
794 return angleInRadians;
816 struct btConvertPointerSizeT
823 btConvertPointerSizeT converter;
825 const size_t bit_mask = ~(alignment - 1);
826 converter.ptr = unalignedPtr;
827 converter.integer += alignment - 1;
828 converter.integer &= bit_mask;
829 return converter.ptr;
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE btScalar btAcos(btScalar x)
SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a)
SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src)
SIMD_FORCE_INLINE void btSetZero(T *a, int n)
SIMD_FORCE_INLINE bool btEqual(btScalar a, btScalar eps)
SIMD_FORCE_INLINE btScalar btCos(btScalar x)
#define SIMD_RADS_PER_DEG
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
SIMD_FORCE_INLINE unsigned btSwapEndian(unsigned val)
SIMD_FORCE_INLINE btScalar btSin(btScalar x)
SIMD_FORCE_INLINE void btSwapEndianDouble(double d, unsigned char *dst)
#define SIMD_DEGS_PER_RAD
SIMD_FORCE_INLINE btScalar btNormalizeAngle(btScalar angleInRadians)
SIMD_FORCE_INLINE btScalar btAsin(btScalar x)
SIMD_FORCE_INLINE unsigned int btSwapEndianFloat(float d)
btSwapFloat uses using char pointers to swap the endianness
SIMD_FORCE_INLINE btScalar btFabs(btScalar x)
SIMD_FORCE_INLINE btScalar btTan(btScalar x)
SIMD_FORCE_INLINE btScalar btDegrees(btScalar x)
SIMD_FORCE_INLINE bool btFuzzyZero(btScalar x)
SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x)
SIMD_FORCE_INLINE bool btGreaterEqual(btScalar a, btScalar eps)
SIMD_FORCE_INLINE btScalar btSqrt(btScalar y)
static btInfMaskConverter btInfinityMask
SIMD_FORCE_INLINE btScalar btLargeDot(const btScalar *a, const btScalar *b, int n)
SIMD_FORCE_INLINE btScalar btLog(btScalar x)
#define SIMD_FORCE_INLINE
SIMD_FORCE_INLINE btScalar btRadians(btScalar x)
SIMD_FORCE_INLINE btScalar btAtan(btScalar x)
SIMD_FORCE_INLINE btScalar btExp(btScalar x)
T * btAlignPointer(T *unalignedPtr, size_t alignment)
align a pointer to the provided alignment, upwards
SIMD_FORCE_INLINE btScalar btFsel(btScalar a, btScalar b, btScalar c)
SIMD_FORCE_INLINE void btSwap(T &a, T &b)
SIMD_FORCE_INLINE bool btMachineIsLittleEndian()
SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y)
#define BT_BULLET_VERSION
int btIsDoublePrecision()
SIMD_FORCE_INLINE btScalar btFmod(btScalar x, btScalar y)
SIMD_FORCE_INLINE int btIsNegative(btScalar x)
SIMD_FORCE_INLINE btScalar btPow(btScalar x, btScalar y)
static T sum(const btAlignedObjectArray< T > &items)
local_group_size(16, 16) .push_constant(Type b
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
constexpr GPUAttachmentType operator-(GPUAttachmentType a, int b)
constexpr GPUAttachmentType operator+(GPUAttachmentType a, int b)
ccl_device_inline float2 operator*(const float2 a, const float2 b)
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline float2 fabs(const float2 a)
ccl_device_inline float3 exp(float3 v)
ccl_device_inline float3 cos(float3 v)
ccl_device_inline float3 log(float3 v)
T atan2(const T &y, const T &x)
T sin(const AngleRadianBase< T > &a)
T tan(const AngleRadianBase< T > &a)
btInfMaskConverter(int _mask=0x7F800000)
rudimentary class to provide type info
btTypedObject(int objectType)
int getObjectType() const