summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
diff options
context:
space:
mode:
authorAndrea Catania <info@andreacatania.com>2018-09-07 16:11:04 +0200
committerAndrea Catania <info@andreacatania.com>2018-09-07 16:11:04 +0200
commit6142448417f4e15bf0bc0c94df7d1862a790e3c7 (patch)
treeb6b0a44df905e0ad2e6f82eacd5ef4acdf9a0df1 /thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
parent53070437514e448c87f6cb31cf5b27a3839dbfa1 (diff)
Update bullet to Master 12409f1118a7c7a266f9071350c70789dfe73bb9
Diffstat (limited to 'thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp')
-rw-r--r--thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp68
1 files changed, 43 insertions, 25 deletions
diff --git a/thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp b/thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
index 572ec36f56..b79f49d611 100644
--- a/thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
+++ b/thirdparty/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
@@ -21,46 +21,64 @@ subject to the following restrictions:
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
-bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
- const btConvexShape* pConvexA, const btConvexShape* pConvexB,
- const btTransform& transformA, const btTransform& transformB,
- btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
- class btIDebugDraw* debugDraw)
+bool btGjkEpaPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& simplexSolver,
+ const btConvexShape* pConvexA, const btConvexShape* pConvexB,
+ const btTransform& transformA, const btTransform& transformB,
+ btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
+ class btIDebugDraw* debugDraw)
{
(void)debugDraw;
(void)v;
(void)simplexSolver;
-// const btScalar radialmargin(btScalar(0.));
-
- btVector3 guessVector(transformB.getOrigin()-transformA.getOrigin());
- btGjkEpaSolver2::sResults results;
-
+ btVector3 guessVectors[] = {
+ btVector3(transformB.getOrigin() - transformA.getOrigin()).normalized(),
+ btVector3(transformA.getOrigin() - transformB.getOrigin()).normalized(),
+ btVector3(0, 0, 1),
+ btVector3(0, 1, 0),
+ btVector3(1, 0, 0),
+ btVector3(1, 1, 0),
+ btVector3(1, 1, 1),
+ btVector3(0, 1, 1),
+ btVector3(1, 0, 1),
+ };
- if(btGjkEpaSolver2::Penetration(pConvexA,transformA,
- pConvexB,transformB,
- guessVector,results))
-
- {
- // debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
- //resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
- wWitnessOnA = results.witnesses[0];
- wWitnessOnB = results.witnesses[1];
- v = results.normal;
- return true;
- } else
+ int numVectors = sizeof(guessVectors) / sizeof(btVector3);
+
+ for (int i = 0; i < numVectors; i++)
{
- if(btGjkEpaSolver2::Distance(pConvexA,transformA,pConvexB,transformB,guessVector,results))
+ simplexSolver.reset();
+ btVector3 guessVector = guessVectors[i];
+
+ btGjkEpaSolver2::sResults results;
+
+ if (btGjkEpaSolver2::Penetration(pConvexA, transformA,
+ pConvexB, transformB,
+ guessVector, results))
+
{
wWitnessOnA = results.witnesses[0];
wWitnessOnB = results.witnesses[1];
v = results.normal;
- return false;
+ return true;
+ }
+ else
+ {
+ if (btGjkEpaSolver2::Distance(pConvexA, transformA, pConvexB, transformB, guessVector, results))
+ {
+ wWitnessOnA = results.witnesses[0];
+ wWitnessOnB = results.witnesses[1];
+ v = results.normal;
+ return false;
+ }
}
}
+ //failed to find a distance/penetration
+ wWitnessOnA.setValue(0, 0, 0);
+ wWitnessOnB.setValue(0, 0, 0);
+ v.setValue(0, 0, 0);
return false;
}
-