2017-08-01 14:30:58 +02:00
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
|
|
|
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "btSphereShape.h"
|
|
|
|
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
|
|
|
|
|
|
|
#include "LinearMath/btQuaternion.h"
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec) const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
(void)vec;
|
2019-01-03 14:26:51 +01:00
|
|
|
return btVector3(btScalar(0.), btScalar(0.), btScalar(0.));
|
2017-08-01 14:30:58 +02:00
|
|
|
}
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
void btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors, btVector3* supportVerticesOut, int numVectors) const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
(void)vectors;
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
for (int i = 0; i < numVectors; i++)
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
supportVerticesOut[i].setValue(btScalar(0.), btScalar(0.), btScalar(0.));
|
2017-08-01 14:30:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
btVector3 btSphereShape::localGetSupportingVertex(const btVector3& vec) const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
btVector3 supVertex;
|
|
|
|
supVertex = localGetSupportingVertexWithoutMargin(vec);
|
|
|
|
|
|
|
|
btVector3 vecnorm = vec;
|
2019-01-03 14:26:51 +01:00
|
|
|
if (vecnorm.length2() < (SIMD_EPSILON * SIMD_EPSILON))
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
vecnorm.setValue(btScalar(-1.), btScalar(-1.), btScalar(-1.));
|
|
|
|
}
|
2017-08-01 14:30:58 +02:00
|
|
|
vecnorm.normalize();
|
2019-01-03 14:26:51 +01:00
|
|
|
supVertex += getMargin() * vecnorm;
|
2017-08-01 14:30:58 +02:00
|
|
|
return supVertex;
|
|
|
|
}
|
|
|
|
|
|
|
|
//broken due to scaling
|
2019-01-03 14:26:51 +01:00
|
|
|
void btSphereShape::getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
|
|
|
const btVector3& center = t.getOrigin();
|
2019-01-03 14:26:51 +01:00
|
|
|
btVector3 extent(getMargin(), getMargin(), getMargin());
|
2017-08-01 14:30:58 +02:00
|
|
|
aabbMin = center - extent;
|
|
|
|
aabbMax = center + extent;
|
|
|
|
}
|
|
|
|
|
2019-01-03 14:26:51 +01:00
|
|
|
void btSphereShape::calculateLocalInertia(btScalar mass, btVector3& inertia) const
|
2017-08-01 14:30:58 +02:00
|
|
|
{
|
2019-01-03 14:26:51 +01:00
|
|
|
btScalar elem = btScalar(0.4) * mass * getMargin() * getMargin();
|
|
|
|
inertia.setValue(elem, elem, elem);
|
2017-08-01 14:30:58 +02:00
|
|
|
}
|