20 #ifdef BT_MANAGED_CODE    31 #define BT_BULLET_VERSION 284    38 #if defined(DEBUG) || defined (_DEBUG)    45                 #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)    47                         #define SIMD_FORCE_INLINE inline    48                         #define ATTRIBUTE_ALIGNED16(a) a    49                         #define ATTRIBUTE_ALIGNED64(a) a    50                         #define ATTRIBUTE_ALIGNED128(a) a    52                         #define SIMD_FORCE_INLINE __forceinline    53                         #define ATTRIBUTE_ALIGNED16(a) __declspec() a    54                         #define ATTRIBUTE_ALIGNED64(a) __declspec() a    55                         #define ATTRIBUTE_ALIGNED128(a) __declspec () a    58                         #pragma warning(disable : 4324) // disable padding warning    63                         #define SIMD_FORCE_INLINE __forceinline    64                         #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a    65                         #define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a    66                         #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a    70                         #include <ppcintrinsics.h>    71                         #define BT_HAVE_NATIVE_FSEL    72                         #define btFsel(a,b,c) __fsel((a),(b),(c))    77 #elif (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))    79                                 #define BT_USE_SIMD_VECTOR3    85 #if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)    87 #endif //(_MSC_FULL_VER >= 160040219)    97                         #include <emmintrin.h>   107                 #define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak();       }}   110                 #define btAssert assert   116                 #define btFullAssert(x)   118                 #define btLikely(_c)  _c   119                 #define btUnlikely(_c) _c   123 #if defined     (__CELLOS_LV2__)   124                 #define SIMD_FORCE_INLINE inline __attribute__((always_inline))   125                 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))   126                 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))   127                 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))   133 #include <spu_printf.h>   134 #define printf spu_printf   135         #define btAssert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}   137         #define btAssert assert   144                 #define btFullAssert(x)   146                 #define btLikely(_c)  _c   147                 #define btUnlikely(_c) _c   153                 #define SIMD_FORCE_INLINE __inline   154                 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))   155                 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))   156                 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))   161                 #define btAssert assert   166                 #define btFullAssert(x)   169                 #define btLikely(_c)   __builtin_expect((_c), 1)   170                 #define btUnlikely(_c) __builtin_expect((_c), 0)   176 #if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION)))   177     #if defined (__i386__) || defined (__x86_64__)   178                 #define BT_USE_SIMD_VECTOR3   182                 #define BT_USE_SSE_IN_API   185             #if defined (__SSE4_1__)   186                 #include <smmintrin.h>   187             #elif defined (__SSSE3__)   188                 #include <tmmintrin.h>   189             #elif defined (__SSE3__)   190                 #include <pmmintrin.h>   192                 #include <emmintrin.h>   195     #elif defined( __ARM_NEON__ )   197             #define BT_USE_NEON 1   198                         #define BT_USE_SIMD_VECTOR3   200             #if defined BT_USE_NEON && defined (__clang__)   201                 #include <arm_neon.h>   206         #define SIMD_FORCE_INLINE inline __attribute__ ((always_inline))   207         #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))   209         #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))   210         #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))   215         #if defined(DEBUG) || defined (_DEBUG)   216          #if defined (__i386__) || defined (__x86_64__)   222                 printf("Assert %s in line %d, file %s\n",#x, __LINE__, __FILE__);\   223                 asm volatile ("int3");\   226         #else//defined (__i386__) || defined (__x86_64__)   227                 #define btAssert assert   228         #endif//defined (__i386__) || defined (__x86_64__)   229         #else//defined(DEBUG) || defined (_DEBUG)   231         #endif//defined(DEBUG) || defined (_DEBUG)   234         #define btFullAssert(x)   235         #define btLikely(_c)  _c   236         #define btUnlikely(_c) _c   240                 #define SIMD_FORCE_INLINE inline   241                 #define ATTRIBUTE_ALIGNED16(a) a   246                 #define ATTRIBUTE_ALIGNED64(a) a   247                 #define ATTRIBUTE_ALIGNED128(a) a   252 #if defined(DEBUG) || defined (_DEBUG)   253                 #define btAssert assert   259                 #define btFullAssert(x)   260                 #define btLikely(_c)  _c   261                 #define btUnlikely(_c) _c   266 #endif  //__CELLOS_LV2__   271 #if defined(BT_USE_DOUBLE_PRECISION)   275 #define BT_LARGE_FLOAT 1e30   280 #define BT_LARGE_FLOAT 1e18f   284 typedef __m128 btSimdFloat4;
   287 #if defined (BT_USE_SSE)   292 static int btNanMask = 0x7F800001;
   293 #define BT_NAN (*(float*)&btNanMask)   298 #define BT_INFINITY (*(float*)&btInfinityMask)   306 #ifndef BT_NO_SIMD_OPERATOR_OVERLOADS   307 inline __m128 
operator + (
const __m128 A, 
const __m128 B)
   309     return _mm_add_ps(A, B);
   312 inline __m128 
operator - (
const __m128 A, 
const __m128 B)
   314     return _mm_sub_ps(A, B);
   317 inline __m128 
operator * (
const __m128 A, 
const __m128 B)
   319     return _mm_mul_ps(A, B);
   321 #endif //BT_NO_SIMD_OPERATOR_OVERLOADS   323 #define btCastfTo128i(a) (_mm_castps_si128(a))   324 #define btCastfTo128d(a) (_mm_castps_pd(a))   325 #define btCastiTo128f(a) (_mm_castsi128_ps(a))   326 #define btCastdTo128f(a) (_mm_castpd_ps(a))   327 #define btCastdTo128i(a) (_mm_castpd_si128(a))   328 #define btAssign128(r0,r1,r2,r3) _mm_setr_ps(r0,r1,r2,r3)   332 #define btCastfTo128i(a) ((__m128i)(a))   333 #define btCastfTo128d(a) ((__m128d)(a))   334 #define btCastiTo128f(a)  ((__m128) (a))   335 #define btCastdTo128f(a) ((__m128) (a))   336 #define btCastdTo128i(a) ((__m128i)(a))   337 #define btAssign128(r0,r1,r2,r3) (__m128){r0,r1,r2,r3}   338 #define BT_INFINITY INFINITY   344         #include <arm_neon.h>   346         typedef float32x4_t btSimdFloat4;
   347         #define BT_INFINITY INFINITY   349         #define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3}   365                 #define BT_INFINITY (btInfinityMask.mask)   376 #include <arm_neon.h>   378 typedef float32x4_t btSimdFloat4;
   379 #define BT_INFINITY INFINITY   381 #define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3}   388 #define BT_DECLARE_ALIGNED_ALLOCATOR() \   389    SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes)   { return btAlignedAlloc(sizeInBytes,16); }   \   390    SIMD_FORCE_INLINE void  operator delete(void* ptr)         { btAlignedFree(ptr); }   \   391    SIMD_FORCE_INLINE void* operator new(size_t, void* ptr)   { return ptr; }   \   392    SIMD_FORCE_INLINE void  operator delete(void*, void*)      { }   \   393    SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes)   { return btAlignedAlloc(sizeInBytes,16); }   \   394    SIMD_FORCE_INLINE void  operator delete[](void* ptr)         { btAlignedFree(ptr); }   \   395    SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr)   { return ptr; }   \   396    SIMD_FORCE_INLINE void  operator delete[](void*, void*)      { }   \   400 #if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)   420 #ifdef USE_APPROXIMATION   422     float xhalf = 0.5f*y;
   424     i = 0x5f375a86 - (i>>1);
   426     y = y*(1.5f - xhalf*y*y);
   427     y = y*(1.5f - xhalf*y*y);
   428     y = y*(1.5f - xhalf*y*y);
   433     unsigned long *tfptr = ((
unsigned long *)&tempf) + 1;
   435     *tfptr = (0xbfcdd90a - *tfptr)>>1; 
   476 #define SIMD_PI           btScalar(3.1415926535897932384626433832795029)   477 #define SIMD_2_PI         (btScalar(2.0) * SIMD_PI)   478 #define SIMD_HALF_PI      (SIMD_PI * btScalar(0.5))   479 #define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))   480 #define SIMD_DEGS_PER_RAD  (btScalar(360.0) / SIMD_2_PI)   481 #define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490)   483 #define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x))))             484 #define btRecip(x) (btScalar(1.0)/btScalar(x))   486 #ifdef BT_USE_DOUBLE_PRECISION   487 #define SIMD_EPSILON      DBL_EPSILON   488 #define SIMD_INFINITY     DBL_MAX   494 #define SIMD_EPSILON      FLT_EPSILON   495 #define SIMD_INFINITY     FLT_MAX   509                 btScalar r = (x - abs_y) / (x + abs_y);
   510                 angle = coeff_1 - coeff_1 * r;
   512                 btScalar r = (x + abs_y) / (abs_y - x);
   513                 angle = coeff_2 - coeff_1 * r;
   515         return (y < 0.0f) ? -angle : angle;
   521         return (((a) <= eps) && !((a) < -eps));
   524         return (!((a) <= eps));
   535 #define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name   540         return a >= 0 ? b : c;
   543 #define btFsels(a,b,c) (btScalar)btFsel(a,b,c)   549    const char *p = (
const char *) &i;
   566     unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
   567     unsigned testEqz = ~testNz;
   568     return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); 
   572     unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
   573     unsigned testEqz = ~testNz; 
   574     return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
   578 #ifdef BT_HAVE_NATIVE_FSEL   579     return (
float)
btFsel((
btScalar)condition - 
btScalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
   581     return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero; 
   596         return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8)  | ((val & 0x000000ff) << 24));
   601         return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
   623     unsigned char *dst = (
unsigned char *)&a;
   624     unsigned char *src = (
unsigned char *)&d;
   637     unsigned char *src = (
unsigned char *)&a;
   638     unsigned char *dst = (
unsigned char *)&d;
   652     unsigned char *src = (
unsigned char *)&d;
   669     unsigned char *dst = (
unsigned char *)&d;
   702     p0 = a[0]; q0 = b[0];
   704     p1 = a[1]; q1 = b[1];
   731         else if(angleInRadians > 
SIMD_PI)
   737                 return angleInRadians;
   747                 :m_objectType(objectType)
   763         struct btConvertPointerSizeT
   771     btConvertPointerSizeT converter;
   774         const size_t bit_mask = ~(alignment - 1);
   775     converter.ptr = unalignedPtr;
   776         converter.integer += alignment-1;
   777         converter.integer &= bit_mask;
   778         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)
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)
int getObjectType() const 
#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)