- Added serialization to btBvhTriangleMeshShape/btOptimizedBvh. See ConcaveDemo for example usage.
- added bt32BitAxisSweep3, which co-exists without recompilation, using template class. This broadphase is recommended for large worlds with many objects (> 16384), until btMultiSwap is finished. - Fixed some recent issues in Bullet 2.57 related to compound (thanks Proctoid) and memory allocations
This commit is contained in:
@@ -14,8 +14,8 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
//enable just one, DO_BENCHMARK_PYRAMIDS or DO_WALL
|
||||
//#define DO_BENCHMARK_PYRAMIDS 1
|
||||
#define DO_WALL 1
|
||||
#define DO_BENCHMARK_PYRAMIDS 1
|
||||
//#define DO_WALL 1
|
||||
|
||||
//Note: some of those settings need 'DO_WALL' demo
|
||||
//#define USE_KINEMATIC_GROUND 1
|
||||
@@ -401,7 +401,10 @@ int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks
|
||||
btVector3 worldAabbMax(1000,1000,1000);
|
||||
|
||||
btBroadphaseInterface* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
|
||||
// btOverlappingPairCache* broadphase = new btSimpleBroadphase;
|
||||
/// For large worlds or over 16384 objects, use the bt32BitAxisSweep3 broadphase
|
||||
// btBroadphaseInterface* broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
|
||||
/// When trying to debug broadphase issues, try to use the btSimpleBroadphase
|
||||
// btBroadphaseInterface* broadphase = new btSimpleBroadphase;
|
||||
|
||||
#ifdef REGISTER_CUSTOM_COLLISION_ALGORITHM
|
||||
dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||
@@ -576,8 +579,8 @@ int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks
|
||||
|
||||
localCreateRigidBody(0.f,trans,shapePtr[shapeIndex[0]]);
|
||||
|
||||
int numWalls = 10;
|
||||
int wallHeight = 10;
|
||||
int numWalls = 15;
|
||||
int wallHeight = 15;
|
||||
float wallDistance = 3;
|
||||
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ int main(int argc,char** argv)
|
||||
}
|
||||
|
||||
|
||||
const int NUM_VERTS_X = 50;
|
||||
const int NUM_VERTS_Y = 50;
|
||||
const int NUM_VERTS_X = 30;
|
||||
const int NUM_VERTS_Y = 30;
|
||||
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
|
||||
|
||||
void ConcaveDemo::setVertexPositions(float waveheight, float offset)
|
||||
@@ -191,8 +191,50 @@ void ConcaveDemo::initPhysics()
|
||||
totalVerts,(btScalar*) &gVertices[0].x(),vertStride);
|
||||
|
||||
bool useQuantizedAabbCompression = true;
|
||||
trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression);
|
||||
|
||||
#define SERIALIZE_TO_DISK 1
|
||||
#ifdef SERIALIZE_TO_DISK
|
||||
trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression);
|
||||
|
||||
///we can serialize the BVH data
|
||||
void* buffer = 0;
|
||||
int numBytes = trimeshShape->getOptimizedBvh()->calculateSerializeBufferSize();
|
||||
buffer = btAlignedAlloc(numBytes,16);
|
||||
bool swapEndian = true;
|
||||
trimeshShape->getOptimizedBvh()->serialize(buffer,numBytes,swapEndian);
|
||||
FILE* file = fopen("bvh.bin","wb");
|
||||
fwrite(buffer,1,numBytes,file);
|
||||
fclose(file);
|
||||
|
||||
#else
|
||||
|
||||
trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression,false);
|
||||
|
||||
char* fileName = "bvh.bin";
|
||||
|
||||
FILE* file = fopen(fileName,"rb");
|
||||
int size=0;
|
||||
btOptimizedBvh* bvh = 0;
|
||||
|
||||
if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */
|
||||
printf("Error: cannot get filesize from %s\n", fileName);
|
||||
exit(0);
|
||||
} else
|
||||
{
|
||||
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
void* buffer = btAlignedAlloc(size,16);
|
||||
memset(buffer,0xcc,size);
|
||||
int read = fread(buffer,1,size,file);
|
||||
fclose(file);
|
||||
bool swapEndian = true;
|
||||
bvh = btOptimizedBvh::deSerializeInPlace(buffer,size,swapEndian);
|
||||
}
|
||||
|
||||
trimeshShape->setOptimizedBvh(bvh);
|
||||
|
||||
#endif
|
||||
|
||||
// btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user