pass collision shapes as const. fixed some issues with continuous convex cast (resulting hitnormal was not initialized properly, results not proper)
This commit is contained in:
@@ -24,6 +24,9 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
|
||||
#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
|
||||
|
||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
@@ -210,8 +213,8 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
|
||||
btConvexShape* convexShape = (btConvexShape*) collisionShape;
|
||||
btVoronoiSimplexSolver simplexSolver;
|
||||
btSubsimplexConvexCast convexCaster(castShape,convexShape,&simplexSolver);
|
||||
//GjkConvexCast convexCaster(castShape,convexShape,&simplexSolver);
|
||||
//ContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
|
||||
//btGjkConvexCast convexCaster(castShape,convexShape,&simplexSolver);
|
||||
//btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
|
||||
|
||||
if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
|
||||
{
|
||||
|
||||
@@ -26,7 +26,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)
|
||||
@@ -93,7 +93,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;
|
||||
@@ -109,21 +109,25 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
||||
dist = pointCollector1.m_distance;
|
||||
n = pointCollector1.m_normalOnBInWorld;
|
||||
|
||||
|
||||
|
||||
//not close enough
|
||||
while (dist > radius)
|
||||
{
|
||||
numIter++;
|
||||
if (numIter > maxIter)
|
||||
{
|
||||
return false; //todo: report a failure
|
||||
|
||||
}
|
||||
btScalar dLambda = btScalar(0.);
|
||||
|
||||
btScalar projectedLinearVelocity = (linVelB-linVelA).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);
|
||||
|
||||
@@ -135,9 +139,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 +172,12 @@ 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;
|
||||
return true;
|
||||
}
|
||||
c = pointCollector.m_pointInWorld;
|
||||
|
||||
n = pointCollector.m_normalOnBInWorld;
|
||||
dist = pointCollector.m_distance;
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -30,13 +30,13 @@ class btContinuousConvexCollision : public btConvexCast
|
||||
{
|
||||
btSimplexSolverInterface* m_simplexSolver;
|
||||
btConvexPenetrationDepthSolver* m_penetrationDepthSolver;
|
||||
btConvexShape* m_convexA;
|
||||
btConvexShape* m_convexB;
|
||||
const btConvexShape* m_convexA;
|
||||
const btConvexShape* m_convexB;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
btContinuousConvexCollision (btConvexShape* shapeA,btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
|
||||
btContinuousConvexCollision (const btConvexShape* shapeA,const btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
|
||||
|
||||
virtual bool calcTimeOfImpact(
|
||||
const btTransform& fromA,
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
virtual ~btConvexPenetrationDepthSolver() {};
|
||||
virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
||||
btConvexShape* convexA,btConvexShape* convexB,
|
||||
const btConvexShape* convexA,const btConvexShape* convexB,
|
||||
const btTransform& transA,const btTransform& transB,
|
||||
btVector3& v, btPoint3& pa, btPoint3& pb,
|
||||
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
|
||||
|
||||
@@ -22,7 +22,7 @@ subject to the following restrictions:
|
||||
#include "btPointCollector.h"
|
||||
|
||||
|
||||
btGjkConvexCast::btGjkConvexCast(btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver)
|
||||
btGjkConvexCast::btGjkConvexCast(const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver)
|
||||
:m_simplexSolver(simplexSolver),
|
||||
m_convexA(convexA),
|
||||
m_convexB(convexB)
|
||||
|
||||
@@ -30,12 +30,12 @@ class btMinkowskiSumShape;
|
||||
class btGjkConvexCast : public btConvexCast
|
||||
{
|
||||
btSimplexSolverInterface* m_simplexSolver;
|
||||
btConvexShape* m_convexA;
|
||||
btConvexShape* m_convexB;
|
||||
const btConvexShape* m_convexA;
|
||||
const btConvexShape* m_convexB;
|
||||
|
||||
public:
|
||||
|
||||
btGjkConvexCast(btConvexShape* convexA,btConvexShape* convexB,btSimplexSolverInterface* simplexSolver);
|
||||
btGjkConvexCast(const btConvexShape* convexA,const btConvexShape* convexB,btSimplexSolverInterface* simplexSolver);
|
||||
|
||||
/// cast a convex against another convex object
|
||||
virtual bool calcTimeOfImpact(
|
||||
|
||||
@@ -580,8 +580,8 @@ using namespace gjkepa_impl;
|
||||
|
||||
|
||||
//
|
||||
bool btGjkEpaSolver::Collide(btConvexShape *shape0,const btTransform &wtrs0,
|
||||
btConvexShape *shape1,const btTransform &wtrs1,
|
||||
bool btGjkEpaSolver::Collide(const btConvexShape *shape0,const btTransform &wtrs0,
|
||||
const btConvexShape *shape1,const btTransform &wtrs1,
|
||||
btScalar radialmargin,
|
||||
btStackAlloc* stackAlloc,
|
||||
sResults& results)
|
||||
|
||||
@@ -43,8 +43,8 @@ struct sResults
|
||||
int epa_iterations;
|
||||
int gjk_iterations;
|
||||
};
|
||||
static bool Collide(btConvexShape* shape0,const btTransform& wtrs0,
|
||||
btConvexShape* shape1,const btTransform& wtrs1,
|
||||
static bool Collide(const btConvexShape* shape0,const btTransform& wtrs0,
|
||||
const btConvexShape* shape1,const btTransform& wtrs1,
|
||||
btScalar radialmargin,
|
||||
btStackAlloc* stackAlloc,
|
||||
sResults& results);
|
||||
|
||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
|
||||
|
||||
bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
||||
btConvexShape* pConvexA, btConvexShape* pConvexB,
|
||||
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
|
||||
const btTransform& transformA, const btTransform& transformB,
|
||||
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
||||
class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
|
||||
|
||||
@@ -26,7 +26,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
||||
public :
|
||||
|
||||
bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
||||
btConvexShape* pConvexA, btConvexShape* pConvexB,
|
||||
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
|
||||
const btTransform& transformA, const btTransform& transformB,
|
||||
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
||||
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
|
||||
|
||||
@@ -35,7 +35,7 @@ int gNumGjkChecks = 0;
|
||||
|
||||
|
||||
|
||||
btGjkPairDetector::btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver)
|
||||
btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver)
|
||||
:m_cachedSeparatingAxis(btScalar(0.),btScalar(0.),btScalar(1.)),
|
||||
m_penetrationDepthSolver(penetrationDepthSolver),
|
||||
m_simplexSolver(simplexSolver),
|
||||
|
||||
@@ -35,8 +35,8 @@ class btGjkPairDetector : public btDiscreteCollisionDetectorInterface
|
||||
btVector3 m_cachedSeparatingAxis;
|
||||
btConvexPenetrationDepthSolver* m_penetrationDepthSolver;
|
||||
btSimplexSolverInterface* m_simplexSolver;
|
||||
btConvexShape* m_minkowskiA;
|
||||
btConvexShape* m_minkowskiB;
|
||||
const btConvexShape* m_minkowskiA;
|
||||
const btConvexShape* m_minkowskiB;
|
||||
bool m_ignoreMargin;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
int m_catchDegeneracies;
|
||||
|
||||
|
||||
btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
|
||||
btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
|
||||
virtual ~btGjkPairDetector() {};
|
||||
|
||||
virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw);
|
||||
|
||||
@@ -71,7 +71,7 @@ btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
|
||||
|
||||
|
||||
bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& simplexSolver,
|
||||
btConvexShape* convexA,btConvexShape* convexB,
|
||||
const btConvexShape* convexA,const btConvexShape* convexB,
|
||||
const btTransform& transA,const btTransform& transB,
|
||||
btVector3& v, btPoint3& pa, btPoint3& pb,
|
||||
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
|
||||
|
||||
@@ -25,7 +25,7 @@ class btMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
||||
public:
|
||||
|
||||
virtual bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
||||
btConvexShape* convexA,btConvexShape* convexB,
|
||||
const btConvexShape* convexA,const btConvexShape* convexB,
|
||||
const btTransform& transA,const btTransform& transB,
|
||||
btVector3& v, btPoint3& pa, btPoint3& pb,
|
||||
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
|
||||
|
||||
Reference in New Issue
Block a user