add support for clipFaceAgainstHull, so we can clip convex polyhedra against triangles (without connectivity information)
in addition to the existing clipHullAgainstHull Fix for debug drawing of contact points comment-out some debug drawing code for triangle meshes
This commit is contained in:
@@ -91,7 +91,7 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
||||
btCollisionObject* ob = static_cast<btCollisionObject*>(m_triBody);
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
///debug drawing of the overlapping triangles
|
||||
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe ))
|
||||
{
|
||||
@@ -100,17 +100,8 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
|
||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
|
||||
|
||||
//btVector3 center = triangle[0] + triangle[1]+triangle[2];
|
||||
//center *= btScalar(0.333333);
|
||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
|
||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
|
||||
#endif
|
||||
|
||||
if (m_convexBody->getCollisionShape()->isConvex())
|
||||
{
|
||||
@@ -119,7 +110,7 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
||||
|
||||
btCollisionShape* tmpShape = ob->getCollisionShape();
|
||||
ob->internalSetTemporaryCollisionShape( &tm );
|
||||
|
||||
|
||||
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr);
|
||||
|
||||
if (m_resultOut->getBody0Internal() == m_triBody)
|
||||
|
||||
@@ -26,6 +26,8 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
|
||||
|
||||
|
||||
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
|
||||
@@ -395,18 +397,8 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
||||
btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*) min1;
|
||||
if (polyhedronA->getConvexPolyhedron() && polyhedronB->getConvexPolyhedron())
|
||||
{
|
||||
|
||||
btScalar maxDist = 0.f;
|
||||
btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
|
||||
|
||||
if (dispatchInfo.m_convexMaxDistanceUseCPT)
|
||||
{
|
||||
maxDist = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold();
|
||||
} else
|
||||
{
|
||||
maxDist = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
|
||||
}
|
||||
|
||||
maxDist =0.f;
|
||||
btVector3 sepNormalWorldSpace;
|
||||
//#define USE_SAT_TEST
|
||||
#ifdef USE_SAT_TEST
|
||||
@@ -421,10 +413,12 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
||||
#endif //USE_SAT_TEST
|
||||
if (foundSepAxis)
|
||||
{
|
||||
btPolyhedralContactClipping::clipFaceContacts(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
|
||||
body0->getWorldTransform(),
|
||||
body1->getWorldTransform(), maxDist, *resultOut);
|
||||
btScalar minDist = gjkPairDetector.getCachedSeparatingDistance();
|
||||
|
||||
btPolyhedralContactClipping::clipHullAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
|
||||
body0->getWorldTransform(),
|
||||
body1->getWorldTransform(), minDist-threshold, threshold, *resultOut);
|
||||
|
||||
if (m_ownManifold)
|
||||
{
|
||||
resultOut->refreshContactPoints();
|
||||
@@ -433,6 +427,31 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
//we can also deal with convex versus triangle (without connectivity data)
|
||||
|
||||
if (polyhedronA->getConvexPolyhedron() && polyhedronB->getShapeType()==TRIANGLE_SHAPE_PROXYTYPE)
|
||||
{
|
||||
|
||||
btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
|
||||
|
||||
btVertexArray vertices;
|
||||
btTriangleShape* tri = (btTriangleShape*)polyhedronB;
|
||||
vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[0]);
|
||||
vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[1]);
|
||||
vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[2]);
|
||||
|
||||
btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
|
||||
btScalar minDist = gjkPairDetector.getCachedSeparatingDistance();
|
||||
btPolyhedralContactClipping::clipFaceAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(),
|
||||
body0->getWorldTransform(), vertices, minDist-threshold, threshold, *resultOut);
|
||||
if (m_ownManifold)
|
||||
{
|
||||
resultOut->refreshContactPoints();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user