Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp89
1 files changed, 42 insertions, 47 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
index e8b567e0efc..bc68b285b8d 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
@@ -21,23 +21,22 @@ subject to the following restrictions:
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
//#include <stdio.h>
-btSphereBoxCollisionAlgorithm::btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap, bool isSwapped)
-: btActivatingCollisionAlgorithm(ci,col0Wrap,col1Wrap),
-m_ownManifold(false),
-m_manifoldPtr(mf),
-m_isSwapped(isSwapped)
+btSphereBoxCollisionAlgorithm::btSphereBoxCollisionAlgorithm(btPersistentManifold* mf, const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* col0Wrap, const btCollisionObjectWrapper* col1Wrap, bool isSwapped)
+ : btActivatingCollisionAlgorithm(ci, col0Wrap, col1Wrap),
+ m_ownManifold(false),
+ m_manifoldPtr(mf),
+ m_isSwapped(isSwapped)
{
- const btCollisionObjectWrapper* sphereObjWrap = m_isSwapped? col1Wrap : col0Wrap;
- const btCollisionObjectWrapper* boxObjWrap = m_isSwapped? col0Wrap : col1Wrap;
-
- if (!m_manifoldPtr && m_dispatcher->needsCollision(sphereObjWrap->getCollisionObject(),boxObjWrap->getCollisionObject()))
+ const btCollisionObjectWrapper* sphereObjWrap = m_isSwapped ? col1Wrap : col0Wrap;
+ const btCollisionObjectWrapper* boxObjWrap = m_isSwapped ? col0Wrap : col1Wrap;
+
+ if (!m_manifoldPtr && m_dispatcher->needsCollision(sphereObjWrap->getCollisionObject(), boxObjWrap->getCollisionObject()))
{
- m_manifoldPtr = m_dispatcher->getNewManifold(sphereObjWrap->getCollisionObject(),boxObjWrap->getCollisionObject());
+ m_manifoldPtr = m_dispatcher->getNewManifold(sphereObjWrap->getCollisionObject(), boxObjWrap->getCollisionObject());
m_ownManifold = true;
}
}
-
btSphereBoxCollisionAlgorithm::~btSphereBoxCollisionAlgorithm()
{
if (m_ownManifold)
@@ -47,17 +46,15 @@ btSphereBoxCollisionAlgorithm::~btSphereBoxCollisionAlgorithm()
}
}
-
-
-void btSphereBoxCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
+void btSphereBoxCollisionAlgorithm::processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
{
(void)dispatchInfo;
(void)resultOut;
if (!m_manifoldPtr)
return;
- const btCollisionObjectWrapper* sphereObjWrap = m_isSwapped? body1Wrap : body0Wrap;
- const btCollisionObjectWrapper* boxObjWrap = m_isSwapped? body0Wrap : body1Wrap;
+ const btCollisionObjectWrapper* sphereObjWrap = m_isSwapped ? body1Wrap : body0Wrap;
+ const btCollisionObjectWrapper* boxObjWrap = m_isSwapped ? body0Wrap : body1Wrap;
btVector3 pOnBox;
@@ -83,10 +80,9 @@ void btSphereBoxCollisionAlgorithm::processCollision (const btCollisionObjectWra
resultOut->refreshContactPoints();
}
}
-
}
-btScalar btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+btScalar btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0, btCollisionObject* col1, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
{
(void)resultOut;
(void)dispatchInfo;
@@ -97,27 +93,26 @@ btScalar btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject*
return btScalar(1.);
}
-
-bool btSphereBoxCollisionAlgorithm::getSphereDistance(const btCollisionObjectWrapper* boxObjWrap, btVector3& pointOnBox, btVector3& normal, btScalar& penetrationDepth, const btVector3& sphereCenter, btScalar fRadius, btScalar maxContactDistance )
+bool btSphereBoxCollisionAlgorithm::getSphereDistance(const btCollisionObjectWrapper* boxObjWrap, btVector3& pointOnBox, btVector3& normal, btScalar& penetrationDepth, const btVector3& sphereCenter, btScalar fRadius, btScalar maxContactDistance)
{
- const btBoxShape* boxShape= (const btBoxShape*)boxObjWrap->getCollisionShape();
- btVector3 const &boxHalfExtent = boxShape->getHalfExtentsWithoutMargin();
+ const btBoxShape* boxShape = (const btBoxShape*)boxObjWrap->getCollisionShape();
+ btVector3 const& boxHalfExtent = boxShape->getHalfExtentsWithoutMargin();
btScalar boxMargin = boxShape->getMargin();
penetrationDepth = 1.0f;
// convert the sphere position to the box's local space
- btTransform const &m44T = boxObjWrap->getWorldTransform();
+ btTransform const& m44T = boxObjWrap->getWorldTransform();
btVector3 sphereRelPos = m44T.invXform(sphereCenter);
// Determine the closest point to the sphere center in the box
btVector3 closestPoint = sphereRelPos;
- closestPoint.setX( btMin(boxHalfExtent.getX(), closestPoint.getX()) );
- closestPoint.setX( btMax(-boxHalfExtent.getX(), closestPoint.getX()) );
- closestPoint.setY( btMin(boxHalfExtent.getY(), closestPoint.getY()) );
- closestPoint.setY( btMax(-boxHalfExtent.getY(), closestPoint.getY()) );
- closestPoint.setZ( btMin(boxHalfExtent.getZ(), closestPoint.getZ()) );
- closestPoint.setZ( btMax(-boxHalfExtent.getZ(), closestPoint.getZ()) );
-
+ closestPoint.setX(btMin(boxHalfExtent.getX(), closestPoint.getX()));
+ closestPoint.setX(btMax(-boxHalfExtent.getX(), closestPoint.getX()));
+ closestPoint.setY(btMin(boxHalfExtent.getY(), closestPoint.getY()));
+ closestPoint.setY(btMax(-boxHalfExtent.getY(), closestPoint.getY()));
+ closestPoint.setZ(btMin(boxHalfExtent.getZ(), closestPoint.getZ()));
+ closestPoint.setZ(btMax(-boxHalfExtent.getZ(), closestPoint.getZ()));
+
btScalar intersectionDist = fRadius + boxMargin;
btScalar contactDist = intersectionDist + maxContactDistance;
normal = sphereRelPos - closestPoint;
@@ -136,42 +131,42 @@ bool btSphereBoxCollisionAlgorithm::getSphereDistance(const btCollisionObjectWra
{
distance = -getSpherePenetration(boxHalfExtent, sphereRelPos, closestPoint, normal);
}
- else //compute the penetration details
+ else //compute the penetration details
{
distance = normal.length();
normal /= distance;
}
pointOnBox = closestPoint + normal * boxMargin;
-// v3PointOnSphere = sphereRelPos - (normal * fRadius);
+ // v3PointOnSphere = sphereRelPos - (normal * fRadius);
penetrationDepth = distance - intersectionDist;
// transform back in world space
btVector3 tmp = m44T(pointOnBox);
pointOnBox = tmp;
-// tmp = m44T(v3PointOnSphere);
-// v3PointOnSphere = tmp;
+ // tmp = m44T(v3PointOnSphere);
+ // v3PointOnSphere = tmp;
tmp = m44T.getBasis() * normal;
normal = tmp;
return true;
}
-btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btVector3 const &boxHalfExtent, btVector3 const &sphereRelPos, btVector3 &closestPoint, btVector3& normal )
+btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration(btVector3 const& boxHalfExtent, btVector3 const& sphereRelPos, btVector3& closestPoint, btVector3& normal)
{
//project the center of the sphere on the closest face of the box
btScalar faceDist = boxHalfExtent.getX() - sphereRelPos.getX();
btScalar minDist = faceDist;
- closestPoint.setX( boxHalfExtent.getX() );
- normal.setValue(btScalar(1.0f), btScalar(0.0f), btScalar(0.0f));
+ closestPoint.setX(boxHalfExtent.getX());
+ normal.setValue(btScalar(1.0f), btScalar(0.0f), btScalar(0.0f));
faceDist = boxHalfExtent.getX() + sphereRelPos.getX();
if (faceDist < minDist)
{
minDist = faceDist;
closestPoint = sphereRelPos;
- closestPoint.setX( -boxHalfExtent.getX() );
- normal.setValue(btScalar(-1.0f), btScalar(0.0f), btScalar(0.0f));
+ closestPoint.setX(-boxHalfExtent.getX());
+ normal.setValue(btScalar(-1.0f), btScalar(0.0f), btScalar(0.0f));
}
faceDist = boxHalfExtent.getY() - sphereRelPos.getY();
@@ -179,8 +174,8 @@ btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btVector3 const &b
{
minDist = faceDist;
closestPoint = sphereRelPos;
- closestPoint.setY( boxHalfExtent.getY() );
- normal.setValue(btScalar(0.0f), btScalar(1.0f), btScalar(0.0f));
+ closestPoint.setY(boxHalfExtent.getY());
+ normal.setValue(btScalar(0.0f), btScalar(1.0f), btScalar(0.0f));
}
faceDist = boxHalfExtent.getY() + sphereRelPos.getY();
@@ -188,8 +183,8 @@ btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btVector3 const &b
{
minDist = faceDist;
closestPoint = sphereRelPos;
- closestPoint.setY( -boxHalfExtent.getY() );
- normal.setValue(btScalar(0.0f), btScalar(-1.0f), btScalar(0.0f));
+ closestPoint.setY(-boxHalfExtent.getY());
+ normal.setValue(btScalar(0.0f), btScalar(-1.0f), btScalar(0.0f));
}
faceDist = boxHalfExtent.getZ() - sphereRelPos.getZ();
@@ -197,8 +192,8 @@ btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btVector3 const &b
{
minDist = faceDist;
closestPoint = sphereRelPos;
- closestPoint.setZ( boxHalfExtent.getZ() );
- normal.setValue(btScalar(0.0f), btScalar(0.0f), btScalar(1.0f));
+ closestPoint.setZ(boxHalfExtent.getZ());
+ normal.setValue(btScalar(0.0f), btScalar(0.0f), btScalar(1.0f));
}
faceDist = boxHalfExtent.getZ() + sphereRelPos.getZ();
@@ -206,8 +201,8 @@ btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btVector3 const &b
{
minDist = faceDist;
closestPoint = sphereRelPos;
- closestPoint.setZ( -boxHalfExtent.getZ() );
- normal.setValue(btScalar(0.0f), btScalar(0.0f), btScalar(-1.0f));
+ closestPoint.setZ(-boxHalfExtent.getZ());
+ normal.setValue(btScalar(0.0f), btScalar(0.0f), btScalar(-1.0f));
}
return minDist;