diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index 9c43627d4..b913f0064 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -397,10 +397,13 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) printf("new numVertices = %d\n", hull->numVertices ()); btConvexHullShape* convexShape = new btConvexHullShape(); + bool updateLocalAabb = false; + for (i=0;inumVertices();i++) { - convexShape->addPoint(hull->getVertexPointer()[i]); + convexShape->addPoint(hull->getVertexPointer()[i],updateLocalAabb); } + convexShape->recalcLocalAabb(); if (sEnableSAT) convexShape->initializePolyhedralFeatures(); diff --git a/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp index 44c77304d..584b9d519 100644 --- a/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btWorldImporter.cpp @@ -1400,8 +1400,8 @@ void btWorldImporter::convertRigidBodyDouble( btRigidBodyDoubleData* colObjData) } bool isDynamic = mass!=0.f; btRigidBody* body = createRigidBody(isDynamic,mass,startTransform,shape,colObjData->m_collisionObjectData.m_name); - body->setFriction(colObjData->m_collisionObjectData.m_friction); - body->setRestitution(colObjData->m_collisionObjectData.m_restitution); + body->setFriction(btScalar(colObjData->m_collisionObjectData.m_friction)); + body->setRestitution(btScalar(colObjData->m_collisionObjectData.m_restitution)); #ifdef USE_INTERNAL_EDGE_UTILITY diff --git a/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp b/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp index 4d0ca1451..0623e351a 100644 --- a/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp +++ b/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp @@ -13,6 +13,10 @@ 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 "btConvexHullShape.h" #include "BulletCollision/CollisionShapes/btCollisionMargin.h" @@ -45,10 +49,11 @@ void btConvexHullShape::setLocalScaling(const btVector3& scaling) recalcLocalAabb(); } -void btConvexHullShape::addPoint(const btVector3& point) +void btConvexHullShape::addPoint(const btVector3& point, bool recalculateLocalAabb) { m_unscaledPoints.push_back(point); - recalcLocalAabb(); + if (recalculateLocalAabb) + recalcLocalAabb(); } diff --git a/src/BulletCollision/CollisionShapes/btConvexHullShape.h b/src/BulletCollision/CollisionShapes/btConvexHullShape.h index f4e8f644b..3bd598ec4 100644 --- a/src/BulletCollision/CollisionShapes/btConvexHullShape.h +++ b/src/BulletCollision/CollisionShapes/btConvexHullShape.h @@ -36,7 +36,7 @@ public: ///btConvexHullShape make an internal copy of the points. btConvexHullShape(const btScalar* points=0,int numPoints=0, int stride=sizeof(btVector3)); - void addPoint(const btVector3& point); + void addPoint(const btVector3& point, bool recalculateLocalAabb = true); btVector3* getUnscaledPoints() diff --git a/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/src/BulletCollision/CollisionShapes/btConvexShape.cpp index 3ffa42228..4b1613021 100644 --- a/src/BulletCollision/CollisionShapes/btConvexShape.cpp +++ b/src/BulletCollision/CollisionShapes/btConvexShape.cpp @@ -13,6 +13,10 @@ 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 "btConvexShape.h" #include "btTriangleShape.h" #include "btSphereShape.h" diff --git a/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp index 5bae24250..a7362ea01 100644 --- a/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp +++ b/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" @@ -40,7 +42,7 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala } #ifndef MIN - #define MIN( _a, _b) ((_a) < (_b) ? (_a) : (_b)) + #define MIN( _a, _b) ((_a) < (_b) ? (_a) : (_b)) #endif btVector3 btMultiSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const { @@ -67,10 +69,10 @@ btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScala const btScalar* rad = &m_radiArray[0]; int numSpheres = m_localPositionArray.size(); - for( int k = 0; k < numSpheres; k+= 128 ) - { - btVector3 temp[128]; - int inner_count = MIN( numSpheres - k, 128 ); + 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(); diff --git a/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp index 7dec689bd..4854f370f 100644 --- a/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp +++ b/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp @@ -12,6 +12,9 @@ subject to the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 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 "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" #include "btConvexPolyhedron.h" diff --git a/src/LinearMath/btVector3.h b/src/LinearMath/btVector3.h index b36b49de3..1cf653588 100644 --- a/src/LinearMath/btVector3.h +++ b/src/LinearMath/btVector3.h @@ -229,7 +229,7 @@ public: * @param v The other vector in the dot product */ SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const { -#if defined BT_USE_SIMD_VECTOR3 +#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) __m128 vd = _mm_mul_ps(mVec128, v.mVec128); __m128 z = _mm_movehl_ps(vd, vd); __m128 y = _mm_shuffle_ps(vd, vd, 0x55); @@ -989,7 +989,7 @@ SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btS SIMD_FORCE_INLINE long btVector3::maxDot( const btVector3 *array, long array_count, btScalar &dotOut ) const { -#if defined BT_USE_SIMD_VECTOR3 +#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON) #if defined _WIN32 || defined (BT_USE_SSE) const long scalar_cutoff = 10; long _maxdot_large( const float *array, const float *vec, unsigned long array_count, float *dotOut ); @@ -998,7 +998,7 @@ SIMD_FORCE_INLINE long btVector3::maxDot( const btVector3 *array, long arra extern long (*_maxdot_large)( const float *array, const float *vec, unsigned long array_count, float *dotOut ); #endif if( array_count < scalar_cutoff ) -#endif//BT_USE_SIMD_VECTOR3 +#endif { btScalar maxDot = -SIMD_INFINITY; int i = 0; @@ -1017,14 +1017,14 @@ SIMD_FORCE_INLINE long btVector3::maxDot( const btVector3 *array, long arra dotOut = maxDot; return ptIndex; } -#if defined BT_USE_SIMD_VECTOR3 +#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON) return _maxdot_large( (float*) array, (float*) &m_floats[0], array_count, &dotOut ); -#endif//BT_USE_SIMD_VECTOR3 +#endif } SIMD_FORCE_INLINE long btVector3::minDot( const btVector3 *array, long array_count, btScalar &dotOut ) const { -#if defined BT_USE_SIMD_VECTOR3 +#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON) #if defined BT_USE_SSE const long scalar_cutoff = 10; long _mindot_large( const float *array, const float *vec, unsigned long array_count, float *dotOut ); @@ -1036,7 +1036,7 @@ SIMD_FORCE_INLINE long btVector3::minDot( const btVector3 *array, long arra #endif if( array_count < scalar_cutoff ) -#endif//BT_USE_SIMD_VECTOR3 +#endif { btScalar minDot = SIMD_INFINITY; int i = 0; @@ -1057,7 +1057,7 @@ SIMD_FORCE_INLINE long btVector3::minDot( const btVector3 *array, long arra return ptIndex; } -#if defined BT_USE_SIMD_VECTOR3 +#if (defined BT_USE_SSE && defined BT_USE_SIMD_VECTOR3 && defined BT_USE_SSE_IN_API) || defined (BT_USE_NEON) return _mindot_large( (float*) array, (float*) &m_floats[0], array_count, &dotOut ); #endif//BT_USE_SIMD_VECTOR3 }