add penetration depth solver for btCollisionWorld::convexSweepTest, to handle touching/penetrating contact (useful for character controller)
This commit is contained in:
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
|
||||||
#include "BulletCollision/CollisionShapes/btSphereShape.h" //for raycasting
|
#include "BulletCollision/CollisionShapes/btSphereShape.h" //for raycasting
|
||||||
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" //for raycasting
|
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" //for raycasting
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
|
#include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
|
||||||
@@ -403,7 +403,8 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
|
|||||||
|
|
||||||
btConvexShape* convexShape = (btConvexShape*) collisionShape;
|
btConvexShape* convexShape = (btConvexShape*) collisionShape;
|
||||||
btVoronoiSimplexSolver simplexSolver;
|
btVoronoiSimplexSolver simplexSolver;
|
||||||
btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
|
btGjkEpaPenetrationDepthSolver gjkEpaPenetrationSolver;
|
||||||
|
btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,&gjkEpaPenetrationSolver);
|
||||||
|
|
||||||
if (convexCaster.calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
|
if (convexCaster.calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||||
#include "btGjkEpaPenetrationDepthSolver.h"
|
#include "btGjkEpaPenetrationDepthSolver.h"
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
|
||||||
|
|
||||||
bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
||||||
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
|
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
|
||||||
@@ -32,10 +33,20 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
|
|||||||
|
|
||||||
const btScalar radialmargin(btScalar(0.));
|
const btScalar radialmargin(btScalar(0.));
|
||||||
|
|
||||||
|
//#define USE_ORIGINAL_GJK 1
|
||||||
|
#ifdef USE_ORIGINAL_GJK
|
||||||
btGjkEpaSolver::sResults results;
|
btGjkEpaSolver::sResults results;
|
||||||
if(btGjkEpaSolver::Collide( pConvexA,transformA,
|
if(btGjkEpaSolver::Collide( pConvexA,transformA,
|
||||||
pConvexB,transformB,
|
pConvexB,transformB,
|
||||||
radialmargin,stackAlloc,results))
|
radialmargin,stackAlloc,results))
|
||||||
|
#else
|
||||||
|
btVector3 guessVector(transformA.getOrigin()-transformB.getOrigin());
|
||||||
|
btGjkEpaSolver2::sResults results;
|
||||||
|
if(btGjkEpaSolver2::Penetration(pConvexA,transformA,
|
||||||
|
pConvexB,transformB,
|
||||||
|
guessVector,results))
|
||||||
|
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
|
// debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
|
||||||
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
|
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
|
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
|
#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
|
#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
|
||||||
#include "btRaycastCallback.h"
|
#include "btRaycastCallback.h"
|
||||||
|
|
||||||
btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to)
|
btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to)
|
||||||
@@ -122,7 +123,7 @@ btTriangleConvexcastCallback::processTriangle (btVector3* triangle, int partId,
|
|||||||
triangleShape.setMargin(m_triangleCollisionMargin);
|
triangleShape.setMargin(m_triangleCollisionMargin);
|
||||||
|
|
||||||
btVoronoiSimplexSolver simplexSolver;
|
btVoronoiSimplexSolver simplexSolver;
|
||||||
|
btGjkEpaPenetrationDepthSolver gjkEpaPenetrationSolver;
|
||||||
|
|
||||||
//#define USE_SUBSIMPLEX_CONVEX_CAST 1
|
//#define USE_SUBSIMPLEX_CONVEX_CAST 1
|
||||||
//if you reenable USE_SUBSIMPLEX_CONVEX_CAST see commented out code below
|
//if you reenable USE_SUBSIMPLEX_CONVEX_CAST see commented out code below
|
||||||
@@ -130,7 +131,7 @@ btTriangleConvexcastCallback::processTriangle (btVector3* triangle, int partId,
|
|||||||
btSubsimplexConvexCast convexCaster(m_convexShape, &triangleShape, &simplexSolver);
|
btSubsimplexConvexCast convexCaster(m_convexShape, &triangleShape, &simplexSolver);
|
||||||
#else
|
#else
|
||||||
//btGjkConvexCast convexCaster(m_convexShape,&triangleShape,&simplexSolver);
|
//btGjkConvexCast convexCaster(m_convexShape,&triangleShape,&simplexSolver);
|
||||||
btContinuousConvexCollision convexCaster(m_convexShape,&triangleShape,&simplexSolver,NULL);
|
btContinuousConvexCollision convexCaster(m_convexShape,&triangleShape,&simplexSolver,&gjkEpaPenetrationSolver);
|
||||||
#endif //#USE_SUBSIMPLEX_CONVEX_CAST
|
#endif //#USE_SUBSIMPLEX_CONVEX_CAST
|
||||||
|
|
||||||
btConvexCast::CastResult castResult;
|
btConvexCast::CastResult castResult;
|
||||||
|
|||||||
Reference in New Issue
Block a user