Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletCollision/CollisionShapes/btSphereShape.cpp
| Show All 12 Lines | |||||
| 3. This notice may not be removed or altered from any source distribution. | 3. This notice may not be removed or altered from any source distribution. | ||||
| */ | */ | ||||
| #include "btSphereShape.h" | #include "btSphereShape.h" | ||||
| #include "BulletCollision/CollisionShapes/btCollisionMargin.h" | #include "BulletCollision/CollisionShapes/btCollisionMargin.h" | ||||
| #include "LinearMath/btQuaternion.h" | #include "LinearMath/btQuaternion.h" | ||||
| btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const | btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec) const | ||||
| { | { | ||||
| (void)vec; | (void)vec; | ||||
| return btVector3(btScalar(0.),btScalar(0.),btScalar(0.)); | return btVector3(btScalar(0.), btScalar(0.), btScalar(0.)); | ||||
| } | } | ||||
| void btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const | void btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors, btVector3* supportVerticesOut, int numVectors) const | ||||
| { | { | ||||
| (void)vectors; | (void)vectors; | ||||
| for (int i=0;i<numVectors;i++) | for (int i = 0; i < numVectors; i++) | ||||
| { | { | ||||
| supportVerticesOut[i].setValue(btScalar(0.),btScalar(0.),btScalar(0.)); | supportVerticesOut[i].setValue(btScalar(0.), btScalar(0.), btScalar(0.)); | ||||
| } | } | ||||
| } | } | ||||
| btVector3 btSphereShape::localGetSupportingVertex(const btVector3& vec)const | btVector3 btSphereShape::localGetSupportingVertex(const btVector3& vec) const | ||||
| { | { | ||||
| btVector3 supVertex; | btVector3 supVertex; | ||||
| supVertex = localGetSupportingVertexWithoutMargin(vec); | supVertex = localGetSupportingVertexWithoutMargin(vec); | ||||
| btVector3 vecnorm = vec; | btVector3 vecnorm = vec; | ||||
| if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON)) | if (vecnorm.length2() < (SIMD_EPSILON * SIMD_EPSILON)) | ||||
| { | { | ||||
| vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.)); | vecnorm.setValue(btScalar(-1.), btScalar(-1.), btScalar(-1.)); | ||||
| } | } | ||||
| vecnorm.normalize(); | vecnorm.normalize(); | ||||
| supVertex+= getMargin() * vecnorm; | supVertex += getMargin() * vecnorm; | ||||
| return supVertex; | return supVertex; | ||||
| } | } | ||||
| //broken due to scaling | //broken due to scaling | ||||
| void btSphereShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const | void btSphereShape::getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const | ||||
| { | { | ||||
| const btVector3& center = t.getOrigin(); | const btVector3& center = t.getOrigin(); | ||||
| btVector3 extent(getMargin(),getMargin(),getMargin()); | btVector3 extent(getMargin(), getMargin(), getMargin()); | ||||
| aabbMin = center - extent; | aabbMin = center - extent; | ||||
| aabbMax = center + extent; | aabbMax = center + extent; | ||||
| } | } | ||||
| void btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const | void btSphereShape::calculateLocalInertia(btScalar mass, btVector3& inertia) const | ||||
| { | { | ||||
| btScalar elem = btScalar(0.4) * mass * getMargin()*getMargin(); | btScalar elem = btScalar(0.4) * mass * getMargin() * getMargin(); | ||||
| inertia.setValue(elem,elem,elem); | inertia.setValue(elem, elem, elem); | ||||
| } | } | ||||