allow multiple concave meshes, each with their own bvh
This commit is contained in:
18
opencl/gpu_narrowphase/host/b3BvhInfo.h
Normal file
18
opencl/gpu_narrowphase/host/b3BvhInfo.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef B3_BVH_INFO_H
|
||||
#define B3_BVH_INFO_H
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
struct b3BvhInfo
|
||||
{
|
||||
b3Vector3 m_aabbMin;
|
||||
b3Vector3 m_aabbMax;
|
||||
b3Vector3 m_quantization;
|
||||
int m_numNodes;
|
||||
int m_numSubTrees;
|
||||
int m_nodeOffset;
|
||||
int m_subTreeOffset;
|
||||
|
||||
};
|
||||
|
||||
#endif //B3_BVH_INFO_H
|
||||
@@ -16,7 +16,10 @@ enum btShapeTypes
|
||||
|
||||
struct b3Collidable
|
||||
{
|
||||
int m_numChildShapes;
|
||||
union {
|
||||
int m_numChildShapes;
|
||||
int m_bvhIndex;
|
||||
};
|
||||
float m_radius;
|
||||
int m_shapeType;
|
||||
int m_shapeIndex;
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef b3AlignedObjectArray<b3Vector3> btVertexArray;
|
||||
#include "../kernels/bvhTraversal.h"
|
||||
#include "../kernels/primitiveContacts.h"
|
||||
|
||||
|
||||
#include "Bullet3Geometry/b3AabbUtil.h"
|
||||
|
||||
|
||||
@@ -853,6 +854,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
|
||||
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
|
||||
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
|
||||
btOpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
|
||||
int numObjects,
|
||||
int maxTriConvexPairCapacity,
|
||||
btOpenCLArray<btInt4>& triangleConvexPairsOut,
|
||||
@@ -1077,13 +1080,11 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
//now perform the tree query on GPU
|
||||
{
|
||||
|
||||
int numNodes = bvhData.size()? bvhData[0]->getQuantizedNodeArray().size() : 0;
|
||||
if (numNodes)
|
||||
|
||||
|
||||
{
|
||||
int numSubTrees = subTreesGPU->size();
|
||||
b3Vector3 bvhAabbMin = bvhData[0]->m_bvhAabbMin;
|
||||
b3Vector3 bvhAabbMax = bvhData[0]->m_bvhAabbMax;
|
||||
b3Vector3 bvhQuantization = bvhData[0]->m_bvhQuantization;
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("m_bvhTraversalKernel");
|
||||
numConcavePairs = numConcavePairsOut.at(0);
|
||||
@@ -1096,10 +1097,8 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
launcher.setBuffer( numConcavePairsOut.getBufferCL());
|
||||
launcher.setBuffer( subTreesGPU->getBufferCL());
|
||||
launcher.setBuffer( treeNodesGPU->getBufferCL());
|
||||
launcher.setConst( bvhAabbMin);
|
||||
launcher.setConst( bvhAabbMax);
|
||||
launcher.setConst( bvhQuantization);
|
||||
launcher.setConst(numSubTrees);
|
||||
launcher.setBuffer( bvhInfo->getBufferCL());
|
||||
|
||||
launcher.setConst( nPairs );
|
||||
launcher.setConst( maxTriConvexPairCapacity);
|
||||
int num = nPairs;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "parallel_primitives/host/btInt2.h"
|
||||
#include "parallel_primitives/host/btInt4.h"
|
||||
#include "b3OptimizedBvh.h"
|
||||
#include "b3BvhInfo.h"
|
||||
|
||||
//#include "../../dynamics/basic_demo/Stubs/ChNarrowPhase.h"
|
||||
|
||||
@@ -85,6 +86,7 @@ struct GpuSatCollision
|
||||
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
|
||||
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
|
||||
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
|
||||
btOpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
int numObjects,
|
||||
int maxTriConvexPairCapacity,
|
||||
btOpenCLArray<btInt4>& triangleConvexPairs,
|
||||
|
||||
@@ -21,6 +21,19 @@ typedef struct
|
||||
//4 bytes
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
} btQuantizedBvhNode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float4 m_aabbMin;
|
||||
float4 m_aabbMax;
|
||||
float4 m_quantization;
|
||||
int m_numNodes;
|
||||
int m_numSubTrees;
|
||||
int m_nodeOffset;
|
||||
int m_subTreeOffset;
|
||||
|
||||
} b3BvhInfo;
|
||||
|
||||
/*
|
||||
bool isLeafNode() const
|
||||
{
|
||||
@@ -185,12 +198,9 @@ __kernel void bvhTraversalKernel( __global const int2* pairs,
|
||||
__global btAabbCL* aabbs,
|
||||
__global int4* concavePairsOut,
|
||||
__global volatile int* numConcavePairsOut,
|
||||
__global const btBvhSubtreeInfo* subtreeHeaders,
|
||||
__global const btQuantizedBvhNode* quantizedNodes,
|
||||
float4 bvhAabbMin,
|
||||
float4 bvhAabbMax,
|
||||
float4 bvhQuantization,
|
||||
int numSubtreeHeaders,
|
||||
__global const btBvhSubtreeInfo* subtreeHeadersRoot,
|
||||
__global const btQuantizedBvhNode* quantizedNodesRoot,
|
||||
__global const b3BvhInfo* bvhInfos,
|
||||
int numPairs,
|
||||
int maxNumConcavePairsCapacity)
|
||||
{
|
||||
@@ -220,7 +230,16 @@ __kernel void bvhTraversalKernel( __global const int2* pairs,
|
||||
)
|
||||
return;
|
||||
|
||||
b3BvhInfo bvhInfo = bvhInfos[collidables[collidableIndexA].m_numChildShapes];
|
||||
|
||||
float4 bvhAabbMin = bvhInfo.m_aabbMin;
|
||||
float4 bvhAabbMax = bvhInfo.m_aabbMax;
|
||||
float4 bvhQuantization = bvhInfo.m_quantization;
|
||||
int numSubtreeHeaders = bvhInfo.m_numSubTrees;
|
||||
__global const btBvhSubtreeInfo* subtreeHeaders = &subtreeHeadersRoot[bvhInfo.m_subTreeOffset];
|
||||
__global const btQuantizedBvhNode* quantizedNodes = &quantizedNodesRoot[bvhInfo.m_nodeOffset];
|
||||
|
||||
|
||||
unsigned short int quantizedQueryAabbMin[3];
|
||||
unsigned short int quantizedQueryAabbMax[3];
|
||||
quantizeWithClamp(quantizedQueryAabbMin,aabbs[bodyIndexB].m_min,false,bvhAabbMin, bvhAabbMax,bvhQuantization);
|
||||
|
||||
@@ -23,6 +23,19 @@ static const char* bvhTraversalKernelCL= \
|
||||
" //4 bytes\n"
|
||||
" int m_escapeIndexOrTriangleIndex;\n"
|
||||
"} btQuantizedBvhNode;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
" float4 m_aabbMin;\n"
|
||||
" float4 m_aabbMax;\n"
|
||||
" float4 m_quantization;\n"
|
||||
" int m_numNodes;\n"
|
||||
" int m_numSubTrees;\n"
|
||||
" int m_nodeOffset;\n"
|
||||
" int m_subTreeOffset;\n"
|
||||
"\n"
|
||||
"} b3BvhInfo;\n"
|
||||
"\n"
|
||||
"/*\n"
|
||||
" bool isLeafNode() const\n"
|
||||
" {\n"
|
||||
@@ -187,12 +200,9 @@ static const char* bvhTraversalKernelCL= \
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global int4* concavePairsOut,\n"
|
||||
" __global volatile int* numConcavePairsOut,\n"
|
||||
" __global const btBvhSubtreeInfo* subtreeHeaders,\n"
|
||||
" __global const btQuantizedBvhNode* quantizedNodes,\n"
|
||||
" float4 bvhAabbMin,\n"
|
||||
" float4 bvhAabbMax,\n"
|
||||
" float4 bvhQuantization,\n"
|
||||
" int numSubtreeHeaders,\n"
|
||||
" __global const btBvhSubtreeInfo* subtreeHeadersRoot,\n"
|
||||
" __global const btQuantizedBvhNode* quantizedNodesRoot,\n"
|
||||
" __global const b3BvhInfo* bvhInfos,\n"
|
||||
" int numPairs,\n"
|
||||
" int maxNumConcavePairsCapacity)\n"
|
||||
"{\n"
|
||||
@@ -222,7 +232,16 @@ static const char* bvhTraversalKernelCL= \
|
||||
" )\n"
|
||||
" return;\n"
|
||||
"\n"
|
||||
" b3BvhInfo bvhInfo = bvhInfos[collidables[collidableIndexA].m_numChildShapes];\n"
|
||||
"\n"
|
||||
" float4 bvhAabbMin = bvhInfo.m_aabbMin;\n"
|
||||
" float4 bvhAabbMax = bvhInfo.m_aabbMax;\n"
|
||||
" float4 bvhQuantization = bvhInfo.m_quantization;\n"
|
||||
" int numSubtreeHeaders = bvhInfo.m_numSubTrees;\n"
|
||||
" __global const btBvhSubtreeInfo* subtreeHeaders = &subtreeHeadersRoot[bvhInfo.m_subTreeOffset];\n"
|
||||
" __global const btQuantizedBvhNode* quantizedNodes = &quantizedNodesRoot[bvhInfo.m_nodeOffset];\n"
|
||||
" \n"
|
||||
"\n"
|
||||
" unsigned short int quantizedQueryAabbMin[3];\n"
|
||||
" unsigned short int quantizedQueryAabbMax[3];\n"
|
||||
" quantizeWithClamp(quantizedQueryAabbMin,aabbs[bodyIndexB].m_min,false,bvhAabbMin, bvhAabbMax,bvhQuantization);\n"
|
||||
|
||||
Reference in New Issue
Block a user