diff options
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp')
-rw-r--r-- | extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp index c996bfcdaba..a7362ea01f4 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp @@ -13,7 +13,9 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ - +#if defined (_WIN32) || defined (__i386__) +#define BT_USE_SSE_IN_API +#endif #include "btMultiSphereShape.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" @@ -39,10 +41,11 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala } - +#ifndef MIN + #define MIN( _a, _b) ((_a) < (_b) ? (_a) : (_b)) +#endif btVector3 btMultiSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const { - int i; btVector3 supVec(0,0,0); btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); @@ -66,18 +69,23 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala const btScalar* rad = &m_radiArray[0]; int numSpheres = m_localPositionArray.size(); - for (i=0;i<numSpheres;i++) + for( int k = 0; k < numSpheres; k+= 128 ) { - vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin(); - pos++; - rad++; - newDot = vec.dot(vtx); - if (newDot > maxDot) + btVector3 temp[128]; + int inner_count = MIN( numSpheres - k, 128 ); + for( long i = 0; i < inner_count; i++ ) + { + temp[i] = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin(); + pos++; + rad++; + } + long i = vec.maxDot( temp, inner_count, newDot); + if( newDot > maxDot ) { maxDot = newDot; - supVec = vtx; + supVec = temp[i]; } - } + } return supVec; @@ -98,18 +106,25 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala const btVector3* pos = &m_localPositionArray[0]; const btScalar* rad = &m_radiArray[0]; int numSpheres = m_localPositionArray.size(); - for (int i=0;i<numSpheres;i++) - { - vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin(); - pos++; - rad++; - newDot = vec.dot(vtx); - if (newDot > maxDot) - { - maxDot = newDot; - supportVerticesOut[j] = vtx; - } - } + + for( int k = 0; k < numSpheres; k+= 128 ) + { + btVector3 temp[128]; + int inner_count = MIN( numSpheres - k, 128 ); + for( long i = 0; i < inner_count; i++ ) + { + temp[i] = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin(); + pos++; + rad++; + } + long i = vec.maxDot( temp, inner_count, newDot); + if( newDot > maxDot ) + { + maxDot = newDot; + supportVerticesOut[j] = temp[i]; + } + } + } } |