add support for BVH acceleration for concave trianglemesh collision against convex hulls
bugfix/improvement in batching
This commit is contained in:
@@ -34,13 +34,13 @@ public:
|
||||
:useOpenCL(true),
|
||||
preferredOpenCLPlatformIndex(-1),
|
||||
preferredOpenCLDeviceIndex(-1),
|
||||
arraySizeX(5),
|
||||
arraySizeY(5 ),
|
||||
arraySizeZ(5),
|
||||
arraySizeX(30),
|
||||
arraySizeY(10 ),
|
||||
arraySizeZ(30),
|
||||
m_useConcaveMesh(false),
|
||||
gapX(4.3),
|
||||
gapY(2.0),
|
||||
gapZ(4.3),
|
||||
gapX(6.3),
|
||||
gapY(12.0),
|
||||
gapZ(6.3),
|
||||
m_instancingRenderer(0),
|
||||
m_window(0)
|
||||
{
|
||||
|
||||
@@ -617,7 +617,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (!gPause)
|
||||
{
|
||||
BT_PROFILE("simulate");
|
||||
BT_PROFILE("clientMoveAndDisplay");
|
||||
|
||||
demo->clientMoveAndDisplay();
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
objLoader* objData = new objLoader();
|
||||
//char* fileName = "data/plane.obj";
|
||||
char* fileName = "data/teddy.obj";//"plane.obj";
|
||||
//char* fileName = "data/sponza_closed.obj";//"plane.obj";
|
||||
//char* fileName = "data/plane100.obj";
|
||||
//char* fileName = "data/teddy.obj";//"plane.obj";
|
||||
char* fileName = "data/sponza_closed.obj";//"plane.obj";
|
||||
|
||||
FILE* f = 0;
|
||||
|
||||
@@ -200,16 +200,16 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
{
|
||||
GraphicsShape* shape = createGraphicsShapeFromWavefrontObj(objData);
|
||||
btVector4 scaling(1,1,1,1);
|
||||
btVector4 scaling(4,4,4,1);
|
||||
|
||||
btAlignedObjectArray<btVector3> verts;
|
||||
for (int i=0;i<shape->m_numvertices;i++)
|
||||
{
|
||||
btVector3 vtx = (btVector3&)shape->m_vertices->at(i).xyzw;
|
||||
verts.push_back(vtx);
|
||||
verts.push_back(vtx*scaling);
|
||||
}
|
||||
|
||||
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,scaling);
|
||||
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,btVector3(1,1,1));
|
||||
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
@@ -222,7 +222,7 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&shape->m_vertices->at(0).xyzw[0], shape->m_numvertices, &shape->m_indices->at(0), shape->m_numIndices);
|
||||
btQuaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color(0,1,0,1.f);//0.5);
|
||||
btVector4 color(0,0,1,1.f);//0.5);//1.f
|
||||
|
||||
|
||||
{
|
||||
@@ -262,7 +262,8 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
float mass = 1;
|
||||
|
||||
btVector3 position(-2*ci.gapX+i*ci.gapX,25+j*ci.gapY,-2*ci.gapZ+k*ci.gapZ);
|
||||
//btVector3 position(-2*ci.gapX+i*ci.gapX,25+j*ci.gapY,-2*ci.gapZ+k*ci.gapZ);
|
||||
btVector3 position(-(ci.arraySizeX/2)*ci.gapX+i*ci.gapX,5+j*ci.gapY,-(ci.arraySizeZ/2)*ci.gapZ+k*ci.gapZ);
|
||||
btQuaternion orn(1,0,0,0);
|
||||
|
||||
btVector4 color(0,1,0,1);
|
||||
@@ -278,6 +279,6 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
float camPos[4]={0,0,0,0};//65.5,4.5,65.5,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(50);
|
||||
m_instancingRenderer->setCameraDistance(120);
|
||||
|
||||
}
|
||||
@@ -157,6 +157,7 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
btVector4* positions = 0;
|
||||
if (animate && numObjects)
|
||||
{
|
||||
BT_PROFILE("gl2cl");
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(btVector4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
@@ -172,10 +173,14 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
m_data->m_rigidBodyPipeline->stepSimulation(1./60.f);
|
||||
{
|
||||
BT_PROFILE("stepSimulation");
|
||||
m_data->m_rigidBodyPipeline->stepSimulation(1./60.f);
|
||||
}
|
||||
|
||||
if (numObjects)
|
||||
{
|
||||
BT_PROFILE("cl2gl_convert");
|
||||
int ciErrNum = 0;
|
||||
cl_mem bodies = m_data->m_rigidBodyPipeline->getBodyBuffer();
|
||||
btLauncherCL launch(m_clData->m_clQueue,m_data->m_copyTransformsToVBOKernel);
|
||||
@@ -188,6 +193,7 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
|
||||
if (animate && numObjects)
|
||||
{
|
||||
BT_PROFILE("cl2gl_upload");
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
m_data->m_instancePosOrnColor->copyToHostPointer(positions,3*numObjects,0);
|
||||
|
||||
Reference in New Issue
Block a user