47 int gridSizeX,
int gridSizeY,
int gridSizeZ,
48 int maxSmallProxies,
int maxLargeProxies,
int maxPairsPerBody,
54 m_bInitialized(false),
57 _initialize(worldAabbMin, worldAabbMax, gridSizeX, gridSizeY, gridSizeZ,
58 maxSmallProxies, maxLargeProxies, maxPairsPerBody,
59 maxBodiesPerCell, cellFactorAABB);
66 int gridSizeX,
int gridSizeY,
int gridSizeZ,
67 int maxSmallProxies,
int maxLargeProxies,
int maxPairsPerBody,
71 m_bInitialized(false),
74 _initialize(worldAabbMin, worldAabbMax, gridSizeX, gridSizeY, gridSizeZ,
75 maxSmallProxies, maxLargeProxies, maxPairsPerBody,
76 maxBodiesPerCell, cellFactorAABB);
91 int gridSizeX,
int gridSizeY,
int gridSizeZ,
92 int maxSmallProxies,
int maxLargeProxies,
int maxPairsPerBody,
106 btVector3 w_size = worldAabbMax - worldAabbMin;
237 unsigned int* pInp =
m_hPairOut + m_hPairScan[i];
240 for(
unsigned int j = 0; j < num; j++)
242 unsigned int indx1_s = pInp[j];
283 btAssert((aabbMin[0]<= aabbMax[0]) && (aabbMin[1]<= aabbMax[1]) && (aabbMin[2]<= aabbMax[2]));
355 int new_largest_index = -1;
363 new_largest_index = i;
423 int new_largest_index = -1;
424 unsigned int num_small = 0;
432 new_largest_index = i;
446 new_largest_index = -1;
447 unsigned int num_large = 0;
455 new_largest_index = i;
479 s3DGridBroadphaseParams = *hostParams;
496 class bt3DGridHashKey
501 void quickSort(bt3DGridHashKey* pData,
int lo,
int hi)
504 bt3DGridHashKey x = pData[(lo+hi)/2];
507 while(pData[i].hash > x.hash) i++;
508 while(x.hash > pData[j].hash) j--;
511 bt3DGridHashKey t = pData[i];
517 if(lo < j) pData->quickSort(pData, lo, j);
518 if(i < hi) pData->quickSort(pData, i, hi);
558 BT_PROFILE(
"bt3DGrid_computePairCacheChanges");
567 BT_PROFILE(
"bt3DGrid_scanOverlappingPairBuff");
581 BT_PROFILE(
"bt3DGrid_squeezeOverlappingPairBuff");
virtual ~btGpu3DGridBroadphase()
btSimpleBroadphaseProxy * m_pHandles
bt3DGridBroadphaseParams m_params
virtual void findPairsLarge()
virtual void computePairCacheChanges()
virtual void setParameters(bt3DGridBroadphaseParams *hostParams)
btScalar m_cellFactorAABB
unsigned int * m_hPairOut
btSimpleBroadphaseProxy * getSimpleProxyFromProxy(btBroadphaseProxy *proxy)
static bool aabbOverlap(btSimpleBroadphaseProxy *proxy0, btSimpleBroadphaseProxy *proxy1)
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
virtual void findOverlappingPairs()
void freeLargeHandle(btSimpleBroadphaseProxy *proxy)
virtual btBroadphaseProxy * createProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, int shapeType, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask, btDispatcher *dispatcher, void *multiSapProxy)
virtual void squeezeOverlappingPairBuff()
unsigned int m_numOverflows
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
void SetNextFree(int next)
void _initialize(const btVector3 &worldAabbMin, const btVector3 &worldAabbMax, int gridSizeX, int gridSizeY, int gridSizeZ, int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, int maxBodiesPerCell=8, btScalar cellFactorAABB=btScalar(1.0f))
unsigned int m_maxPairsPerBody
virtual void scanOverlappingPairBuff()
const btScalar & getZ() const
Return the z value.
virtual void prepareAABB()
unsigned int * m_hBodiesHash
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
virtual void findCellStart()
unsigned int m_maxBodiesPerCell
#define BT_3DGRID_PAIR_NEW_FLG
btOverlappingPairCache * m_pairCache
void addPairsToCache(btDispatcher *dispatcher)
unsigned int * m_hPairBuff
unsigned int m_numPairsAdded
virtual btBroadphasePair * findPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)=0
virtual btBroadphaseProxy * createProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, int shapeType, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask, btDispatcher *dispatcher, void *multiSapProxy)
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btBroadphaseRayCallback &rayCallback, const btVector3 &aabbMin=btVector3(0, 0, 0), const btVector3 &aabbMax=btVector3(0, 0, 0))
unsigned int m_numPairsRemoved
bool isLargeProxy(const btVector3 &aabbMin, const btVector3 &aabbMax)
const btScalar & getY() const
Return the y value.
#define btAlignedFree(ptr)
const btScalar & getX() const
Return the x value.
btScalar length() const
Return the length of the vector.
btGpu3DGridBroadphase(const btVector3 &worldAabbMin, const btVector3 &worldAabbMax, int gridSizeX, int gridSizeY, int gridSizeZ, int maxSmallProxies, int maxLargeProxies, int maxPairsPerBody, int maxBodiesPerCell=8, btScalar cellFactorAABB=btScalar(1.0f))
virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy *proxy0, btDispatcher *dispatcher)=0
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
static bt3DGridBroadphaseParams s3DGridBroadphaseParams
The 3 following lines include the CPU implementation of the kernels, keep them in this order...
btVector3 can be used to represent 3D points and vectors.
unsigned int * m_hCellStart
virtual bool process(const btBroadphaseProxy *proxy)=0
unsigned int * m_hPairBuffStartCurr
btSimpleBroadphaseProxy * m_pLargeHandles
virtual btBroadphasePair * addOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)=0
The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead.
unsigned int * m_hPairScan
int m_firstFreeLargeHandle
#define btAlignedAlloc(size, alignment)
virtual void calcHashAABB()
virtual void resetPool(btDispatcher *dispatcher)
reset broadphase internal structures, to ensure determinism/reproducability
void * m_pLargeHandlesRawPtr
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
const T & btMin(const T &a, const T &b)
void addLarge2LargePairsToCache(btDispatcher *dispatcher)
#define BT_3DGRID_PAIR_ANY_FLG
Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman...
int m_LastLargeHandleIndex
virtual void calculateOverlappingPairs(btDispatcher *dispatcher)
calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during th...
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
virtual void * removeOverlappingPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1, btDispatcher *dispatcher)=0
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btBroadphaseRayCallback &rayCallback, const btVector3 &aabbMin=btVector3(0, 0, 0), const btVector3 &aabbMax=btVector3(0, 0, 0))