Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2472


Ignore:
Timestamp:
Dec 15, 2008, 10:20:59 PM (16 years ago)
Author:
rgrieder
Message:

Trying to minimise changes to Bullet v2.73.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/bullet/LinearMath/btScalar.h

    r2471 r2472  
    44This software is provided 'as-is', without any express or implied warranty.
    55In no event will the authors be held liable for any damages arising from the use of this software.
    6 Permission is granted to anyone to use this software for any purpose,
    7 including commercial applications, and to alter it and redistribute it freely,
     6Permission is granted to anyone to use this software for any purpose, 
     7including commercial applications, and to alter it and redistribute it freely, 
    88subject to the following restrictions:
    99
     
    7979
    8080#else
    81 
     81       
    8282#if defined     (__CELLOS_LV2__)
    8383                #define SIMD_FORCE_INLINE inline
     
    119119                #define btLikely(_c)   __builtin_expect((_c), 1)
    120120                #define btUnlikely(_c) __builtin_expect((_c), 0)
    121 
     121               
    122122
    123123#else
     
    179179
    180180#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
    181 
     181               
    182182SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); }
    183183SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabs(x); }
     
    194194
    195195#else
    196 
    197 SIMD_FORCE_INLINE btScalar btSqrt(btScalar y)
    198 {
     196               
     197SIMD_FORCE_INLINE btScalar btSqrt(btScalar y) 
     198{ 
    199199#ifdef USE_APPROXIMATION
    200200    double x, z, tempf;
     
    212212        return x*y;
    213213#else
    214         return sqrtf(y);
     214        return sqrtf(y); 
    215215#endif
    216216}
     
    219219SIMD_FORCE_INLINE btScalar btSin(btScalar x) { return sinf(x); }
    220220SIMD_FORCE_INLINE btScalar btTan(btScalar x) { return tanf(x); }
    221 SIMD_FORCE_INLINE btScalar btAcos(btScalar x) {
     221SIMD_FORCE_INLINE btScalar btAcos(btScalar x) { 
    222222        btAssert(x <= btScalar(1.));
    223         return acosf(x);
     223        return acosf(x); 
    224224}
    225225SIMD_FORCE_INLINE btScalar btAsin(btScalar x) { return asinf(x); }
     
    250250#endif
    251251
    252 SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x)
     252SIMD_FORCE_INLINE btScalar btAtan2Fast(btScalar y, btScalar x) 
    253253{
    254254        btScalar coeff_1 = SIMD_PI / 4.0f;
     
    308308///btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360
    309309///Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html
    310 SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
     310SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) 
    311311{
    312312    // Set testNz to 0xFFFFFFFF if condition is nonzero, 0x00000000 if condition is zero
    313313    // Rely on positive value or'ed with its negative having sign bit on
    314     // and zero value or'ed with its negative (which is still zero) having sign bit off
     314    // and zero value or'ed with its negative (which is still zero) having sign bit off 
    315315    // Use arithmetic shift right, shifting the sign bit through all 32 bits
    316316    unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
    317317    unsigned testEqz = ~testNz;
    318     return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
     318    return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); 
    319319}
    320320SIMD_FORCE_INLINE int btSelect(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
    321321{
    322322    unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31);
    323     unsigned testEqz = ~testNz;
     323    unsigned testEqz = ~testNz; 
    324324    return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
    325325}
     
    329329    return (float)btFsel((btScalar)condition - btScalar(1.0f), valueIfConditionNonZero, valueIfConditionZero);
    330330#else
    331     return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero;
     331    return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero; 
    332332#endif
    333333}
     
    364364///btSwapFloat uses using char pointers to swap the endianness
    365365////btSwapFloat/btSwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values
    366 ///Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754.
    367 ///When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception.
    368 ///In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you.
     366///Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. 
     367///When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. 
     368///In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. 
    369369///so instead of returning a float/double, we return integer/long long integer
    370370SIMD_FORCE_INLINE unsigned int  btSwapEndianFloat(float d)
     
    382382
    383383// unswap using char pointers
    384 SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a)
     384SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a) 
    385385{
    386386    float d = 0.0f;
     
    414414
    415415// unswap using char pointers
    416 SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src)
     416SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src) 
    417417{
    418418    double d = 0.0;
Note: See TracChangeset for help on using the changeset viewer.