This commit is contained in:
@@ -35,7 +35,10 @@
|
||||
#include "../Extras/ExtraSolid35/Solid3JohnsonSimplexSolver.h"
|
||||
#include "../Extras/EPA/EpaPenetrationDepthSolver.h"
|
||||
|
||||
|
||||
#define USE_ORIGINAL 1
|
||||
#ifndef USE_ORIGINAL
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
|
||||
#endif //USE_ORIGINAL
|
||||
|
||||
static bool gRefMode = false;
|
||||
static int gMethod = 0;
|
||||
@@ -295,6 +298,9 @@ static bool TestEPA(const MyConvex& hull0, const MyConvex& hull1)
|
||||
else
|
||||
Solver = &Solver2;
|
||||
|
||||
|
||||
#ifdef USE_ORIGINAL
|
||||
|
||||
btGjkPairDetector GJK(&convexA, &convexB, &simplexSolver, Solver);
|
||||
GJK.m_catchDegeneracies = 1;
|
||||
convexA.setMargin(0.01f);
|
||||
@@ -309,6 +315,21 @@ static bool TestEPA(const MyConvex& hull0, const MyConvex& hull1)
|
||||
gLastUsedMethod = GJK.m_lastUsedMethod;
|
||||
gNumGjkIterations = GJK.m_curIter;
|
||||
gLastDegenerateSimplex= GJK.m_degenerateSimplex;
|
||||
#else
|
||||
MyResult output;
|
||||
btVector3 witnesses[2];
|
||||
btVector3 normal;
|
||||
btScalar depth;
|
||||
|
||||
btGjkEpaSolver::Collide(&convexA,hull0.mTransform,
|
||||
&convexB,hull1.mTransform,
|
||||
0.01,0.01,
|
||||
witnesses,normal,depth);
|
||||
if (depth>0)
|
||||
{
|
||||
output.addContactPoint(normal,witnesses[1],-depth);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -892,5 +892,14 @@ void DemoApplication::clientResetScene()
|
||||
btRigidBody::upcast(colObj)->setAngularVelocity(btVector3(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//quickly search some issue at a certain simulation frame, pressing space to reset
|
||||
int fixed=18;
|
||||
for (int i=0;i<fixed;i++)
|
||||
{
|
||||
getDynamicsWorld()->stepSimulation(1./60.f,1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,9 @@ get current memory management functions.
|
||||
*/
|
||||
//! @{
|
||||
gim_alloc_function *gim_get_alloc_handler (void);
|
||||
#ifdef ALLOCA_GIMPACT
|
||||
gim_alloca_function *gim_get_alloca_handler(void);
|
||||
#endif //
|
||||
gim_realloc_function *gim_get_realloc_handler (void);
|
||||
gim_free_function *gim_get_free_handler (void);
|
||||
//! @}
|
||||
|
||||
@@ -133,10 +133,13 @@ void * gim_alloc(size_t size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#ifdef ALLOCA_GIMPACT
|
||||
void * gim_alloca(size_t size)
|
||||
{
|
||||
if (g_allocafn) return g_allocafn(size); else return alloca(size);
|
||||
if (g_allocafn) return g_allocafn(size); else
|
||||
return alloca(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void * gim_realloc(void *ptr, size_t oldsize, size_t newsize)
|
||||
@@ -305,13 +308,13 @@ void gim_destroy_buffer_manager(GUINT buffer_manager_id)
|
||||
|
||||
GBUFFER_DATA * buffers = GIM_DYNARRAY_POINTER(GBUFFER_DATA,bm_data->m_buffer_array);
|
||||
GUINT i, buffer_count = bm_data->m_buffer_array.m_size;
|
||||
for (i=0;i<buffer_count ;i++ )
|
||||
{
|
||||
for (i=0;i<buffer_count ;i++ )
|
||||
{
|
||||
if(buffers[i].m_buffer_handle!=0) //Is active
|
||||
{
|
||||
// free handle
|
||||
bm_data->m_prototype.free_fn(buffers[i].m_buffer_handle,buffers[i].m_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//destroy buffer array
|
||||
@@ -339,7 +342,7 @@ void gim_get_buffer_manager_data(GUINT buffer_manager_id,GBUFFER_MANAGER_DATA **
|
||||
void gim_init_buffer_managers()
|
||||
{
|
||||
GUINT i;
|
||||
for (i=0;i<MAX_BUFFER_MANAGERS;i++)
|
||||
for (i=0;i<MAX_BUFFER_MANAGERS;i++)
|
||||
{
|
||||
g_buffer_managers[i].m_active = 0;
|
||||
g_buffer_managers[i].m_buffer_array.m_pdata = 0;
|
||||
@@ -347,7 +350,7 @@ void gim_init_buffer_managers()
|
||||
g_buffer_managers[i].m_buffer_array.m_size = 0;
|
||||
g_buffer_managers[i].m_free_positions.m_pdata = 0;
|
||||
g_buffer_managers[i].m_free_positions.m_reserve_size = 0;
|
||||
g_buffer_managers[i].m_free_positions.m_size = 0;
|
||||
g_buffer_managers[i].m_free_positions.m_size = 0;
|
||||
}
|
||||
g_buffer_managers_count = 0;
|
||||
// Add the two most important buffer managers
|
||||
|
||||
@@ -121,13 +121,13 @@ void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,sho
|
||||
|
||||
}
|
||||
|
||||
void btCollisionWorld::performDiscreteCollisionDetection()
|
||||
|
||||
|
||||
|
||||
void btCollisionWorld::performDiscreteCollisionDetection(btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
BEGIN_PROFILE("performDiscreteCollisionDetection");
|
||||
|
||||
btDispatcherInfo dispatchInfo;
|
||||
dispatchInfo.m_timeStep = 0.f;
|
||||
dispatchInfo.m_stepCount = 0;
|
||||
|
||||
//update aabb (of all moved objects)
|
||||
|
||||
|
||||
@@ -236,8 +236,8 @@ public:
|
||||
|
||||
void removeCollisionObject(btCollisionObject* collisionObject);
|
||||
|
||||
virtual void performDiscreteCollisionDetection();
|
||||
|
||||
virtual void performDiscreteCollisionDetection( btDispatcherInfo& dispatchInfo);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ subject to the following restrictions:
|
||||
|
||||
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
|
||||
|
||||
#ifdef USE_BT_GJKEPA
|
||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
|
||||
#endif //USE_BT_GJKEPA
|
||||
|
||||
//#include "NarrowPhaseCollision/EpaPenetrationDepthSolver.h"
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -155,6 +159,26 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_BT_GJKEPA
|
||||
btVector3 witnesses[2];
|
||||
btVector3 normal(0,0,0);
|
||||
btScalar depth(0);
|
||||
btConvexShape* shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
|
||||
btConvexShape* shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
|
||||
const btScalar margin(shape0->getMargin()+shape1->getMargin());
|
||||
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||
if(btGjkEpaSolver::Collide( shape0,body0->getWorldTransform(),
|
||||
shape1,body1->getWorldTransform(),
|
||||
shape0->getMargin(),shape1->getMargin(),
|
||||
witnesses,normal,depth))
|
||||
{
|
||||
|
||||
|
||||
//optional: draw the contact+normal
|
||||
//dispatchInfo.m_debugDraw->drawLine(witnesses[1],witnesses[1]+normal,btVector3(255,0,0));
|
||||
resultOut->addContactPoint(normal,witnesses[1],-depth);
|
||||
}
|
||||
#else
|
||||
checkPenetrationDepthSolver();
|
||||
|
||||
btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
|
||||
@@ -175,6 +199,7 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
||||
|
||||
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||
m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -267,8 +267,14 @@ void btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep)
|
||||
///apply gravity, predict motion
|
||||
predictUnconstraintMotion(timeStep);
|
||||
|
||||
btDispatcherInfo dispatchInfo;
|
||||
dispatchInfo.m_timeStep = timeStep;
|
||||
dispatchInfo.m_stepCount = 0;
|
||||
dispatchInfo.m_debugDraw = getDebugDrawer();
|
||||
|
||||
|
||||
///perform collision detection
|
||||
performDiscreteCollisionDetection();
|
||||
performDiscreteCollisionDetection(dispatchInfo);
|
||||
|
||||
calculateSimulationIslands();
|
||||
|
||||
|
||||
@@ -52,8 +52,13 @@ int btSimpleDynamicsWorld::stepSimulation( float timeStep,int maxSubSteps, floa
|
||||
///apply gravity, predict motion
|
||||
predictUnconstraintMotion(timeStep);
|
||||
|
||||
btDispatcherInfo dispatchInfo;
|
||||
dispatchInfo.m_timeStep = timeStep;
|
||||
dispatchInfo.m_stepCount = 0;
|
||||
dispatchInfo.m_debugDraw = getDebugDrawer();
|
||||
|
||||
///perform collision detection
|
||||
performDiscreteCollisionDetection();
|
||||
performDiscreteCollisionDetection(dispatchInfo );
|
||||
|
||||
///solve contact constraints
|
||||
int numManifolds = m_dispatcher1->getNumManifolds();
|
||||
|
||||
Reference in New Issue
Block a user