added debug drawing for concave objects (draws overlapping triangles)

This commit is contained in:
ejcoumans 2006-07-05 05:03:09 +00:00
parent 6163b42e8c
commit d2570694a9
3 changed files with 30 additions and 6 deletions

View File

@ -23,6 +23,7 @@ subject to the following restrictions:
#include "CollisionDispatch/ManifoldResult.h"
#include "NarrowPhaseCollision/RaycastCallback.h"
#include "CollisionShapes/TriangleShape.h"
#include "IDebugDraw.h"
ConvexConcaveCollisionAlgorithm::ConvexConcaveCollisionAlgorithm( const CollisionAlgorithmConstructionInfo& ci,BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
: CollisionAlgorithm(ci),m_convex(*proxy0),m_concave(*proxy1),
@ -77,7 +78,27 @@ void ConvexTriangleCallback::ProcessTriangle(SimdVector3* triangle,int partId, i
CollisionAlgorithmConstructionInfo ci;
ci.m_dispatcher = m_dispatcher;
CollisionObject* ob = static_cast<CollisionObject*>(m_triangleProxy.m_clientObject);
///debug drawing of the overlapping triangles
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->GetDebugMode() > 0)
{
SimdVector3 color(255,255,0);
SimdTransform& tr = ob->m_worldTransform;
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);
//SimdVector3 center = triangle[0] + triangle[1]+triangle[2];
//center *= 0.333333f;
//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);
}
CollisionObject* colObj = static_cast<CollisionObject*>(m_convexProxy->m_clientObject);
@ -86,8 +107,7 @@ void ConvexTriangleCallback::ProcessTriangle(SimdVector3* triangle,int partId, i
TriangleShape tm(triangle[0],triangle[1],triangle[2]);
tm.SetMargin(m_collisionMarginTriangle);
CollisionObject* ob = static_cast<CollisionObject*>(m_triangleProxy.m_clientObject);
CollisionShape* tmpShape = ob->m_collisionShape;
ob->m_collisionShape = &tm;
@ -137,7 +157,7 @@ void ConvexConcaveCollisionAlgorithm::ClearCache()
void ConvexConcaveCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseProxy* ,const DispatcherInfo& dispatchInfo)
{
CollisionObject* convexBody = static_cast<CollisionObject* >(m_convex.m_clientObject);
CollisionObject* triBody = static_cast<CollisionObject* >(m_concave.m_clientObject);

View File

@ -32,7 +32,7 @@ subject to the following restrictions:
#include "CollisionShapes/TriangleMesh.h"
#include "IDebugDraw.h"
//#include "GLDebugDrawer.h"
#include "GLDebugDrawer.h"
#include "PHY_Pro.h"
@ -57,6 +57,7 @@ CcdPhysicsEnvironment* physicsEnvironmentPtr = 0;
TriangleMesh meshData;
StridingMeshInterface* ptr;
GLDebugDrawer debugDrawer;
//GL_LineSegmentShape shapeE(SimdPoint3(-50,0,0),
// SimdPoint3(50,0,0));
@ -214,7 +215,7 @@ int main(int argc,char** argv)
#endif//DEBUG_MESH
// GLDebugDrawer debugDrawer;
ConstraintSolver* solver = new SequentialImpulseConstraintSolver;
//ConstraintSolver* solver = new OdeConstraintSolver;
@ -322,7 +323,7 @@ int main(int argc,char** argv)
}
*/
//for the line that represents the AABB extents
// physicsEnvironmentPtr->setDebugDrawer(&debugDrawer);
physicsEnvironmentPtr->setDebugDrawer(&debugDrawer);
}
@ -336,6 +337,8 @@ void renderme()
float m[16];
int i;
debugDrawer.SetDebugMode(getDebugMode());
for (i=0;i<numObjects;i++)
{
SimdTransform transA;

View File

@ -675,6 +675,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
dispatchInfo.m_timeStep = timeStep;
dispatchInfo.m_stepCount = 0;
dispatchInfo.m_enableSatConvex = m_enableSatCollisionDetection;
dispatchInfo.m_debugDraw = this->m_debugDrawer;
scene->RefreshOverlappingPairs();
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(&scene->GetOverlappingPair(0),scene->GetNumOverlappingPairs(),dispatchInfo);