remove some warnings
This commit is contained in:
@@ -124,7 +124,8 @@ static int loadCurrentDemoEntry(const char* startFileName)
|
||||
FILE* f = fopen(startFileName,"r");
|
||||
if (f)
|
||||
{
|
||||
fscanf(f,"%d",¤tEntry);
|
||||
int result;
|
||||
result = fscanf(f,"%d",¤tEntry);
|
||||
fclose(f);
|
||||
}
|
||||
return currentEntry;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,8 @@ static int loadCurrentDemoEntry(const char* startFileName)
|
||||
FILE* f = fopen(startFileName,"r");
|
||||
if (f)
|
||||
{
|
||||
fscanf(f,"%d",¤tEntry);
|
||||
int bytesScanned;
|
||||
bytesScanned = fscanf(f,"%d",¤tEntry);
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,25 +142,25 @@ void URDFvisual2BulletCollisionShape(my_shared_ptr<const Link> link, GraphicsPhy
|
||||
{
|
||||
printf("processing a cylinder\n");
|
||||
urdf::Cylinder* cyl = (urdf::Cylinder*)visual->geometry.get();
|
||||
|
||||
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
//int numVerts = sizeof(barrel_vertices)/(9*sizeof(float));
|
||||
int numSteps = 32;
|
||||
for (int i=0;i<numSteps;i++)
|
||||
{
|
||||
|
||||
|
||||
btVector3 vert(cyl->radius*btSin(SIMD_2_PI*(float(i)/numSteps)),cyl->radius*btCos(SIMD_2_PI*(float(i)/numSteps)),cyl->length/2.);
|
||||
vertices.push_back(vert);
|
||||
vert[2] = -cyl->length/2.;
|
||||
vertices.push_back(vert);
|
||||
|
||||
|
||||
}
|
||||
btConvexHullShape* cylZShape = new btConvexHullShape(&vertices[0].x(), vertices.size(), sizeof(btVector3));
|
||||
cylZShape->initializePolyhedralFeatures();
|
||||
//btVector3 halfExtents(cyl->radius,cyl->radius,cyl->length/2.);
|
||||
//btCylinderShapeZ* cylZShape = new btCylinderShapeZ(halfExtents);
|
||||
cylZShape->setMargin(0.001);
|
||||
|
||||
|
||||
shape = cylZShape;
|
||||
break;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void URDFvisual2BulletCollisionShape(my_shared_ptr<const Link> link, GraphicsPhy
|
||||
|
||||
|
||||
btRigidBody* body = new btRigidBody(rbci);
|
||||
|
||||
|
||||
world->addRigidBody(body,bodyCollisionFilterGroup,bodyCollisionFilterMask);
|
||||
// body->setFriction(0);
|
||||
|
||||
@@ -359,13 +359,13 @@ void ImportUrdfDemo::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
);//+btIDebugDraw::DBG_DrawConstraintLimits);
|
||||
|
||||
|
||||
|
||||
|
||||
btVector3 gravity(0,0,0);
|
||||
gravity[upAxis]=-9.8;
|
||||
|
||||
m_dynamicsWorld->setGravity(gravity);
|
||||
int argc=0;
|
||||
char* filename="somefile.urdf";
|
||||
const char* filename="somefile.urdf";
|
||||
|
||||
std::string xml_string;
|
||||
|
||||
@@ -418,7 +418,7 @@ void ImportUrdfDemo::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
groundHalfExtents[upAxis]=1.f;
|
||||
btBoxShape* box = new btBoxShape(groundHalfExtents);
|
||||
box->initializePolyhedralFeatures();
|
||||
|
||||
|
||||
gfxBridge.createCollisionShapeGraphicsObject(box);
|
||||
btTransform start; start.setIdentity();
|
||||
btVector3 groundOrigin(0,0,0);
|
||||
@@ -428,6 +428,6 @@ void ImportUrdfDemo::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
btVector3 color(0.5,0.5,0.5);
|
||||
gfxBridge.createRigidBodyGraphicsObject(body,color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
|
||||
char* sLuaFileName = "init_physics.lua";
|
||||
const char* sLuaFileName = "init_physics.lua";
|
||||
|
||||
static const float scaling=0.35f;
|
||||
static LuaPhysicsSetup* sLuaDemo = 0;
|
||||
|
||||
@@ -145,7 +145,7 @@ struct sth_stash* sth_create(int cachew, int cacheh, RenderCallbacks* renderCall
|
||||
memset(stash,0,sizeof(struct sth_stash));
|
||||
|
||||
stash->m_renderCallbacks = renderCallbacks;
|
||||
|
||||
|
||||
// Allocate memory for the first texture
|
||||
texture = (struct sth_texture*)malloc(sizeof(struct sth_texture));
|
||||
if (texture == NULL)
|
||||
@@ -161,11 +161,11 @@ struct sth_stash* sth_create(int cachew, int cacheh, RenderCallbacks* renderCall
|
||||
stash->itw = 1.0f/cachew;
|
||||
stash->ith = 1.0f/cacheh;
|
||||
stash->textures = texture;
|
||||
|
||||
stash->m_renderCallbacks->updateTexture(texture, 0, stash->tw, stash->th);
|
||||
|
||||
|
||||
stash->m_renderCallbacks->updateTexture(texture, 0, stash->tw, stash->th);
|
||||
|
||||
return stash;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
@@ -177,7 +177,7 @@ int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
if (fnt == NULL) goto error;
|
||||
memset(fnt,0,sizeof(struct sth_font));
|
||||
|
||||
|
||||
|
||||
// Init hash lookup.
|
||||
for (i = 0; i < HASH_LUT_SIZE; ++i)
|
||||
fnt->lut[i] = -1;
|
||||
@@ -187,8 +187,8 @@ int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
// Init stb_truetype
|
||||
if (!stbtt_InitFont(&fnt->font, fnt->data, 0))
|
||||
goto error;
|
||||
|
||||
|
||||
|
||||
|
||||
// Store normalized line height. The real line height is got
|
||||
// by multiplying the lineh by font size.
|
||||
stbtt_GetFontVMetrics(&fnt->font, &ascent, &descent, &lineGap);
|
||||
@@ -203,7 +203,7 @@ int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer)
|
||||
fnt->next = stash->fonts;
|
||||
stash->fonts = fnt;
|
||||
|
||||
|
||||
|
||||
return idx++;
|
||||
|
||||
error:
|
||||
@@ -220,7 +220,7 @@ int sth_add_font(struct sth_stash* stash, const char* path)
|
||||
int datasize;
|
||||
unsigned char* data = NULL;
|
||||
int idx;
|
||||
|
||||
|
||||
// Read in the font data.
|
||||
fp = fopen(path, "rb");
|
||||
if (!fp) goto error;
|
||||
@@ -229,10 +229,11 @@ int sth_add_font(struct sth_stash* stash, const char* path)
|
||||
fseek(fp,0,SEEK_SET);
|
||||
data = (unsigned char*)malloc(datasize);
|
||||
if (data == NULL) goto error;
|
||||
fread(data, 1, datasize, fp);
|
||||
int bytesRead;
|
||||
bytesRead = fread(data, 1, datasize, fp);
|
||||
fclose(fp);
|
||||
fp = 0;
|
||||
|
||||
|
||||
idx = sth_add_font_from_memory(stash, data);
|
||||
// Modify type of the loaded font.
|
||||
if (idx)
|
||||
@@ -241,7 +242,7 @@ int sth_add_font(struct sth_stash* stash, const char* path)
|
||||
free(data);
|
||||
|
||||
return idx;
|
||||
|
||||
|
||||
error:
|
||||
if (data) free(data);
|
||||
if (fp) fclose(fp);
|
||||
@@ -271,7 +272,7 @@ int sth_add_bitmap_font(struct sth_stash* stash, int ascent, int descent, int li
|
||||
fnt->type = BMFONT;
|
||||
fnt->next = stash->fonts;
|
||||
stash->fonts = fnt;
|
||||
|
||||
|
||||
return idx++;
|
||||
|
||||
error:
|
||||
@@ -295,7 +296,7 @@ error:
|
||||
|
||||
if (stash == NULL) return;
|
||||
texture = stash->textures;
|
||||
while (texture != NULL && texture->id != id)
|
||||
while (texture != NULL && texture->id != id)
|
||||
texture = texture->next;
|
||||
|
||||
if (texture == NULL)
|
||||
@@ -313,7 +314,7 @@ error:
|
||||
while (fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT) return;
|
||||
|
||||
|
||||
for (; *s; ++s)
|
||||
{
|
||||
if (!decutf8(&state, &codepoint, *(unsigned char*)s)) break;
|
||||
@@ -338,7 +339,7 @@ error:
|
||||
glyph->xoff = xoffset;
|
||||
glyph->yoff = yoffset - base;
|
||||
glyph->xadv = xadvance;
|
||||
|
||||
|
||||
// Find code point and size.
|
||||
h = hashint(codepoint) & (HASH_LUT_SIZE-1);
|
||||
// Insert char to hash lookup.
|
||||
@@ -353,7 +354,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
float scale;
|
||||
struct sth_texture* texture = NULL;
|
||||
struct sth_glyph* glyph = NULL;
|
||||
|
||||
|
||||
unsigned int h;
|
||||
float size = isize/10.0f;
|
||||
int rh;
|
||||
@@ -369,10 +370,10 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
i = fnt->glyphs[i].next;
|
||||
}
|
||||
// Could not find glyph.
|
||||
|
||||
|
||||
// For bitmap fonts: ignore this glyph.
|
||||
if (fnt->type == BMFONT) return 0;
|
||||
|
||||
|
||||
// For truetype fonts: create this glyph.
|
||||
scale = stbtt_ScaleForPixelHeight(&fnt->font, size);
|
||||
g = stbtt_FindGlyphIndex(&fnt->font, codepoint);
|
||||
@@ -380,7 +381,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
stbtt_GetGlyphBitmapBox(&fnt->font, g, scale,scale, &x0,&y0,&x1,&y1);
|
||||
gw = x1-x0;
|
||||
gh = y1-y0;
|
||||
|
||||
|
||||
// Check if glyph is larger than maximum texture size
|
||||
if (gw >= stash->tw || gh >= stash->th)
|
||||
return 0;
|
||||
@@ -396,7 +397,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
if (texture->rows[i].h >= rh && texture->rows[i].x+gw+1 <= stash->tw)
|
||||
br = &texture->rows[i];
|
||||
}
|
||||
|
||||
|
||||
// If no row is found, there are 3 possibilities:
|
||||
// - add new row
|
||||
// - try next texture
|
||||
@@ -421,10 +422,10 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
texture = texture->next;
|
||||
if (texture == NULL) goto error;
|
||||
memset(texture,0,sizeof(struct sth_texture));
|
||||
|
||||
|
||||
stash->m_renderCallbacks->updateTexture(texture,0,stash->tw,stash->th);
|
||||
|
||||
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -434,10 +435,10 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
br->x = BORDER_X_LEFT;
|
||||
br->y = py+BORDER_Y_BOTTOM;
|
||||
br->h = rh+ADDITIONAL_HEIGHT;
|
||||
texture->nrows++;
|
||||
texture->nrows++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Alloc space for new glyph.
|
||||
fnt->nglyphs++;
|
||||
fnt->glyphs = (sth_glyph*)realloc(fnt->glyphs, fnt->nglyphs*sizeof(struct sth_glyph));
|
||||
@@ -473,7 +474,7 @@ static struct sth_glyph* get_glyph(struct sth_stash* stash, struct sth_font* fnt
|
||||
stash->m_renderCallbacks->updateTexture(texture,glyph, stash->tw, stash->th);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return glyph;
|
||||
|
||||
error:
|
||||
@@ -486,26 +487,26 @@ static int get_quad(struct sth_stash* stash, struct sth_font* fnt, struct sth_gl
|
||||
{
|
||||
float rx,ry;
|
||||
float scale = 1.f/s_retinaScale;//1.0f;
|
||||
|
||||
|
||||
if (fnt->type == BMFONT)
|
||||
scale = isize/(glyph->size*10.0f);
|
||||
|
||||
rx = (*x + scale * float(glyph->xoff));
|
||||
ry = (*y + scale * float(glyph->yoff));
|
||||
|
||||
|
||||
q->x0 = rx;
|
||||
q->y0 = ry + 1.5f*0.5f*float(isize)/10.f;
|
||||
|
||||
q->x1 = rx + scale * float(glyph->x1 - glyph->x0_);
|
||||
q->y1 = ry + scale * float(glyph->y1 - glyph->y0)+ 1.5f*0.5f*float(isize)/10.f;
|
||||
|
||||
|
||||
q->s0 = float(glyph->x0_) * stash->itw;
|
||||
q->t0 = float(glyph->y0) * stash->ith;
|
||||
q->s1 = float(glyph->x1) * stash->itw;
|
||||
q->t1 = float(glyph->y1) * stash->ith;
|
||||
|
||||
|
||||
*x += scale * glyph->xadv;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -523,7 +524,7 @@ static Vertex* setv(Vertex* v, float x, float y, float s, float t, float width,
|
||||
}
|
||||
v->position.p[2] = 0.f;
|
||||
v->position.p[3] = 1.f;
|
||||
|
||||
|
||||
v->uv.p[0] = s;
|
||||
v->uv.p[1] = t;
|
||||
|
||||
@@ -531,7 +532,7 @@ static Vertex* setv(Vertex* v, float x, float y, float s, float t, float width,
|
||||
v->colour.p[1] = 0.1f;
|
||||
v->colour.p[2] = 0.1f;
|
||||
v->colour.p[3] = 1.f;
|
||||
|
||||
|
||||
return v+1;
|
||||
}
|
||||
|
||||
@@ -545,7 +546,7 @@ static void flush_draw(struct sth_stash* stash)
|
||||
{
|
||||
if (texture->nverts > 0)
|
||||
{
|
||||
stash->m_renderCallbacks->render(texture);
|
||||
stash->m_renderCallbacks->render(texture);
|
||||
texture->nverts = 0;
|
||||
}
|
||||
texture = texture->next;
|
||||
@@ -584,7 +585,7 @@ void sth_end_draw(struct sth_stash* stash)
|
||||
stash->nverts += 6;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
flush_draw(stash);
|
||||
stash->drawing = 0;
|
||||
}
|
||||
@@ -606,7 +607,7 @@ void sth_draw_texture(struct sth_stash* stash,
|
||||
short isize = (short)(size*10.0f);
|
||||
Vertex* v;
|
||||
struct sth_font* fnt = NULL;
|
||||
|
||||
|
||||
if (stash == NULL) return;
|
||||
|
||||
if (!stash->textures) return;
|
||||
@@ -614,23 +615,23 @@ void sth_draw_texture(struct sth_stash* stash,
|
||||
while(fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT && !fnt->data) return;
|
||||
|
||||
|
||||
int once = true;
|
||||
for (; once; ++s)
|
||||
{
|
||||
once=false;
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
continue;
|
||||
glyph = get_glyph(stash, fnt, codepoint, isize);
|
||||
if (!glyph)
|
||||
if (!glyph)
|
||||
continue;
|
||||
texture = glyph->texture;
|
||||
if (texture->nverts+6 >= VERT_COUNT)
|
||||
flush_draw(stash);
|
||||
|
||||
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q))
|
||||
|
||||
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q))
|
||||
continue;
|
||||
|
||||
|
||||
v = &texture->newverts[texture->nverts];
|
||||
q.x0 = 0;
|
||||
q.y0 = 0;
|
||||
@@ -646,11 +647,11 @@ void sth_draw_texture(struct sth_stash* stash,
|
||||
v = setv(v, q.x0, q.y1, 0,1,(float)screenwidth,(float)screenheight);
|
||||
texture->nverts += 6;
|
||||
}
|
||||
|
||||
|
||||
flush_draw(stash);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (dx) *dx = x;
|
||||
}
|
||||
@@ -664,7 +665,7 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
float x, float y,
|
||||
const char* s, float* dx, int screenwidth, int screenheight, int measureOnly, float retinaScale)
|
||||
{
|
||||
|
||||
|
||||
unsigned int codepoint;
|
||||
struct sth_glyph* glyph = NULL;
|
||||
struct sth_texture* texture = NULL;
|
||||
@@ -673,7 +674,7 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
short isize = (short)(size*10.0f);
|
||||
Vertex* v;
|
||||
struct sth_font* fnt = NULL;
|
||||
|
||||
|
||||
s_retinaScale = retinaScale;
|
||||
if (stash == NULL) return;
|
||||
|
||||
@@ -682,23 +683,23 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
while(fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT && !fnt->data) return;
|
||||
|
||||
|
||||
for (; *s; ++s)
|
||||
{
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
if (decutf8(&state, &codepoint, *(unsigned char*)s))
|
||||
continue;
|
||||
glyph = get_glyph(stash, fnt, codepoint, isize);
|
||||
if (!glyph) continue;
|
||||
texture = glyph->texture;
|
||||
|
||||
|
||||
if (!measureOnly)
|
||||
{
|
||||
if (texture->nverts+6 >= VERT_COUNT)
|
||||
flush_draw(stash);
|
||||
}
|
||||
|
||||
|
||||
if (!get_quad(stash, fnt, glyph, isize, &x, &y, &q)) continue;
|
||||
|
||||
|
||||
if (!measureOnly)
|
||||
{
|
||||
v = &texture->newverts[texture->nverts];
|
||||
@@ -714,7 +715,7 @@ void sth_draw_text(struct sth_stash* stash,
|
||||
texture->nverts += 6;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (dx) *dx = x;
|
||||
}
|
||||
|
||||
@@ -730,16 +731,16 @@ void sth_dim_text(struct sth_stash* stash,
|
||||
short isize = (short)(size*10.0f);
|
||||
struct sth_font* fnt = NULL;
|
||||
float x = 0, y = 0;
|
||||
|
||||
if (stash == NULL)
|
||||
|
||||
if (stash == NULL)
|
||||
return;
|
||||
if (!stash->textures)
|
||||
if (!stash->textures)
|
||||
return;
|
||||
fnt = stash->fonts;
|
||||
while(fnt != NULL && fnt->idx != idx) fnt = fnt->next;
|
||||
if (fnt == NULL) return;
|
||||
if (fnt->type != BMFONT && !fnt->data) return;
|
||||
|
||||
|
||||
*minx = *maxx = x;
|
||||
*miny = *maxy = y;
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ typedef Status (*PFNXGETWINDOWATTRIBUTES) (Display* a,Window b,XWindowAttributes
|
||||
#define X11_LIBRARY "libX11.so.6"
|
||||
|
||||
#define MyXSync m_data->m_x11_XSync
|
||||
#define MyXGetKeyboardMapping m_data->m_x11_XGetKeyboardMapping
|
||||
#define MyXSetErrorHandler m_data->m_x11_XSetErrorHandler
|
||||
#define MyXOpenDisplay m_data->m_x11_XOpenDisplay
|
||||
#define MyXCreateColormap m_data->m_x11_XCreateColormap
|
||||
@@ -87,6 +88,7 @@ typedef Status (*PFNXGETWINDOWATTRIBUTES) (Display* a,Window b,XWindowAttributes
|
||||
|
||||
#else
|
||||
#define MyXSync XSync
|
||||
#define MyXGetKeyboardMapping XGetKeyboardMapping
|
||||
#define MyXSetErrorHandler XSetErrorHandler
|
||||
#define MyXOpenDisplay XOpenDisplay
|
||||
#define MyXCreateColormap XCreateColormap
|
||||
@@ -612,9 +614,21 @@ void X11OpenGLWindow::closeWindow()
|
||||
|
||||
int X11OpenGLWindow::getAsciiCodeFromVirtualKeycode(int keycode)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
KeySym key, key_lc, key_uc;
|
||||
|
||||
key = MyXKeycodeToKeysym( m_data->m_dpy, keycode, 0 );
|
||||
int keysyms_per_keycode_return;
|
||||
KeySym *keysym = MyXGetKeyboardMapping(m_data->m_dpy,
|
||||
keycode,
|
||||
1,
|
||||
&keysyms_per_keycode_return);
|
||||
|
||||
key = keysym[0];
|
||||
|
||||
|
||||
//key = MyXKeycodeToKeysym( m_data->m_dpy, keycode, 0 );
|
||||
|
||||
switch( key )
|
||||
{
|
||||
case XK_Escape: return B3G_ESCAPE;
|
||||
@@ -660,9 +674,12 @@ int X11OpenGLWindow::getAsciiCodeFromVirtualKeycode(int keycode)
|
||||
{
|
||||
return (int) key;
|
||||
}
|
||||
return -1;
|
||||
result = -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
MyXFree(keysym);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::pumpMessage()
|
||||
|
||||
@@ -5,8 +5,14 @@
|
||||
--flags {}
|
||||
|
||||
|
||||
|
||||
defines { "LUA_COMPAT_ALL"}
|
||||
|
||||
if os.is("Linux") then
|
||||
defines {"LUA_USE_LINUX"}
|
||||
end
|
||||
if os.is("MacOSX") then
|
||||
defines {"LUA_USE_MACOSX"}
|
||||
end
|
||||
|
||||
targetdir "../../lib"
|
||||
includedirs {
|
||||
@@ -18,4 +24,4 @@
|
||||
}
|
||||
|
||||
include "lua_compiler"
|
||||
include "lua_standalone"
|
||||
include "lua_standalone"
|
||||
|
||||
@@ -115,6 +115,7 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym);
|
||||
|
||||
|
||||
#if defined(LUA_USE_DLOPEN)
|
||||
|
||||
/*
|
||||
** {========================================================================
|
||||
** This is an implementation of loadlib based on the dlfcn interface.
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
#if defined(LUA_USE_LINUX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||
#define LUA_USE_READLINE /* needs some extra libraries */
|
||||
//#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||
//#define LUA_USE_READLINE /* needs some extra libraries */
|
||||
#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
|
||||
#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
|
||||
#define LUA_USE_LONGLONG /* assume support for long long */
|
||||
@@ -51,8 +51,8 @@
|
||||
|
||||
#if defined(LUA_USE_MACOSX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* does not need -ldl */
|
||||
#define LUA_USE_READLINE /* needs an extra library: -lreadline */
|
||||
//#define LUA_USE_DLOPEN /* does not need -ldl */
|
||||
//#define LUA_USE_READLINE /* needs an extra library: -lreadline */
|
||||
#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
|
||||
#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
|
||||
#define LUA_USE_LONGLONG /* assume support for long long */
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
#define NOCRYPT
|
||||
#define NOUNCRYPT
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
|
||||
@@ -276,8 +276,9 @@ void b3GpuGridBroadphase::calculateOverlappingPairs(int maxPairs)
|
||||
{
|
||||
b3AlignedObjectArray<b3Int4> pairsCpu;
|
||||
m_gpuPairs.copyToHost(pairsCpu);
|
||||
|
||||
printf("m_gpuPairs.size()=%d\n",m_gpuPairs.size());
|
||||
|
||||
int sz = m_gpuPairs.size();
|
||||
printf("m_gpuPairs.size()=%d\n",sz);
|
||||
for (int i=0;i<m_gpuPairs.size();i++)
|
||||
{
|
||||
printf("pair %d = %d,%d\n",i,pairsCpu[i].x,pairsCpu[i].y);
|
||||
|
||||
@@ -782,7 +782,8 @@ cl_program b3OpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
binarySize = ftell( file );
|
||||
rewind( file );
|
||||
binary = (char*)malloc(sizeof(char)*binarySize);
|
||||
fread( binary, sizeof(char), binarySize, file );
|
||||
int bytesRead;
|
||||
bytesRead = fread( binary, sizeof(char), binarySize, file );
|
||||
fclose( file );
|
||||
|
||||
m_cpProgram = clCreateProgramWithBinary( clContext, 1,&device, &binarySize, (const unsigned char**)&binary, 0, &status );
|
||||
|
||||
@@ -74,13 +74,14 @@ bFile::bFile(const char *filename, const char headerString[7])
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
|
||||
mFileBuffer = (char*)malloc(mFileLen+1);
|
||||
fread(mFileBuffer, mFileLen, 1, fp);
|
||||
int bytesRead;
|
||||
bytesRead = fread(mFileBuffer, mFileLen, 1, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
//
|
||||
parseHeader();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +102,9 @@ bFile::bFile( char *memoryBuffer, int len, const char headerString[7])
|
||||
}
|
||||
mFileBuffer = memoryBuffer;
|
||||
mFileLen = len;
|
||||
|
||||
|
||||
parseHeader();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -210,12 +211,12 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
// read the DNA1 block and extract SDNA
|
||||
if (getNextBlock(&dna, tempBuffer, mFlags) > 0)
|
||||
{
|
||||
if (strncmp((tempBuffer + ChunkUtils::getOffset(mFlags)), "SDNANAME", 8) ==0)
|
||||
if (strncmp((tempBuffer + ChunkUtils::getOffset(mFlags)), "SDNANAME", 8) ==0)
|
||||
dna.oldPtr = (tempBuffer + ChunkUtils::getOffset(mFlags));
|
||||
else dna.oldPtr = 0;
|
||||
}
|
||||
else dna.oldPtr = 0;
|
||||
}
|
||||
}
|
||||
// Some Bullet files are missing the DNA1 block
|
||||
// In Blender it's DNA1 + ChunkUtils::getOffset() + SDNA + NAME
|
||||
// In Bullet tests its SDNA + NAME
|
||||
@@ -224,7 +225,7 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
dna.oldPtr = blenderData + i;
|
||||
dna.len = mFileLen-i;
|
||||
|
||||
// Also no REND block, so exit now.
|
||||
// Also no REND block, so exit now.
|
||||
if (mVersion==276) break;
|
||||
}
|
||||
|
||||
@@ -240,11 +241,11 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
|
||||
|
||||
mFileDNA = new bDNA();
|
||||
|
||||
|
||||
|
||||
|
||||
///mFileDNA->init will convert part of DNA file endianness to current CPU endianness if necessary
|
||||
mFileDNA->init((char*)dna.oldPtr, dna.len, (mFlags & FD_ENDIAN_SWAP)!=0);
|
||||
|
||||
|
||||
|
||||
if (mVersion==276)
|
||||
{
|
||||
@@ -270,10 +271,10 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
mMemoryDNA = new bDNA();
|
||||
int littleEndian= 1;
|
||||
littleEndian= ((char*)&littleEndian)[0];
|
||||
|
||||
|
||||
mMemoryDNA->init(memDna,memDnaLength,littleEndian==0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///@todo we need a better version check, add version/sub version info from FileGlobal into memory DNA/header files
|
||||
@@ -289,16 +290,16 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
//printf ("Warning, file DNA is newer than built in.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
mFileDNA->initCmpFlags(mMemoryDNA);
|
||||
|
||||
|
||||
parseData();
|
||||
|
||||
|
||||
resolvePointers(verboseMode);
|
||||
|
||||
|
||||
updateOldPointers();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -309,8 +310,8 @@ void bFile::swap(char *head, bChunkInd& dataChunk, bool ignoreEndianFlag)
|
||||
char *data = head;
|
||||
short *strc = mFileDNA->getStruct(dataChunk.dna_nr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const char s[] = "SoftBodyMaterialData";
|
||||
int szs = sizeof(s);
|
||||
if (strncmp((char*)&dataChunk.code,"ARAY",4)==0)
|
||||
@@ -322,7 +323,7 @@ void bFile::swap(char *head, bChunkInd& dataChunk, bool ignoreEndianFlag)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int len = mFileDNA->getLength(strc[0]);
|
||||
|
||||
@@ -410,11 +411,11 @@ void bFile::swapDNA(char* ptr)
|
||||
|
||||
|
||||
// Parse names
|
||||
if (swap)
|
||||
if (swap)
|
||||
dataLen = ChunkUtils::swapInt(*intPtr);
|
||||
else
|
||||
else
|
||||
dataLen = *intPtr;
|
||||
|
||||
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
intPtr++;
|
||||
|
||||
@@ -426,7 +427,7 @@ void bFile::swapDNA(char* ptr)
|
||||
cp++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
nr= (long)cp;
|
||||
//long mask=3;
|
||||
@@ -448,9 +449,9 @@ void bFile::swapDNA(char* ptr)
|
||||
intPtr = (int*)cp;
|
||||
assert(strncmp(cp, "TYPE", 4)==0); intPtr++;
|
||||
|
||||
if (swap)
|
||||
if (swap)
|
||||
dataLen = ChunkUtils::swapInt(*intPtr);
|
||||
else
|
||||
else
|
||||
dataLen = *intPtr;
|
||||
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
@@ -485,7 +486,7 @@ void bFile::swapDNA(char* ptr)
|
||||
intPtr = (int*)cp;
|
||||
assert(strncmp(cp, "TLEN", 4)==0); intPtr++;
|
||||
|
||||
|
||||
|
||||
shtPtr = (short*)intPtr;
|
||||
for ( i=0; i<dataLen; i++, shtPtr++)
|
||||
{
|
||||
@@ -493,7 +494,7 @@ void bFile::swapDNA(char* ptr)
|
||||
shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]);
|
||||
}
|
||||
|
||||
if (dataLen & 1)
|
||||
if (dataLen & 1)
|
||||
shtPtr++;
|
||||
|
||||
/*
|
||||
@@ -509,12 +510,12 @@ void bFile::swapDNA(char* ptr)
|
||||
|
||||
intPtr = (int*)shtPtr;
|
||||
cp = (char*)intPtr;
|
||||
assert(strncmp(cp, "STRC", 4)==0);
|
||||
assert(strncmp(cp, "STRC", 4)==0);
|
||||
intPtr++;
|
||||
|
||||
if (swap)
|
||||
if (swap)
|
||||
dataLen = ChunkUtils::swapInt(*intPtr);
|
||||
else
|
||||
else
|
||||
dataLen = *intPtr;
|
||||
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
@@ -525,7 +526,7 @@ void bFile::swapDNA(char* ptr)
|
||||
shtPtr = (short*)intPtr;
|
||||
for ( i=0; i<dataLen; i++)
|
||||
{
|
||||
|
||||
|
||||
//if (swap)
|
||||
{
|
||||
int len = shtPtr[1];
|
||||
@@ -573,11 +574,11 @@ void bFile::preSwap()
|
||||
mFileBuffer[8]='V';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mDataStart = 12;
|
||||
|
||||
char *dataPtr = mFileBuffer+mDataStart;
|
||||
@@ -595,7 +596,7 @@ void bFile::preSwap()
|
||||
while (1)
|
||||
{
|
||||
// one behind
|
||||
if (dataChunk.code == B3_SDNA || dataChunk.code==B3_DNA1 || dataChunk.code == B3_TYPE || dataChunk.code == B3_TLEN || dataChunk.code==B3_STRC)
|
||||
if (dataChunk.code == B3_SDNA || dataChunk.code==B3_DNA1 || dataChunk.code == B3_TYPE || dataChunk.code == B3_TLEN || dataChunk.code==B3_STRC)
|
||||
{
|
||||
|
||||
swapDNA(dataPtr);
|
||||
@@ -604,7 +605,7 @@ void bFile::preSwap()
|
||||
{
|
||||
//if (dataChunk.code == DNA1) break;
|
||||
dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags);
|
||||
|
||||
|
||||
swapLen(dataPtr);
|
||||
if (dataChunk.dna_nr>=0)
|
||||
{
|
||||
@@ -632,7 +633,7 @@ void bFile::preSwap()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -644,7 +645,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
||||
if (mFlags & FD_ENDIAN_SWAP)
|
||||
swap(head, dataChunk, ignoreEndianFlag);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!mFileDNA->flagEqual(dataChunk.dna_nr))
|
||||
{
|
||||
@@ -656,7 +657,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
||||
|
||||
oldStruct = mFileDNA->getStruct(dataChunk.dna_nr);
|
||||
oldType = mFileDNA->getType(oldStruct[0]);
|
||||
|
||||
|
||||
oldLen = mFileDNA->getLength(oldStruct[0]);
|
||||
|
||||
if ((mFlags&FD_BROKEN_DNA)!=0)
|
||||
@@ -951,7 +952,7 @@ void bFile::safeSwapPtr(char *dst, const char *src)
|
||||
B3_SWITCH_LONGINT(longValue);
|
||||
*((int*)dst) = (int)(longValue>>3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (ptrMem==8 && ptrFile==4)
|
||||
{
|
||||
@@ -991,7 +992,7 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
||||
const char* type = mFileDNA->getType(dna_addr[0]);
|
||||
const char* name = mFileDNA->getName(dna_addr[1]);
|
||||
|
||||
|
||||
|
||||
|
||||
int eleLen = mFileDNA->getElementSize(dna_addr[0], dna_addr[1]);
|
||||
|
||||
@@ -1008,7 +1009,7 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
||||
//int arrayLenold = mFileDNA->getArraySize((char*)name.c_str());
|
||||
int arrayLen = mFileDNA->getArraySizeNew(dna_addr[1]);
|
||||
//assert(arrayLenold == arrayLen);
|
||||
|
||||
|
||||
if (name[0] == '*')
|
||||
{
|
||||
// cast pointers
|
||||
@@ -1022,11 +1023,11 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
||||
{
|
||||
//void **sarray = (void**)strcData;
|
||||
//void **darray = (void**)data;
|
||||
|
||||
|
||||
char *cpc, *cpo;
|
||||
cpc = (char*)strcData;
|
||||
cpo = (char*)data;
|
||||
|
||||
|
||||
for (int a=0; a<arrayLen; a++)
|
||||
{
|
||||
safeSwapPtr(cpc, cpo);
|
||||
@@ -1162,7 +1163,7 @@ void bFile::resolvePointersMismatch()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (i=0; i<m_pointerPtrFixupArray.size(); i++)
|
||||
{
|
||||
char* cur= m_pointerPtrFixupArray.at(i);
|
||||
@@ -1227,7 +1228,7 @@ void bFile::resolvePointersChunk(const bChunkInd& dataChunk, int verboseMode)
|
||||
|
||||
int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verboseMode,int recursion)
|
||||
{
|
||||
|
||||
|
||||
bParse::bDNA* fileDna = mFileDNA ? mFileDNA : mMemoryDNA;
|
||||
|
||||
char* memType;
|
||||
@@ -1238,7 +1239,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
char* elemPtr= strcPtr;
|
||||
|
||||
short int* oldStruct = fileDna->getStruct(dna_nr);
|
||||
|
||||
|
||||
int elementLength = oldStruct[1];
|
||||
oldStruct+=2;
|
||||
|
||||
@@ -1249,8 +1250,8 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
|
||||
memType = fileDna->getType(oldStruct[0]);
|
||||
memName = fileDna->getName(oldStruct[1]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int arrayLen = fileDna->getArraySizeNew(oldStruct[1]);
|
||||
if (memName[0] == '*')
|
||||
@@ -1268,7 +1269,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
}
|
||||
//skip the *
|
||||
printf("<%s type=\"pointer\"> ",&memName[1]);
|
||||
printf("%d ", array[a]);
|
||||
printf("%p ", array[a]);
|
||||
printf("</%s>\n",&memName[1]);
|
||||
}
|
||||
|
||||
@@ -1286,7 +1287,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
printf(" ");
|
||||
}
|
||||
printf("<%s type=\"pointer\"> ",&memName[1]);
|
||||
printf("%d ", ptr);
|
||||
printf("%p ", ptr);
|
||||
printf("</%s>\n",&memName[1]);
|
||||
}
|
||||
ptr = findLibPointer(ptr);
|
||||
@@ -1316,7 +1317,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
} else
|
||||
{
|
||||
int revType = fileDna->getReverseType(oldStruct[0]);
|
||||
if (oldStruct[0]>=firstStructType) //revType != -1 &&
|
||||
if (oldStruct[0]>=firstStructType) //revType != -1 &&
|
||||
{
|
||||
char cleanName[MAX_STRLEN];
|
||||
getCleanName(memName,cleanName);
|
||||
@@ -1421,7 +1422,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1429,7 +1430,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
int size = fileDna->getElementSize(oldStruct[0], oldStruct[1]);
|
||||
totalSize += size;
|
||||
elemPtr+=size;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
@@ -1445,9 +1446,9 @@ void bFile::resolvePointers(int verboseMode)
|
||||
|
||||
if (1) //mFlags & (FD_BITS_VARIES | FD_VERSION_VARIES))
|
||||
{
|
||||
resolvePointersMismatch();
|
||||
resolvePointersMismatch();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
if (verboseMode & FD_VERBOSE_EXPORT_XML)
|
||||
@@ -1465,9 +1466,9 @@ void bFile::resolvePointers(int verboseMode)
|
||||
//dataChunk.len
|
||||
short int* oldStruct = fileDna->getStruct(dataChunk.dna_nr);
|
||||
char* oldType = fileDna->getType(oldStruct[0]);
|
||||
|
||||
|
||||
if (verboseMode & FD_VERBOSE_EXPORT_XML)
|
||||
printf(" <%s pointer=%d>\n",oldType,dataChunk.oldPtr);
|
||||
printf(" <%s pointer=%p>\n",oldType,dataChunk.oldPtr);
|
||||
|
||||
resolvePointersChunk(dataChunk, verboseMode);
|
||||
|
||||
@@ -1483,8 +1484,8 @@ void bFile::resolvePointers(int verboseMode)
|
||||
printf("</bullet_physics>\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1518,13 +1519,13 @@ void bFile::dumpChunks(bParse::bDNA* dna)
|
||||
bChunkInd& dataChunk = m_chunks[i];
|
||||
char* codeptr = (char*)&dataChunk.code;
|
||||
char codestr[5] = {codeptr[0],codeptr[1],codeptr[2],codeptr[3],0};
|
||||
|
||||
|
||||
short* newStruct = dna->getStruct(dataChunk.dna_nr);
|
||||
char* typeName = dna->getType(newStruct[0]);
|
||||
printf("%3d: %s ",i,typeName);
|
||||
|
||||
printf("code=%s ",codestr);
|
||||
|
||||
|
||||
printf("ptr=%p ",dataChunk.oldPtr);
|
||||
printf("len=%d ",dataChunk.len);
|
||||
printf("nr=%d ",dataChunk.nr);
|
||||
@@ -1534,8 +1535,8 @@ void bFile::dumpChunks(bParse::bDNA* dna)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1544,7 +1545,7 @@ void bFile::dumpChunks(bParse::bDNA* dna)
|
||||
ifd.success = 0;
|
||||
ifd.IDname = NULL;
|
||||
ifd.just_print_it = 1;
|
||||
for (i=0; i<bf->m_blocks.size(); ++i)
|
||||
for (i=0; i<bf->m_blocks.size(); ++i)
|
||||
{
|
||||
BlendBlock* bb = bf->m_blocks[i];
|
||||
printf("tag='%s'\tptr=%p\ttype=%s\t[%4d]", bb->tag, bb,bf->types[bb->type_index].name,bb->m_array_entries_.size());
|
||||
@@ -1563,7 +1564,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
for (int i=0;i<m_chunks.size();i++)
|
||||
{
|
||||
bChunkInd& dataChunk = m_chunks.at(i);
|
||||
|
||||
|
||||
// Ouch! need to rebuild the struct
|
||||
short *oldStruct,*curStruct;
|
||||
char *oldType, *newType;
|
||||
@@ -1574,7 +1575,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
oldLen = fileDna->getLength(oldStruct[0]);
|
||||
///don't try to convert Link block data, just memcpy it. Other data can be converted.
|
||||
reverseOld = mMemoryDNA->getReverseType(oldType);
|
||||
|
||||
|
||||
|
||||
if ((reverseOld!=-1))
|
||||
{
|
||||
@@ -1586,7 +1587,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
// make sure it's the same
|
||||
assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!");
|
||||
|
||||
|
||||
|
||||
curLen = mMemoryDNA->getLength(curStruct[0]);
|
||||
dataChunk.dna_nr = reverseOld;
|
||||
if (strcmp("Link",oldType)!=0)
|
||||
@@ -1596,10 +1597,10 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
{
|
||||
// printf("keep length of link = %d\n",dataChunk.len);
|
||||
}
|
||||
|
||||
|
||||
//write the structure header
|
||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||
|
||||
|
||||
|
||||
|
||||
short int* curStruct1;
|
||||
@@ -1615,7 +1616,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
printf("serious error, struct mismatch: don't write\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1625,9 +1626,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
|
||||
bool swap = false;
|
||||
bool varies = false;
|
||||
|
||||
if (flags &FD_ENDIAN_SWAP)
|
||||
if (flags &FD_ENDIAN_SWAP)
|
||||
swap = true;
|
||||
if (flags &FD_BITS_VARIES)
|
||||
if (flags &FD_BITS_VARIES)
|
||||
varies = true;
|
||||
|
||||
if (VOID_IS_8)
|
||||
@@ -1697,11 +1698,11 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
|
||||
{
|
||||
b3Long64 oldPtr =0;
|
||||
memcpy(&oldPtr, &head.m_uniqueInts[0], 8);
|
||||
if (swap)
|
||||
if (swap)
|
||||
B3_SWITCH_LONGINT(oldPtr);
|
||||
chunk.m_uniqueInt = (int)(oldPtr >> 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
chunk.dna_nr = head.dna_nr;
|
||||
chunk.nr = head.nr;
|
||||
|
||||
@@ -1,117 +1,117 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
#define GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
|
||||
|
||||
#include "btVector3.h"
|
||||
#include "btAlignedObjectArray.h"
|
||||
|
||||
struct GrahamVector3 : public btVector3
|
||||
{
|
||||
GrahamVector3(const btVector3& org, int orgIndex)
|
||||
:btVector3(org),
|
||||
m_orgIndex(orgIndex)
|
||||
{
|
||||
}
|
||||
btScalar m_angle;
|
||||
int m_orgIndex;
|
||||
};
|
||||
|
||||
|
||||
struct btAngleCompareFunc {
|
||||
btVector3 m_anchor;
|
||||
btAngleCompareFunc(const btVector3& anchor)
|
||||
: m_anchor(anchor)
|
||||
{
|
||||
}
|
||||
bool operator()(const GrahamVector3& a, const GrahamVector3& b) const {
|
||||
if (a.m_angle != b.m_angle)
|
||||
return a.m_angle < b.m_angle;
|
||||
else
|
||||
{
|
||||
btScalar al = (a-m_anchor).length2();
|
||||
btScalar bl = (b-m_anchor).length2();
|
||||
if (al != bl)
|
||||
return al < bl;
|
||||
else
|
||||
{
|
||||
return a.m_orgIndex < b.m_orgIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void GrahamScanConvexHull2D(btAlignedObjectArray<GrahamVector3>& originalPoints, btAlignedObjectArray<GrahamVector3>& hull, const btVector3& normalAxis)
|
||||
{
|
||||
btVector3 axis0,axis1;
|
||||
btPlaneSpace1(normalAxis,axis0,axis1);
|
||||
|
||||
|
||||
if (originalPoints.size()<=1)
|
||||
{
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
hull.push_back(originalPoints[0]);
|
||||
return;
|
||||
}
|
||||
//step1 : find anchor point with smallest projection on axis0 and move it to first location
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
{
|
||||
// const btVector3& left = originalPoints[i];
|
||||
// const btVector3& right = originalPoints[0];
|
||||
btScalar projL = originalPoints[i].dot(axis0);
|
||||
btScalar projR = originalPoints[0].dot(axis0);
|
||||
if (projL < projR)
|
||||
{
|
||||
originalPoints.swap(0,i);
|
||||
}
|
||||
}
|
||||
|
||||
//also precompute angles
|
||||
originalPoints[0].m_angle = -1e30f;
|
||||
for (int i=1;i<originalPoints.size();i++)
|
||||
{
|
||||
btVector3 xvec = axis0;
|
||||
btVector3 ar = originalPoints[i]-originalPoints[0];
|
||||
originalPoints[i].m_angle = btCross(xvec, ar).dot(normalAxis) / ar.length();
|
||||
}
|
||||
|
||||
//step 2: sort all points, based on 'angle' with this anchor
|
||||
btAngleCompareFunc comp(originalPoints[0]);
|
||||
originalPoints.quickSortInternal(comp,1,originalPoints.size()-1);
|
||||
|
||||
int i;
|
||||
for (i = 0; i<2; i++)
|
||||
hull.push_back(originalPoints[i]);
|
||||
|
||||
//step 3: keep all 'convex' points and discard concave points (using back tracking)
|
||||
for (; i != originalPoints.size(); i++)
|
||||
{
|
||||
bool isConvex = false;
|
||||
while (!isConvex&& hull.size()>1) {
|
||||
btVector3& a = hull[hull.size()-2];
|
||||
btVector3& b = hull[hull.size()-1];
|
||||
isConvex = btCross(a-b,a-originalPoints[i]).dot(normalAxis)> 0;
|
||||
if (!isConvex)
|
||||
hull.pop_back();
|
||||
else
|
||||
hull.push_back(originalPoints[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
#define GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
|
||||
|
||||
#include "btVector3.h"
|
||||
#include "btAlignedObjectArray.h"
|
||||
|
||||
struct GrahamVector3 : public btVector3
|
||||
{
|
||||
GrahamVector3(const btVector3& org, int orgIndex)
|
||||
:btVector3(org),
|
||||
m_orgIndex(orgIndex)
|
||||
{
|
||||
}
|
||||
btScalar m_angle;
|
||||
int m_orgIndex;
|
||||
};
|
||||
|
||||
|
||||
struct btAngleCompareFunc {
|
||||
btVector3 m_anchor;
|
||||
btAngleCompareFunc(const btVector3& anchor)
|
||||
: m_anchor(anchor)
|
||||
{
|
||||
}
|
||||
bool operator()(const GrahamVector3& a, const GrahamVector3& b) const {
|
||||
if (a.m_angle != b.m_angle)
|
||||
return a.m_angle < b.m_angle;
|
||||
else
|
||||
{
|
||||
btScalar al = (a-m_anchor).length2();
|
||||
btScalar bl = (b-m_anchor).length2();
|
||||
if (al != bl)
|
||||
return al < bl;
|
||||
else
|
||||
{
|
||||
return a.m_orgIndex < b.m_orgIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void GrahamScanConvexHull2D(btAlignedObjectArray<GrahamVector3>& originalPoints, btAlignedObjectArray<GrahamVector3>& hull, const btVector3& normalAxis)
|
||||
{
|
||||
btVector3 axis0,axis1;
|
||||
btPlaneSpace1(normalAxis,axis0,axis1);
|
||||
|
||||
|
||||
if (originalPoints.size()<=1)
|
||||
{
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
hull.push_back(originalPoints[0]);
|
||||
return;
|
||||
}
|
||||
//step1 : find anchor point with smallest projection on axis0 and move it to first location
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
{
|
||||
// const btVector3& left = originalPoints[i];
|
||||
// const btVector3& right = originalPoints[0];
|
||||
btScalar projL = originalPoints[i].dot(axis0);
|
||||
btScalar projR = originalPoints[0].dot(axis0);
|
||||
if (projL < projR)
|
||||
{
|
||||
originalPoints.swap(0,i);
|
||||
}
|
||||
}
|
||||
|
||||
//also precompute angles
|
||||
originalPoints[0].m_angle = -1e30f;
|
||||
for (int i=1;i<originalPoints.size();i++)
|
||||
{
|
||||
btVector3 xvec = axis0;
|
||||
btVector3 ar = originalPoints[i]-originalPoints[0];
|
||||
originalPoints[i].m_angle = btCross(xvec, ar).dot(normalAxis) / ar.length();
|
||||
}
|
||||
|
||||
//step 2: sort all points, based on 'angle' with this anchor
|
||||
btAngleCompareFunc comp(originalPoints[0]);
|
||||
originalPoints.quickSortInternal(comp,1,originalPoints.size()-1);
|
||||
|
||||
int i;
|
||||
for (i = 0; i<2; i++)
|
||||
hull.push_back(originalPoints[i]);
|
||||
|
||||
//step 3: keep all 'convex' points and discard concave points (using back tracking)
|
||||
for (; i != originalPoints.size(); i++)
|
||||
{
|
||||
bool isConvex = false;
|
||||
while (!isConvex&& hull.size()>1) {
|
||||
btVector3& a = hull[hull.size()-2];
|
||||
btVector3& b = hull[hull.size()-1];
|
||||
isConvex = btCross(a-b,a-originalPoints[i]).dot(normalAxis)> 0;
|
||||
if (!isConvex)
|
||||
hull.pop_back();
|
||||
else
|
||||
hull.push_back(originalPoints[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
|
||||
@@ -46,7 +46,8 @@ class btIDebugDraw
|
||||
DBG_DrawConstraints = (1 << 11),
|
||||
DBG_DrawConstraintLimits = (1 << 12),
|
||||
DBG_FastWireframe = (1<<13),
|
||||
DBG_DrawNormals = (1<<14),
|
||||
DBG_DrawNormals = (1<<14),
|
||||
DBG_DrawFrames = (1<<15),
|
||||
DBG_MAX_DEBUG_DRAW_MODE
|
||||
};
|
||||
|
||||
@@ -147,7 +148,7 @@ class btIDebugDraw
|
||||
const btVector3& vx = axis;
|
||||
btVector3 vy = normal.cross(axis);
|
||||
btScalar step = stepDegrees * SIMD_RADS_PER_DEG;
|
||||
int nSteps = (int)((maxAngle - minAngle) / step);
|
||||
int nSteps = (int)btFabs((maxAngle - minAngle) / step);
|
||||
if(!nSteps) nSteps = 1;
|
||||
btVector3 prev = center + radiusA * vx * btCos(minAngle) + radiusB * vy * btSin(minAngle);
|
||||
if(drawSect)
|
||||
@@ -438,11 +439,10 @@ class btIDebugDraw
|
||||
drawLine(transform*pt0,transform*pt1,color);
|
||||
drawLine(transform*pt2,transform*pt3,color);
|
||||
}
|
||||
|
||||
virtual void flushLines()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void flushLines()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
0
src/LinearMath/btPoolAllocator.h
Executable file → Normal file
0
src/LinearMath/btPoolAllocator.h
Executable file → Normal file
@@ -10,7 +10,7 @@
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
// Credits: The Clock class was inspired by the Timer classes in
|
||||
// Credits: The Clock class was inspired by the Timer classes in
|
||||
// Ogre (www.ogre3d.org).
|
||||
|
||||
#include "btQuickprof.h"
|
||||
@@ -27,8 +27,8 @@ static btClock gProfileClock;
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined (SUNOS) || defined (__SUNOS__)
|
||||
#include <stdio.h>
|
||||
#if defined (SUNOS) || defined (__SUNOS__)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
@@ -37,7 +37,7 @@ static btClock gProfileClock;
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOWINRES
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#define NOIME
|
||||
|
||||
#ifdef _XBOX
|
||||
#include <Xtl.h>
|
||||
@@ -121,34 +121,34 @@ void btClock::reset()
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Returns the time in ms since the last call to reset or since
|
||||
/// Returns the time in ms since the last call to reset or since
|
||||
/// the btClock was created.
|
||||
unsigned long int btClock::getTimeMilliseconds()
|
||||
{
|
||||
#ifdef BT_USE_WINDOWS_TIMERS
|
||||
LARGE_INTEGER currentTime;
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
m_data->mStartTime.QuadPart;
|
||||
// Compute the number of millisecond ticks elapsed.
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// bridge, aka south bridge. See Microsoft KB274323.)
|
||||
unsigned long elapsedTicks = GetTickCount() - m_data->mStartTick;
|
||||
signed long msecOff = (signed long)(msecTicks - elapsedTicks);
|
||||
if (msecOff < -100 || msecOff > 100)
|
||||
{
|
||||
// Adjust the starting time forwards.
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
m_data->mPrevElapsedTime);
|
||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||
elapsedTime -= msecAdjustment;
|
||||
|
||||
// Recompute the number of millisecond ticks elapsed.
|
||||
msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
}
|
||||
|
||||
@@ -171,36 +171,36 @@ unsigned long int btClock::getTimeMilliseconds()
|
||||
|
||||
struct timeval currentTime;
|
||||
gettimeofday(¤tTime, 0);
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000 +
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000 +
|
||||
(currentTime.tv_usec - m_data->mStartTime.tv_usec) / 1000;
|
||||
#endif //__CELLOS_LV2__
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Returns the time in us since the last call to reset or since
|
||||
/// Returns the time in us since the last call to reset or since
|
||||
/// the Clock was created.
|
||||
unsigned long int btClock::getTimeMicroseconds()
|
||||
{
|
||||
#ifdef BT_USE_WINDOWS_TIMERS
|
||||
LARGE_INTEGER currentTime;
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
m_data->mStartTime.QuadPart;
|
||||
|
||||
// Compute the number of millisecond ticks elapsed.
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// bridge, aka south bridge. See Microsoft KB274323.)
|
||||
unsigned long elapsedTicks = GetTickCount() - m_data->mStartTick;
|
||||
signed long msecOff = (signed long)(msecTicks - elapsedTicks);
|
||||
if (msecOff < -100 || msecOff > 100)
|
||||
{
|
||||
// Adjust the starting time forwards.
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
m_data->mPrevElapsedTime);
|
||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||
elapsedTime -= msecAdjustment;
|
||||
@@ -210,7 +210,7 @@ unsigned long int btClock::getTimeMicroseconds()
|
||||
m_data->mPrevElapsedTime = elapsedTime;
|
||||
|
||||
// Convert to microseconds.
|
||||
unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime /
|
||||
unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
|
||||
return usecTicks;
|
||||
@@ -229,10 +229,10 @@ unsigned long int btClock::getTimeMicroseconds()
|
||||
|
||||
struct timeval currentTime;
|
||||
gettimeofday(¤tTime, 0);
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000000 +
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000000 +
|
||||
(currentTime.tv_usec - m_data->mStartTime.tv_usec);
|
||||
#endif//__CELLOS_LV2__
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
|
||||
}
|
||||
|
||||
// We didn't find it, so add it
|
||||
|
||||
|
||||
CProfileNode * node = new CProfileNode( name, this );
|
||||
node->Sibling = Child;
|
||||
Child = node;
|
||||
@@ -337,7 +337,7 @@ void CProfileNode::Reset( void )
|
||||
{
|
||||
TotalCalls = 0;
|
||||
TotalTime = 0.0f;
|
||||
|
||||
|
||||
|
||||
if ( Child ) {
|
||||
Child->Reset();
|
||||
@@ -359,7 +359,7 @@ void CProfileNode::Call( void )
|
||||
|
||||
bool CProfileNode::Return( void )
|
||||
{
|
||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||
unsigned long int time;
|
||||
Profile_Get_Ticks(&time);
|
||||
time-=StartTime;
|
||||
@@ -452,8 +452,8 @@ void CProfileManager::Start_Profile( const char * name )
|
||||
{
|
||||
if (name != CurrentNode->Get_Name()) {
|
||||
CurrentNode = CurrentNode->Get_Sub_Node( name );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CurrentNode->Call();
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ void CProfileManager::Stop_Profile( void )
|
||||
* This resets everything except for the tree structure. All of the timing data is reset. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Reset( void )
|
||||
{
|
||||
{
|
||||
gProfileClock.reset();
|
||||
Root.Reset();
|
||||
Root.Call();
|
||||
@@ -523,9 +523,9 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time );
|
||||
float totalTime = 0.f;
|
||||
|
||||
|
||||
|
||||
int numChildren = 0;
|
||||
|
||||
|
||||
for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next())
|
||||
{
|
||||
numChildren++;
|
||||
@@ -546,7 +546,7 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
}
|
||||
for (i=0;i<spacing;i++) printf(".");
|
||||
printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
|
||||
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
profileIterator->Enter_Child(i);
|
||||
|
||||
@@ -97,7 +97,7 @@ inline int btGetVersion()
|
||||
#ifdef BT_DEBUG
|
||||
#ifdef _MSC_VER
|
||||
#include <stdio.h>
|
||||
#define btAssert(x) { if(!(x)){printf("Assert " __FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||
#else//_MSC_VER
|
||||
#include <assert.h>
|
||||
#define btAssert assert
|
||||
@@ -125,7 +125,7 @@ inline int btGetVersion()
|
||||
#ifdef __SPU__
|
||||
#include <spu_printf.h>
|
||||
#define printf spu_printf
|
||||
#define btAssert(x) {if(!(x)){printf("Assert " __FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}
|
||||
#define btAssert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}
|
||||
#else
|
||||
#define btAssert assert
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,7 @@ extern char** gArgv;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct ExecuteBullet3NarrowphaseKernels : public ::testing::Test
|
||||
struct ExecuteBullet3NarrowphaseKernels : public ::testing::Test
|
||||
{
|
||||
cl_context m_clContext;
|
||||
cl_device_id m_clDevice;
|
||||
@@ -41,7 +41,7 @@ namespace
|
||||
initCL();
|
||||
}
|
||||
|
||||
virtual ~ExecuteBullet3NarrowphaseKernels()
|
||||
virtual ~ExecuteBullet3NarrowphaseKernels()
|
||||
{
|
||||
// You can do clean-up work that doesn't throw exceptions here.
|
||||
exitCL();
|
||||
@@ -51,8 +51,8 @@ namespace
|
||||
// and cleaning up each test, you can define the following methods:
|
||||
|
||||
#include "initCL.h"
|
||||
|
||||
virtual void SetUp()
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace
|
||||
// before each test).
|
||||
}
|
||||
|
||||
virtual void TearDown()
|
||||
virtual void TearDown()
|
||||
{
|
||||
// Code here will be called immediately after each test (right
|
||||
// before the destructor).
|
||||
@@ -71,13 +71,13 @@ namespace
|
||||
TEST_F(ExecuteBullet3NarrowphaseKernels,satKernelsCL)
|
||||
{
|
||||
cl_int errNum=0;
|
||||
|
||||
|
||||
char flags[1024]={0};
|
||||
|
||||
cl_program satProg = b3OpenCLUtils::compileCLProgramFromString(m_clContext,m_clDevice,satKernelsCL,&errNum,flags,0,true);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
|
||||
|
||||
|
||||
{
|
||||
cl_kernel m_findSeparatingAxisKernel = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satKernelsCL, "findSeparatingAxisKernel",&errNum,satProg );
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
@@ -101,9 +101,9 @@ namespace
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(m_findConcaveSeparatingAxisKernel );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
{
|
||||
cl_kernel m_findCompoundPairsKernel = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satKernelsCL, "findCompoundPairsKernel",&errNum,satProg );
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(m_findCompoundPairsKernel);
|
||||
@@ -122,7 +122,7 @@ namespace
|
||||
TEST_F(ExecuteBullet3NarrowphaseKernels,satConcaveKernelsCL)
|
||||
{
|
||||
cl_int errNum=0;
|
||||
|
||||
|
||||
char flags[1024]={0};
|
||||
|
||||
cl_program satConcaveProg = b3OpenCLUtils::compileCLProgramFromString(m_clContext,m_clDevice,satConcaveKernelsCL,&errNum,flags,0,true);
|
||||
@@ -133,20 +133,20 @@ namespace
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(m_findConcaveSeparatingAxisVertexFaceKernel);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
cl_kernel m_findConcaveSeparatingAxisEdgeEdgeKernel = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satConcaveKernelsCL, "findConcaveSeparatingAxisEdgeEdgeKernel",&errNum,satConcaveProg );
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(m_findConcaveSeparatingAxisEdgeEdgeKernel);
|
||||
}
|
||||
|
||||
|
||||
clReleaseProgram(satConcaveProg);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(ExecuteBullet3NarrowphaseKernels,satClipKernelsCL)
|
||||
{
|
||||
|
||||
|
||||
char flags[1024]={0};
|
||||
cl_int errNum=0;
|
||||
//#ifdef CL_PLATFORM_INTEL
|
||||
@@ -167,7 +167,7 @@ namespace
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(m_clipCompoundsHullHullKernel);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satClipKernelsCL, "findClippingFacesKernel",&errNum,satClipContactsProg);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
@@ -177,13 +177,13 @@ namespace
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satClipKernelsCL, "clipFacesAndFindContactsKernel",&errNum,satClipContactsProg);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satClipKernelsCL, "clipHullHullConcaveConvexKernel",&errNum,satClipContactsProg);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,9 +191,9 @@ namespace
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,satClipKernelsCL,
|
||||
"newContactReductionKernel",&errNum,satClipContactsProg);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
|
||||
clReleaseProgram(satClipContactsProg);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace
|
||||
TEST_F(ExecuteBullet3NarrowphaseKernels,bvhTraversalKernels)
|
||||
{
|
||||
|
||||
|
||||
|
||||
cl_int errNum=0;
|
||||
cl_program bvhTraversalProg = b3OpenCLUtils::compileCLProgramFromString(m_clContext,m_clDevice,bvhTraversalKernelCL,&errNum,"",0,true);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
@@ -209,7 +209,7 @@ namespace
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,bvhTraversalKernelCL, "bvhTraversalKernel",&errNum,bvhTraversalProg,"");
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
clReleaseProgram(bvhTraversalProg);
|
||||
}
|
||||
@@ -224,21 +224,21 @@ namespace
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,primitiveContactsKernelsCL, "primitiveContactsKernel",&errNum,primitiveContactsProg,"");
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,primitiveContactsKernelsCL, "findConcaveSphereContactsKernel",&errNum,primitiveContactsProg );
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,primitiveContactsKernelsCL, "processCompoundPairsPrimitivesKernel",&errNum,primitiveContactsProg,"");
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
|
||||
clReleaseProgram(primitiveContactsProg);
|
||||
}
|
||||
|
||||
@@ -272,8 +272,8 @@ namespace
|
||||
unzFile zipfile = unzOpen( relativeFileName);
|
||||
if ( zipfile == NULL )
|
||||
{
|
||||
printf( "%s: not found\n" );
|
||||
|
||||
printf( "%s: not found\n" ,relativeFileName);
|
||||
|
||||
}
|
||||
|
||||
// Get info about the zip file
|
||||
@@ -286,17 +286,17 @@ namespace
|
||||
} else
|
||||
{
|
||||
result = unzLocateFile(zipfile, fileName, 0);
|
||||
if (result == UNZ_OK)
|
||||
if (result == UNZ_OK)
|
||||
{
|
||||
unz_file_info info;
|
||||
result = unzGetCurrentFileInfo( zipfile, &info, NULL, 0, NULL, 0, NULL, 0 );
|
||||
if ( result != UNZ_OK )
|
||||
if ( result != UNZ_OK )
|
||||
{
|
||||
b3Printf("unzGetCurrentFileInfo() != UNZ_OK (%d)\n", result);
|
||||
} else
|
||||
{
|
||||
result = unzOpenCurrentFile(zipfile);
|
||||
if (result == UNZ_OK)
|
||||
if (result == UNZ_OK)
|
||||
{
|
||||
buffer = (unsigned char*)malloc(info.uncompressed_size);
|
||||
result = unzReadCurrentFile(zipfile,buffer,info.uncompressed_size);
|
||||
@@ -334,7 +334,7 @@ namespace
|
||||
f = fopen(relativeFileName,"rb");
|
||||
}
|
||||
//first try from data.zip, otherwise directly load the file from disk
|
||||
|
||||
|
||||
if (f)
|
||||
{
|
||||
int sizeInBytes=0;
|
||||
@@ -355,7 +355,7 @@ namespace
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return buffer;
|
||||
@@ -374,7 +374,7 @@ namespace
|
||||
int num = *(int*)&buf[serializedBytes];
|
||||
|
||||
launcher.launch1D( num);
|
||||
|
||||
|
||||
free(buf);
|
||||
//this clFinish is for testing on errors
|
||||
}
|
||||
@@ -382,13 +382,13 @@ namespace
|
||||
|
||||
TEST_F(ExecuteBullet3NarrowphaseKernels,mprKernelsCL)
|
||||
{
|
||||
|
||||
|
||||
cl_int errNum=0;
|
||||
const char* srcConcave = satConcaveKernelsCL;
|
||||
char flags[1024]={0};
|
||||
cl_program mprProg = b3OpenCLUtils::compileCLProgramFromString(m_clContext,m_clDevice,mprKernelsCL,&errNum,flags,0,true);
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
|
||||
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,mprKernelsCL, "mprPenetrationKernel",&errNum,mprProg );
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
@@ -397,7 +397,7 @@ namespace
|
||||
{
|
||||
const char* fileNames[]={"mprPenetrationKernel60.bin","mprPenetrationKernel61.bin","mprPenetrationKernel70.bin","mprPenetrationKernel128.bin"};
|
||||
int results[] = {0,1,46,98};
|
||||
|
||||
|
||||
int numTests = sizeof(fileNames)/sizeof(const char*);
|
||||
for (int i=0;i<numTests;i++)
|
||||
{
|
||||
@@ -414,7 +414,7 @@ namespace
|
||||
ASSERT_EQ(results[i],numContacts);
|
||||
}
|
||||
//printf("numContacts = %d\n",numContacts);
|
||||
|
||||
|
||||
//nContacts = m_totalContactsOut.at(0);
|
||||
}
|
||||
|
||||
@@ -422,15 +422,15 @@ namespace
|
||||
|
||||
|
||||
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
{
|
||||
cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,mprKernelsCL, "findSeparatingAxisUnitSphereKernel",&errNum,mprProg );
|
||||
ASSERT_EQ(CL_SUCCESS,errNum);
|
||||
clReleaseKernel(k);
|
||||
clReleaseKernel(k);
|
||||
}
|
||||
|
||||
|
||||
|
||||
clReleaseProgram(mprProg);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ __kernel void testKernel( __global int* testData, __global b3Contact4Data_t* c
|
||||
void myprintf(const char* msg)
|
||||
{
|
||||
//OutputDebugStringA(msg);
|
||||
printf(msg);
|
||||
printf("%s",msg);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@@ -160,7 +160,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
cl_command_queue queue = clCreateCommandQueue(context, dev, 0, &errNum);
|
||||
|
||||
|
||||
|
||||
cl_program pairBenchProg=0;
|
||||
|
||||
cl_kernel testKernel = b3OpenCLUtils::compileCLKernelFromString(context,dev,s_testKernelString,"testKernel",&errNum,pairBenchProg);
|
||||
@@ -173,7 +173,7 @@ int main(int argc, char* argv[])
|
||||
b3OpenCLArray<int> atomicCounter(context,queue);
|
||||
b3OpenCLArray<b3Contact4Data> deviceContacts(context,queue);
|
||||
b3AlignedObjectArray<b3Contact4Data> hostContacts;
|
||||
|
||||
|
||||
b3Contact4Data tmp;
|
||||
int sz = sizeof(b3Contact4Data);
|
||||
memset(&tmp,1,sz);
|
||||
@@ -182,7 +182,7 @@ int main(int argc, char* argv[])
|
||||
memset(&tmp,2,sz);
|
||||
deviceContacts.push_back(tmp);
|
||||
b3Contact4Data tmp3 = tmp;
|
||||
|
||||
|
||||
|
||||
atomicCounter.push_back(0);
|
||||
deviceElements.resize(numWorkItems);
|
||||
@@ -190,7 +190,7 @@ int main(int argc, char* argv[])
|
||||
run.setBuffer(deviceElements.getBufferCL());
|
||||
run.setBuffer(deviceContacts.getBufferCL());
|
||||
run.setBuffer(atomicCounter.getBufferCL());
|
||||
|
||||
|
||||
run.launch1D(numWorkItems);
|
||||
|
||||
b3AlignedObjectArray<int> hostElements;
|
||||
@@ -198,7 +198,7 @@ int main(int argc, char* argv[])
|
||||
deviceContacts.copyToHost(hostContacts);
|
||||
tmp2 = hostContacts[0];
|
||||
tmp3 = hostContacts[1];
|
||||
|
||||
|
||||
|
||||
printf("...\n");
|
||||
|
||||
@@ -207,7 +207,7 @@ int main(int argc, char* argv[])
|
||||
printf("kernel failed to compile\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user