+ improved KinematicCharacterController

+ improved btSubsimplexConvexCast, btContinuousConvexCollision and btGjkConvexCast to support configuration that start in touching/penetration, required for 'sliding'.
+ added files to CMakeLists.txt for CharacterController
+ bump up version to 2.70 (preparation for beta)
This commit is contained in:
erwin.coumans
2008-07-09 00:08:49 +00:00
parent 76bac83937
commit dcd57f333b
23 changed files with 431 additions and 243 deletions

View File

@@ -51,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);
@@ -108,8 +116,8 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
dist = pointCollector1.m_distance;
n = pointCollector1.m_normalOnBInWorld;
btScalar projectedLinearVelocity = relLinVel.dot(n);
//not close enough
while (dist > radius)
{
@@ -120,7 +128,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
}
btScalar dLambda = btScalar(0.);
btScalar projectedLinearVelocity = (linVelB-linVelA).dot(n);
projectedLinearVelocity = relLinVel.dot(n);
//calculate safe moving fraction from distance / (linear+rotational velocity)
@@ -130,6 +138,8 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
lambda = lambda + dLambda;
if (lambda > btScalar(1.))
@@ -187,6 +197,10 @@ 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;

View File

@@ -42,20 +42,21 @@ public:
CastResult()
:m_fraction(btScalar(1e30)),
m_debugDrawer(0)
m_debugDrawer(0),
m_allowedPenetration(btScalar(0))
{
}
virtual ~CastResult() {};
btVector3 m_normal;
btVector3 m_hitPoint;
btScalar m_fraction;
btTransform m_hitTransformA;
btTransform m_hitTransformB;
btVector3 m_normal;
btVector3 m_hitPoint;
btScalar m_fraction; //input and output
btIDebugDraw* m_debugDrawer;
btScalar m_allowedPenetration;
};

View File

@@ -158,6 +158,11 @@ bool btGjkConvexCast::calcTimeOfImpact(
}
//is n normalized?
//don't report time of impact for motion away from the contact normal (or causes minor penetration)
if (n.dot(r)>=-result.m_allowedPenetration)
return false;
result.m_fraction = lambda;
result.m_normal = n;
result.m_hitPoint = c;

View File

@@ -119,6 +119,8 @@ bool btSubsimplexConvexCast::calcTimeOfImpact(
{
dist2 = v.length2();
hasResult = true;
//todo: check this normal for validity
n=v;
//printf("V=%f , %f, %f\n",v[0],v[1],v[2]);
//printf("DIST2=%f\n",dist2);
//printf("numverts = %i\n",m_simplexSolver->numVertices());
@@ -130,8 +132,17 @@ bool btSubsimplexConvexCast::calcTimeOfImpact(
//int numiter = MAX_ITERATIONS - maxIter;
// printf("number of iterations: %d", numiter);
//don't report a time of impact when moving 'away' from the hitnormal
result.m_fraction = lambda;
result.m_normal = n.normalized();
//don't report time of impact for motion away from the contact normal (or causes minor penetration)
if (result.m_normal.dot(r)>=-result.m_allowedPenetration)
return false;
btVector3 hitA,hitB;
m_simplexSolver->compute_points(hitA,hitB);
result.m_hitPoint=hitB;