Merge pull request #1417 from elect86/master

Update btContinuousConvexCollision.h
This commit is contained in:
erwincoumans
2017-11-03 08:11:37 -07:00
committed by GitHub
3 changed files with 6 additions and 23 deletions

View File

@@ -69,8 +69,6 @@ void btStaticPlaneShape::processAllTriangles(btTriangleCallback* callback,const
//tangentDir0/tangentDir1 can be precalculated //tangentDir0/tangentDir1 can be precalculated
btPlaneSpace1(m_planeNormal,tangentDir0,tangentDir1); btPlaneSpace1(m_planeNormal,tangentDir0,tangentDir1);
btVector3 supVertex0,supVertex1;
btVector3 projectedCenter = center - (m_planeNormal.dot(center) - m_planeConstant)*m_planeNormal; btVector3 projectedCenter = center - (m_planeNormal.dot(center) - m_planeConstant)*m_planeNormal;
btVector3 triangle[3]; btVector3 triangle[3];

View File

@@ -113,12 +113,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
if ((relLinVelocLength+maxAngularProjectedVelocity) == 0.f) if ((relLinVelocLength+maxAngularProjectedVelocity) == 0.f)
return false; return false;
btScalar lambda = btScalar(0.); btScalar lambda = btScalar(0.);
btVector3 v(1,0,0);
int maxIter = MAX_ITERATIONS;
btVector3 n; btVector3 n;
n.setValue(btScalar(0.),btScalar(0.),btScalar(0.)); n.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
@@ -137,8 +132,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
btPointCollector pointCollector1; btPointCollector pointCollector1;
{ {
computeClosestPoints(fromA,fromB,pointCollector1); computeClosestPoints(fromA,fromB,pointCollector1);
hasResult = pointCollector1.m_hasResult; hasResult = pointCollector1.m_hasResult;
@@ -172,28 +166,20 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity); dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
lambda += dLambda;
lambda = lambda + dLambda;
if (lambda > btScalar(1.)) if (lambda > btScalar(1.) || lambda < btScalar(0.))
return false; return false;
if (lambda < btScalar(0.))
return false;
//todo: next check with relative epsilon //todo: next check with relative epsilon
if (lambda <= lastLambda) if (lambda <= lastLambda)
{ {
return false; return false;
//n.setValue(0,0,0); //n.setValue(0,0,0);
break; //break;
} }
lastLambda = lambda; lastLambda = lambda;
//interpolate to next lambda //interpolate to next lambda
btTransform interpolatedTransA,interpolatedTransB,relativeTrans; btTransform interpolatedTransA,interpolatedTransB,relativeTrans;
@@ -223,7 +209,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
} }
numIter++; numIter++;
if (numIter > maxIter) if (numIter > MAX_ITERATIONS)
{ {
result.reportFailure(-2, numIter); result.reportFailure(-2, numIter);
return false; return false;
@@ -237,6 +223,5 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
} }
return false; return false;
} }

View File

@@ -25,7 +25,7 @@ class btStaticPlaneShape;
/// btContinuousConvexCollision implements angular and linear time of impact for convex objects. /// btContinuousConvexCollision implements angular and linear time of impact for convex objects.
/// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis). /// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis).
/// Algorithm operates in worldspace, in order to keep inbetween motion globally consistent. /// Algorithm operates in worldspace, in order to keep in between motion globally consistent.
/// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops /// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops
class btContinuousConvexCollision : public btConvexCast class btContinuousConvexCollision : public btConvexCast
{ {