remove some warnings

This commit is contained in:
Erwin Coumans
2014-08-21 13:31:12 -07:00
parent 590504bf72
commit 4af9c5a4c9
24 changed files with 1136 additions and 1104 deletions

View File

@@ -5,7 +5,7 @@
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
#define MSTRINGIFY(A) #A
static char* particleKernelsString =
static const char* particleKernelsString =
#include "ParticleKernels.cl"
#define INTEROPKERNEL_SRC_PATH "demo/gpudemo/ParticleKernels.cl"
@@ -40,7 +40,7 @@ static char* particleKernelsString =
//#define NUM_PARTICLES_Y 30
//#define NUM_PARTICLES_Z 30
B3_ATTRIBUTE_ALIGNED16(struct) b3SimParams
{
@@ -48,7 +48,7 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3SimParams
b3Vector3 m_gravity;
float m_worldMin[4];
float m_worldMax[4];
float m_particleRad;
float m_globalDamping;
float m_boundaryDamping;
@@ -59,7 +59,7 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3SimParams
float m_attraction;
float m_dummy;
b3SimParams()
{
m_gravity.setValue(0,-.3,0.f);
@@ -83,7 +83,7 @@ B3_ATTRIBUTE_ALIGNED16(struct) b3SimParams
struct ParticleInternalData
{
cl_kernel m_updatePositionsKernel;
cl_kernel m_updatePositionsKernel2;
@@ -92,7 +92,7 @@ struct ParticleInternalData
cl_kernel m_collideParticlesKernel;
b3GpuSapBroadphase* m_broadphaseGPU;
cl_mem m_clPositionBuffer;
@@ -102,7 +102,7 @@ struct ParticleInternalData
b3AlignedObjectArray<b3SimParams> m_simParamCPU;
b3OpenCLArray<b3SimParams>* m_simParamGPU;
ParticleInternalData()
:
@@ -144,7 +144,7 @@ void ParticleDemo::exitCL()
clReleaseKernel(m_data->m_updateAabbsKernel);
clReleaseKernel(m_data->m_collideParticlesKernel);
}
GpuDemo::exitCL();
}
@@ -158,12 +158,12 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
{
initCL(ci.preferredOpenCLDeviceIndex,ci.preferredOpenCLPlatformIndex);
int numParticles = NUM_PARTICLES_X*NUM_PARTICLES_Y*NUM_PARTICLES_Z;
int maxObjects = NUM_PARTICLES_X*NUM_PARTICLES_Y*NUM_PARTICLES_Z+1024;
int maxPairsSmallProxy = 32;
float radius = m_data->m_simParamCPU[0].m_particleRad;
@@ -219,15 +219,15 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
float position[4] = {0,0,0,0};
float quaternion[4] = {0,0,0,1};
float scaling[4] = {radius,radius,radius,1};
int userIndex = 0;
int totalParticles = NUM_PARTICLES_X*NUM_PARTICLES_Y*NUM_PARTICLES_Z;
int curColor = 0;
b3Vector4 colors[4] =
b3Vector4 colors[4] =
{
b3MakeVector4(1,1,1,1),
b3MakeVector4(1,1,0.3,1),
@@ -241,9 +241,9 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
float angle = b3RandRange(-B3_PI, B3_PI);
for (int ii=0;ii<totalParticles;ii++)
{
float arg = b3RandRange(-B3_PI,B3_PI);
float rad = m_data->m_simParamCPU[0].m_particleRad;
position[0] = arg*b3Cos(arg + angle);
position[1] = 3.0f + arg;
@@ -255,8 +255,8 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
int id = m_instancingRenderer->registerGraphicsInstance(shapeId,position,quaternion,color,scaling);
void* userPtr = (void*)userIndex;
int collidableIndex = userIndex;
b3Vector3 aabbMin,aabbMax;
b3Vector3 particleRadius=b3MakeVector3(rad,rad,rad);
@@ -268,7 +268,7 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
angle += b3RandRange(-(float)B3_PI, (float)B3_PI);
}
}
m_data->m_broadphaseGPU->writeAabbsToGpu();
@@ -291,7 +291,7 @@ void ParticleDemo::exitPhysics()
void ParticleDemo::renderScene()
{
if (m_instancingRenderer)
{
m_instancingRenderer->renderScene();
@@ -315,7 +315,7 @@ void ParticleDemo::clientMoveAndDisplay()
assert(err==GL_NO_ERROR);
glFinish();
#if 1
@@ -326,10 +326,10 @@ void ParticleDemo::clientMoveAndDisplay()
bool useCpu = false;
if (useCpu)
{
float* posBuffer = (float*)hostPtr;
for (int i=0;i<numParticles;i++)
{
posBuffer[i*4+1] += 0.1;
@@ -350,19 +350,19 @@ void ParticleDemo::clientMoveAndDisplay()
);
clFinish(m_clData->m_clQueue);
}
if (0)
{
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( m_data->m_velocitiesGPU->getBufferCL(), true ),
b3BufferInfoCL( m_data->m_clPositionBuffer)
};
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updatePositionsKernel,"m_updatePositionsKernel" );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
@@ -370,18 +370,18 @@ void ParticleDemo::clientMoveAndDisplay()
launcher.launch1D( numParticles);
clFinish(m_clData->m_clQueue);
}
if (1)
{
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( m_data->m_clPositionBuffer),
b3BufferInfoCL( m_data->m_velocitiesGPU->getBufferCL() ),
b3BufferInfoCL( m_data->m_simParamGPU->getBufferCL(),true)
};
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updatePositionsKernel2 ,"m_updatePositionsKernel2");
launcher.setConst( numParticles);
@@ -391,21 +391,21 @@ void ParticleDemo::clientMoveAndDisplay()
launcher.launch1D( numParticles);
clFinish(m_clData->m_clQueue);
}
if (0)
{
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( m_data->m_clPositionBuffer),
b3BufferInfoCL( m_data->m_broadphaseGPU->getAabbBufferWS()),
};
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updateAabbsKernel,"m_updateAabbsKernel" );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( m_data->m_simParamCPU[0].m_particleRad);
launcher.setConst( numParticles);
launcher.launch1D( numParticles);
clFinish(m_clData->m_clQueue);
}
@@ -422,12 +422,12 @@ void ParticleDemo::clientMoveAndDisplay()
if (numPairsGPU)
{
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( m_data->m_clPositionBuffer),
b3BufferInfoCL( m_data->m_velocitiesGPU->getBufferCL() ),
b3BufferInfoCL( m_data->m_broadphaseGPU->getOverlappingPairBuffer(),true),
};
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_collideParticlesKernel,"m_collideParticlesKernel");
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( numPairsGPU);
@@ -450,15 +450,15 @@ void ParticleDemo::clientMoveAndDisplay()
//clReleaseMemObject(clBuffer);
clFinish(m_clData->m_clQueue);
}
}
#endif
glUnmapBuffer( GL_ARRAY_BUFFER);
glFlush();
}

View File

@@ -94,7 +94,8 @@ static int loadCurrentDemoEntry(const char* startFileName)
FILE* f = fopen(startFileName,"r");
if (f)
{
fscanf(f,"%d",&currentEntry);
int bytesScanned;
bytesScanned = fscanf(f,"%d",&currentEntry);
fclose(f);
}
return currentEntry;
@@ -130,20 +131,20 @@ int selectedDemo = 1;
GpuDemo::CreateFunc* allDemos[]=
{
//ConcaveCompound2Scene::MyCreateFunc,
//ConcaveSphereScene::MyCreateFunc,
// ConcaveSphereScene::MyCreateFunc,
ConcaveScene::MyCreateFunc,
GpuBoxPlaneScene::MyCreateFunc,
GpuConstraintsDemo::MyCreateFunc,
//GpuConvexPlaneScene::MyCreateFunc,
@@ -155,14 +156,14 @@ GpuDemo::CreateFunc* allDemos[]=
GpuSphereScene::MyCreateFunc,
ConcaveSphereScene::MyCreateFunc,
ConcaveCompoundScene::MyCreateFunc,
//GpuTetraScene::MyCreateFunc,
@@ -170,7 +171,7 @@ GpuDemo::CreateFunc* allDemos[]=
Bullet2FileDemo::MyCreateFunc,
PairBench::MyCreateFunc,
GpuRaytraceScene::MyCreateFunc,
@@ -534,7 +535,7 @@ FILE* defaultOutput = stdout;
void myprintf(const char* msg)
{
fprintf(defaultOutput,msg);
fprintf(defaultOutput,"%s",msg);
}
@@ -560,7 +561,7 @@ void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName
char* pixels = (char*)malloc(textureWidth*textureHeight*numComponents);
err=glGetError();
assert(err==GL_NO_ERROR);
for (int j=0;j<textureHeight;j++)
{
for (int i=0;i<textureWidth;i++)
@@ -576,7 +577,7 @@ void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName
{
//swap the pixels
unsigned char tmp;
for (int j=0;j<textureHeight/2;j++)
{
for (int i=0;i<textureWidth;i++)
@@ -591,9 +592,9 @@ void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName
}
}
}
stbi_write_png(fileName, textureWidth,textureHeight, numComponents, pixels, textureWidth*numComponents);
free(pixels);
free(orgPixels);
@@ -615,7 +616,7 @@ int main(int argc, char* argv[])
int sz6 = sizeof(b3Transform);
//b3OpenCLUtils::setCachePath("/Users/erwincoumans/develop/mycache");
b3SetCustomEnterProfileZoneFunc(b3ProfileManager::Start_Profile);
b3SetCustomLeaveProfileZoneFunc(b3ProfileManager::Stop_Profile);
@@ -699,7 +700,7 @@ int main(int argc, char* argv[])
gDebugForceLoadingFromSource = args.CheckCmdLineFlag("load_cl_kernels_from_disk");
gDebugSkipLoadingBinary = args.CheckCmdLineFlag("disable_cached_cl_kernels");
#ifndef B3_NO_PROFILE
b3ProfileManager::Reset();
@@ -719,7 +720,7 @@ int main(int argc, char* argv[])
window->setWindowTitle("Bullet 3.x GPU Rigid Body http://bulletphysics.org");
printf("-----------------------------------------------------\n");
#ifndef __APPLE__
@@ -732,7 +733,7 @@ int main(int argc, char* argv[])
GLPrimitiveRenderer prim(g_OpenGLWidth,g_OpenGLHeight);
stash = initFont(&prim);
@@ -782,7 +783,7 @@ int main(int argc, char* argv[])
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);//|GL_STENCIL_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
sth_begin_draw(stash);
//sth_draw_text(stash, droidRegular,12.f, dx, dy-50, "How does this OpenGL True Type font look? ", &dx,width,height);
int spacing = 0;//g_OpenGLHeight;
@@ -820,13 +821,13 @@ int main(int argc, char* argv[])
for (int i=0;i<nummsg;i++)
{
char txt[512];
sprintf(txt,msg[i]);
sprintf(txt,"%s",msg[i]);
//sth_draw_text(stash, droidRegular,i, 10, dy-spacing, txt, &dx,g_OpenGLWidth,g_OpenGLHeight);
sth_draw_text(stash, droidRegular,fontSize, 10, spacing, txt, &dx,g_OpenGLWidth,g_OpenGLHeight);
spacing+=fontSize;
fontSize = 32;
}
sth_end_draw(stash);
sth_flush_draw(stash);
window->endRendering();
@@ -852,7 +853,7 @@ int main(int argc, char* argv[])
// demo->myinit();
bool useGpu = false;
//int maxObjectCapacity=128*1024;
int maxObjectCapacity=1024*1024;
maxObjectCapacity = b3Max(maxObjectCapacity,ci.arraySizeX*ci.arraySizeX*ci.arraySizeX+10);
@@ -874,7 +875,7 @@ int main(int argc, char* argv[])
printf("-----------------------------------------------------\n");
@@ -883,14 +884,14 @@ int main(int argc, char* argv[])
if (benchmark)
{
char prefixFileName[1024];
char csvFileName[1024];
char detailsFileName[1024];
b3OpenCLDeviceInfo info;
b3OpenCLUtils::getDeviceInfo(demo->getInternalData()->m_clDevice,&info);
//todo: move this time stuff into the Platform/Window class
#ifdef _WIN32
SYSTEMTIME time;
@@ -906,11 +907,11 @@ int main(int argc, char* argv[])
}
sprintf(prefixFileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d",info.m_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond);
#else
timeval now;
gettimeofday(&now,0);
struct tm* ptm;
ptm = localtime (&now.tv_sec);
char buf[1024];
@@ -926,7 +927,7 @@ int main(int argc, char* argv[])
ptm->tm_hour,
ptm->tm_min,
ptm->tm_sec);
#endif
sprintf(csvFileName,"%s.csv",prefixFileName);
@@ -944,7 +945,7 @@ int main(int argc, char* argv[])
// fprintf(f,"%s (%dx%dx%d=%d),\n", g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,ci.arraySizeX*ci.arraySizeY*ci.arraySizeZ);
}
fprintf(defaultOutput,"Demo settings:\n");
fprintf(defaultOutput," SelectedDemo=%d, demoname = %s\n", selectedDemo, demo->getName());
fprintf(defaultOutput," x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
@@ -971,7 +972,7 @@ int main(int argc, char* argv[])
if (exportFrame || exportMovie)
{
if (!renderTexture)
{
renderTexture = new GLRenderToTexture();
@@ -993,10 +994,10 @@ int main(int argc, char* argv[])
renderTexture->init(g_OpenGLWidth,g_OpenGLHeight,renderTextureId, RENDERTEXTURE_COLOR);
}
bool result = renderTexture->enable();
}
}
err = glGetError();
assert(err==GL_NO_ERROR);
@@ -1052,10 +1053,10 @@ int main(int argc, char* argv[])
}
*/
if (exportFrame || exportMovie)
{
char fileName[1024];
sprintf(fileName,"screenShot%d.png",frameIndex++);
writeTextureToPng(g_OpenGLWidth,g_OpenGLHeight,fileName);
@@ -1085,7 +1086,7 @@ int main(int argc, char* argv[])
B3_PROFILE("glFinish");
}
if (dump_timings)
{
@@ -1147,7 +1148,7 @@ int main(int argc, char* argv[])
{
delete gui;
gui=0;

View File

@@ -27,7 +27,7 @@ extern bool enableExperimentalCpuConcaveCollision;
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
///work-in-progress
///work-in-progress
///This ReadBulletSample is kept as simple as possible without dependencies to the Bullet SDK.
///It can be used to load .bullet data for other physics SDKs
///For a more complete example how to load and convert Bullet data using the Bullet SDK check out
@@ -66,23 +66,23 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
//const char* fileName="../../bin/1000 convex.bullet";
//const char* fileName="../../bin/1000 stack.bullet";
//const char* fileName="../../bin/3000 fall.bullet";
//const char* fileName="../../bin/testFile.bullet";
FILE* f = fopen(fileName,"rb");
if (f)
{
fclose(f);
bool verboseDumpAllTypes = false;
bParse::b3BulletFile* bulletFile2 = new bParse::b3BulletFile(fileName);
bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
if (ok)
bulletFile2->parse(verboseDumpAllTypes);
else
@@ -99,7 +99,7 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
printf("Error parsing file %s.\n",fileName);
exit(0);
}
if (verboseDumpAllTypes)
{
bulletFile2->dumpChunks(bulletFile2->getFileDNA());
@@ -107,7 +107,7 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
b3BulletDataExtractor extractor(renderer,np,rbWorld);
extractor.convertAllObjects(bulletFile2);
delete bulletFile2;
return;
@@ -163,7 +163,7 @@ CONCAVE_SHAPES_START_HERE,
GIMPACT_SHAPE_PROXYTYPE,
///Multimaterial mesh
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
EMPTY_SHAPE_PROXYTYPE,
STATIC_PLANE_PROXYTYPE,
CUSTOM_CONCAVE_SHAPE_TYPE,
@@ -177,7 +177,7 @@ CONCAVE_SHAPES_END_HERE,
INVALID_SHAPE_PROXYTYPE,
MAX_BROADPHASE_COLLISION_TYPES
};
b3BulletDataExtractor::b3BulletDataExtractor(GLInstancingRenderer& renderer, b3GpuNarrowPhase& np, b3GpuRigidBodyPipeline& rbWorld)
@@ -214,7 +214,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
{
Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
Bullet3SerializeBullet2::b3CollisionShapeData* shapeData = (Bullet3SerializeBullet2::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape;
for (int j=0;j<m_instanceGroups.size();j++)
@@ -237,7 +237,7 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
for (int j=0;j<m_instanceGroups[i]->m_rigidBodies.size();j++)
{
Bullet3SerializeBullet2::b3RigidBodyFloatData* colObjData = (Bullet3SerializeBullet2::b3RigidBodyFloatData*)m_instanceGroups[i]->m_rigidBodies[j];
b3Matrix3x3 mat;
mat.deSerializeFloat((const b3Matrix3x3FloatData&)colObjData->m_collisionObjectData.m_worldTransform.m_basis);
b3Quaternion orn;
@@ -259,23 +259,23 @@ void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
}
if (keepStaticObjects || colObjData->m_inverseMass!=0.f)
{
m_rbPipeline.registerPhysicsInstance(mass,pos,quaternion,m_instanceGroups[i]->m_collisionShapeIndex,0,true);
m_renderer.registerGraphicsInstance(m_instanceGroups[i]->m_collisionShapeIndex,pos,quaternion,color,m_graphicsShapes[i]->m_scaling);
}
}
}
}
for (i=0;i<bulletFile2->m_collisionObjects.size();i++)
{
}
m_rbPipeline.writeAllInstancesToGpu();
}
@@ -303,7 +303,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
case CONVEX_HULL_SHAPE_PROXYTYPE:
{
Bullet3SerializeBullet2::b3ConvexInternalShapeData* bsd = (Bullet3SerializeBullet2::b3ConvexInternalShapeData*)shapeData;
switch (shapeData->m_shapeType)
{
case BOX_SHAPE_PROXYTYPE:
@@ -331,7 +331,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
b3Vector3 pt = b3MakeVector3(convexData->m_unscaledPointsFloatPtr[i].m_floats[0],
convexData->m_unscaledPointsFloatPtr[i].m_floats[1],
convexData->m_unscaledPointsFloatPtr[i].m_floats[2]);//convexData->m_unscaledPointsFloatPtr[i].m_floats[3]);
tmpPoints.push_back(pt*localScaling);
}
}
@@ -378,7 +378,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
}
};
break;
}
case CYLINDER_SHAPE_PROXYTYPE:
@@ -408,9 +408,9 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
}
};
break;
}
case MULTI_SPHERE_SHAPE_PROXYTYPE:
@@ -426,7 +426,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
shape = new b3MultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
break;
}
#endif
default:
@@ -453,13 +453,13 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
//dat.
}
///trimesh->m_meshInterface.m_meshPartsPtr
//trimesh->m_meshInterface.m_scaling
}
//trimesh->m_meshInterface
//b3TriangleIndexVertexArray* meshInterface = createMeshInterface(trimesh->m_meshInterface);
//scaling
//b3Vector3 scaling; scaling.deSerializeFloat(trimesh->m_meshInterface.m_scaling);
@@ -489,7 +489,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
{
printf("error: couldn't create childShape for compoundShape\n");
}
}
shape = compoundShape;
@@ -519,7 +519,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
{
return 0;
}
#endif
#endif
default:
{
printf("unsupported shape type (%d)\n",shapeData->m_shapeType);
@@ -527,7 +527,7 @@ int b3BulletDataExtractor::convertCollisionShape( Bullet3SerializeBullet2::b3Co
}
return shapeIndex;
}
int b3BulletDataExtractor::createBoxShape( const Bullet3SerializeBullet2::b3Vector3FloatData& halfDimensions, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling, float collisionMargin)
@@ -544,7 +544,7 @@ int b3BulletDataExtractor::createBoxShape( const Bullet3SerializeBullet2::b3Vect
{
int numVertices = sizeof(cube_vertices)/strideInBytes;
int numIndices = sizeof(cube_indices)/sizeof(int);
GraphicsShape* gfxShape = new GraphicsShape;
gfxShape->m_vertices = cube_vertices;
gfxShape->m_numvertices = numVertices;
@@ -569,7 +569,7 @@ int b3BulletDataExtractor::createSphereShape( float radius, const Bullet3Seriali
int b3BulletDataExtractor::createPlaneShape( const Bullet3SerializeBullet2::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet3SerializeBullet2::b3Vector3FloatData& localScaling)
{
printf("createPlaneShape with normal %f,%f,%f and planeConstant\n",planeNormal.m_floats[0], planeNormal.m_floats[1],planeNormal.m_floats[2],planeConstant);
printf("createPlaneShape with normal %f,%f,%f and planeConstant %f\n",planeNormal.m_floats[0], planeNormal.m_floats[1],planeNormal.m_floats[2],planeConstant);
return -1;
}
@@ -582,7 +582,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
b3ConvexUtility* utilPtr = new b3ConvexUtility();
bool merge = true;
utilPtr->initializePolyhedralFeatures(tmpPoints,numPoints,merge);
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
{
int numVertices = utilPtr->m_vertices.size();
@@ -594,7 +594,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
b3Vector3 normal=b3MakeVector3(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
if (face.m_indices.size()>2)
{
GraphicsVertex vtx;
const b3Vector3& orgVertex = utilPtr->m_vertices[face.m_indices[0]];
vtx.xyzw[0] = orgVertex[0];vtx.xyzw[1] = orgVertex[1];vtx.xyzw[2] = orgVertex[2];vtx.xyzw[3] = 0.f;
@@ -602,7 +602,7 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
vtx.uv[0] = 0.5f;vtx.uv[1] = 0.5f;
int newvtxindex0 = vertices->size();
vertices->push_back(vtx);
for (int j=1;j<face.m_indices.size()-1;j++)
{
indicesPtr->push_back(newvtxindex0);
@@ -630,15 +630,15 @@ GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
}
}
}
GraphicsShape* gfxShape = new GraphicsShape;
gfxShape->m_vertices = &vertices->at(0).xyzw[0];
gfxShape->m_numvertices = vertices->size();
gfxShape->m_indices = &indicesPtr->at(0);
gfxShape->m_numIndices = indicesPtr->size();
for (int i=0;i<4;i++)
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
return gfxShape;
}
}
}

View File

@@ -27,13 +27,13 @@
GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj::shape_t>& shapes)
{
b3AlignedObjectArray<GLInstanceVertex>* vertices = new b3AlignedObjectArray<GLInstanceVertex>;
{
// int numVertices = obj->vertexCount;
// int numIndices = 0;
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
for (int s=0;s<shapes.size();s++)
{
tinyobj::shape_t& shape = shapes[s];
@@ -42,18 +42,18 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
for (int f=0;f<faceCount;f+=3)
{
//b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
if (1)
{
b3Vector3 normal=b3MakeVector3(0,1,0);
int vtxBaseIndex = vertices->size();
indicesPtr->push_back(vtxBaseIndex);
indicesPtr->push_back(vtxBaseIndex+1);
indicesPtr->push_back(vtxBaseIndex+2);
GLInstanceVertex vtx0;
vtx0.xyzw[0] = shape.mesh.positions[shape.mesh.indices[f]*3+0];
vtx0.xyzw[1] = shape.mesh.positions[shape.mesh.indices[f]*3+1];
@@ -101,15 +101,15 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
}
}
}
GLInstanceGraphicsShape* gfxShape = new GLInstanceGraphicsShape;
gfxShape->m_vertices = vertices;
gfxShape->m_numvertices = vertices->size();
gfxShape->m_indices = indicesPtr;
gfxShape->m_numIndices = indicesPtr->size();
for (int i=0;i<4;i++)
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
return gfxShape;
}
}
@@ -117,15 +117,15 @@ GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj
void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fileName, const b3Vector3& shift, const b3Vector3& scaling)
{
char relativeFileName[1024];
const char* prefix[]={"./data/","../data/","../../data/","../../../data/","../../../../data/"};
int prefixIndex=-1;
{
int numPrefixes = sizeof(prefix)/sizeof(char*);
for (int i=0;i<numPrefixes;i++)
@@ -145,7 +145,7 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
if (prefixIndex<0)
return;
int index=10;
{
@@ -154,7 +154,7 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
std::string err = tinyobj::LoadObj(shapes, relativeFileName, prefix[prefixIndex]);
GLInstanceGraphicsShape* shape = createGraphicsShapeFromWavefrontObj(shapes);
b3AlignedObjectArray<b3Vector3> verts;
for (int i=0;i<shape->m_numvertices;i++)
@@ -167,9 +167,9 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
shape->m_vertices->at(i).xyzw[2]);
verts.push_back(vtx*scaling);
}
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,b3MakeVector3(1,1,1));
{
int strideInBytes = 9*sizeof(float);
int numVertices = sizeof(cube_vertices)/strideInBytes;
@@ -180,10 +180,10 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
int shapeId = ci.m_instancingRenderer->registerShape(&shape->m_vertices->at(0).xyzw[0], shape->m_numvertices, &shape->m_indices->at(0), shape->m_numIndices);
b3Quaternion orn(0,0,0,1);
b3Vector4 color=b3MakeVector4(0.3,0.3,1,1.f);//0.5);//1.f
{
float mass = 0.f;
b3Vector3 position=b3MakeVector3(0,0,0);
@@ -200,8 +200,8 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
}
}
}
@@ -218,11 +218,11 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
//char* fileName = "teddy.obj";//"plane.obj";
// char* fileName = "sponza_closed.obj";//"plane.obj";
//char* fileName = "leoTest1.obj";
char* fileName = "samurai_monastry.obj";
const char* fileName = "samurai_monastry.obj";
// char* fileName = "teddy2_VHACD_CHs.obj";
b3Vector3 shift1=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
b3Vector4 scaling=b3MakeVector4(10,10,10,1);
// createConcaveMesh(ci,"plane100.obj",shift1,scaling);
@@ -233,8 +233,8 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
// b3Vector3 shift3(130,-150,-75);//0,230,80);//150,-100,-120);
// createConcaveMesh(ci,"leoTest1.obj",shift3,scaling);
createConcaveMesh(ci,fileName,shift1,scaling);
createConcaveMesh(ci,fileName,shift1,scaling);
} else
{
@@ -250,17 +250,17 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
b3Vector3 position=b3MakeVector3(0,-2,0);
b3Quaternion orn(0,0,0,1);
b3Vector4 color=b3MakeVector4(0,0,1,1);
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
}
}
createDynamicObjects(ci);
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
float camPos[4]={0,0,0,0};//65.5,4.5,65.5,0};
@@ -285,15 +285,15 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
int group=1;
int mask=1;
int index=0;
if (1)
{
int curColor = 0;
b3Vector4 colors[4] =
b3Vector4 colors[4] =
{
b3MakeVector4(1,1,1,1),
b3MakeVector4(1,1,0.3,1),
@@ -345,14 +345,14 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
23+j*CONCAVE_GAPY,
-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ);
b3Quaternion orn(0,0,0,1);
b3Vector4 color = colors[curColor];
curColor++;
curColor&=3;
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
index++;
}
}
@@ -377,10 +377,10 @@ void ConcaveCompoundScene::setupScene(const ConstructionInfo& ci)
void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
{
char* fileName = "teddy2_VHACD_CHs.obj";
const char* fileName = "teddy2_VHACD_CHs.obj";
//char* fileName = "cube_offset.obj";
b3Vector3 shift=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
const char* prefix[]={"./data/","../data/","../../data/","../../../data/","../../../../data/"};
@@ -388,12 +388,12 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
char relativeFileName[1024];
{
int numPrefixes = sizeof(prefix)/sizeof(char*);
for (int i=0;i<numPrefixes;i++)
{
sprintf(relativeFileName,"%s%s",prefix[i],fileName);
FILE* f = 0;
f = fopen(relativeFileName,"r");
@@ -422,7 +422,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
b3AlignedObjectArray<int> indexArray;
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
@@ -436,8 +436,8 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
b3Assert(stride2 == strideInBytes);
{
b3AlignedObjectArray<b3GpuChildShape> childShapes;
int numChildShapes = shapes.size();
@@ -455,7 +455,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
//for now, only support polyhedral child shapes
b3GpuChildShape child;
b3Vector3 pos=b3MakeVector3(0,0,0);
b3Quaternion orn(0,0,0,1);
for (int v=0;v<4;v++)
@@ -463,21 +463,21 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
child.m_childPosition[v] = pos[v];
child.m_childOrientation[v] = orn[v];
}
b3Transform tr;
tr.setIdentity();
tr.setOrigin(pos);
tr.setRotation(orn);
int baseIndex = vertexArray.size();
for (int f=0;f<numFaces;f++)
{
for (int i=0;i<3;i++)
{
indexArray.push_back(baseIndex+shape.mesh.indices[f*3+i]);
}
}
b3Vector3 center=b3MakeVector3(0,0,0);
@@ -488,8 +488,8 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
for (int v=0;v<numVertices;v++)
{
GLInstanceVertex vert;
vert.uv[0] = 0.5f;
vert.uv[1] = 0.5f;
@@ -540,20 +540,20 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
colIndex = childColIndex;
}
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
}
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
b3Vector4 colors[4] =
b3Vector4 colors[4] =
{
b3MakeVector4(1,0,0,1),
b3MakeVector4(0,1,0,1),
b3MakeVector4(0,0,1,1),
b3MakeVector4(0,1,1,1),
};
int curColor = 0;
for (int i=0;i<1;i++)//ci.arraySizeX;i++)
{
@@ -569,14 +569,14 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
// b3Quaternion orn(0,0,0,1);
b3Quaternion orn(b3MakeVector3(0,0,1),1.8);
b3Vector4 color = colors[curColor];
curColor++;
curColor&=3;
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
index++;
}
}
@@ -588,14 +588,14 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
{
int strideInBytes = 9*sizeof(float);
int numVertices = sizeof(cube_vertices)/strideInBytes;
int numIndices = sizeof(cube_indices)/sizeof(int);
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
b3AlignedObjectArray<int> indexArray;
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
int group=1;
@@ -610,14 +610,14 @@ void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
{
int childColIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
b3Vector3 childPositions[3] = {
b3MakeVector3(0,-2,0),
b3MakeVector3(0,0,0),
b3MakeVector3(0,0,2)
};
b3AlignedObjectArray<b3GpuChildShape> childShapes;
int numChildShapes = 3;
for (int i=0;i<numChildShapes;i++)
@@ -657,20 +657,20 @@ b3Vector3 childPositions[3] = {
}
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
}
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
b3Vector4 colors[4] =
b3Vector4 colors[4] =
{
b3MakeVector4(1,0,0,1),
b3MakeVector4(0,1,0,1),
b3MakeVector4(0,0,1,1),
b3MakeVector4(0,1,1,1),
};
int curColor = 0;
for (int i=0;i<ci.arraySizeX;i++)
{
@@ -684,14 +684,14 @@ b3Vector3 childPositions[3] = {
b3Vector3 position=b3MakeVector3((-ci.arraySizeX/2+i)*ci.gapX,50+j*ci.gapY,(-ci.arraySizeZ/2+k)*ci.gapZ);
//b3Quaternion orn(0,0,0,1);
b3Quaternion orn(b3MakeVector3(1,0,0),0.7);
b3Vector4 color = colors[curColor];
curColor++;
curColor&=3;
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
index++;
}
}
@@ -714,7 +714,7 @@ void ConcaveSphereScene::setupScene(const ConstructionInfo& ci)
void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
{
b3Vector4 colors[4] =
b3Vector4 colors[4] =
{
b3MakeVector4(1,0,0,1),
b3MakeVector4(0,1,0,1),
@@ -737,20 +737,20 @@ void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
{
float mass = 1.f;
b3Vector3 position=b3MakeVector3(-(ci.arraySizeX/2)*8+i*8,50+j*8,-(ci.arraySizeZ/2)*8+k*8);
//b3Vector3 position(0,-41,0);//0,0,0);//i*radius*3,-41+j*radius*3,k*radius*3);
b3Quaternion orn(0,0,0,1);
b3Vector4 color = colors[curColor];
curColor++;
curColor&=3;
b3Vector4 scaling=b3MakeVector4(radius,radius,radius,1);
int id = ci.m_instancingRenderer->registerGraphicsInstance(prevGraphicsShapeIndex,position,orn,color,scaling);
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
index++;
}
}