2017-08-01 12:30:58 +00:00
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
|
|
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BT_COLLISION__DISPATCHER_H
|
|
|
|
#define BT_COLLISION__DISPATCHER_H
|
|
|
|
|
|
|
|
#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
|
|
|
|
#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
|
|
|
|
|
|
|
|
#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
|
|
|
|
|
|
|
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
|
|
|
#include "LinearMath/btAlignedObjectArray.h"
|
|
|
|
|
|
|
|
class btIDebugDraw;
|
|
|
|
class btOverlappingPairCache;
|
|
|
|
class btPoolAllocator;
|
|
|
|
class btCollisionConfiguration;
|
|
|
|
|
|
|
|
#include "btCollisionCreateFunc.h"
|
|
|
|
|
|
|
|
#define USE_DISPATCH_REGISTRY_ARRAY 1
|
|
|
|
|
|
|
|
class btCollisionDispatcher;
|
|
|
|
///user can override this nearcallback for collision filtering and more finegrained control over collision detection
|
|
|
|
typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
|
|
|
|
|
|
|
|
///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
|
|
|
|
///Time of Impact, Closest Points and Penetration Depth.
|
|
|
|
class btCollisionDispatcher : public btDispatcher
|
|
|
|
{
|
|
|
|
protected:
|
2019-01-03 13:26:51 +00:00
|
|
|
int m_dispatcherFlags;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btAlignedObjectArray<btPersistentManifold*> m_manifoldsPtr;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btNearCallback m_nearCallback;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btPoolAllocator* m_collisionAlgorithmPoolAllocator;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btPoolAllocator* m_persistentManifoldPoolAllocator;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
btCollisionAlgorithmCreateFunc* m_doubleDispatchContactPoints[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
|
|
|
|
|
|
|
|
btCollisionAlgorithmCreateFunc* m_doubleDispatchClosestPoints[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btCollisionConfiguration* m_collisionConfiguration;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum DispatcherFlags
|
|
|
|
{
|
|
|
|
CD_STATIC_STATIC_REPORTED = 1,
|
|
|
|
CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2,
|
|
|
|
CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4
|
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int getDispatcherFlags() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_dispatcherFlags;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void setDispatcherFlags(int flags)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
m_dispatcherFlags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
///registerCollisionCreateFunc allows registration of custom/alternative collision create functions
|
2019-01-03 13:26:51 +00:00
|
|
|
void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void registerClosestPointsCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int getNumManifolds() const
|
|
|
|
{
|
|
|
|
return int(m_manifoldsPtr.size());
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btPersistentManifold** getInternalManifoldPointer()
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
return m_manifoldsPtr.size() ? &m_manifoldsPtr[0] : 0;
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btPersistentManifold* getManifoldByIndexInternal(int index)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2021-09-29 13:47:08 +00:00
|
|
|
btAssert(index>=0);
|
|
|
|
btAssert(index<m_manifoldsPtr.size());
|
2017-08-01 12:30:58 +00:00
|
|
|
return m_manifoldsPtr[index];
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
const btPersistentManifold* getManifoldByIndexInternal(int index) const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2021-09-29 13:47:08 +00:00
|
|
|
btAssert(index>=0);
|
|
|
|
btAssert(index<m_manifoldsPtr.size());
|
2017-08-01 12:30:58 +00:00
|
|
|
return m_manifoldsPtr[index];
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btCollisionDispatcher(btCollisionConfiguration* collisionConfiguration);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
virtual ~btCollisionDispatcher();
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual btPersistentManifold* getNewManifold(const btCollisionObject* b0, const btCollisionObject* b1);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void releaseManifold(btPersistentManifold* manifold);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
virtual void clearManifold(btPersistentManifold* manifold);
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, btPersistentManifold* sharedManifold, ebtDispatcherQueryType queryType);
|
|
|
|
|
|
|
|
virtual bool needsCollision(const btCollisionObject* body0, const btCollisionObject* body1);
|
|
|
|
|
|
|
|
virtual bool needsResponse(const btCollisionObject* body0, const btCollisionObject* body1);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache, const btDispatcherInfo& dispatchInfo, btDispatcher* dispatcher);
|
|
|
|
|
|
|
|
void setNearCallback(btNearCallback nearCallback)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
m_nearCallback = nearCallback;
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btNearCallback getNearCallback() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_nearCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
//by default, Bullet will use this near callback
|
2019-01-03 13:26:51 +00:00
|
|
|
static void defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void* allocateCollisionAlgorithm(int size);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void freeCollisionAlgorithm(void* ptr);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btCollisionConfiguration* getCollisionConfiguration()
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_collisionConfiguration;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
const btCollisionConfiguration* getCollisionConfiguration() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_collisionConfiguration;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void setCollisionConfiguration(btCollisionConfiguration* config)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
m_collisionConfiguration = config;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual btPoolAllocator* getInternalManifoldPool()
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_persistentManifoldPoolAllocator;
|
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual const btPoolAllocator* getInternalManifoldPool() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
return m_persistentManifoldPoolAllocator;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //BT_COLLISION__DISPATCHER_H
|