fixed a crashing bug in new vehicle physics, and removed some debugging code in contact/friction physics code.

This commit is contained in:
Erwin Coumans 2006-04-02 20:15:24 +00:00
parent 1d5cca805b
commit cf2f1956de
5 changed files with 85 additions and 90 deletions

@ -124,15 +124,17 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject)
//bool removeFromBroadphase = false;
{
/*BroadphaseInterface* scene = */GetBroadphase();
BroadphaseProxy* bp = collisionObject->m_broadphaseHandle;
BroadphaseProxy* bp = collisionObject->m_broadphaseHandle;
if (bp)
{
//
// only clear the cached algorithms
//
GetBroadphase()->CleanProxyFromPairs(bp);
GetBroadphase()->DestroyProxy(bp);
}
}
std::vector<CollisionObject*>::iterator i = std::find(m_collisionObjects.begin(), m_collisionObjects.end(), collisionObject);

@ -128,7 +128,7 @@ bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simpl
}
}
//#define DEBUG_DRAW 1
#ifdef DEBUG_DRAW
if (debugDraw)
{
@ -165,7 +165,9 @@ bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simpl
MyResult res;
gjkdet.GetClosestPoints(input,res,debugDraw);
//the penetration depth is over-estimated, relax it
float penetration_relaxation= 0.1f;
minNorm*=penetration_relaxation;
if (res.m_hasResult)
{
@ -185,3 +187,6 @@ bool MinkowskiPenetrationDepthSolver::CalcPenDepth(SimplexSolverInterface& simpl
}
return res.m_hasResult;
}

@ -123,18 +123,6 @@ float resolveSingleCollision(
// printf("distance=%f\n",distance);
if (distance>0.f)
{
contactPoint.m_appliedImpulse = 0.f;
contactPoint.m_accumulatedTangentImpulse0 = 0.f;
contactPoint.m_accumulatedTangentImpulse1 = 0.f;
return 0.f;
}
#define MAXPENETRATIONPERFRAME -0.05
distance = distance < MAXPENETRATIONPERFRAME? MAXPENETRATIONPERFRAME:distance;
const SimdVector3& normal = contactPoint.m_normalWorldOnB;
SimdVector3 rel_pos1 = pos1 - body1.getCenterOfMassPosition();
@ -153,7 +141,7 @@ float resolveSingleCollision(
SimdScalar Kfps = 1.f / solverInfo.m_timeStep ;
float damping = solverInfo.m_damping ;
float Kerp = solverInfo.m_tau;
float Kerp = solverInfo.m_erp;
if (useGlobalSettingContacts)
{
@ -168,7 +156,7 @@ float resolveSingleCollision(
float clipDist = distance + allowedPenetration;
float dist = (clipDist > 0.f) ? 0.f : clipDist;
//distance = 0.f;
SimdScalar positionalError = Kcor *-clipDist;
SimdScalar positionalError = Kcor *-dist;
//jacDiagABInv;
SimdScalar velocityError = -(1.0f + restitution) * rel_vel;// * damping;

@ -23,11 +23,12 @@ struct ContactSolverInfo
inline ContactSolverInfo()
{
m_tau = 0.4f;
m_damping = 0.9f;
m_damping = 1.0f;
m_friction = 0.3f;
m_restitution = 0.f;
m_maxErrorReduction = 20.f;
m_numIterations = 10;
m_erp = 0.4f;
m_sor = 1.3f;
}
@ -39,6 +40,7 @@ struct ContactSolverInfo
int m_numIterations;
float m_maxErrorReduction;
float m_sor;
float m_erp;
};

@ -26,13 +26,6 @@ subject to the following restrictions:
#include "JacobianEntry.h"
#include "GEN_MinMax.h"
//debugging
bool doApplyImpulse = true;
bool useImpulseFriction = true;//true;//false;
@ -97,6 +90,8 @@ float SimpleConstraintSolver::Solve(PersistentManifold* manifoldPtr, const Conta
for (int i=0;i<numpoints ;i++)
{
ManifoldPoint& cp = manifoldPtr->GetContactPoint(i);
if (cp.GetDistance() <= 0.f)
{
const SimdVector3& pos1 = cp.GetPositionWorldOnA();
const SimdVector3& pos2 = cp.GetPositionWorldOnB();
@ -147,7 +142,7 @@ float SimpleConstraintSolver::Solve(PersistentManifold* manifoldPtr, const Conta
//apply previous frames impulse on both bodies
body0->applyImpulse(totalImpulse, rel_pos1);
body1->applyImpulse(-totalImpulse, rel_pos2);
}
}
}
@ -166,6 +161,8 @@ float SimpleConstraintSolver::Solve(PersistentManifold* manifoldPtr, const Conta
j=i;
ManifoldPoint& cp = manifoldPtr->GetContactPoint(j);
if (cp.GetDistance() <= 0.f)
{
if (iter == 0)
{
@ -189,6 +186,7 @@ float SimpleConstraintSolver::Solve(PersistentManifold* manifoldPtr, const Conta
}
}
}
}
return maxImpulse;
}
@ -208,7 +206,7 @@ float SimpleConstraintSolver::SolveFriction(PersistentManifold* manifoldPtr, con
int j=i;
ManifoldPoint& cp = manifoldPtr->GetContactPoint(j);
if (cp.GetDistance() <= 0.f)
{
resolveSingleFriction(