57 if(index >= (
int)numBodies)
64 pos.
x = (bbMin.
fx + bbMax.
fx) * 0.5f;
65 pos.
y = (bbMin.
fy + bbMax.
fy) * 0.5f;
66 pos.
z = (bbMin.
fz + bbMax.
fz) * 0.5f;
79 if(index >= (
int)numBodies)
83 uint2 sortedData = pHash[index];
92 volatile uint2 prevData = pHash[index-1];
93 sharedHash[0] = prevData.
x;
98 cellStart[sortedData.
x] = index;
106 return (min0.
fx <= max1.
fx)&& (min1.
fx <= max0.
fx) &&
107 (min0.
fy <= max1.
fy)&& (min1.
fy <= max0.
fy) &&
108 (min0.
fz <= max1.
fz)&& (min1.
fz <= max0.
fz);
119 uint2* pPairBuffStartCurr,
122 if ( (gridPos.
x < 0) || (gridPos.
x > (
int)
BT_GPU_params.m_gridSizeX - 1)
124 || (gridPos.
z < 0) || (gridPos.
z > (
int)
BT_GPU_params.m_gridSizeZ - 1))
130 uint bucketStart = pCellStart[gridHash];
131 if (bucketStart == 0xffffffff)
136 uint2 sortedData = pHash[index];
137 uint unsorted_indx = sortedData.
y;
140 uint handleIndex = min0.
uw;
141 uint2 start_curr = pPairBuffStartCurr[handleIndex];
142 uint start = start_curr.
x;
143 uint curr = start_curr.
y;
144 uint2 start_curr_next = pPairBuffStartCurr[handleIndex+1];
145 uint curr_max = start_curr_next.
x - start - 1;
147 bucketEnd = (bucketEnd > numBodies) ? numBodies : bucketEnd;
148 for(
uint index2 = bucketStart; index2 < bucketEnd; index2++)
150 uint2 cellData = pHash[index2];
151 if (cellData.
x != gridHash)
155 uint unsorted_indx2 = cellData.
y;
156 if (unsorted_indx2 < unsorted_indx)
162 uint handleIndex2 = min1.
uw;
164 for(k = 0; k < curr; k++)
167 if(old_pair == handleIndex2)
195 if(index >= (
int)numBodies)
199 uint2 sortedData = pHash[index];
200 uint unsorted_indx = sortedData.
y;
204 pos.
x = (bbMin.
fx + bbMax.
fx) * 0.5f;
205 pos.
y = (bbMin.
fy + bbMax.
fy) * 0.5f;
206 pos.
z = (bbMin.
fz + bbMax.
fz) * 0.5f;
210 for(
int z=-1; z<=1; z++) {
211 for(
int y=-1; y<=1; y++) {
212 for(
int x=-1; x<=1; x++) {
225 if(index >= (
int)numBodies)
229 uint2 sortedData = pHash[index];
230 uint unsorted_indx = sortedData.
y;
233 uint handleIndex = min0.
uw;
234 uint2 start_curr = pPairBuffStartCurr[handleIndex];
235 uint start = start_curr.
x;
236 uint curr = start_curr.
y;
237 uint2 start_curr_next = pPairBuffStartCurr[handleIndex+1];
238 uint curr_max = start_curr_next.
x - start - 1;
239 for(
uint i = 0; i < numLarge; i++)
241 uint indx2 = numBodies + i;
247 uint handleIndex2 = min1.
uw;
248 for(k = 0; k < curr; k++)
251 if(old_pair == handleIndex2)
278 if(index >= (
int)numBodies)
283 uint handleIndex = bbMin.
uw;
284 uint2 start_curr = pPairBuffStartCurr[handleIndex];
285 uint start = start_curr.
x;
286 uint curr = start_curr.
y;
287 uint *pInp = pPairBuff + start;
288 uint num_changes = 0;
289 for(
uint k = 0; k < curr; k++, pInp++)
296 pPairScan[index+1] = num_changes;
305 if(index >= (
int)numBodies)
310 uint handleIndex = bbMin.
uw;
311 uint2 start_curr = pPairBuffStartCurr[handleIndex];
312 uint start = start_curr.
x;
313 uint curr = start_curr.
y;
314 uint* pInp = pPairBuff + start;
315 uint* pOut = pPairOut + pPairScan[index];
318 for(
uint k = 0; k < curr; k++, pInp++)
327 *pOut2 = (*pInp) & (~BT_3DGRID_PAIR_ANY_FLG);
353 int numThreads, numBlocks;
365 int numThreads, numBlocks;
379 int numThreads, numBlocks;
390 void BT_GPU_PREF(
findPairsLarge(
bt3DGrid3F1U* pAABB,
unsigned int* pHash,
unsigned int* pCellStart,
unsigned int* pPairBuff,
unsigned int* pPairBuffStartCurr,
unsigned int numBodies,
unsigned int numLarge))
395 int numThreads, numBlocks;
408 int numThreads, numBlocks;
418 int numThreads, numBlocks;
BT_GPU___device__ uint cudaTestAABBOverlap(bt3DGrid3F1U min0, bt3DGrid3F1U max0, bt3DGrid3F1U min1, bt3DGrid3F1U max1)
BT_GPU___global__ void findCellStartD(uint2 *pHash, uint *cellStart, uint numBodies)
void BT_GPU_PREF() computeGridSize(int n, int blockSize, int &numBlocks, int &numThreads)
#define BT_GPU___syncthreads()
#define BT_GPU_make_uint2(x, y)
#define BT_GPU___mul24(a, b)
#define BT_GPU_CHECK_ERROR(s)
void BT_GPU_PREF() findOverlappingPairs(bt3DGrid3F1U *pAABB, unsigned int *pHash, unsigned int *pCellStart, unsigned int *pPairBuff, unsigned int *pPairBuffStartCurr, unsigned int numBodies)
#define BT_GPU_SAFE_CALL(func)
void BT_GPU_PREF() findPairsLarge(bt3DGrid3F1U *pAABB, unsigned int *pHash, unsigned int *pCellStart, unsigned int *pPairBuff, unsigned int *pPairBuffStartCurr, unsigned int numBodies, unsigned int numLarge)
#define BT_GPU___device__
#define BT_3DGRID_PAIR_NEW_FLG
#define BT_GPU_EXECKERNEL(numb, numt, kfunc, args)
BT_GPU___device__ int3 bt3DGrid_calcGridPos(float4 p)
BT_GPU___global__ void calcHashAABBD(bt3DGrid3F1U *pAABB, uint2 *pHash, uint numBodies)
void BT_GPU_PREF() computePairCacheChanges(unsigned int *pPairBuff, unsigned int *pPairBuffStartCurr, unsigned int *pPairScan, bt3DGrid3F1U *pAABB, unsigned int numBodies)
#define BT_GPU___global__
void BT_GPU_PREF() findCellStart(unsigned int *hash, unsigned int *cellStart, unsigned int numBodies, unsigned int numCells)
#define BT_GPU_FETCH(a, b)
BT_GPU___global__ void findPairsLargeD(bt3DGrid3F1U *pAABB, uint2 *pHash, uint *pCellStart, uint *pPairBuff, uint2 *pPairBuffStartCurr, uint numBodies, uint numLarge)
#define BT_GPU___shared__
void BT_GPU_PREF() calcHashAABB(bt3DGrid3F1U *pAABB, unsigned int *hash, unsigned int numBodies)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BT_GPU___global__ void findOverlappingPairsD(bt3DGrid3F1U *pAABB, uint2 *pHash, uint *pCellStart, uint *pPairBuff, uint2 *pPairBuffStartCurr, uint numBodies)
#define BT_3DGRID_PAIR_FOUND_FLG
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void BT_GPU_PREF() squeezeOverlappingPairBuff(unsigned int *pPairBuff, unsigned int *pPairBuffStartCurr, unsigned int *pPairScan, unsigned int *pPairOut, bt3DGrid3F1U *pAABB, unsigned int numBodies)
BT_GPU___global__ void squeezeOverlappingPairBuffD(uint *pPairBuff, uint2 *pPairBuffStartCurr, uint *pPairScan, uint *pPairOut, bt3DGrid3F1U *pAABB, uint numBodies)
BT_GPU___device__ uint bt3DGrid_calcGridHash(int3 gridPos)
BT_GPU___device__ void findPairsInCell(int3 gridPos, uint index, uint2 *pHash, uint *pCellStart, bt3DGrid3F1U *pAABB, uint *pPairBuff, uint2 *pPairBuffStartCurr, uint numBodies)
#define BT_3DGRID_PAIR_ANY_FLG
void BT_GPU_PREF(findCellStart(unsigned int *hash, unsigned int *cellStart, unsigned int numBodies, unsigned int numCells))
#define BT_GPU_make_int3(x, y, z)
BT_GPU___global__ void computePairCacheChangesD(uint *pPairBuff, uint2 *pPairBuffStartCurr, uint *pPairScan, bt3DGrid3F1U *pAABB, uint numBodies)