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/NarrowPhaseCollision/btContinuousConvexCollision.cpp')
-rw-r--r--extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
index 2c565734e97..6551cfb92fe 100644
--- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
+++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
@@ -16,7 +16,6 @@ subject to the following restrictions:
#include "btContinuousConvexCollision.h"
#include "BulletCollision/CollisionShapes/btConvexShape.h"
-#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
#include "LinearMath/btTransformUtil.h"
#include "BulletCollision/CollisionShapes/btSphereShape.h"
@@ -26,7 +25,7 @@ subject to the following restrictions:
-btContinuousConvexCollision::btContinuousConvexCollision ( btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* penetrationDepthSolver)
+btContinuousConvexCollision::btContinuousConvexCollision ( const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* penetrationDepthSolver)
:m_simplexSolver(simplexSolver),
m_penetrationDepthSolver(penetrationDepthSolver),
m_convexA(convexA),m_convexB(convexB)
@@ -35,7 +34,7 @@ m_convexA(convexA),m_convexB(convexB)
/// This maximum should not be necessary. It allows for untested/degenerate cases in production code.
/// You don't want your game ever to lock-up.
-#define MAX_ITERATIONS 1000
+#define MAX_ITERATIONS 64
bool btContinuousConvexCollision::calcTimeOfImpact(
const btTransform& fromA,
@@ -52,10 +51,18 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
btTransformUtil::calculateVelocity(fromA,toA,btScalar(1.),linVelA,angVelA);
btTransformUtil::calculateVelocity(fromB,toB,btScalar(1.),linVelB,angVelB);
+
btScalar boundingRadiusA = m_convexA->getAngularMotionDisc();
btScalar boundingRadiusB = m_convexB->getAngularMotionDisc();
btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB;
+ btVector3 relLinVel = (linVelB-linVelA);
+
+ btScalar relLinVelocLength = (linVelB-linVelA).length();
+
+ if ((relLinVelocLength+maxAngularProjectedVelocity) == 0.f)
+ return false;
+
btScalar radius = btScalar(0.001);
@@ -93,7 +100,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
btGjkPairDetector::ClosestPointInput input;
//we don't use margins during CCD
- gjk.setIgnoreMargin(true);
+ // gjk.setIgnoreMargin(true);
input.m_transformA = fromA;
input.m_transformB = fromB;
@@ -108,25 +115,31 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
btScalar dist;
dist = pointCollector1.m_distance;
n = pointCollector1.m_normalOnBInWorld;
+
+ btScalar projectedLinearVelocity = relLinVel.dot(n);
//not close enough
while (dist > radius)
{
numIter++;
if (numIter > maxIter)
+ {
return false; //todo: report a failure
-
+ }
btScalar dLambda = btScalar(0.);
+ projectedLinearVelocity = relLinVel.dot(n);
+
//calculate safe moving fraction from distance / (linear+rotational velocity)
//btScalar clippedDist = GEN_min(angularConservativeRadius,dist);
//btScalar clippedDist = dist;
- btScalar projectedLinearVelocity = (linVelB-linVelA).dot(n);
dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
+
+
lambda = lambda + dLambda;
if (lambda > btScalar(1.))
@@ -135,9 +148,14 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
if (lambda < btScalar(0.))
return false;
+
//todo: next check with relative epsilon
if (lambda <= lastLambda)
+ {
+ return false;
+ //n.setValue(0,0,0);
break;
+ }
lastLambda = lambda;
@@ -163,11 +181,13 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
{
//degenerate ?!
result.m_fraction = lastLambda;
- result.m_normal = n;
+ n = pointCollector.m_normalOnBInWorld;
+ result.m_normal=n;//.setValue(1,1,1);// = n;
+ result.m_hitPoint = pointCollector.m_pointInWorld;
return true;
}
c = pointCollector.m_pointInWorld;
-
+ n = pointCollector.m_normalOnBInWorld;
dist = pointCollector.m_distance;
} else
{
@@ -177,8 +197,13 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
}
+ //don't report time of impact for motion away from the contact normal (or causes minor penetration)
+ if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=result.m_allowedPenetration)//SIMD_EPSILON)
+ return false;
+
result.m_fraction = lambda;
result.m_normal = n;
+ result.m_hitPoint = c;
return true;
}