mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-07 08:10:08 +00:00
add additional callback
This commit is contained in:
parent
1897939ec7
commit
d26952acac
@ -33,8 +33,6 @@ class btDispatcher;
|
|||||||
class btCollisionObject;
|
class btCollisionObject;
|
||||||
|
|
||||||
class btCollisionShape;
|
class btCollisionShape;
|
||||||
typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCollisionShape* pShape1);
|
|
||||||
extern btShapePairCallback gCompoundCompoundChildShapePairCallback;
|
|
||||||
|
|
||||||
/// btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes
|
/// btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes
|
||||||
class btCompoundCompoundCollisionAlgorithm : public btCompoundCollisionAlgorithm
|
class btCompoundCompoundCollisionAlgorithm : public btCompoundCollisionAlgorithm
|
||||||
|
@ -111,6 +111,7 @@ void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const b
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject();
|
bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject();
|
||||||
|
bool isNewCollision = m_manifoldPtr->getNumContacts() == 0;
|
||||||
|
|
||||||
btVector3 pointA = pointInWorld + normalOnBInWorld * depth;
|
btVector3 pointA = pointInWorld + normalOnBInWorld * depth;
|
||||||
|
|
||||||
@ -187,5 +188,9 @@ void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const b
|
|||||||
(*gContactAddedCallback)(m_manifoldPtr->getContactPoint(insertIndex),obj0Wrap,newPt.m_partId0,newPt.m_index0,obj1Wrap,newPt.m_partId1,newPt.m_index1);
|
(*gContactAddedCallback)(m_manifoldPtr->getContactPoint(insertIndex),obj0Wrap,newPt.m_partId0,newPt.m_index0,obj1Wrap,newPt.m_partId1,newPt.m_index1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gContactStartedCallback && isNewCollision)
|
||||||
|
{
|
||||||
|
gContactStartedCallback(m_manifoldPtr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ subject to the following restrictions:
|
|||||||
btScalar gContactBreakingThreshold = btScalar(0.02);
|
btScalar gContactBreakingThreshold = btScalar(0.02);
|
||||||
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
||||||
ContactProcessedCallback gContactProcessedCallback = 0;
|
ContactProcessedCallback gContactProcessedCallback = 0;
|
||||||
|
ContactStartedCallback gContactStartedCallback = 0;
|
||||||
|
ContactEndedCallback gContactEndedCallback = 0;
|
||||||
///gContactCalcArea3Points will approximate the convex hull area using 3 points
|
///gContactCalcArea3Points will approximate the convex hull area using 3 points
|
||||||
///when setting it to false, it will use 4 points to compute the area: it is more accurate but slower
|
///when setting it to false, it will use 4 points to compute the area: it is more accurate but slower
|
||||||
bool gContactCalcArea3Points = true;
|
bool gContactCalcArea3Points = true;
|
||||||
|
@ -28,10 +28,18 @@ struct btCollisionResult;
|
|||||||
///maximum contact breaking and merging threshold
|
///maximum contact breaking and merging threshold
|
||||||
extern btScalar gContactBreakingThreshold;
|
extern btScalar gContactBreakingThreshold;
|
||||||
|
|
||||||
|
#ifndef SWIG
|
||||||
|
class btPersistentManifold;
|
||||||
|
|
||||||
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
||||||
typedef bool (*ContactProcessedCallback)(btManifoldPoint& cp,void* body0,void* body1);
|
typedef bool (*ContactProcessedCallback)(btManifoldPoint& cp,void* body0,void* body1);
|
||||||
|
typedef void (*ContactStartedCallback)(btPersistentManifold* const &manifold);
|
||||||
|
typedef void (*ContactEndedCallback)(btPersistentManifold* const &manifold);
|
||||||
extern ContactDestroyedCallback gContactDestroyedCallback;
|
extern ContactDestroyedCallback gContactDestroyedCallback;
|
||||||
extern ContactProcessedCallback gContactProcessedCallback;
|
extern ContactProcessedCallback gContactProcessedCallback;
|
||||||
|
extern ContactStartedCallback gContactStartedCallback;
|
||||||
|
extern ContactEndedCallback gContactEndedCallback;
|
||||||
|
#endif //SWIG
|
||||||
|
|
||||||
//the enum starts at 1024 to avoid type conflicts with btTypedConstraint
|
//the enum starts at 1024 to avoid type conflicts with btTypedConstraint
|
||||||
enum btContactManifoldTypes
|
enum btContactManifoldTypes
|
||||||
@ -171,6 +179,11 @@ public:
|
|||||||
|
|
||||||
btAssert(m_pointCache[lastUsedIndex].m_userPersistentData==0);
|
btAssert(m_pointCache[lastUsedIndex].m_userPersistentData==0);
|
||||||
m_cachedPoints--;
|
m_cachedPoints--;
|
||||||
|
|
||||||
|
if (gContactEndedCallback && m_cachedPoints == 0)
|
||||||
|
{
|
||||||
|
gContactEndedCallback(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void replaceContactPoint(const btManifoldPoint& newPoint,int insertIndex)
|
void replaceContactPoint(const btManifoldPoint& newPoint,int insertIndex)
|
||||||
{
|
{
|
||||||
@ -220,6 +233,11 @@ public:
|
|||||||
{
|
{
|
||||||
clearUserCache(m_pointCache[i]);
|
clearUserCache(m_pointCache[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gContactEndedCallback && m_cachedPoints)
|
||||||
|
{
|
||||||
|
gContactEndedCallback(this);
|
||||||
|
}
|
||||||
m_cachedPoints = 0;
|
m_cachedPoints = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user