21 #ifdef BT_MANAGED_CODE    32 #define BT_BULLET_VERSION 286    39 #if defined(DEBUG) || defined (_DEBUG)    46                 #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)    48                         #define SIMD_FORCE_INLINE inline    49                         #define ATTRIBUTE_ALIGNED16(a) a    50                         #define ATTRIBUTE_ALIGNED64(a) a    51                         #define ATTRIBUTE_ALIGNED128(a) a    53                         #define SIMD_FORCE_INLINE __forceinline    54                         #define ATTRIBUTE_ALIGNED16(a) __declspec() a    55                         #define ATTRIBUTE_ALIGNED64(a) __declspec() a    56                         #define ATTRIBUTE_ALIGNED128(a) __declspec () a    59                         #pragma warning(disable : 4324) // disable padding warning    61                         #pragma warning(disable:4996) //Turn off warnings about deprecated C routines    64                         #define SIMD_FORCE_INLINE __forceinline    65                         #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a    66                         #define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a    67                         #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a    71                         #include <ppcintrinsics.h>    72                         #define BT_HAVE_NATIVE_FSEL    73                         #define btFsel(a,b,c) __fsel((a),(b),(c))    78 #elif (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))    80                                 #define BT_USE_SIMD_VECTOR3    86 #if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)    88 #endif //(_MSC_FULL_VER >= 160040219)    98                         #include <emmintrin.h>   108                 #define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u (%s)\n", __LINE__, #x);__debugbreak();     }}   111                 #define btAssert assert   117                 #define btFullAssert(x)   119                 #define btLikely(_c)  _c   120                 #define btUnlikely(_c) _c   124 #if defined     (__CELLOS_LV2__)   125                 #define SIMD_FORCE_INLINE inline __attribute__((always_inline))   126                 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))   127                 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))   128                 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))   134 #include <spu_printf.h>   135 #define printf spu_printf   136         #define btAssert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}   138         #define btAssert assert   145                 #define btFullAssert(x)   147                 #define btLikely(_c)  _c   148                 #define btUnlikely(_c) _c   154                 #define SIMD_FORCE_INLINE __inline   155                 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))   156                 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))   157                 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))   162                 #define btAssert assert   167                 #define btFullAssert(x)   170                 #define btLikely(_c)   __builtin_expect((_c), 1)   171                 #define btUnlikely(_c) __builtin_expect((_c), 0)   177 #if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION)))   178     #if defined (__i386__) || defined (__x86_64__)   179                 #define BT_USE_SIMD_VECTOR3   183                 #define BT_USE_SSE_IN_API   186             #if defined (__SSE4_1__)   187                 #include <smmintrin.h>   188             #elif defined (__SSSE3__)   189                 #include <tmmintrin.h>   190             #elif defined (__SSE3__)   191                 #include <pmmintrin.h>   193                 #include <emmintrin.h>   196     #elif defined( __ARM_NEON__ )   198             #define BT_USE_NEON 1   199                         #define BT_USE_SIMD_VECTOR3   201             #if defined BT_USE_NEON && defined (__clang__)   202                 #include <arm_neon.h>   207         #define SIMD_FORCE_INLINE inline __attribute__ ((always_inline))   208         #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))   210         #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))   211         #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))   216         #if defined(DEBUG) || defined (_DEBUG)   217          #if defined (__i386__) || defined (__x86_64__)   223                 printf("Assert %s in line %d, file %s\n",#x, __LINE__, __FILE__);\   224                 asm volatile ("int3");\   227         #else//defined (__i386__) || defined (__x86_64__)   228                 #define btAssert assert   229         #endif//defined (__i386__) || defined (__x86_64__)   230         #else//defined(DEBUG) || defined (_DEBUG)   232         #endif//defined(DEBUG) || defined (_DEBUG)   235         #define btFullAssert(x)   236         #define btLikely(_c)  _c   237         #define btUnlikely(_c) _c   241                 #define SIMD_FORCE_INLINE inline   242                 #define ATTRIBUTE_ALIGNED16(a) a   247                 #define ATTRIBUTE_ALIGNED64(a) a   248                 #define ATTRIBUTE_ALIGNED128(a) a   253 #if defined(DEBUG) || defined (_DEBUG)   254                 #define btAssert assert   260                 #define btFullAssert(x)   261                 #define btLikely(_c)  _c   262                 #define btUnlikely(_c) _c   267 #endif  //__CELLOS_LV2__   272 #if defined(BT_USE_DOUBLE_PRECISION)   276 #define BT_LARGE_FLOAT 1e30   281 #define BT_LARGE_FLOAT 1e18f   285 typedef __m128 btSimdFloat4;
   288 #if defined (BT_USE_SSE)   293 static int btNanMask = 0x7F800001;
   294 #define BT_NAN (*(float*)&btNanMask)   299 #define BT_INFINITY (*(float*)&btInfinityMask)   307 #ifndef BT_NO_SIMD_OPERATOR_OVERLOADS   308 inline __m128 
operator + (
const __m128 A, 
const __m128 B)
   310     return _mm_add_ps(A, B);
   313 inline __m128 
operator - (
const __m128 A, 
const __m128 B)
   315     return _mm_sub_ps(A, B);
   318 inline __m128 
operator * (
const __m128 A, 
const __m128 B)
   320     return _mm_mul_ps(A, B);
   322 #endif //BT_NO_SIMD_OPERATOR_OVERLOADS   324 #define btCastfTo128i(a) (_mm_castps_si128(a))   325 #define btCastfTo128d(a) (_mm_castps_pd(a))   326 #define btCastiTo128f(a) (_mm_castsi128_ps(a))   327 #define btCastdTo128f(a) (_mm_castpd_ps(a))   328 #define btCastdTo128i(a) (_mm_castpd_si128(a))   329 #define btAssign128(r0,r1,r2,r3) _mm_setr_ps(r0,r1,r2,r3)   333 #define btCastfTo128i(a) ((__m128i)(a))   334 #define btCastfTo128d(a) ((__m128d)(a))   335 #define btCastiTo128f(a)  ((__m128) (a))   336 #define btCastdTo128f(a) ((__m128) (a))   337 #define btCastdTo128i(a) ((__m128i)(a))   338 #define btAssign128(r0,r1,r2,r3) (__m128){r0,r1,r2,r3}   339 #define BT_INFINITY INFINITY   345         #include <arm_neon.h>   347         typedef float32x4_t btSimdFloat4;
   348         #define BT_INFINITY INFINITY   350         #define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3}   366                 #define BT_INFINITY (btInfinityMask.mask)   377 #include <arm_neon.h>   379 typedef float32x4_t btSimdFloat4;
   380 #define BT_INFINITY INFINITY   382 #define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3}   389 #define BT_DECLARE_ALIGNED_ALLOCATOR() \   390    SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes)   { return btAlignedAlloc(sizeInBytes,16); }   \   391    SIMD_FORCE_INLINE void  operator delete(void* ptr)         { btAlignedFree(ptr); }   \   392    SIMD_FORCE_INLINE void* operator new(size_t, void* ptr)   { return ptr; }   \   393    SIMD_FORCE_INLINE void  operator delete(void*, void*)      { }   \   394    SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes)   { return btAlignedAlloc(sizeInBytes,16); }   \   395    SIMD_FORCE_INLINE void  operator delete[](void* ptr)         { btAlignedFree(ptr); }   \   396    SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr)   { return ptr; }   \   397    SIMD_FORCE_INLINE void  operator delete[](void*, void*)      { }   \   401 #if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)   421 #ifdef USE_APPROXIMATION   423     float xhalf = 0.5f*y;
   425     i = 0x5f375a86 - (i>>1);
   427     y = y*(1.5f - xhalf*y*y);
   428     y = y*(1.5f - xhalf*y*y);
   429     y = y*(1.5f - xhalf*y*y);
   434     unsigned long *tfptr = ((
unsigned long *)&tempf) + 1;
   436     *tfptr = (0xbfcdd90a - *tfptr)>>1; 
   477 #define SIMD_PI           btScalar(3.1415926535897932384626433832795029)   478 #define SIMD_2_PI         (btScalar(2.0) * SIMD_PI)   479 #define SIMD_HALF_PI      (SIMD_PI * btScalar(0.5))   480 #define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))   481 #define SIMD_DEGS_PER_RAD  (btScalar(360.0) / SIMD_2_PI)   482 #define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490)   484 #define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x))))             485 #define btRecip(x) (btScalar(1.0)/btScalar(x))   487 #ifdef BT_USE_DOUBLE_PRECISION   488 #define SIMD_EPSILON      DBL_EPSILON   489 #define SIMD_INFINITY     DBL_MAX   495 #define SIMD_EPSILON      FLT_EPSILON   496 #define SIMD_INFINITY     FLT_MAX   510                 btScalar r = (x - abs_y) / (x + abs_y);
   511                 angle = coeff_1 - coeff_1 * r;
   513                 btScalar r = (x + abs_y) / (abs_y - x);
   514                 angle = coeff_2 - coeff_1 * r;
   516         return (y < 0.0f) ? -angle : angle;
   522         return (((a) <= eps) && !((a) < -eps));
   525         return (!((a) <= eps));
   536 #define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name   541         return a >= 0 ? b : c;
   544 #define btFsels(a,b,c) (btScalar)btFsel(a,b,c)   550    const char *p = (
const char *) &i;
   567     unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
   568     unsigned testEqz = ~testNz;
   569     return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); 
   573     unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
   574     unsigned testEqz = ~testNz; 
   575     return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
   579 #ifdef BT_HAVE_NATIVE_FSEL   580     return (
float)
btFsel((
btScalar)condition - 
btScalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
   582     return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero; 
   597         return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8)  | ((val & 0x000000ff) << 24));
   602         return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
   624     unsigned char *dst = (
unsigned char *)&a;
   625     unsigned char *src = (
unsigned char *)&d;
   638     unsigned char *src = (
unsigned char *)&a;
   639     unsigned char *dst = (
unsigned char *)&d;
   653     unsigned char *src = (
unsigned char *)&d;
   670     unsigned char *dst = (
unsigned char *)&d;
   703     p0 = a[0]; q0 = b[0];
   705     p1 = a[1]; q1 = b[1];
   732         else if(angleInRadians > 
SIMD_PI)
   738                 return angleInRadians;
   748                 :m_objectType(objectType)
   764         struct btConvertPointerSizeT
   772     btConvertPointerSizeT converter;
   775         const size_t bit_mask = ~(alignment - 1);
   776     converter.ptr = unalignedPtr;
   777         converter.integer += alignment-1;
   778         converter.integer &= bit_mask;
   779         return converter.ptr;
 int btIsNegative(btScalar x)
static T sum(const btAlignedObjectArray< T > &items)
unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBo...
btScalar btRadians(btScalar x)
btScalar btDegrees(btScalar x)
btScalar btSin(btScalar x)
btScalar btSqrt(btScalar y)
bool btGreaterEqual(btScalar a, btScalar eps)
#define SIMD_FORCE_INLINE
bool btEqual(btScalar a, btScalar eps)
btMatrix3x3 operator+(const btMatrix3x3 &m1, const btMatrix3x3 &m2)
int getObjectType() const
btInfMaskConverter(int mask=0x7F800000)
btScalar btFsel(btScalar a, btScalar b, btScalar c)
bool btMachineIsLittleEndian()
btScalar btAtan2Fast(btScalar y, btScalar x)
#define SIMD_DEGS_PER_RAD
btScalar btAtan2(btScalar x, btScalar y)
btTypedObject(int objectType)
btMatrix3x3 operator*(const btMatrix3x3 &m, const btScalar &k)
void btSetZero(T *a, int n)
btScalar btPow(btScalar x, btScalar y)
btScalar btAcos(btScalar x)
unsigned int btSwapEndianFloat(float d)
btSwapFloat uses using char pointers to swap the endianness 
btScalar btNormalizeAngle(btScalar angleInRadians)
btScalar btAtan(btScalar x)
btScalar btLog(btScalar x)
btMatrix3x3 operator-(const btMatrix3x3 &m1, const btMatrix3x3 &m2)
rudimentary class to provide type info 
btScalar btFmod(btScalar x, btScalar y)
bool btFuzzyZero(btScalar x)
#define BT_BULLET_VERSION
btScalar btExp(btScalar x)
void btSwapEndianDouble(double d, unsigned char *dst)
unsigned btSwapEndian(unsigned val)
static btInfMaskConverter btInfinityMask
T * btAlignPointer(T *unalignedPtr, size_t alignment)
align a pointer to the provided alignment, upwards 
btScalar btAsin(btScalar x)
#define SIMD_RADS_PER_DEG
float btUnswapEndianFloat(unsigned int a)
btScalar btTan(btScalar x)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btCos(btScalar x)
btScalar btLargeDot(const btScalar *a, const btScalar *b, int n)
btScalar btFabs(btScalar x)
double btUnswapEndianDouble(const unsigned char *src)