faster scene construction when not using instancing (avoid copy individual vertices/shapes to GPU, but do it afterwards in a batch), copy GPU data in 'writeAllBodiesToGpu' method
add option --no_instanced_collision_shapes, this only applies to the 2 benchmark screnes at the moment always use the user specified b3Config file, so the settings can be set at runtime, not just at compile time adjust default constants in b3Config (needs more tweaking, ideally at run-time)
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include"../../Wavefront/objLoader.h"
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
#include "Bullet3OpenCL/NarrowphaseCollision/b3ConvexUtility.h"
|
||||
|
||||
|
||||
#include "OpenGLWindow/GLInstanceGraphicsShape.h"
|
||||
#define CONCAVE_GAPX 16
|
||||
@@ -323,21 +325,50 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
int curColor = 0;
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,1,1,1),
|
||||
b3Vector4(1,1,0.3,1),
|
||||
b3Vector4(0.3,1,1,1),
|
||||
b3Vector4(0.3,0.3,1,1),
|
||||
};
|
||||
{
|
||||
b3Vector4(1,1,1,1),
|
||||
b3Vector4(1,1,0.3,1),
|
||||
b3Vector4(0.3,1,1,1),
|
||||
b3Vector4(0.3,0.3,1,1),
|
||||
};
|
||||
|
||||
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
{
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
|
||||
unsigned char* vts = (unsigned char*) cube_vertices;
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3Vector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
if (numVertices)
|
||||
{
|
||||
utilPtr->initializePolyhedralFeatures(&verts[0],verts.size(),merge);
|
||||
}
|
||||
}
|
||||
|
||||
// int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
int colIndex=-1;
|
||||
if (ci.m_useInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
|
||||
for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
if (!ci.m_useInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
float mass = 1;
|
||||
|
||||
//b3Vector3 position(-2*ci.gapX+i*ci.gapX,25+j*ci.gapY,-2*ci.gapZ+k*ci.gapZ);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h"
|
||||
#include "OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
#include "Bullet3OpenCL/Raycast/b3GpuRaycast.h"
|
||||
#include "Bullet3OpenCL/NarrowphaseCollision/b3ConvexUtility.h"
|
||||
|
||||
|
||||
void GpuConvexScene::setupScene(const ConstructionInfo& ci)
|
||||
@@ -88,26 +89,56 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
float scaling[4] = {1,1,1,1};
|
||||
int prevBody = -1;
|
||||
int insta = 0;
|
||||
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
|
||||
{
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
|
||||
unsigned char* vts = (unsigned char*) vertices;
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3Vector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
if (numVertices)
|
||||
{
|
||||
utilPtr->initializePolyhedralFeatures(&verts[0],verts.size(),merge);
|
||||
}
|
||||
}
|
||||
|
||||
int colIndex=-1;
|
||||
if (ci.m_useInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
//int colIndex = m_data->m_np->registerSphereShape(1);
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
|
||||
|
||||
//printf("%d of %d\n", i, ci.arraySizeX);
|
||||
for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&vertices[0],strideInBytes,numVertices, scaling);
|
||||
if (!ci.m_useInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
float mass = 1.f;
|
||||
if (j==0)//ci.arraySizeY-1)
|
||||
{
|
||||
@@ -128,7 +159,7 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
|
||||
if (prevBody>=0)
|
||||
{
|
||||
b3Point2PointConstraint* p2p = new b3Point2PointConstraint(pid,prevBody,b3Vector3(0,-1.1,0),b3Vector3(0,1.1,0));
|
||||
//b3Point2PointConstraint* p2p = new b3Point2PointConstraint(pid,prevBody,b3Vector3(0,-1.1,0),b3Vector3(0,1.1,0));
|
||||
// m_data->m_rigidBodyPipeline->addConstraint(p2p);//,false);
|
||||
}
|
||||
prevBody = pid;
|
||||
|
||||
@@ -114,7 +114,7 @@ void GpuRigidBodyDemo::initPhysics(const ConstructionInfo& ci)
|
||||
m_data->m_bp = bp;
|
||||
b3DynamicBvhBroadphase* broadphaseDbvt = new b3DynamicBvhBroadphase(config.m_maxConvexBodies);
|
||||
|
||||
m_data->m_rigidBodyPipeline = new b3GpuRigidBodyPipeline(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue, np, bp,broadphaseDbvt);
|
||||
m_data->m_rigidBodyPipeline = new b3GpuRigidBodyPipeline(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue, np, bp,broadphaseDbvt,config);
|
||||
|
||||
|
||||
setupScene(ci);
|
||||
|
||||
Reference in New Issue
Block a user