mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 22:00:05 +00:00
bt -> b3 and BT -> B3 rename for content and filenames
This commit is contained in:
parent
6bcb5b9d5f
commit
7366e262fd
@ -30,7 +30,7 @@ Gwen::Controls::Canvas* pCanvas = NULL;
|
||||
|
||||
void MyMouseMoveCallback( float x, float y)
|
||||
{
|
||||
//btDefaultMouseCallback(button,state,x,y);
|
||||
//b3DefaultMouseCallback(button,state,x,y);
|
||||
|
||||
static int m_lastmousepos[2] = {0,0};
|
||||
static bool isInitialized = false;
|
||||
@ -48,7 +48,7 @@ void MyMouseMoveCallback( float x, float y)
|
||||
|
||||
void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
//btDefaultMouseCallback(button,state,x,y);
|
||||
//b3DefaultMouseCallback(button,state,x,y);
|
||||
|
||||
if (pCanvas)
|
||||
{
|
||||
@ -219,8 +219,8 @@ int main()
|
||||
|
||||
float retinaScale = 1.f;
|
||||
|
||||
btgDefaultOpenGLWindow* window = new btgDefaultOpenGLWindow();
|
||||
btgWindowConstructionInfo wci;
|
||||
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
||||
b3gWindowConstructionInfo wci;
|
||||
wci.m_width = sWidth;
|
||||
wci.m_height = sHeight;
|
||||
|
||||
|
@ -94,7 +94,7 @@ void loadBufferData(){
|
||||
glBindBuffer(GL_ARRAY_BUFFER, sData.m_vertexBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(Vertex), vertexData, GL_STATIC_DRAW);
|
||||
GLuint err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ void loadBufferData(){
|
||||
glEnableVertexAttribArray(sData.m_positionAttribute);
|
||||
glEnableVertexAttribArray(sData.m_colourAttribute);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(sData.m_textureAttribute);
|
||||
|
||||
@ -113,7 +113,7 @@ void loadBufferData(){
|
||||
glVertexAttribPointer(sData.m_colourAttribute , 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)sizeof(vec4));
|
||||
glVertexAttribPointer(sData.m_textureAttribute , 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(sizeof(vec4)+sizeof(vec4)));
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
}
|
||||
|
||||
@ -123,15 +123,15 @@ void initTestTexture()
|
||||
glGenTextures(1,(GLuint*)&sData.m_texturehandle);
|
||||
|
||||
GLint err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,sData.m_texturehandle);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
int width=256;
|
||||
int height=256;
|
||||
@ -150,12 +150,12 @@ void initTestTexture()
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width,height,0,GL_RED,GL_UNSIGNED_BYTE,image);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
free(image);
|
||||
|
||||
@ -206,19 +206,19 @@ void loadShader(){
|
||||
|
||||
sData.m_positionUniform = glGetUniformLocation(sData.m_shaderProg, "p");
|
||||
if (sData.m_positionUniform < 0) {
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
sData.m_colourAttribute = glGetAttribLocation(sData.m_shaderProg, "colour");
|
||||
if (sData.m_colourAttribute < 0) {
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
sData.m_positionAttribute = glGetAttribLocation(sData.m_shaderProg, "position");
|
||||
if (sData.m_positionAttribute < 0) {
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
sData.m_textureAttribute = glGetAttribLocation(sData.m_shaderProg,"texuv");
|
||||
if (sData.m_textureAttribute < 0) {
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
@ -227,7 +227,7 @@ void display() {
|
||||
|
||||
|
||||
GLint err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
const float timeScale = 0.008f;
|
||||
|
||||
@ -236,30 +236,30 @@ void display() {
|
||||
glBindVertexArray(sData.m_vertexArrayObject);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
// glBindTexture(GL_TEXTURE_2D,sData.m_texturehandle);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
vec2 p( 0.f,0.f);//?b?0.5f * sinf(timeValue), 0.5f * cosf(timeValue) );
|
||||
glUniform2fv(sData.m_positionUniform, 1, (const GLfloat *)&p);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(sData.m_positionAttribute);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(sData.m_colourAttribute);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glEnableVertexAttribArray(sData.m_textureAttribute);
|
||||
|
||||
@ -267,18 +267,18 @@ void display() {
|
||||
glVertexAttribPointer(sData.m_colourAttribute , 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)sizeof(vec4));
|
||||
glVertexAttribPointer(sData.m_textureAttribute , 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *)(sizeof(vec4)+sizeof(vec4)));
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, sData.m_indexBuffer);
|
||||
|
||||
//glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
int indexCount = 6;
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
// glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
// glutSwapBuffers();
|
||||
}
|
||||
@ -325,8 +325,8 @@ int main(int argc, char* argv[])
|
||||
printf("\n");
|
||||
|
||||
|
||||
btgDefaultOpenGLWindow* window = new btgDefaultOpenGLWindow();
|
||||
window->createWindow(btgWindowConstructionInfo(width,height));
|
||||
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
||||
window->createWindow(b3gWindowConstructionInfo(width,height));
|
||||
window->setWindowTitle("font test");
|
||||
|
||||
|
||||
@ -347,7 +347,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
// render.InitShaders();
|
||||
@ -356,12 +356,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
window->runMainLoop();
|
||||
|
||||
// window->setMouseCallback(btDefaultMouseCallback);
|
||||
// window->setKeyboardCallback(btDefaultKeyboardCallback);
|
||||
// window->setWheelCallback(btDefaultWheelCallback);
|
||||
// window->setMouseCallback(b3DefaultMouseCallback);
|
||||
// window->setKeyboardCallback(b3DefaultKeyboardCallback);
|
||||
// window->setWheelCallback(b3DefaultWheelCallback);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
int done;
|
||||
@ -381,7 +381,7 @@ int main(int argc, char* argv[])
|
||||
stash = sth_create(fontTextureWidth,fontTextureHeight,renderCallbacks);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
if (!stash)
|
||||
{
|
||||
@ -404,9 +404,9 @@ int main(int argc, char* argv[])
|
||||
#ifdef LOAD_FONT_FROM_FILE
|
||||
unsigned char* data;
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
btAssert(fp);
|
||||
b3Assert(fp);
|
||||
if (fp)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
@ -415,7 +415,7 @@ int main(int argc, char* argv[])
|
||||
data = (unsigned char*)malloc(datasize);
|
||||
if (data == NULL)
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@ -425,18 +425,18 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
if (!(droidRegular = sth_add_font_from_memory(stash, data)))
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return -1;
|
||||
}
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
// Load the remaining truetype fonts directly.
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Italic.ttf");
|
||||
|
||||
if (!(droidItalic = sth_add_font(stash,fullFontFileName)))
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return -1;
|
||||
}
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Bold.ttf");
|
||||
@ -444,20 +444,20 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (!(droidBold = sth_add_font(stash,fullFontFileName)))
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return -1;
|
||||
}
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSansJapanese.ttf");
|
||||
if (!(droidJapanese = sth_add_font(stash,fullFontFileName)))
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return -1;
|
||||
}
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
#else//LOAD_FONT_FROM_FILE
|
||||
char* data2 = OpenSansData;
|
||||
unsigned char* data = (unsigned char*) data2;
|
||||
@ -473,17 +473,17 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
CProfileManager::Reset();
|
||||
GLint err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
// glClearColor(0.5f,0.5f,0.5f,1.f);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
window->startRendering();
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glClearColor(1,1,1,1);//.4, .4, 0.4, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
@ -491,40 +491,40 @@ int main(int argc, char* argv[])
|
||||
//display();
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("font stash rendering");
|
||||
B3_PROFILE("font stash rendering");
|
||||
// Update and render
|
||||
glEnable(GL_BLEND);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
//glColor4ub(255,0,0,255);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
sx = 0; sy = height;
|
||||
|
||||
@ -548,7 +548,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
if (0)
|
||||
for (int i=0;i<1;i++)
|
||||
@ -558,7 +558,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
//need to save this file as UTF-8 without signature, codepage 650001 in Visual Studio
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
//sth_draw_text(stash, droidJapanese,16.f, dx, dy-36, (const char*) "\xE7\xA7\x81\xE3\x81\xAF\xE3\x82\xAC\xE3\x83\xA9\xE3\x82\xB9\xE3\x82\x92\xE9\xA3\x9F\xE3\x81\xB9\xE3\x82\x89\xE3\x82\x8C\xE3\x81\xBE\xE3\x81\x99\xE3\x80\x82",&dx,
|
||||
// width,height);//はabcdefghijlkmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_-+=?/\][{}.,<>`~@#$%^", &dx);
|
||||
@ -567,7 +567,7 @@ int main(int argc, char* argv[])
|
||||
dx = sx;
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
sth_flush_draw(stash);
|
||||
dx=0;
|
||||
sth_draw_text(stash, droidRegular,14.f, dx, dy-80, "How does this OpenGL True Type font look? ", &dx,width,height);
|
||||
@ -590,7 +590,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
sth_flush_draw(stash);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
} else
|
||||
@ -599,12 +599,12 @@ int main(int argc, char* argv[])
|
||||
dy = height;
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
sth_draw_texture(stash, droidRegular, 16.f, 0, 0,width,height, "a", &dx);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
dumpTextureToPng(fontTextureWidth, fontTextureHeight,"newPic.png");
|
||||
|
||||
@ -613,27 +613,27 @@ int main(int argc, char* argv[])
|
||||
once++;
|
||||
}
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
sth_end_draw(stash);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
//glFinish();
|
||||
}
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
window->endRendering();
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
{
|
||||
BT_PROFILE("glFinish");
|
||||
B3_PROFILE("glFinish");
|
||||
glFinish();
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
err = glGetError();
|
||||
btAssert(err==GL_NO_ERROR);
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
|
||||
stbi__sbpush(out, 0x78); // DEFLATE 32K window
|
||||
stbi__sbpush(out, 0x5e); // FLEVEL = 1
|
||||
stbi__zlib_add(1,1); // BFINAL = 1
|
||||
stbi__zlib_add(1,2); // BTYPE = 1 -- fixed huffman
|
||||
stbi__zlib_add(1,2); // B3YPE = 1 -- fixed huffman
|
||||
|
||||
for (i=0; i < stbi__ZHASH; ++i)
|
||||
hash_table[i] = NULL;
|
||||
|
@ -30,11 +30,11 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
|
||||
//#include "../../opencl/gpu_rigidbody_pipeline/btGpuNarrowphaseAndSolver.h"//for m_maxNumObjectCapacity
|
||||
//#include "../../opencl/gpu_rigidbody_pipeline/b3GpuNarrowphaseAndSolver.h"//for m_maxNumObjectCapacity
|
||||
|
||||
static InternalDataRenderer* sData2;
|
||||
|
||||
struct btGraphicsInstance
|
||||
struct b3GraphicsInstance
|
||||
{
|
||||
GLuint m_cube_vao;
|
||||
GLuint m_index_vbo;
|
||||
@ -49,7 +49,7 @@ struct btGraphicsInstance
|
||||
int m_vertexArrayOffset;
|
||||
int m_primitiveType;
|
||||
|
||||
btGraphicsInstance() :m_cube_vao(-1),m_index_vbo(-1),m_numIndices(-1),m_numVertices(-1),m_numGraphicsInstances(0),m_instanceOffset(0),m_vertexArrayOffset(0),m_primitiveType(BT_GL_TRIANGLES),m_texturehandle(0)
|
||||
b3GraphicsInstance() :m_cube_vao(-1),m_index_vbo(-1),m_numIndices(-1),m_numVertices(-1),m_numGraphicsInstances(0),m_instanceOffset(0),m_vertexArrayOffset(0),m_primitiveType(B3_GL_TRIANGLES),m_texturehandle(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
{
|
||||
if (!m_mouseButton)
|
||||
{
|
||||
if (btFabs(deltax)>btFabs(deltay))
|
||||
if (b3Fabs(deltax)>b3Fabs(deltay))
|
||||
{
|
||||
m_azi -= deltax*0.1;
|
||||
|
||||
@ -137,7 +137,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (btFabs(deltax)>btFabs(deltay))
|
||||
if (b3Fabs(deltax)>b3Fabs(deltay))
|
||||
{
|
||||
b3Vector3 fwd = m_cameraTargetPosition-m_cameraPosition;
|
||||
b3Vector3 side = m_cameraUp.cross(fwd);
|
||||
@ -158,7 +158,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
{
|
||||
float xDelta = x-m_mouseXpos;
|
||||
float yDelta = y-m_mouseYpos;
|
||||
// if (btFabs(xDelta)>btFabs(yDelta))
|
||||
// if (b3Fabs(xDelta)>b3Fabs(yDelta))
|
||||
// {
|
||||
m_azi += xDelta*0.1;
|
||||
// } else
|
||||
@ -191,23 +191,23 @@ struct GLInstanceRendererInternalData* GLInstancingRenderer::getInternalData()
|
||||
return m_data;
|
||||
}
|
||||
|
||||
void btDefaultWheelCallback(float deltax, float deltay)
|
||||
void b3DefaultWheelCallback(float deltax, float deltay)
|
||||
{
|
||||
if (sData2)
|
||||
sData2->wheelCallback(deltax,deltay);
|
||||
}
|
||||
void btDefaultMouseButtonCallback(int button, int state, float x, float y)
|
||||
void b3DefaultMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
if (sData2)
|
||||
sData2->mouseButtonCallback(button, state, x, y);
|
||||
}
|
||||
void btDefaultMouseMoveCallback( float x, float y)
|
||||
void b3DefaultMouseMoveCallback( float x, float y)
|
||||
{
|
||||
if (sData2)
|
||||
sData2->mouseMoveCallback( x, y);
|
||||
}
|
||||
|
||||
void btDefaultKeyboardCallback(int key, int state)
|
||||
void b3DefaultKeyboardCallback(int key, int state)
|
||||
{
|
||||
}
|
||||
|
||||
@ -535,11 +535,11 @@ void GLInstancingRenderer::writeSingleInstanceTransformToGPU(float* position, fl
|
||||
glFlush();
|
||||
|
||||
char* orgBase = (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_READ_WRITE);
|
||||
//btGraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
//b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
int totalNumInstances= 0;
|
||||
for (int k=0;k<m_graphicsInstances.size();k++)
|
||||
{
|
||||
btGraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
totalNumInstances+=gfxObj->m_numGraphicsInstances;
|
||||
}
|
||||
|
||||
@ -581,7 +581,7 @@ void GLInstancingRenderer::writeTransforms()
|
||||
|
||||
for (int k=0;k<m_graphicsInstances.size();k++)
|
||||
{
|
||||
btGraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
totalNumInstances+=gfxObj->m_numGraphicsInstances;
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ void GLInstancingRenderer::writeTransforms()
|
||||
for (int k=0;k<m_graphicsInstances.size();k++)
|
||||
{
|
||||
//int k=0;
|
||||
btGraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
|
||||
|
||||
|
||||
@ -654,10 +654,10 @@ void GLInstancingRenderer::writeTransforms()
|
||||
|
||||
int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
|
||||
{
|
||||
btAssert(shapeIndex == (m_graphicsInstances.size()-1));
|
||||
btAssert(m_graphicsInstances.size()<m_maxNumObjectCapacity-1);
|
||||
b3Assert(shapeIndex == (m_graphicsInstances.size()-1));
|
||||
b3Assert(m_graphicsInstances.size()<m_maxNumObjectCapacity-1);
|
||||
|
||||
btGraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||
|
||||
int index = gfxObj->m_numGraphicsInstances + gfxObj->m_instanceOffset;
|
||||
|
||||
@ -689,12 +689,12 @@ int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const float*
|
||||
|
||||
int GLInstancingRenderer::registerShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType)
|
||||
{
|
||||
btGraphicsInstance* gfxObj = new btGraphicsInstance;
|
||||
b3GraphicsInstance* gfxObj = new b3GraphicsInstance;
|
||||
gfxObj->m_primitiveType = primitiveType;
|
||||
|
||||
if (m_graphicsInstances.size())
|
||||
{
|
||||
btGraphicsInstance* prevObj = m_graphicsInstances[m_graphicsInstances.size()-1];
|
||||
b3GraphicsInstance* prevObj = m_graphicsInstances[m_graphicsInstances.size()-1];
|
||||
gfxObj->m_instanceOffset = prevObj->m_instanceOffset + prevObj->m_numGraphicsInstances;
|
||||
gfxObj->m_vertexArrayOffset = prevObj->m_vertexArrayOffset + prevObj->m_numVertices;
|
||||
} else
|
||||
@ -814,7 +814,7 @@ void GLInstancingRenderer::init()
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
{
|
||||
BT_PROFILE("texture");
|
||||
B3_PROFILE("texture");
|
||||
if(m_textureenabled)
|
||||
{
|
||||
if(!m_textureinitialized)
|
||||
@ -918,7 +918,7 @@ void GLInstancingRenderer::init()
|
||||
}
|
||||
|
||||
|
||||
void btCreateFrustum(
|
||||
void b3CreateFrustum(
|
||||
float left,
|
||||
float right,
|
||||
float bottom,
|
||||
@ -952,7 +952,7 @@ void btCreateFrustum(
|
||||
|
||||
|
||||
|
||||
void btCreateLookAt(const b3Vector3& eye, const b3Vector3& center,const b3Vector3& up, GLfloat result[16])
|
||||
void b3CreateLookAt(const b3Vector3& eye, const b3Vector3& center,const b3Vector3& up, GLfloat result[16])
|
||||
{
|
||||
b3Vector3 f = (center - eye).normalized();
|
||||
b3Vector3 u = up.normalized();
|
||||
@ -1049,13 +1049,13 @@ void GLInstancingRenderer::updateCamera()
|
||||
|
||||
if (m_glutScreenWidth > m_glutScreenHeight)
|
||||
{
|
||||
btCreateFrustum(-aspect * m_frustumZNear, aspect * m_frustumZNear, -m_frustumZNear, m_frustumZNear, m_frustumZNear, m_frustumZFar,projectionMatrix);
|
||||
b3CreateFrustum(-aspect * m_frustumZNear, aspect * m_frustumZNear, -m_frustumZNear, m_frustumZNear, m_frustumZNear, m_frustumZFar,projectionMatrix);
|
||||
} else
|
||||
{
|
||||
btCreateFrustum(-aspect * m_frustumZNear, aspect * m_frustumZNear, -m_frustumZNear, m_frustumZNear, m_frustumZNear, m_frustumZFar,projectionMatrix);
|
||||
b3CreateFrustum(-aspect * m_frustumZNear, aspect * m_frustumZNear, -m_frustumZNear, m_frustumZNear, m_frustumZNear, m_frustumZFar,projectionMatrix);
|
||||
}
|
||||
|
||||
btCreateLookAt(m_data->m_cameraPosition,m_data->m_cameraTargetPosition,m_data->m_cameraUp,modelviewMatrix);
|
||||
b3CreateLookAt(m_data->m_cameraPosition,m_data->m_cameraTargetPosition,m_data->m_cameraUp,modelviewMatrix);
|
||||
|
||||
|
||||
}
|
||||
@ -1108,7 +1108,7 @@ void GLInstancingRenderer::getMouseDirection(float* dir, int x, int y)
|
||||
float bottom = -1.f;
|
||||
float nearPlane = 1.f;
|
||||
float tanFov = (top-bottom)*0.5f / nearPlane;
|
||||
float fov = b3Scalar(2.0) * btAtan(tanFov);
|
||||
float fov = b3Scalar(2.0) * b3Atan(tanFov);
|
||||
|
||||
b3Vector3 rayFrom = m_data->m_cameraPosition;
|
||||
b3Vector3 rayForward = (m_data->m_cameraTargetPosition-m_data->m_cameraPosition);
|
||||
@ -1156,10 +1156,10 @@ void GLInstancingRenderer::getMouseDirection(float* dir, int x, int y)
|
||||
|
||||
void GLInstancingRenderer::RenderScene(void)
|
||||
{
|
||||
BT_PROFILE("GLInstancingRenderer::RenderScene");
|
||||
B3_PROFILE("GLInstancingRenderer::RenderScene");
|
||||
|
||||
{
|
||||
BT_PROFILE("init");
|
||||
B3_PROFILE("init");
|
||||
init();
|
||||
}
|
||||
|
||||
@ -1167,7 +1167,7 @@ void GLInstancingRenderer::RenderScene(void)
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
{
|
||||
BT_PROFILE("updateCamera");
|
||||
B3_PROFILE("updateCamera");
|
||||
updateCamera();
|
||||
}
|
||||
err = glGetError();
|
||||
@ -1200,7 +1200,7 @@ void GLInstancingRenderer::RenderScene(void)
|
||||
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
{
|
||||
BT_PROFILE("glFlush2");
|
||||
B3_PROFILE("glFlush2");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
|
||||
glFlush();
|
||||
@ -1226,7 +1226,7 @@ void GLInstancingRenderer::RenderScene(void)
|
||||
for (int i=0;i<m_graphicsInstances.size();i++)
|
||||
{
|
||||
|
||||
btGraphicsInstance* gfxObj = m_graphicsInstances[i];
|
||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[i];
|
||||
if (gfxObj->m_numGraphicsInstances)
|
||||
{
|
||||
// int myOffset = gfxObj->m_instanceOffset*4*sizeof(float);
|
||||
@ -1272,7 +1272,7 @@ void GLInstancingRenderer::RenderScene(void)
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("glFlush");
|
||||
B3_PROFILE("glFlush");
|
||||
glFlush();
|
||||
}
|
||||
|
||||
@ -1281,9 +1281,9 @@ void GLInstancingRenderer::RenderScene(void)
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gfxObj->m_index_vbo);
|
||||
{
|
||||
BT_PROFILE("glDrawElementsInstanced");
|
||||
B3_PROFILE("glDrawElementsInstanced");
|
||||
|
||||
if (gfxObj->m_primitiveType==BT_GL_POINTS)
|
||||
if (gfxObj->m_primitiveType==B3_GL_POINTS)
|
||||
{
|
||||
glUseProgram(instancingShaderPointSprite);
|
||||
glUniformMatrix4fv(ProjectionMatrixPointSprite, 1, false, &projectionMatrix[0]);
|
||||
@ -1321,7 +1321,7 @@ void GLInstancingRenderer::RenderScene(void)
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
{
|
||||
BT_PROFILE("glUseProgram(0);");
|
||||
B3_PROFILE("glUseProgram(0);");
|
||||
glUseProgram(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
glBindVertexArray(0);
|
||||
|
@ -18,21 +18,21 @@ subject to the following restrictions:
|
||||
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
|
||||
void btDefaultMouseButtonCallback( int button, int state, float x, float y);
|
||||
void btDefaultMouseMoveCallback( float x, float y);
|
||||
void btDefaultKeyboardCallback(int key, int state);
|
||||
void btDefaultWheelCallback( float deltax, float deltay);
|
||||
void b3DefaultMouseButtonCallback( int button, int state, float x, float y);
|
||||
void b3DefaultMouseMoveCallback( float x, float y);
|
||||
void b3DefaultKeyboardCallback(int key, int state);
|
||||
void b3DefaultWheelCallback( float deltax, float deltay);
|
||||
|
||||
enum
|
||||
{
|
||||
BT_GL_TRIANGLES = 1,
|
||||
BT_GL_POINTS
|
||||
B3_GL_TRIANGLES = 1,
|
||||
B3_GL_POINTS
|
||||
};
|
||||
|
||||
class GLInstancingRenderer
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<struct btGraphicsInstance*> m_graphicsInstances;
|
||||
b3AlignedObjectArray<struct b3GraphicsInstance*> m_graphicsInstances;
|
||||
|
||||
int m_maxNumObjectCapacity;
|
||||
int m_maxShapeCapacityInBytes;
|
||||
@ -54,7 +54,7 @@ public:
|
||||
void CleanupShaders();
|
||||
|
||||
///vertices must be in the format x,y,z, nx,ny,nz, u,v
|
||||
int registerShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType=BT_GL_TRIANGLES);
|
||||
int registerShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType=B3_GL_TRIANGLES);
|
||||
|
||||
///position x,y,z, quaternion x,y,z,w, color r,g,b,a, scaling x,y,z
|
||||
int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
|
||||
|
@ -1,22 +1,22 @@
|
||||
#ifndef MAC_OPENGL_WINDOW_H
|
||||
#define MAC_OPENGL_WINDOW_H
|
||||
|
||||
#include "btgWindowInterface.h"
|
||||
#include "b3gWindowInterface.h"
|
||||
|
||||
#define btgDefaultOpenGLWindow MacOpenGLWindow
|
||||
#define b3gDefaultOpenGLWindow MacOpenGLWindow
|
||||
|
||||
class MacOpenGLWindow : public btgWindowInterface
|
||||
class MacOpenGLWindow : public b3gWindowInterface
|
||||
{
|
||||
struct MacOpenGLWindowInternalData* m_internalData;
|
||||
float m_mouseX;
|
||||
float m_mouseY;
|
||||
|
||||
|
||||
btMouseButtonCallback m_mouseButtonCallback;
|
||||
btMouseMoveCallback m_mouseMoveCallback;
|
||||
btWheelCallback m_wheelCallback;
|
||||
btKeyboardCallback m_keyboardCallback;
|
||||
btRenderCallback m_renderCallback;
|
||||
b3MouseButtonCallback m_mouseButtonCallback;
|
||||
b3MouseMoveCallback m_mouseMoveCallback;
|
||||
b3WheelCallback m_wheelCallback;
|
||||
b3KeyboardCallback m_keyboardCallback;
|
||||
b3RenderCallback m_renderCallback;
|
||||
|
||||
float m_retinaScaleFactor;
|
||||
public:
|
||||
@ -40,28 +40,28 @@ public:
|
||||
|
||||
void runMainLoop();
|
||||
|
||||
void setMouseButtonCallback(btMouseButtonCallback mouseCallback)
|
||||
void setMouseButtonCallback(b3MouseButtonCallback mouseCallback)
|
||||
{
|
||||
m_mouseButtonCallback = mouseCallback;
|
||||
}
|
||||
|
||||
void setMouseMoveCallback(btMouseMoveCallback mouseCallback)
|
||||
void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)
|
||||
{
|
||||
m_mouseMoveCallback = mouseCallback;
|
||||
}
|
||||
|
||||
void setResizeCallback(btResizeCallback resizeCallback);
|
||||
void setResizeCallback(b3ResizeCallback resizeCallback);
|
||||
|
||||
void setKeyboardCallback( btKeyboardCallback keyboardCallback)
|
||||
void setKeyboardCallback( b3KeyboardCallback keyboardCallback)
|
||||
{
|
||||
m_keyboardCallback = keyboardCallback;
|
||||
}
|
||||
btKeyboardCallback getKeyboardCallback()
|
||||
b3KeyboardCallback getKeyboardCallback()
|
||||
{
|
||||
return m_keyboardCallback;
|
||||
}
|
||||
|
||||
void setWheelCallback (btWheelCallback wheelCallback)
|
||||
void setWheelCallback (b3WheelCallback wheelCallback)
|
||||
{
|
||||
m_wheelCallback = wheelCallback;
|
||||
}
|
||||
@ -71,13 +71,13 @@ public:
|
||||
return m_retinaScaleFactor;
|
||||
}
|
||||
|
||||
virtual void createWindow(const btgWindowConstructionInfo& ci);
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci);
|
||||
|
||||
virtual float getTimeInSeconds();
|
||||
|
||||
|
||||
|
||||
virtual void setRenderCallback( btRenderCallback renderCallback);
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||
|
||||
virtual void setWindowTitle(const char* title);
|
||||
|
||||
|
@ -26,11 +26,11 @@ struct InternalData2
|
||||
int m_mouseXpos;
|
||||
int m_mouseYpos;
|
||||
|
||||
btWheelCallback m_wheelCallback;
|
||||
btMouseMoveCallback m_mouseMoveCallback;
|
||||
btMouseButtonCallback m_mouseButtonCallback;
|
||||
btResizeCallback m_resizeCallback;
|
||||
btKeyboardCallback m_keyboardCallback;
|
||||
b3WheelCallback m_wheelCallback;
|
||||
b3MouseMoveCallback m_mouseMoveCallback;
|
||||
b3MouseButtonCallback m_mouseButtonCallback;
|
||||
b3ResizeCallback m_resizeCallback;
|
||||
b3KeyboardCallback m_keyboardCallback;
|
||||
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ void Win32OpenGLWindow::disableOpenGL()
|
||||
|
||||
|
||||
|
||||
void Win32OpenGLWindow::createWindow(const btgWindowConstructionInfo& ci)
|
||||
void Win32OpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
|
||||
{
|
||||
Win32Window::createWindow(ci);
|
||||
|
||||
|
@ -21,7 +21,7 @@ subject to the following restrictions:
|
||||
|
||||
#include "Win32Window.h"
|
||||
|
||||
#define btgDefaultOpenGLWindow Win32OpenGLWindow
|
||||
#define b3gDefaultOpenGLWindow Win32OpenGLWindow
|
||||
|
||||
class Win32OpenGLWindow : public Win32Window
|
||||
{
|
||||
@ -40,7 +40,7 @@ public:
|
||||
|
||||
virtual ~Win32OpenGLWindow();
|
||||
|
||||
virtual void createWindow(const btgWindowConstructionInfo& ci);
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci);
|
||||
|
||||
virtual void closeWindow();
|
||||
|
||||
|
@ -57,31 +57,31 @@ int getAsciiCodeFromVirtualKeycode(int virtualKeyCode)
|
||||
int keycode = 0xffffffff;
|
||||
switch (virtualKeyCode)
|
||||
{
|
||||
case VK_F1: {keycode = BTG_F1; break;}
|
||||
case VK_F2: {keycode = BTG_F2; break;}
|
||||
case VK_F3: {keycode = BTG_F3; break;}
|
||||
case VK_F4: {keycode = BTG_F4; break;}
|
||||
case VK_F5: {keycode = BTG_F5; break;}
|
||||
case VK_F6: {keycode = BTG_F6; break;}
|
||||
case VK_F7: {keycode = BTG_F7; break;}
|
||||
case VK_F8: {keycode = BTG_F8; break;}
|
||||
case VK_F9: {keycode = BTG_F9; break;}
|
||||
case VK_F10: {keycode= BTG_F10; break;}
|
||||
case VK_F1: {keycode = B3G_F1; break;}
|
||||
case VK_F2: {keycode = B3G_F2; break;}
|
||||
case VK_F3: {keycode = B3G_F3; break;}
|
||||
case VK_F4: {keycode = B3G_F4; break;}
|
||||
case VK_F5: {keycode = B3G_F5; break;}
|
||||
case VK_F6: {keycode = B3G_F6; break;}
|
||||
case VK_F7: {keycode = B3G_F7; break;}
|
||||
case VK_F8: {keycode = B3G_F8; break;}
|
||||
case VK_F9: {keycode = B3G_F9; break;}
|
||||
case VK_F10: {keycode= B3G_F10; break;}
|
||||
|
||||
case VK_SPACE: {keycode= ' '; break;}
|
||||
|
||||
case VK_NEXT: {keycode= BTG_PAGE_DOWN; break;}
|
||||
case VK_PRIOR: {keycode= BTG_PAGE_UP; break;}
|
||||
case VK_NEXT: {keycode= B3G_PAGE_DOWN; break;}
|
||||
case VK_PRIOR: {keycode= B3G_PAGE_UP; break;}
|
||||
|
||||
case VK_INSERT: {keycode= BTG_INSERT; break;}
|
||||
case VK_DELETE: {keycode= BTG_DELETE; break;}
|
||||
case VK_INSERT: {keycode= B3G_INSERT; break;}
|
||||
case VK_DELETE: {keycode= B3G_DELETE; break;}
|
||||
|
||||
case VK_END:{keycode= BTG_END; break;}
|
||||
case VK_HOME:{keycode= BTG_HOME; break;}
|
||||
case VK_LEFT:{keycode= BTG_LEFT_ARROW; break;}
|
||||
case VK_UP:{keycode= BTG_UP_ARROW; break;}
|
||||
case VK_RIGHT:{keycode= BTG_RIGHT_ARROW; break;}
|
||||
case VK_DOWN:{keycode= BTG_DOWN_ARROW; break;}
|
||||
case VK_END:{keycode= B3G_END; break;}
|
||||
case VK_HOME:{keycode= B3G_HOME; break;}
|
||||
case VK_LEFT:{keycode= B3G_LEFT_ARROW; break;}
|
||||
case VK_UP:{keycode= B3G_UP_ARROW; break;}
|
||||
case VK_RIGHT:{keycode= B3G_RIGHT_ARROW; break;}
|
||||
case VK_DOWN:{keycode= B3G_DOWN_ARROW; break;}
|
||||
default:
|
||||
{
|
||||
keycode = MapVirtualKey( virtualKeyCode, MAPVK_VK_TO_CHAR ) & 0x0000FFFF;
|
||||
@ -332,7 +332,7 @@ void Win32Window::setWindowTitle(const char* titleChar)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Win32Window::createWindow(const btgWindowConstructionInfo& ci)
|
||||
void Win32Window::createWindow(const b3gWindowConstructionInfo& ci)
|
||||
{
|
||||
int oglViewportWidth = ci.m_width;
|
||||
int oglViewportHeight = ci.m_height;
|
||||
@ -570,7 +570,7 @@ Win32Window::~Win32Window()
|
||||
|
||||
}
|
||||
|
||||
void Win32Window::setRenderCallback( btRenderCallback renderCallback)
|
||||
void Win32Window::setRenderCallback( b3RenderCallback renderCallback)
|
||||
{
|
||||
|
||||
}
|
||||
@ -643,35 +643,35 @@ bool Win32Window::requestedExit() const
|
||||
return m_data->m_quit;
|
||||
}
|
||||
|
||||
void Win32Window::setWheelCallback(btWheelCallback wheelCallback)
|
||||
void Win32Window::setWheelCallback(b3WheelCallback wheelCallback)
|
||||
{
|
||||
m_data->m_wheelCallback = wheelCallback;
|
||||
}
|
||||
|
||||
void Win32Window::setMouseMoveCallback(btMouseMoveCallback mouseCallback)
|
||||
void Win32Window::setMouseMoveCallback(b3MouseMoveCallback mouseCallback)
|
||||
{
|
||||
m_data->m_mouseMoveCallback = mouseCallback;
|
||||
}
|
||||
|
||||
void Win32Window::setMouseButtonCallback(btMouseButtonCallback mouseCallback)
|
||||
void Win32Window::setMouseButtonCallback(b3MouseButtonCallback mouseCallback)
|
||||
{
|
||||
m_data->m_mouseButtonCallback = mouseCallback;
|
||||
}
|
||||
|
||||
void Win32Window::setResizeCallback(btResizeCallback resizeCallback)
|
||||
void Win32Window::setResizeCallback(b3ResizeCallback resizeCallback)
|
||||
{
|
||||
m_data->m_resizeCallback = resizeCallback;
|
||||
if (m_data->m_resizeCallback)
|
||||
(*m_data->m_resizeCallback)(m_data->m_openglViewportWidth,m_data->m_openglViewportHeight);
|
||||
}
|
||||
|
||||
void Win32Window::setKeyboardCallback( btKeyboardCallback keyboardCallback)
|
||||
void Win32Window::setKeyboardCallback( b3KeyboardCallback keyboardCallback)
|
||||
{
|
||||
m_data->m_keyboardCallback = keyboardCallback;
|
||||
|
||||
}
|
||||
|
||||
btKeyboardCallback Win32Window::getKeyboardCallback()
|
||||
b3KeyboardCallback Win32Window::getKeyboardCallback()
|
||||
{
|
||||
return m_data->m_keyboardCallback;
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ subject to the following restrictions:
|
||||
|
||||
struct InternalData2;
|
||||
|
||||
#include "btgWindowInterface.h"
|
||||
#include "b3gWindowInterface.h"
|
||||
|
||||
class Win32Window : public btgWindowInterface
|
||||
class Win32Window : public b3gWindowInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
@ -40,7 +40,7 @@ public:
|
||||
|
||||
virtual ~Win32Window();
|
||||
|
||||
virtual void createWindow(const btgWindowConstructionInfo& ci);
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci);
|
||||
|
||||
virtual void switchFullScreen(bool fullscreen,int width=0,int height=0,int colorBitsPerPixel=0);
|
||||
|
||||
@ -64,15 +64,15 @@ public:
|
||||
|
||||
virtual void getMouseCoordinates(int& x, int& y);
|
||||
|
||||
virtual void setMouseMoveCallback(btMouseMoveCallback mouseCallback);
|
||||
virtual void setMouseButtonCallback(btMouseButtonCallback mouseCallback);
|
||||
virtual void setResizeCallback(btResizeCallback resizeCallback);
|
||||
virtual void setWheelCallback(btWheelCallback wheelCallback);
|
||||
virtual void setKeyboardCallback( btKeyboardCallback keyboardCallback);
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback);
|
||||
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback);
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback);
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback);
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
|
||||
|
||||
virtual btKeyboardCallback getKeyboardCallback();
|
||||
virtual b3KeyboardCallback getKeyboardCallback();
|
||||
|
||||
virtual void setRenderCallback( btRenderCallback renderCallback);
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||
|
||||
virtual void setWindowTitle(const char* title);
|
||||
};
|
||||
|
@ -23,11 +23,11 @@ struct InternalData2
|
||||
XWindowAttributes m_gwa;
|
||||
XEvent m_xev;
|
||||
|
||||
btWheelCallback m_wheelCallback;
|
||||
btMouseMoveCallback m_mouseMoveCallback;
|
||||
btMouseButtonCallback m_mouseButtonCallback;
|
||||
btResizeCallback m_resizeCallback;
|
||||
btKeyboardCallback m_keyboardCallback;
|
||||
b3WheelCallback m_wheelCallback;
|
||||
b3MouseMoveCallback m_mouseMoveCallback;
|
||||
b3MouseButtonCallback m_mouseButtonCallback;
|
||||
b3ResizeCallback m_resizeCallback;
|
||||
b3KeyboardCallback m_keyboardCallback;
|
||||
|
||||
InternalData2()
|
||||
:m_dpy(0),
|
||||
@ -89,7 +89,7 @@ void X11OpenGLWindow::disableOpenGL()
|
||||
}
|
||||
|
||||
|
||||
void X11OpenGLWindow::createWindow(const btgWindowConstructionInfo& ci)
|
||||
void X11OpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
|
||||
{
|
||||
m_data->m_dpy = XOpenDisplay(NULL);
|
||||
|
||||
@ -139,23 +139,23 @@ int X11OpenGLWindow::getAsciiCodeFromVirtualKeycode(int keycode)
|
||||
key = XKeycodeToKeysym( m_data->m_dpy, keycode, 0 );
|
||||
switch( key )
|
||||
{
|
||||
case XK_Escape: return BTG_ESCAPE;
|
||||
case XK_Escape: return B3G_ESCAPE;
|
||||
|
||||
case XK_F1: return BTG_F1;
|
||||
case XK_F2: return BTG_F2;
|
||||
case XK_F3: return BTG_F3;
|
||||
case XK_F4: return BTG_F4;
|
||||
case XK_F5: return BTG_F5;
|
||||
case XK_F6: return BTG_F6;
|
||||
case XK_F7: return BTG_F7;
|
||||
case XK_F8: return BTG_F8;
|
||||
case XK_F9: return BTG_F9;
|
||||
case XK_F10: return BTG_F10;
|
||||
case XK_F11: return BTG_F11;
|
||||
case XK_F12: return BTG_F12;
|
||||
case XK_F13: return BTG_F13;
|
||||
case XK_F14: return BTG_F14;
|
||||
case XK_F15: return BTG_F15;
|
||||
case XK_F1: return B3G_F1;
|
||||
case XK_F2: return B3G_F2;
|
||||
case XK_F3: return B3G_F3;
|
||||
case XK_F4: return B3G_F4;
|
||||
case XK_F5: return B3G_F5;
|
||||
case XK_F6: return B3G_F6;
|
||||
case XK_F7: return B3G_F7;
|
||||
case XK_F8: return B3G_F8;
|
||||
case XK_F9: return B3G_F9;
|
||||
case XK_F10: return B3G_F10;
|
||||
case XK_F11: return B3G_F11;
|
||||
case XK_F12: return B3G_F12;
|
||||
case XK_F13: return B3G_F13;
|
||||
case XK_F14: return B3G_F14;
|
||||
case XK_F15: return B3G_F15;
|
||||
default:
|
||||
// Make uppercase
|
||||
XConvertCase( key, &key_lc, &key_uc );
|
||||
@ -377,7 +377,7 @@ void X11OpenGLWindow::setRequestExit()
|
||||
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::setRenderCallback( btRenderCallback renderCallback)
|
||||
void X11OpenGLWindow::setRenderCallback( b3RenderCallback renderCallback)
|
||||
{
|
||||
|
||||
}
|
||||
@ -388,27 +388,27 @@ void X11OpenGLWindow::setWindowTitle(const char* title)
|
||||
}
|
||||
|
||||
|
||||
void X11OpenGLWindow::setWheelCallback(btWheelCallback wheelCallback)
|
||||
void X11OpenGLWindow::setWheelCallback(b3WheelCallback wheelCallback)
|
||||
{
|
||||
m_data->m_wheelCallback = wheelCallback;
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::setMouseMoveCallback(btMouseMoveCallback mouseCallback)
|
||||
void X11OpenGLWindow::setMouseMoveCallback(b3MouseMoveCallback mouseCallback)
|
||||
{
|
||||
m_data->m_mouseMoveCallback = mouseCallback;
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::setMouseButtonCallback(btMouseButtonCallback mouseCallback)
|
||||
void X11OpenGLWindow::setMouseButtonCallback(b3MouseButtonCallback mouseCallback)
|
||||
{
|
||||
m_data->m_mouseButtonCallback = mouseCallback;
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::setResizeCallback(btResizeCallback resizeCallback)
|
||||
void X11OpenGLWindow::setResizeCallback(b3ResizeCallback resizeCallback)
|
||||
{
|
||||
m_data->m_resizeCallback = resizeCallback;
|
||||
}
|
||||
|
||||
void X11OpenGLWindow::setKeyboardCallback( btKeyboardCallback keyboardCallback)
|
||||
void X11OpenGLWindow::setKeyboardCallback( b3KeyboardCallback keyboardCallback)
|
||||
{
|
||||
m_data->m_keyboardCallback = keyboardCallback;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#ifndef X11_OPENGL_WINDOW_H
|
||||
#define X11_OPENGL_WINDOW_H
|
||||
|
||||
#define btgDefaultOpenGLWindow X11OpenGLWindow
|
||||
#define b3gDefaultOpenGLWindow X11OpenGLWindow
|
||||
|
||||
#include "btgWindowInterface.h"
|
||||
#include "b3gWindowInterface.h"
|
||||
|
||||
class X11OpenGLWindow : public btgWindowInterface
|
||||
class X11OpenGLWindow : public b3gWindowInterface
|
||||
{
|
||||
|
||||
struct InternalData2* m_data;
|
||||
@ -27,7 +27,7 @@ public:
|
||||
|
||||
virtual ~X11OpenGLWindow();
|
||||
|
||||
virtual void createWindow(const btgWindowConstructionInfo& ci);
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci);
|
||||
|
||||
virtual void closeWindow();
|
||||
|
||||
@ -47,13 +47,13 @@ public:
|
||||
virtual void setRequestExit() ;
|
||||
|
||||
|
||||
virtual void setMouseMoveCallback(btMouseMoveCallback mouseCallback);
|
||||
virtual void setMouseButtonCallback(btMouseButtonCallback mouseCallback);
|
||||
virtual void setResizeCallback(btResizeCallback resizeCallback);
|
||||
virtual void setWheelCallback(btWheelCallback wheelCallback);
|
||||
virtual void setKeyboardCallback( btKeyboardCallback keyboardCallback);
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback);
|
||||
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback);
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback);
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback);
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
|
||||
|
||||
virtual void setRenderCallback( btRenderCallback renderCallback);
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||
|
||||
virtual void setWindowTitle(const char* title);
|
||||
|
||||
|
109
btgui/OpenGLWindow/b3gWindowInterface.h
Normal file
109
btgui/OpenGLWindow/b3gWindowInterface.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef B3G_WINDOW_INTERFACE_H
|
||||
#define B3G_WINDOW_INTERFACE_H
|
||||
|
||||
|
||||
typedef void (*b3WheelCallback)(float deltax, float deltay);
|
||||
typedef void (*b3ResizeCallback)( float width, float height);
|
||||
typedef void (*b3MouseMoveCallback)( float x, float y);
|
||||
typedef void (*b3MouseButtonCallback)(int button, int state, float x, float y);
|
||||
typedef void (*b3KeyboardCallback)(int keycode, int state);
|
||||
typedef void (*b3RenderCallback) ();
|
||||
|
||||
enum {
|
||||
B3G_ESCAPE = 27,
|
||||
B3G_F1 = 0xff00,
|
||||
B3G_F2,
|
||||
B3G_F3,
|
||||
B3G_F4,
|
||||
B3G_F5,
|
||||
B3G_F6,
|
||||
B3G_F7,
|
||||
B3G_F8,
|
||||
B3G_F9,
|
||||
B3G_F10,
|
||||
B3G_F11,
|
||||
B3G_F12,
|
||||
B3G_F13,
|
||||
B3G_F14,
|
||||
B3G_F15,
|
||||
B3G_LEFT_ARROW,
|
||||
B3G_RIGHT_ARROW,
|
||||
B3G_UP_ARROW,
|
||||
B3G_DOWN_ARROW,
|
||||
B3G_PAGE_UP,
|
||||
B3G_PAGE_DOWN,
|
||||
B3G_END,
|
||||
B3G_HOME,
|
||||
B3G_INSERT,
|
||||
B3G_DELETE
|
||||
};
|
||||
|
||||
struct b3gWindowConstructionInfo
|
||||
{
|
||||
int m_width;
|
||||
int m_height;
|
||||
bool m_fullscreen;
|
||||
int m_colorBitsPerPixel;
|
||||
void* m_windowHandle;
|
||||
const char* m_title;
|
||||
int m_openglVersion;
|
||||
|
||||
b3gWindowConstructionInfo(int width=1024, int height=768)
|
||||
:m_width(width),
|
||||
m_height(height),
|
||||
m_fullscreen(false),
|
||||
m_colorBitsPerPixel(32),
|
||||
m_windowHandle(0),
|
||||
m_title("title"),
|
||||
m_openglVersion(3)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class b3gWindowInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~b3gWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void createDefaultWindow(int width, int height, const char* title)
|
||||
{
|
||||
b3gWindowConstructionInfo ci(width,height);
|
||||
ci.m_title = title;
|
||||
createWindow(ci);
|
||||
}
|
||||
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci)=0;
|
||||
|
||||
virtual void closeWindow()=0;
|
||||
|
||||
virtual void runMainLoop()=0;
|
||||
virtual float getTimeInSeconds()=0;
|
||||
|
||||
virtual bool requestedExit() const = 0;
|
||||
virtual void setRequestExit() = 0;
|
||||
|
||||
virtual void startRendering()=0;
|
||||
|
||||
virtual void endRendering()=0;
|
||||
|
||||
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)=0;
|
||||
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback)=0;
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback)=0;
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback)=0;
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback)=0;
|
||||
virtual b3KeyboardCallback getKeyboardCallback()=0;
|
||||
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback) = 0;
|
||||
|
||||
virtual void setWindowTitle(const char* title)=0;
|
||||
|
||||
virtual float getRetinaScale() const =0;
|
||||
|
||||
};
|
||||
|
||||
#endif //B3G_WINDOW_INTERFACE_H
|
@ -1,109 +0,0 @@
|
||||
#ifndef BTG_WINDOW_INTERFACE_H
|
||||
#define BTG_WINDOW_INTERFACE_H
|
||||
|
||||
|
||||
typedef void (*btWheelCallback)(float deltax, float deltay);
|
||||
typedef void (*btResizeCallback)( float width, float height);
|
||||
typedef void (*btMouseMoveCallback)( float x, float y);
|
||||
typedef void (*btMouseButtonCallback)(int button, int state, float x, float y);
|
||||
typedef void (*btKeyboardCallback)(int keycode, int state);
|
||||
typedef void (*btRenderCallback) ();
|
||||
|
||||
enum {
|
||||
BTG_ESCAPE = 27,
|
||||
BTG_F1 = 0xff00,
|
||||
BTG_F2,
|
||||
BTG_F3,
|
||||
BTG_F4,
|
||||
BTG_F5,
|
||||
BTG_F6,
|
||||
BTG_F7,
|
||||
BTG_F8,
|
||||
BTG_F9,
|
||||
BTG_F10,
|
||||
BTG_F11,
|
||||
BTG_F12,
|
||||
BTG_F13,
|
||||
BTG_F14,
|
||||
BTG_F15,
|
||||
BTG_LEFT_ARROW,
|
||||
BTG_RIGHT_ARROW,
|
||||
BTG_UP_ARROW,
|
||||
BTG_DOWN_ARROW,
|
||||
BTG_PAGE_UP,
|
||||
BTG_PAGE_DOWN,
|
||||
BTG_END,
|
||||
BTG_HOME,
|
||||
BTG_INSERT,
|
||||
BTG_DELETE
|
||||
};
|
||||
|
||||
struct btgWindowConstructionInfo
|
||||
{
|
||||
int m_width;
|
||||
int m_height;
|
||||
bool m_fullscreen;
|
||||
int m_colorBitsPerPixel;
|
||||
void* m_windowHandle;
|
||||
const char* m_title;
|
||||
int m_openglVersion;
|
||||
|
||||
btgWindowConstructionInfo(int width=1024, int height=768)
|
||||
:m_width(width),
|
||||
m_height(height),
|
||||
m_fullscreen(false),
|
||||
m_colorBitsPerPixel(32),
|
||||
m_windowHandle(0),
|
||||
m_title("title"),
|
||||
m_openglVersion(3)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class btgWindowInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~btgWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void createDefaultWindow(int width, int height, const char* title)
|
||||
{
|
||||
btgWindowConstructionInfo ci(width,height);
|
||||
ci.m_title = title;
|
||||
createWindow(ci);
|
||||
}
|
||||
|
||||
virtual void createWindow(const btgWindowConstructionInfo& ci)=0;
|
||||
|
||||
virtual void closeWindow()=0;
|
||||
|
||||
virtual void runMainLoop()=0;
|
||||
virtual float getTimeInSeconds()=0;
|
||||
|
||||
virtual bool requestedExit() const = 0;
|
||||
virtual void setRequestExit() = 0;
|
||||
|
||||
virtual void startRendering()=0;
|
||||
|
||||
virtual void endRendering()=0;
|
||||
|
||||
|
||||
virtual void setMouseMoveCallback(btMouseMoveCallback mouseCallback)=0;
|
||||
virtual void setMouseButtonCallback(btMouseButtonCallback mouseCallback)=0;
|
||||
virtual void setResizeCallback(btResizeCallback resizeCallback)=0;
|
||||
virtual void setWheelCallback(btWheelCallback wheelCallback)=0;
|
||||
virtual void setKeyboardCallback( btKeyboardCallback keyboardCallback)=0;
|
||||
virtual btKeyboardCallback getKeyboardCallback()=0;
|
||||
|
||||
virtual void setRenderCallback( btRenderCallback renderCallback) = 0;
|
||||
|
||||
virtual void setWindowTitle(const char* title)=0;
|
||||
|
||||
virtual float getRetinaScale() const =0;
|
||||
|
||||
};
|
||||
|
||||
#endif //BTG_WINDOW_INTERFACE_H
|
@ -72,7 +72,7 @@ void Usage()
|
||||
|
||||
void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
//btDefaultMouseCallback(button,state,x,y);
|
||||
//b3DefaultMouseCallback(button,state,x,y);
|
||||
|
||||
if (pCanvas)
|
||||
{
|
||||
@ -106,7 +106,7 @@ void MyResizeCallback(float width, float height)
|
||||
|
||||
void MyMouseMoveCallback( float x, float y)
|
||||
{
|
||||
//btDefaultMouseCallback(button,state,x,y);
|
||||
//b3DefaultMouseCallback(button,state,x,y);
|
||||
|
||||
static int m_lastmousepos[2] = {0,0};
|
||||
static bool isInitialized = false;
|
||||
@ -278,8 +278,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
printf("\n");
|
||||
btgDefaultOpenGLWindow* window = new btgDefaultOpenGLWindow();
|
||||
btgWindowConstructionInfo wci;
|
||||
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
||||
b3gWindowConstructionInfo wci;
|
||||
wci.m_width = g_OpenGLWidth;
|
||||
wci.m_height = g_OpenGLHeight;
|
||||
|
||||
@ -320,8 +320,8 @@ int main(int argc, char* argv[])
|
||||
window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||
window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
window->setResizeCallback(MyResizeCallback);
|
||||
window->setKeyboardCallback(btDefaultKeyboardCallback);
|
||||
window->setWheelCallback(btDefaultWheelCallback);
|
||||
window->setKeyboardCallback(b3DefaultKeyboardCallback);
|
||||
window->setWheelCallback(b3DefaultWheelCallback);
|
||||
|
||||
|
||||
//GLPrimitiveRenderer* pprender = new GLPrimitiveRenderer(g_OpenGLWidth,g_OpenGLHeight);
|
||||
@ -350,13 +350,13 @@ int main(int argc, char* argv[])
|
||||
CProfileManager::Reset();
|
||||
|
||||
{
|
||||
BT_PROFILE("loop");
|
||||
B3_PROFILE("loop");
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("startRendering");
|
||||
B3_PROFILE("startRendering");
|
||||
window->startRendering();
|
||||
}
|
||||
render.RenderScene();
|
||||
@ -371,7 +371,7 @@ int main(int argc, char* argv[])
|
||||
float dx=0;
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("font sth_draw_text");
|
||||
B3_PROFILE("font sth_draw_text");
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
GLint err = glGetError();
|
||||
@ -400,7 +400,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("gwen RenderCanvas");
|
||||
B3_PROFILE("gwen RenderCanvas");
|
||||
|
||||
if (pCanvas)
|
||||
{
|
||||
@ -488,7 +488,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
count = 100;
|
||||
{
|
||||
//BT_PROFILE("processProfileData");
|
||||
//B3_PROFILE("processProfileData");
|
||||
processProfileData(m_profileIterator,false);
|
||||
}
|
||||
//CProfileManager::dumpAll();
|
||||
|
@ -46,7 +46,7 @@ struct GraphicsShape
|
||||
|
||||
struct InstanceGroup
|
||||
{
|
||||
// Bullet::btCollisionShapeData* m_shape;
|
||||
// Bullet::b3CollisionShapeData* m_shape;
|
||||
int m_collisionShapeIndex;
|
||||
|
||||
// b3AlignedObjectArray<bParse::bStructHandle*> m_rigidBodies;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "Bullet2GpuDemo.h"
|
||||
#include "../btGpuDynamicsWorld.h"
|
||||
#include "../b3GpuDynamicsWorld.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
#include "gpu_rigidbody/host/btRigidBody.h"
|
||||
#include "BulletCollision/CollisionShapes/b3BoxShape.h"
|
||||
#include "gpu_rigidbody/host/b3RigidBody.h"
|
||||
|
||||
void Bullet2GpuDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
@ -10,14 +10,14 @@ void Bullet2GpuDemo::setupScene(const ConstructionInfo& ci)
|
||||
// m_data->m_np = np;
|
||||
// m_data->m_bp = bp;
|
||||
// m_data->m_rigidBodyPipeline
|
||||
m_gpuDynamicsWorld = new btGpuDynamicsWorld(m_data->m_bp,m_data->m_np,m_data->m_rigidBodyPipeline);
|
||||
m_gpuDynamicsWorld = new b3GpuDynamicsWorld(m_data->m_bp,m_data->m_np,m_data->m_rigidBodyPipeline);
|
||||
|
||||
btVector3 halfExtents(100,1,100);
|
||||
btBoxShape* boxShape = new btBoxShape(halfExtents);
|
||||
btVector3 localInertia;
|
||||
btScalar mass=1.f;
|
||||
b3Vector3 halfExtents(100,1,100);
|
||||
b3BoxShape* boxShape = new b3BoxShape(halfExtents);
|
||||
b3Vector3 localInertia;
|
||||
b3Scalar mass=1.f;
|
||||
boxShape->calculateLocalInertia(mass,localInertia);
|
||||
btRigidBody* body = new btRigidBody(mass,0,boxShape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(mass,0,boxShape,localInertia);
|
||||
m_gpuDynamicsWorld->addRigidBody(body);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ class Bullet2GpuDemo : public GpuRigidBodyDemo
|
||||
{
|
||||
protected:
|
||||
|
||||
class btGpuDynamicsWorld* m_gpuDynamicsWorld;
|
||||
class b3GpuDynamicsWorld* m_gpuDynamicsWorld;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -14,8 +14,8 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
|
||||
#include "btCpuDynamicsWorld.h"
|
||||
#include "btGpuDynamicsWorld.h"
|
||||
#include "b3CpuDynamicsWorld.h"
|
||||
#include "b3GpuDynamicsWorld.h"
|
||||
|
||||
|
||||
#define SCALING 1.
|
||||
@ -27,20 +27,20 @@ subject to the following restrictions:
|
||||
|
||||
#include "GpuDemo.h"
|
||||
//#include "GlutStuff.h"
|
||||
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
|
||||
//#include "btBulletDynamicsCommon.h"
|
||||
///b3BulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
|
||||
//#include "b3BulletDynamicsCommon.h"
|
||||
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
|
||||
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3TriangleMesh.h"
|
||||
#include "BulletCollision/CollisionShapes/b3BvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3SphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3ConvexHullShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3BoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3CompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3StaticPlaneShape.h"
|
||||
|
||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||
#include "LinearMath/btDefaultMotionState.h"
|
||||
#include "BulletDynamics/Dynamics/b3RigidBody.h"
|
||||
#include "LinearMath/b3DefaultMotionState.h"
|
||||
#include "LinearMath/b3Quickprof.h"
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ void GpuDemo::clientMoveAndDisplay()
|
||||
if (once)
|
||||
{
|
||||
once=false;
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
b3DefaultSerializer* serializer = new b3DefaultSerializer();
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
FILE* file = fopen("testFile.bullet","wb");
|
||||
@ -103,7 +103,7 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
if (1)
|
||||
{
|
||||
btSphereShape* sphere = new btSphereShape(1);
|
||||
b3SphereShape* sphere = new b3SphereShape(1);
|
||||
m_collisionShapes.push_back(sphere);
|
||||
|
||||
/// Create Dynamic Objects
|
||||
@ -129,9 +129,9 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
float gapZ =ci.gapZ;
|
||||
for(int j = 0;j<sizeZ;j++)
|
||||
{
|
||||
//btCollisionShape* shape = k==0? boxShape : colShape;
|
||||
//b3CollisionShape* shape = k==0? boxShape : colShape;
|
||||
|
||||
btCollisionShape* shape = sphere;
|
||||
b3CollisionShape* shape = sphere;
|
||||
|
||||
|
||||
b3Scalar mass = 1;
|
||||
@ -152,9 +152,9 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
b3DefaultMotionState* myMotionState = new b3DefaultMotionState(startTransform);
|
||||
b3RigidBody::b3RigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(rbInfo);
|
||||
|
||||
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@ -167,10 +167,10 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
b3Vector3 planeNormal(0,1,0);
|
||||
b3Scalar planeConstant=0;
|
||||
|
||||
btCollisionShape* shape = new btStaticPlaneShape(planeNormal,planeConstant);
|
||||
//btBoxShape* plane = new btBoxShape(b3Vector3(100,1,100));
|
||||
b3CollisionShape* shape = new b3StaticPlaneShape(planeNormal,planeConstant);
|
||||
//b3BoxShape* plane = new b3BoxShape(b3Vector3(100,1,100));
|
||||
//plane->initializePolyhedralFeatures();
|
||||
//btSphereShape* shape = new btSphereShape(1000);
|
||||
//b3SphereShape* shape = new b3SphereShape(1000);
|
||||
|
||||
b3Scalar mass(0.);
|
||||
|
||||
@ -184,9 +184,9 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
groundTransform.setOrigin(b3Vector3(0,0,0));
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
b3DefaultMotionState* myMotionState = new b3DefaultMotionState(groundTransform);
|
||||
b3RigidBody::b3RigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(rbInfo);
|
||||
|
||||
//add the body to the dynamics world
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@ -197,12 +197,12 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
btCollisionShape* groundShape =0;
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
b3CollisionShape* groundShape =0;
|
||||
// b3CollisionShape* groundShape = new b3StaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
|
||||
if (ci.m_useConcaveMesh)
|
||||
{
|
||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||
b3TriangleMesh* meshInterface = new b3TriangleMesh();
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> concaveVertices;
|
||||
concaveVertices.push_back(b3Vector3(0,-20,0));
|
||||
@ -217,16 +217,16 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[4],concaveVertices[1],true);
|
||||
|
||||
#if 0
|
||||
groundShape = new btBvhTriangleMeshShape(meshInterface,true);//btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
groundShape = new b3BvhTriangleMeshShape(meshInterface,true);//b3StaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
#else
|
||||
btBoxShape* shape =new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(10.),b3Scalar(250.)));
|
||||
b3BoxShape* shape =new b3BoxShape(b3Vector3(b3Scalar(250.),b3Scalar(10.),b3Scalar(250.)));
|
||||
shape->initializePolyhedralFeatures();
|
||||
groundShape = shape;
|
||||
#endif
|
||||
|
||||
} else
|
||||
{
|
||||
groundShape = new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(50.),b3Scalar(250.)));
|
||||
groundShape = new b3BoxShape(b3Vector3(b3Scalar(250.),b3Scalar(50.),b3Scalar(250.)));
|
||||
}
|
||||
|
||||
m_collisionShapes.push_back(groundShape);
|
||||
@ -248,9 +248,9 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
groundShape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
b3DefaultMotionState* myMotionState = new b3DefaultMotionState(groundTransform);
|
||||
b3RigidBody::b3RigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(rbInfo);
|
||||
|
||||
//add the body to the dynamics world
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@ -272,14 +272,14 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
vertices.push_back(b3Vector3(-1,-1,1));
|
||||
|
||||
#if 0
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
b3PolyhedralConvexShape* colShape = new b3ConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
colShape->initializePolyhedralFeatures();
|
||||
#else
|
||||
btCompoundShape* compoundShape = 0;
|
||||
b3CompoundShape* compoundShape = 0;
|
||||
{
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
b3PolyhedralConvexShape* colShape = new b3ConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
colShape->initializePolyhedralFeatures();
|
||||
compoundShape = new btCompoundShape();
|
||||
compoundShape = new b3CompoundShape();
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(b3Vector3(0,-1,0));
|
||||
@ -289,18 +289,18 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
tr.setOrigin(b3Vector3(2,0,0));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
}
|
||||
btCollisionShape* colShape = compoundShape;
|
||||
b3CollisionShape* colShape = compoundShape;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
btPolyhedralConvexShape* boxShape = new btBoxShape(b3Vector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
b3PolyhedralConvexShape* boxShape = new b3BoxShape(b3Vector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
boxShape->initializePolyhedralFeatures();
|
||||
|
||||
|
||||
|
||||
|
||||
//btCollisionShape* colShape = new btSphereShape(b3Scalar(1.));
|
||||
//b3CollisionShape* colShape = new b3SphereShape(b3Scalar(1.));
|
||||
m_collisionShapes.push_back(colShape);
|
||||
m_collisionShapes.push_back(boxShape);
|
||||
|
||||
@ -329,9 +329,9 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
float gapZ = !ci.m_useConcaveMesh&&k==0? 3.05 : ci.gapZ;
|
||||
for(int j = 0;j<sizeZ;j++)
|
||||
{
|
||||
//btCollisionShape* shape = k==0? boxShape : colShape;
|
||||
//b3CollisionShape* shape = k==0? boxShape : colShape;
|
||||
|
||||
btCollisionShape* shape = colShape;
|
||||
b3CollisionShape* shape = colShape;
|
||||
|
||||
|
||||
b3Scalar mass = 1;
|
||||
@ -352,9 +352,9 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
b3DefaultMotionState* myMotionState = new b3DefaultMotionState(startTransform);
|
||||
b3RigidBody::b3RigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(rbInfo);
|
||||
|
||||
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@ -368,12 +368,12 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
btCollisionShape* groundShape =0;
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
b3CollisionShape* groundShape =0;
|
||||
// b3CollisionShape* groundShape = new b3StaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
|
||||
if (ci.m_useConcaveMesh)
|
||||
{
|
||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||
b3TriangleMesh* meshInterface = new b3TriangleMesh();
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> concaveVertices;
|
||||
concaveVertices.push_back(b3Vector3(0,-20,0));
|
||||
@ -388,16 +388,16 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[4],concaveVertices[1],true);
|
||||
|
||||
#if 0
|
||||
groundShape = new btBvhTriangleMeshShape(meshInterface,true);//btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
groundShape = new b3BvhTriangleMeshShape(meshInterface,true);//b3StaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
#else
|
||||
btBoxShape* shape =new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(10.),b3Scalar(250.)));
|
||||
b3BoxShape* shape =new b3BoxShape(b3Vector3(b3Scalar(250.),b3Scalar(10.),b3Scalar(250.)));
|
||||
shape->initializePolyhedralFeatures();
|
||||
groundShape = shape;
|
||||
#endif
|
||||
|
||||
} else
|
||||
{
|
||||
groundShape = new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(50.),b3Scalar(250.)));
|
||||
groundShape = new b3BoxShape(b3Vector3(b3Scalar(250.),b3Scalar(50.),b3Scalar(250.)));
|
||||
}
|
||||
|
||||
m_collisionShapes.push_back(groundShape);
|
||||
@ -419,9 +419,9 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
groundShape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
b3DefaultMotionState* myMotionState = new b3DefaultMotionState(groundTransform);
|
||||
b3RigidBody::b3RigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(rbInfo);
|
||||
|
||||
//add the body to the dynamics world
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@ -443,14 +443,14 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
vertices.push_back(b3Vector3(-1,-1,1));
|
||||
|
||||
#if 1
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
b3PolyhedralConvexShape* colShape = new b3ConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
colShape->initializePolyhedralFeatures();
|
||||
#else
|
||||
btCompoundShape* compoundShape = 0;
|
||||
b3CompoundShape* compoundShape = 0;
|
||||
{
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
b3PolyhedralConvexShape* colShape = new b3ConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
colShape->initializePolyhedralFeatures();
|
||||
compoundShape = new btCompoundShape();
|
||||
compoundShape = new b3CompoundShape();
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(b3Vector3(0,-1,0));
|
||||
@ -460,18 +460,18 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
tr.setOrigin(b3Vector3(2,0,0));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
}
|
||||
btCollisionShape* colShape = compoundShape;
|
||||
b3CollisionShape* colShape = compoundShape;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
btPolyhedralConvexShape* boxShape = new btBoxShape(b3Vector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
b3PolyhedralConvexShape* boxShape = new b3BoxShape(b3Vector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
boxShape->initializePolyhedralFeatures();
|
||||
|
||||
|
||||
|
||||
|
||||
//btCollisionShape* colShape = new btSphereShape(b3Scalar(1.));
|
||||
//b3CollisionShape* colShape = new b3SphereShape(b3Scalar(1.));
|
||||
m_collisionShapes.push_back(colShape);
|
||||
m_collisionShapes.push_back(boxShape);
|
||||
|
||||
@ -500,9 +500,9 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
float gapZ = !ci.m_useConcaveMesh&&k==0? 3.05 : ci.gapZ;
|
||||
for(int j = 0;j<sizeZ;j++)
|
||||
{
|
||||
//btCollisionShape* shape = k==0? boxShape : colShape;
|
||||
//b3CollisionShape* shape = k==0? boxShape : colShape;
|
||||
|
||||
btCollisionShape* shape = colShape;
|
||||
b3CollisionShape* shape = colShape;
|
||||
|
||||
|
||||
b3Scalar mass = 1;
|
||||
@ -523,9 +523,9 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
b3DefaultMotionState* myMotionState = new b3DefaultMotionState(startTransform);
|
||||
b3RigidBody::b3RigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
|
||||
b3RigidBody* body = new b3RigidBody(rbInfo);
|
||||
|
||||
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
@ -546,10 +546,10 @@ void GpuDemo::initPhysics(const ConstructionInfo& ci)
|
||||
///collision configuration contains default setup for memory, collision setup
|
||||
if (ci.useOpenCL)
|
||||
{
|
||||
m_dynamicsWorld = new btGpuDynamicsWorld(ci.preferredOpenCLPlatformIndex,ci.preferredOpenCLDeviceIndex);
|
||||
m_dynamicsWorld = new b3GpuDynamicsWorld(ci.preferredOpenCLPlatformIndex,ci.preferredOpenCLDeviceIndex);
|
||||
} else
|
||||
{
|
||||
m_dynamicsWorld = new btCpuDynamicsWorld();
|
||||
m_dynamicsWorld = new b3CpuDynamicsWorld();
|
||||
}
|
||||
|
||||
|
||||
@ -581,8 +581,8 @@ void GpuDemo::exitPhysics()
|
||||
{
|
||||
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
|
||||
{
|
||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||
btRigidBody* body = btRigidBody::upcast(obj);
|
||||
b3CollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||
b3RigidBody* body = b3RigidBody::upcast(obj);
|
||||
if (body && body->getMotionState())
|
||||
{
|
||||
delete body->getMotionState();
|
||||
@ -595,7 +595,7 @@ void GpuDemo::exitPhysics()
|
||||
//delete collision shapes
|
||||
for (int j=0;j<m_collisionShapes.size();j++)
|
||||
{
|
||||
btCollisionShape* shape = m_collisionShapes[j];
|
||||
b3CollisionShape* shape = m_collisionShapes[j];
|
||||
delete shape;
|
||||
}
|
||||
m_collisionShapes.clear();
|
||||
|
@ -19,14 +19,14 @@ subject to the following restrictions:
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
|
||||
|
||||
class btBroadphaseInterface;
|
||||
class btCollisionShape;
|
||||
class b3BroadphaseInterface;
|
||||
class b3CollisionShape;
|
||||
class b3OverlappingPairCache;
|
||||
class btCollisionDispatcher;
|
||||
class btConstraintSolver;
|
||||
struct btCollisionAlgorithmCreateFunc;
|
||||
class btDefaultCollisionConfiguration;
|
||||
class btDynamicsWorld;
|
||||
class b3CollisionDispatcher;
|
||||
class b3ConstraintSolver;
|
||||
struct b3CollisionAlgorithmCreateFunc;
|
||||
class b3DefaultCollisionConfiguration;
|
||||
class b3DynamicsWorld;
|
||||
class GLInstancingRenderer;
|
||||
|
||||
///GpuDemo is good starting point for learning the code base and porting.
|
||||
@ -38,10 +38,10 @@ class GpuDemo
|
||||
|
||||
protected:
|
||||
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
b3DynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
b3AlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
b3AlignedObjectArray<b3CollisionShape*> m_collisionShapes;
|
||||
|
||||
float getDeltaTimeInSeconds()
|
||||
{
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
virtual void exitPhysics();
|
||||
|
||||
virtual const btDynamicsWorld* getDynamicsWorld() const
|
||||
virtual const b3DynamicsWorld* getDynamicsWorld() const
|
||||
{
|
||||
return m_dynamicsWorld;
|
||||
}
|
||||
|
@ -2,18 +2,18 @@
|
||||
#include "OpenGL3CoreRenderer.h"
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
//#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
//#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||
//#include "BulletDynamics/Dynamics/b3DiscreteDynamicsWorld.h"
|
||||
//#include "BulletCollision/CollisionDispatch/b3CollisionObject.h"
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
|
||||
/*#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||
/*#include "BulletCollision/CollisionShapes/b3BvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3ConvexPolyhedron.h"
|
||||
#include "BulletCollision/CollisionShapes/b3ConvexHullShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3CollisionShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3BoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3CompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3SphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3StaticPlaneShape.h"
|
||||
|
||||
#include "../../rendering/WavefrontObjLoader/objLoader.h"
|
||||
*/
|
||||
@ -61,7 +61,7 @@ struct GraphicsShape
|
||||
|
||||
|
||||
|
||||
GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilPtr)
|
||||
GraphicsShape* createGraphicsShapeFromConvexHull(const b3ConvexPolyhedron* utilPtr)
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
@ -71,7 +71,7 @@ GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilP
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
for (int f=0;f<utilPtr->m_faces.size();f++)
|
||||
{
|
||||
const btFace& face = utilPtr->m_faces[f];
|
||||
const b3Face& face = utilPtr->m_faces[f];
|
||||
b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (face.m_indices.size()>2)
|
||||
{
|
||||
@ -124,7 +124,7 @@ GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilP
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
GraphicsShape* createGraphicsShapeFromCompoundShape(b3CompoundShape* compound)
|
||||
{
|
||||
GraphicsShape* gfxShape = new GraphicsShape();
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertexArray = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
@ -135,13 +135,13 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
//create a graphics shape for each child, combine them into a single graphics shape using their child transforms
|
||||
for (int i=0;i<compound->getNumChildShapes();i++)
|
||||
{
|
||||
btAssert(compound->getChildShape(i)->isPolyhedral());
|
||||
b3Assert(compound->getChildShape(i)->isPolyhedral());
|
||||
if (compound->getChildShape(i)->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* convexHull = (btPolyhedralConvexShape*) compound->getChildShape(i);
|
||||
b3PolyhedralConvexShape* convexHull = (b3PolyhedralConvexShape*) compound->getChildShape(i);
|
||||
b3Transform tr = compound->getChildTransform(i);
|
||||
|
||||
const btConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
const b3ConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
GraphicsShape* childGfxShape = createGraphicsShapeFromConvexHull(polyhedron);
|
||||
int baseIndex = vertexArray->size();
|
||||
|
||||
@ -173,8 +173,8 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
}
|
||||
}
|
||||
|
||||
btPolyhedralConvexShape* convexHull = (btPolyhedralConvexShape*) compound->getChildShape(0);
|
||||
const btConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
b3PolyhedralConvexShape* convexHull = (b3PolyhedralConvexShape*) compound->getChildShape(0);
|
||||
const b3ConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
GraphicsShape* childGfxShape = createGraphicsShapeFromConvexHull(polyhedron);
|
||||
|
||||
gfxShape->m_indices = &indexArray->at(0);
|
||||
@ -189,7 +189,7 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
return gfxShape;
|
||||
}
|
||||
|
||||
GraphicsShape* createGraphicsShapeFromConcaveMesh(const btBvhTriangleMeshShape* trimesh)
|
||||
GraphicsShape* createGraphicsShapeFromConcaveMesh(const b3BvhTriangleMeshShape* trimesh)
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
@ -425,15 +425,15 @@ GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
|
||||
|
||||
//very incomplete conversion from physics to graphics
|
||||
void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOnly, int numObjects, btCollisionObject** colObjArray)
|
||||
void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOnly, int numObjects, b3CollisionObject** colObjArray)
|
||||
{
|
||||
///@todo: we need to sort the objects based on collision shape type, so we can share instances
|
||||
BT_PROFILE("graphics_from_physics");
|
||||
B3_PROFILE("graphics_from_physics");
|
||||
|
||||
int strideInBytes = sizeof(float)*9;
|
||||
|
||||
int prevGraphicsShapeIndex = -1;
|
||||
btCollisionShape* prevShape = 0;
|
||||
b3CollisionShape* prevShape = 0;
|
||||
|
||||
|
||||
int numColObj = numObjects;
|
||||
@ -444,7 +444,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
|
||||
for (int i=0;i<numColObj;i++)
|
||||
{
|
||||
btCollisionObject* colObj = colObjArray[i];
|
||||
b3CollisionObject* colObj = colObjArray[i];
|
||||
|
||||
b3Vector3 pos = colObj->getWorldTransform().getOrigin();
|
||||
b3Quaternion orn = colObj->getWorldTransform().getRotation();
|
||||
@ -470,8 +470,8 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
if (colObj->getCollisionShape()->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* polyShape = (btPolyhedralConvexShape*)colObj->getCollisionShape();
|
||||
const btConvexPolyhedron* pol = polyShape->getConvexPolyhedron();
|
||||
b3PolyhedralConvexShape* polyShape = (b3PolyhedralConvexShape*)colObj->getCollisionShape();
|
||||
const b3ConvexPolyhedron* pol = polyShape->getConvexPolyhedron();
|
||||
GraphicsShape* gfxShape = createGraphicsShapeFromConvexHull(pol);
|
||||
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&gfxShape->m_vertices[0],gfxShape->m_numvertices,gfxShape->m_indices,gfxShape->m_numIndices);
|
||||
@ -482,7 +482,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
if (colObj->getCollisionShape()->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*) colObj->getCollisionShape();
|
||||
b3BvhTriangleMeshShape* trimesh = (b3BvhTriangleMeshShape*) colObj->getCollisionShape();
|
||||
GraphicsShape* gfxShape = createGraphicsShapeFromConcaveMesh(trimesh);
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&gfxShape->m_vertices[0],gfxShape->m_numvertices,gfxShape->m_indices,gfxShape->m_numIndices);
|
||||
prevShape = colObj->getCollisionShape();
|
||||
@ -492,7 +492,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
if (colObj->getCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btCompoundShape* compound = (btCompoundShape*) colObj->getCollisionShape();
|
||||
b3CompoundShape* compound = (b3CompoundShape*) colObj->getCollisionShape();
|
||||
GraphicsShape* gfxShape = createGraphicsShapeFromCompoundShape(compound);
|
||||
if (gfxShape)
|
||||
{
|
||||
@ -508,11 +508,11 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
if (colObj->getCollisionShape()->getShapeType()==SPHERE_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btSphereShape* sphere = (btSphereShape*) colObj->getCollisionShape();
|
||||
b3SphereShape* sphere = (b3SphereShape*) colObj->getCollisionShape();
|
||||
b3Scalar radius = sphere->getRadius();
|
||||
|
||||
//btConvexHullShape* spherePoly = new btConvexHullShape(
|
||||
//const btConvexPolyhedron* pol = polyShape->getConvexPolyhedron();
|
||||
//b3ConvexHullShape* spherePoly = new b3ConvexHullShape(
|
||||
//const b3ConvexPolyhedron* pol = polyShape->getConvexPolyhedron();
|
||||
|
||||
/*
|
||||
objLoader loader;
|
||||
@ -572,7 +572,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,BT_GL_POINTS);
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
if (radius>=10)
|
||||
@ -599,7 +599,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
if (colObj->getCollisionShape()->getShapeType()==STATIC_PLANE_PROXYTYPE)
|
||||
{
|
||||
btStaticPlaneShape* plane= (btStaticPlaneShape*) colObj->getCollisionShape();
|
||||
b3StaticPlaneShape* plane= (b3StaticPlaneShape*) colObj->getCollisionShape();
|
||||
prevShape = colObj->getCollisionShape();
|
||||
|
||||
//plane->getPlaneNormal()
|
||||
@ -624,7 +624,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
printf("Error: unsupported collision shape type in %s %d\n", __FILE__, __LINE__);
|
||||
prevGraphicsShapeIndex = -1;
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -660,7 +660,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
|
||||
|
||||
|
||||
void OpenGL3CoreRenderer::renderPhysicsWorld(int numObjects, btCollisionObject** colObjArray, bool syncOnly)
|
||||
void OpenGL3CoreRenderer::renderPhysicsWorld(int numObjects, b3CollisionObject** colObjArray, bool syncOnly)
|
||||
{
|
||||
//sync changes from physics world to render world
|
||||
//for now, we don't deal with adding/removing objects to the world during the simulation, to keep the rendererer simpler
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef OPENGL3_CORE_RENDERER_H
|
||||
#define OPENGL3_CORE_RENDERER_H
|
||||
|
||||
class btCollisionObject;
|
||||
class b3CollisionObject;
|
||||
class GLInstancingRenderer;
|
||||
|
||||
class OpenGL3CoreRenderer
|
||||
@ -14,7 +14,7 @@ public:
|
||||
void init();
|
||||
void reshape(int w, int h);
|
||||
void keyboardCallback(unsigned char key);
|
||||
void renderPhysicsWorld(int numObjects, btCollisionObject** colObjArray, bool syncOnly);
|
||||
void renderPhysicsWorld(int numObjects, b3CollisionObject** colObjArray, bool syncOnly);
|
||||
|
||||
GLInstancingRenderer* getInstancingRenderer()
|
||||
{
|
||||
|
17
demo/donttouch/b3CpuDynamicsWorld.cpp
Normal file
17
demo/donttouch/b3CpuDynamicsWorld.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "b3CpuDynamicsWorld.h"
|
||||
|
||||
#include "b3BulletDynamicsCommon.h"
|
||||
|
||||
b3CpuDynamicsWorld::b3CpuDynamicsWorld()
|
||||
:b3DiscreteDynamicsWorld(
|
||||
new b3CollisionDispatcher(new b3DefaultCollisionConfiguration()),
|
||||
new b3DynamicBvhBroadphase(),new b3SequentialImpulseConstraintSolver(),
|
||||
new b3DefaultCollisionConfiguration()//todo: remove this!
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
b3CpuDynamicsWorld::~b3CpuDynamicsWorld()
|
||||
{
|
||||
|
||||
}
|
24
demo/donttouch/b3CpuDynamicsWorld.h
Normal file
24
demo/donttouch/b3CpuDynamicsWorld.h
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef B3_CPU_DYNAMICS_WORLD_H
|
||||
#define B3_CPU_DYNAMICS_WORLD_H
|
||||
|
||||
class b3DefaultCollisionConfiguration;
|
||||
class b3CollisionDispatcher;
|
||||
struct b3DynamicBvhBroadphase;
|
||||
class b3SequentialImpulseConstraintSolver;
|
||||
|
||||
#include "BulletDynamics/Dynamics/b3DiscreteDynamicsWorld.h"
|
||||
|
||||
class b3CpuDynamicsWorld : public b3DiscreteDynamicsWorld
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
b3CpuDynamicsWorld();
|
||||
|
||||
virtual ~b3CpuDynamicsWorld();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //B3_CPU_DYNAMICS_WORLD_H
|
@ -1,13 +1,13 @@
|
||||
#include "btGpuDynamicsWorld.h"
|
||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||
#include "b3GpuDynamicsWorld.h"
|
||||
#include "BulletDynamics/Dynamics/b3RigidBody.h"
|
||||
|
||||
#include "../../../opencl/gpu_rigidbody_pipeline2/CLPhysicsDemo.h"
|
||||
#include "../../../opencl/gpu_rigidbody_pipeline/btGpuNarrowPhaseAndSolver.h"
|
||||
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||
#include "../../../opencl/gpu_rigidbody_pipeline/b3GpuNarrowPhaseAndSolver.h"
|
||||
#include "BulletCollision/CollisionShapes/b3PolyhedralConvexShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3BvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3CompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3SphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/b3StaticPlaneShape.h"
|
||||
|
||||
#include "LinearMath/b3Quickprof.h"
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
|
||||
|
||||
|
||||
btGpuDynamicsWorld::btGpuDynamicsWorld(int preferredOpenCLPlatformIndex,int preferredOpenCLDeviceIndex)
|
||||
:btDynamicsWorld(0,0,0),
|
||||
b3GpuDynamicsWorld::b3GpuDynamicsWorld(int preferredOpenCLPlatformIndex,int preferredOpenCLDeviceIndex)
|
||||
:b3DynamicsWorld(0,0,0),
|
||||
m_gravity(0,-10,0),
|
||||
m_once(true)
|
||||
{
|
||||
@ -29,12 +29,12 @@ m_once(true)
|
||||
m_gpuPhysics->init(preferredOpenCLDeviceIndex,preferredOpenCLPlatformIndex,useInterop);
|
||||
}
|
||||
|
||||
btGpuDynamicsWorld::~btGpuDynamicsWorld()
|
||||
b3GpuDynamicsWorld::~b3GpuDynamicsWorld()
|
||||
{
|
||||
delete m_gpuPhysics;
|
||||
}
|
||||
|
||||
void btGpuDynamicsWorld::exitOpenCL()
|
||||
void b3GpuDynamicsWorld::exitOpenCL()
|
||||
{
|
||||
}
|
||||
|
||||
@ -43,13 +43,13 @@ void btGpuDynamicsWorld::exitOpenCL()
|
||||
|
||||
|
||||
|
||||
int btGpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Scalar fixedTimeStep)
|
||||
int b3GpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Scalar fixedTimeStep)
|
||||
{
|
||||
#ifndef BT_NO_PROFILE
|
||||
#ifndef B3_NO_PROFILE
|
||||
// CProfileManager::Reset();
|
||||
#endif //BT_NO_PROFILE
|
||||
#endif //B3_NO_PROFILE
|
||||
|
||||
BT_PROFILE("stepSimulation");
|
||||
B3_PROFILE("stepSimulation");
|
||||
|
||||
//convert all shapes now, and if any change, reset all (todo)
|
||||
|
||||
@ -63,14 +63,14 @@ int btGpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Sc
|
||||
|
||||
{
|
||||
{
|
||||
BT_PROFILE("readbackBodiesToCpu");
|
||||
B3_PROFILE("readbackBodiesToCpu");
|
||||
//now copy info back to rigid bodies....
|
||||
m_gpuPhysics->readbackBodiesToCpu();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("scatter transforms into rigidbody (CPU)");
|
||||
B3_PROFILE("scatter transforms into rigidbody (CPU)");
|
||||
for (int i=0;i<this->m_collisionObjects.size();i++)
|
||||
{
|
||||
b3Vector3 pos;
|
||||
@ -85,20 +85,20 @@ int btGpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Sc
|
||||
}
|
||||
|
||||
|
||||
#ifndef BT_NO_PROFILE
|
||||
#ifndef B3_NO_PROFILE
|
||||
//CProfileManager::Increment_Frame_Counter();
|
||||
#endif //BT_NO_PROFILE
|
||||
#endif //B3_NO_PROFILE
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void btGpuDynamicsWorld::setGravity(const b3Vector3& gravity)
|
||||
void b3GpuDynamicsWorld::setGravity(const b3Vector3& gravity)
|
||||
{
|
||||
}
|
||||
|
||||
int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* colShape)
|
||||
int b3GpuDynamicsWorld::findOrRegisterCollisionShape(const b3CollisionShape* colShape)
|
||||
{
|
||||
int index = m_uniqueShapes.findLinearSearch(colShape);
|
||||
if (index==m_uniqueShapes.size())
|
||||
@ -107,7 +107,7 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
{
|
||||
m_uniqueShapes.push_back(colShape);
|
||||
|
||||
btPolyhedralConvexShape* convex = (btPolyhedralConvexShape*)colShape;
|
||||
b3PolyhedralConvexShape* convex = (b3PolyhedralConvexShape*)colShape;
|
||||
int numVertices=convex->getNumVertices();
|
||||
|
||||
int strideInBytes=sizeof(b3Vector3);
|
||||
@ -126,7 +126,7 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
{
|
||||
m_uniqueShapes.push_back(colShape);
|
||||
|
||||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*) colShape;
|
||||
b3BvhTriangleMeshShape* trimesh = (b3BvhTriangleMeshShape*) colShape;
|
||||
b3StridingMeshInterface* meshInterface = trimesh->getMeshInterface();
|
||||
b3AlignedObjectArray<b3Vector3> vertices;
|
||||
b3AlignedObjectArray<int> indices;
|
||||
@ -181,9 +181,9 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
indices.push_back(indices.size());
|
||||
}
|
||||
}
|
||||
//GraphicsShape* gfxShape = 0;//btBulletDataExtractor::createGraphicsShapeFromWavefrontObj(objData);
|
||||
//GraphicsShape* gfxShape = 0;//b3BulletDataExtractor::createGraphicsShapeFromWavefrontObj(objData);
|
||||
|
||||
//GraphicsShape* gfxShape = btBulletDataExtractor::createGraphicsShapeFromConvexHull(&sUnitSpherePoints[0],MY_UNITSPHERE_POINTS);
|
||||
//GraphicsShape* gfxShape = b3BulletDataExtractor::createGraphicsShapeFromConvexHull(&sUnitSpherePoints[0],MY_UNITSPHERE_POINTS);
|
||||
float meshScaling[4] = {1,1,1,1};
|
||||
//int shapeIndex = renderer.registerShape(gfxShape->m_vertices,gfxShape->m_numvertices,gfxShape->m_indices,gfxShape->m_numIndices);
|
||||
float groundPos[4] = {0,0,0,0};
|
||||
@ -195,9 +195,9 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
m_uniqueShapeMapping.push_back(gpuShapeIndex);
|
||||
} else
|
||||
{
|
||||
printf("Error: no vertices in mesh in btGpuDynamicsWorld::addRigidBody\n");
|
||||
printf("Error: no vertices in mesh in b3GpuDynamicsWorld::addRigidBody\n");
|
||||
index = -1;
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
|
||||
@ -206,14 +206,14 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
if (colShape->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
|
||||
{
|
||||
|
||||
btCompoundShape* compound = (btCompoundShape*) colShape;
|
||||
b3AlignedObjectArray<btGpuChildShape> childShapes;
|
||||
b3CompoundShape* compound = (b3CompoundShape*) colShape;
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
|
||||
for (int i=0;i<compound->getNumChildShapes();i++)
|
||||
{
|
||||
//for now, only support polyhedral child shapes
|
||||
btAssert(compound->getChildShape(i)->isPolyhedral());
|
||||
btGpuChildShape child;
|
||||
b3Assert(compound->getChildShape(i)->isPolyhedral());
|
||||
b3GpuChildShape child;
|
||||
child.m_shapeIndex = findOrRegisterCollisionShape(compound->getChildShape(i));
|
||||
b3Vector3 pos = compound->getChildTransform(i).getOrigin();
|
||||
b3Quaternion orn = compound->getChildTransform(i).getRotation();
|
||||
@ -233,16 +233,16 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
|
||||
|
||||
|
||||
/*printf("Error: unsupported compound type (%d) in btGpuDynamicsWorld::addRigidBody\n",colShape->getShapeType());
|
||||
/*printf("Error: unsupported compound type (%d) in b3GpuDynamicsWorld::addRigidBody\n",colShape->getShapeType());
|
||||
index = -1;
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
*/
|
||||
} else
|
||||
{
|
||||
if (colShape->getShapeType()==SPHERE_SHAPE_PROXYTYPE)
|
||||
{
|
||||
m_uniqueShapes.push_back(colShape);
|
||||
btSphereShape* sphere = (btSphereShape*)colShape;
|
||||
b3SphereShape* sphere = (b3SphereShape*)colShape;
|
||||
|
||||
int gpuShapeIndex = m_gpuPhysics->registerSphereShape(sphere->getRadius());
|
||||
m_uniqueShapeMapping.push_back(gpuShapeIndex);
|
||||
@ -251,15 +251,15 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
if (colShape->getShapeType()==STATIC_PLANE_PROXYTYPE)
|
||||
{
|
||||
m_uniqueShapes.push_back(colShape);
|
||||
btStaticPlaneShape* plane = (btStaticPlaneShape*)colShape;
|
||||
b3StaticPlaneShape* plane = (b3StaticPlaneShape*)colShape;
|
||||
|
||||
int gpuShapeIndex = m_gpuPhysics->registerPlaneShape(plane->getPlaneNormal(),plane->getPlaneConstant());
|
||||
m_uniqueShapeMapping.push_back(gpuShapeIndex);
|
||||
} else
|
||||
{
|
||||
printf("Error: unsupported shape type (%d) in btGpuDynamicsWorld::addRigidBody\n",colShape->getShapeType());
|
||||
printf("Error: unsupported shape type (%d) in b3GpuDynamicsWorld::addRigidBody\n",colShape->getShapeType());
|
||||
index = -1;
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,7 +271,7 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
return index;
|
||||
}
|
||||
|
||||
void btGpuDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
void b3GpuDynamicsWorld::addRigidBody(b3RigidBody* body)
|
||||
{
|
||||
|
||||
body->setMotionState(0);
|
||||
@ -292,9 +292,9 @@ void btGpuDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
}
|
||||
}
|
||||
|
||||
void btGpuDynamicsWorld::removeCollisionObject(btCollisionObject* colObj)
|
||||
void b3GpuDynamicsWorld::removeCollisionObject(b3CollisionObject* colObj)
|
||||
{
|
||||
btDynamicsWorld::removeCollisionObject(colObj);
|
||||
b3DynamicsWorld::removeCollisionObject(colObj);
|
||||
}
|
||||
|
||||
|
109
demo/donttouch/b3GpuDynamicsWorld.h
Normal file
109
demo/donttouch/b3GpuDynamicsWorld.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef B3_GPU_DYNAMICS_WORLD_H
|
||||
#define B3_GPU_DYNAMICS_WORLD_H
|
||||
|
||||
class b3Vector3;
|
||||
class b3RigidBody;
|
||||
class b3CollisionObject;
|
||||
struct b3GpuInternalData;//use this struct to avoid 'leaking' all OpenCL headers into clients code base
|
||||
class CLPhysicsDemo;
|
||||
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
//#include "BulletDynamics/Dynamics/b3DynamicsWorld.h"
|
||||
|
||||
|
||||
class b3GpuDynamicsWorld //: public b3DynamicsWorld
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<const class b3CollisionShape*> m_uniqueShapes;
|
||||
b3AlignedObjectArray<int> m_uniqueShapeMapping;
|
||||
|
||||
|
||||
CLPhysicsDemo* m_gpuPhysics;
|
||||
b3Vector3 m_gravity;
|
||||
bool m_once;
|
||||
|
||||
bool initOpenCL(int preferredDeviceIndex, int preferredPlatformIndex, bool useInterop);
|
||||
void exitOpenCL();
|
||||
|
||||
int findOrRegisterCollisionShape(const b3CollisionShape* colShape);
|
||||
|
||||
|
||||
public:
|
||||
b3GpuDynamicsWorld(int preferredOpenCLPlatformIndex,int preferredOpenCLDeviceIndex);
|
||||
|
||||
virtual ~b3GpuDynamicsWorld();
|
||||
|
||||
virtual int stepSimulation( b3Scalar timeStep,int maxSubSteps=1, b3Scalar fixedTimeStep=b3Scalar(1.)/b3Scalar(60.));
|
||||
|
||||
virtual void synchronizeMotionStates()
|
||||
{
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
void debugDrawWorld() {}
|
||||
|
||||
void setGravity(const b3Vector3& gravity);
|
||||
|
||||
void addRigidBody(b3RigidBody* body);
|
||||
|
||||
void removeCollisionObject(b3CollisionObject* colObj);
|
||||
|
||||
|
||||
|
||||
b3AlignedObjectArray<class b3CollisionObject*>& getCollisionObjectArray();
|
||||
|
||||
const b3AlignedObjectArray<class b3CollisionObject*>& getCollisionObjectArray() const;
|
||||
|
||||
virtual void addAction(b3ActionInterface* action)
|
||||
{
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
virtual void removeAction(b3ActionInterface* action)
|
||||
{
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
|
||||
b3Vector3 getGravity () const
|
||||
{
|
||||
return m_gravity;
|
||||
}
|
||||
|
||||
virtual void addRigidBody(b3RigidBody* body, short group, short mask)
|
||||
{
|
||||
addRigidBody(body);
|
||||
}
|
||||
|
||||
virtual void removeRigidBody(b3RigidBody* body)
|
||||
{
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
virtual void setConstraintSolver(b3ConstraintSolver* solver)
|
||||
{
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
virtual b3ConstraintSolver* getConstraintSolver()
|
||||
{
|
||||
b3Assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual b3DynamicsWorldType getWorldType() const
|
||||
{
|
||||
return B3_GPU_PHYSICS_WORLD;
|
||||
}
|
||||
|
||||
virtual void clearForces()
|
||||
{
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //B3_GPU_DYNAMICS_WORLD_H
|
@ -1,17 +0,0 @@
|
||||
#include "btCpuDynamicsWorld.h"
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
btCpuDynamicsWorld::btCpuDynamicsWorld()
|
||||
:btDiscreteDynamicsWorld(
|
||||
new btCollisionDispatcher(new btDefaultCollisionConfiguration()),
|
||||
new b3DynamicBvhBroadphase(),new btSequentialImpulseConstraintSolver(),
|
||||
new btDefaultCollisionConfiguration()//todo: remove this!
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
btCpuDynamicsWorld::~btCpuDynamicsWorld()
|
||||
{
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
|
||||
#ifndef BT_CPU_DYNAMICS_WORLD_H
|
||||
#define BT_CPU_DYNAMICS_WORLD_H
|
||||
|
||||
class btDefaultCollisionConfiguration;
|
||||
class btCollisionDispatcher;
|
||||
struct b3DynamicBvhBroadphase;
|
||||
class btSequentialImpulseConstraintSolver;
|
||||
|
||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
|
||||
class btCpuDynamicsWorld : public btDiscreteDynamicsWorld
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
btCpuDynamicsWorld();
|
||||
|
||||
virtual ~btCpuDynamicsWorld();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_CPU_DYNAMICS_WORLD_H
|
@ -1,109 +0,0 @@
|
||||
#ifndef BT_GPU_DYNAMICS_WORLD_H
|
||||
#define BT_GPU_DYNAMICS_WORLD_H
|
||||
|
||||
class b3Vector3;
|
||||
class btRigidBody;
|
||||
class btCollisionObject;
|
||||
struct btGpuInternalData;//use this struct to avoid 'leaking' all OpenCL headers into clients code base
|
||||
class CLPhysicsDemo;
|
||||
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
//#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
||||
|
||||
|
||||
class btGpuDynamicsWorld //: public btDynamicsWorld
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<const class btCollisionShape*> m_uniqueShapes;
|
||||
b3AlignedObjectArray<int> m_uniqueShapeMapping;
|
||||
|
||||
|
||||
CLPhysicsDemo* m_gpuPhysics;
|
||||
b3Vector3 m_gravity;
|
||||
bool m_once;
|
||||
|
||||
bool initOpenCL(int preferredDeviceIndex, int preferredPlatformIndex, bool useInterop);
|
||||
void exitOpenCL();
|
||||
|
||||
int findOrRegisterCollisionShape(const btCollisionShape* colShape);
|
||||
|
||||
|
||||
public:
|
||||
btGpuDynamicsWorld(int preferredOpenCLPlatformIndex,int preferredOpenCLDeviceIndex);
|
||||
|
||||
virtual ~btGpuDynamicsWorld();
|
||||
|
||||
virtual int stepSimulation( b3Scalar timeStep,int maxSubSteps=1, b3Scalar fixedTimeStep=b3Scalar(1.)/b3Scalar(60.));
|
||||
|
||||
virtual void synchronizeMotionStates()
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
void debugDrawWorld() {}
|
||||
|
||||
void setGravity(const b3Vector3& gravity);
|
||||
|
||||
void addRigidBody(btRigidBody* body);
|
||||
|
||||
void removeCollisionObject(btCollisionObject* colObj);
|
||||
|
||||
|
||||
|
||||
b3AlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray();
|
||||
|
||||
const b3AlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray() const;
|
||||
|
||||
virtual void addAction(btActionInterface* action)
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
virtual void removeAction(btActionInterface* action)
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
|
||||
b3Vector3 getGravity () const
|
||||
{
|
||||
return m_gravity;
|
||||
}
|
||||
|
||||
virtual void addRigidBody(btRigidBody* body, short group, short mask)
|
||||
{
|
||||
addRigidBody(body);
|
||||
}
|
||||
|
||||
virtual void removeRigidBody(btRigidBody* body)
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
virtual void setConstraintSolver(btConstraintSolver* solver)
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
virtual btConstraintSolver* getConstraintSolver()
|
||||
{
|
||||
btAssert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual btDynamicsWorldType getWorldType() const
|
||||
{
|
||||
return BT_GPU_PHYSICS_WORLD;
|
||||
}
|
||||
|
||||
virtual void clearForces()
|
||||
{
|
||||
btAssert(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //BT_GPU_DYNAMICS_WORLD_H
|
@ -12,7 +12,7 @@
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
//#include "OpenGL3CoreRenderer.h"
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
//#include "btGpuDynamicsWorld.h"
|
||||
//#include "b3GpuDynamicsWorld.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "OpenGLTrueTypeFont/fontstash.h"
|
||||
@ -34,7 +34,7 @@
|
||||
#include "Gwen/Controls/CheckBox.h"
|
||||
#include "Gwen/Controls/TreeControl.h"
|
||||
|
||||
btgDefaultOpenGLWindow* window=0;
|
||||
b3gDefaultOpenGLWindow* window=0;
|
||||
|
||||
GLPrimitiveRenderer* primRenderer = 0;
|
||||
GwenOpenGL3CoreRenderer* pRenderer = 0;
|
||||
@ -159,7 +159,7 @@ public:
|
||||
for (int i=0;i<numPlatforms;i++)
|
||||
{
|
||||
cl_platform_id platform = b3OpenCLUtils::getPlatform(i);
|
||||
btOpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLUtils::getPlatformInfo(platform, &platformInfo);
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_ALL;
|
||||
cl_int errNum;
|
||||
@ -177,7 +177,7 @@ public:
|
||||
Gwen::Controls::TreeNode* deviceNode = m_node->AddNode( txt );
|
||||
|
||||
cl_device_id device = b3OpenCLUtils::getDevice(context,j);
|
||||
btOpenCLDeviceInfo info;
|
||||
b3OpenCLDeviceInfo info;
|
||||
b3OpenCLUtils::getDeviceInfo(device,&info);
|
||||
|
||||
Gwen::Controls::TreeNode* node;
|
||||
@ -439,7 +439,7 @@ static void MouseButtonCallback(int button, int state, float x, float y)
|
||||
sLastmousepos[1] = y;
|
||||
} else
|
||||
{
|
||||
btDefaultMouseButtonCallback(button,state,x,y);
|
||||
b3DefaultMouseButtonCallback(button,state,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,9 +471,9 @@ static void MouseMoveCallback(float x,float y)
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
window = new btgDefaultOpenGLWindow();
|
||||
window = new b3gDefaultOpenGLWindow();
|
||||
|
||||
btgWindowConstructionInfo wci(sGlutScreenWidth,sGlutScreenHeight);
|
||||
b3gWindowConstructionInfo wci(sGlutScreenWidth,sGlutScreenHeight);
|
||||
|
||||
window->createWindow(wci);
|
||||
window->setResizeCallback(MyResizeCallback);
|
||||
@ -511,23 +511,23 @@ int main(int argc, char* argv[])
|
||||
//saveOpenGLState(sGlutScreenWidth,sGlutScreenHeight);
|
||||
|
||||
{
|
||||
BT_PROFILE("gui->draw");
|
||||
B3_PROFILE("gui->draw");
|
||||
//gui->draw(g_OpenGLWidth,g_OpenGLHeight);
|
||||
|
||||
{
|
||||
BT_PROFILE("UpdateText");
|
||||
B3_PROFILE("UpdateText");
|
||||
if (prof)
|
||||
prof->UpdateText();
|
||||
}
|
||||
{
|
||||
BT_PROFILE("RenderCanvas");
|
||||
B3_PROFILE("RenderCanvas");
|
||||
pCanvas->RenderCanvas();
|
||||
}
|
||||
|
||||
//restoreOpenGLState();
|
||||
}
|
||||
{
|
||||
BT_PROFILE("window->endRendering");
|
||||
B3_PROFILE("window->endRendering");
|
||||
window->endRendering();
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ GpuDemo::~GpuDemo()
|
||||
{
|
||||
if (m_clData)
|
||||
{
|
||||
btAssert(m_clData->m_clInitialized==false);
|
||||
b3Assert(m_clData->m_clInitialized==false);
|
||||
|
||||
delete m_clData;
|
||||
}
|
||||
@ -69,7 +69,7 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
|
||||
b3OpenCLUtils::printDeviceInfo(m_clData->m_clDevice);
|
||||
btOpenCLDeviceInfo info;
|
||||
b3OpenCLDeviceInfo info;
|
||||
b3OpenCLUtils::getDeviceInfo(m_clData->m_clDevice,&info);
|
||||
m_clData->m_clDeviceName = info.m_deviceName;
|
||||
m_clData->m_clInitialized = true;
|
||||
@ -98,7 +98,7 @@ int GpuDemo::registerGraphicsSphereShape(const ConstructionInfo& ci, float radiu
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
graphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,BT_GL_POINTS);
|
||||
graphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
if (radius>=mediumSphereThreshold)
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
float gapY;
|
||||
float gapZ;
|
||||
GLInstancingRenderer* m_instancingRenderer;
|
||||
class btgWindowInterface* m_window;
|
||||
class b3gWindowInterface* m_window;
|
||||
class GwenUserInterface* m_gui;
|
||||
|
||||
ConstructionInfo()
|
||||
|
@ -12,9 +12,9 @@ static char* particleKernelsString =
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
//#include "../../opencl/primitives/AdlPrimitives/Math/Math.h"
|
||||
//#include "../../opencl/broadphase_benchmark/btGridBroadphaseCL.h"
|
||||
//#include "../../opencl/broadphase_benchmark/b3GridBroadphaseCL.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "GpuDemoInternalData.h"
|
||||
|
||||
@ -43,9 +43,9 @@ static char* particleKernelsString =
|
||||
|
||||
|
||||
|
||||
ATTRIBUTE_ALIGNED16(struct) btSimParams
|
||||
ATTRIBUTE_ALIGNED16(struct) b3SimParams
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
b3Vector3 m_gravity;
|
||||
float m_worldMin[4];
|
||||
float m_worldMax[4];
|
||||
@ -61,7 +61,7 @@ ATTRIBUTE_ALIGNED16(struct) btSimParams
|
||||
float m_dummy;
|
||||
|
||||
|
||||
btSimParams()
|
||||
b3SimParams()
|
||||
{
|
||||
m_gravity.setValue(0,-0.03,0.f);
|
||||
m_particleRad = 0.023f;
|
||||
@ -98,10 +98,10 @@ struct ParticleInternalData
|
||||
cl_mem m_clPositionBuffer;
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> m_velocitiesCPU;
|
||||
btOpenCLArray<b3Vector3>* m_velocitiesGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_velocitiesGPU;
|
||||
|
||||
b3AlignedObjectArray<btSimParams> m_simParamCPU;
|
||||
btOpenCLArray<btSimParams>* m_simParamGPU;
|
||||
b3AlignedObjectArray<b3SimParams> m_simParamCPU;
|
||||
b3OpenCLArray<b3SimParams>* m_simParamGPU;
|
||||
|
||||
|
||||
|
||||
@ -170,12 +170,12 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
m_data->m_broadphaseGPU = new b3GpuSapBroadphase(m_clData->m_clContext ,m_clData->m_clDevice,m_clData->m_clQueue);//overlappingPairCache,b3Vector3(4.f, 4.f, 4.f), 128, 128, 128,maxObjects, maxObjects, maxPairsSmallProxy, 100.f, 128,
|
||||
|
||||
/*m_data->m_broadphaseGPU = new btGridBroadphaseCl(overlappingPairCache,b3Vector3(radius,radius,radius), 128, 128, 128,
|
||||
/*m_data->m_broadphaseGPU = new b3GridBroadphaseCl(overlappingPairCache,b3Vector3(radius,radius,radius), 128, 128, 128,
|
||||
maxObjects, maxObjects, maxPairsSmallProxy, 100.f, 128,
|
||||
m_clData->m_clContext ,m_clData->m_clDevice,m_clData->m_clQueue);
|
||||
*/
|
||||
|
||||
m_data->m_velocitiesGPU = new btOpenCLArray<b3Vector3>(m_clData->m_clContext,m_clData->m_clQueue,numParticles);
|
||||
m_data->m_velocitiesGPU = new b3OpenCLArray<b3Vector3>(m_clData->m_clContext,m_clData->m_clQueue,numParticles);
|
||||
m_data->m_velocitiesCPU.resize(numParticles);
|
||||
for (int i=0;i<numParticles;i++)
|
||||
{
|
||||
@ -183,7 +183,7 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
|
||||
}
|
||||
m_data->m_velocitiesGPU->copyFromHost(m_data->m_velocitiesCPU);
|
||||
|
||||
m_data->m_simParamGPU = new btOpenCLArray<btSimParams>(m_clData->m_clContext,m_clData->m_clQueue,1,false);
|
||||
m_data->m_simParamGPU = new b3OpenCLArray<b3SimParams>(m_clData->m_clContext,m_clData->m_clQueue,1,false);
|
||||
m_data->m_simParamGPU->copyFromHost(m_data->m_simParamCPU);
|
||||
|
||||
cl_int pErrNum;
|
||||
@ -210,7 +210,7 @@ void ParticleDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
shapeId = m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,BT_GL_POINTS);
|
||||
shapeId = m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
int numVertices = sizeof(low_sphere_vertices)/strideInBytes;
|
||||
@ -341,14 +341,14 @@ void ParticleDemo::clientMoveAndDisplay()
|
||||
|
||||
if (0)
|
||||
{
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( m_data->m_velocitiesGPU->getBufferCL(), true ),
|
||||
btBufferInfoCL( m_data->m_clPositionBuffer)
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( m_data->m_velocitiesGPU->getBufferCL(), true ),
|
||||
b3BufferInfoCL( m_data->m_clPositionBuffer)
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_updatePositionsKernel );
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updatePositionsKernel );
|
||||
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numParticles);
|
||||
|
||||
launcher.launch1D( numParticles);
|
||||
@ -359,16 +359,16 @@ void ParticleDemo::clientMoveAndDisplay()
|
||||
|
||||
if (1)
|
||||
{
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( m_data->m_clPositionBuffer),
|
||||
btBufferInfoCL( m_data->m_velocitiesGPU->getBufferCL() ),
|
||||
btBufferInfoCL( m_data->m_simParamGPU->getBufferCL(),true)
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( m_data->m_clPositionBuffer),
|
||||
b3BufferInfoCL( m_data->m_velocitiesGPU->getBufferCL() ),
|
||||
b3BufferInfoCL( m_data->m_simParamGPU->getBufferCL(),true)
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_updatePositionsKernel2 );
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updatePositionsKernel2 );
|
||||
|
||||
launcher.setConst( numParticles);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
float timeStep = 1.f/60.f;
|
||||
launcher.setConst( timeStep);
|
||||
|
||||
@ -378,13 +378,13 @@ void ParticleDemo::clientMoveAndDisplay()
|
||||
}
|
||||
|
||||
{
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( m_data->m_clPositionBuffer),
|
||||
btBufferInfoCL( m_data->m_broadphaseGPU->getAabbBufferWS()),
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( m_data->m_clPositionBuffer),
|
||||
b3BufferInfoCL( m_data->m_broadphaseGPU->getAabbBufferWS()),
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_updateAabbsKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updateAabbsKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( m_data->m_simParamCPU[0].m_particleRad);
|
||||
launcher.setConst( numParticles);
|
||||
|
||||
@ -404,14 +404,14 @@ void ParticleDemo::clientMoveAndDisplay()
|
||||
|
||||
if (numPairsGPU)
|
||||
{
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( m_data->m_clPositionBuffer),
|
||||
btBufferInfoCL( m_data->m_velocitiesGPU->getBufferCL() ),
|
||||
btBufferInfoCL( m_data->m_broadphaseGPU->getOverlappingPairBuffer(),true),
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( m_data->m_clPositionBuffer),
|
||||
b3BufferInfoCL( m_data->m_velocitiesGPU->getBufferCL() ),
|
||||
b3BufferInfoCL( m_data->m_broadphaseGPU->getOverlappingPairBuffer(),true),
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_collideParticlesKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_collideParticlesKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numPairsGPU);
|
||||
launcher.launch1D( numPairsGPU);
|
||||
clFinish(m_clData->m_clQueue);
|
||||
@ -454,7 +454,7 @@ void ParticleDemo::clientMoveAndDisplay()
|
||||
glFlush();
|
||||
|
||||
char* orgBase = (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_READ_WRITE);
|
||||
//btGraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
//b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||
int totalNumInstances= numParticles;
|
||||
|
||||
|
||||
|
@ -3,15 +3,15 @@
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/btgWindowInterface.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
|
||||
static btKeyboardCallback oldCallback = 0;
|
||||
static b3KeyboardCallback oldCallback = 0;
|
||||
extern bool gReset;
|
||||
|
||||
#define MSTRINGIFY(A) #A
|
||||
@ -70,9 +70,9 @@ typedef struct
|
||||
float fy;
|
||||
float fz;
|
||||
int uw;
|
||||
} btAABBCL;
|
||||
} b3AABBCL;
|
||||
|
||||
__kernel void updateAabbSimple( __global float4* posOrnColors, const int numNodes, __global btAABBCL* pAABB)
|
||||
__kernel void updateAabbSimple( __global float4* posOrnColors, const int numNodes, __global b3AABBCL* pAABB)
|
||||
{
|
||||
int nodeId = get_global_id(0);
|
||||
if( nodeId < numNodes )
|
||||
@ -102,8 +102,8 @@ struct PairBenchInternalData
|
||||
cl_kernel m_colorPairsKernel;
|
||||
cl_kernel m_updateAabbSimple;
|
||||
|
||||
btOpenCLArray<btVector4>* m_instancePosOrnColor;
|
||||
btOpenCLArray<float>* m_bodyTimes;
|
||||
b3OpenCLArray<b3Vector4>* m_instancePosOrnColor;
|
||||
b3OpenCLArray<float>* m_bodyTimes;
|
||||
PairBenchInternalData()
|
||||
:m_broadphaseGPU(0),
|
||||
m_moveObjectsKernel(0),
|
||||
@ -141,7 +141,7 @@ static void PairKeyboardCallback(int key, int state)
|
||||
gReset = true;
|
||||
}
|
||||
|
||||
//btDefaultKeyboardCallback(key,state);
|
||||
//b3DefaultKeyboardCallback(key,state);
|
||||
oldCallback(key,state);
|
||||
}
|
||||
|
||||
@ -190,8 +190,8 @@ void PairBench::initPhysics(const ConstructionInfo& ci)
|
||||
b3Vector3 position(k*3,i*3,j*3);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color(0,1,0,1);
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 color(0,1,0,1);
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
b3Vector3 aabbHalfExtents(1,1,1);
|
||||
|
||||
@ -236,21 +236,21 @@ void PairBench::clientMoveAndDisplay()
|
||||
|
||||
bool animate=true;
|
||||
int numObjects= m_instancingRenderer->getInternalData()->m_totalNumInstances;
|
||||
btVector4* positions = 0;
|
||||
b3Vector4* positions = 0;
|
||||
if (animate)
|
||||
{
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
|
||||
|
||||
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(btVector4);
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(b3Vector4);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
cl_bool blocking= CL_TRUE;
|
||||
char* hostPtr= (char*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_WRITE_BIT|GL_MAP_READ_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
positions = (btVector4*)hostPtr;
|
||||
positions = (b3Vector4*)hostPtr;
|
||||
|
||||
if (m_data->m_instancePosOrnColor && m_data->m_instancePosOrnColor->size() != 3*numObjects)
|
||||
{
|
||||
@ -259,10 +259,10 @@ void PairBench::clientMoveAndDisplay()
|
||||
}
|
||||
if (!m_data->m_instancePosOrnColor)
|
||||
{
|
||||
m_data->m_instancePosOrnColor = new btOpenCLArray<btVector4>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_instancePosOrnColor = new b3OpenCLArray<b3Vector4>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_instancePosOrnColor->resize(3*numObjects);
|
||||
m_data->m_instancePosOrnColor->copyFromHostPointer(positions,3*numObjects,0);
|
||||
m_data->m_bodyTimes = new btOpenCLArray<float>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_bodyTimes = new b3OpenCLArray<float>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_bodyTimes ->resize(numObjects);
|
||||
b3AlignedObjectArray<float> tmp;
|
||||
tmp.resize(numObjects);
|
||||
@ -278,7 +278,7 @@ void PairBench::clientMoveAndDisplay()
|
||||
if (1)
|
||||
{
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_sineWaveKernel);
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_sineWaveKernel);
|
||||
launcher.setBuffer(m_data->m_instancePosOrnColor->getBufferCL() );
|
||||
launcher.setBuffer(m_data->m_bodyTimes->getBufferCL() );
|
||||
launcher.setConst( numObjects);
|
||||
@ -288,7 +288,7 @@ void PairBench::clientMoveAndDisplay()
|
||||
else
|
||||
{
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_moveObjectsKernel);
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_moveObjectsKernel);
|
||||
launcher.setBuffer(m_data->m_instancePosOrnColor->getBufferCL() );
|
||||
launcher.setConst( numObjects);
|
||||
launcher.launch1D( numObjects);
|
||||
@ -298,7 +298,7 @@ void PairBench::clientMoveAndDisplay()
|
||||
}
|
||||
|
||||
{
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_updateAabbSimple);
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_updateAabbSimple);
|
||||
launcher.setBuffer(m_data->m_instancePosOrnColor->getBufferCL() );
|
||||
launcher.setConst( numObjects);
|
||||
launcher.setBuffer(m_data->m_broadphaseGPU->getAabbBufferWS());
|
||||
@ -307,7 +307,7 @@ void PairBench::clientMoveAndDisplay()
|
||||
|
||||
}
|
||||
{
|
||||
BT_PROFILE("calculateOverlappingPairs");
|
||||
B3_PROFILE("calculateOverlappingPairs");
|
||||
m_data->m_broadphaseGPU->calculateOverlappingPairs();
|
||||
//int numPairs = m_data->m_broadphaseGPU->getNumOverlap();
|
||||
//printf("numPairs = %d\n", numPairs);
|
||||
@ -331,7 +331,7 @@ void PairBench::clientMoveAndDisplay()
|
||||
int numPairs = m_data->m_broadphaseGPU->getNumOverlap();
|
||||
cl_mem pairBuf = m_data->m_broadphaseGPU->getOverlappingPairBuffer();
|
||||
|
||||
btLauncherCL launcher(m_clData->m_clQueue, m_data->m_colorPairsKernel);
|
||||
b3LauncherCL launcher(m_clData->m_clQueue, m_data->m_colorPairsKernel);
|
||||
launcher.setBuffer(m_data->m_instancePosOrnColor->getBufferCL() );
|
||||
launcher.setConst( numObjects);
|
||||
launcher.setBuffer( pairBuf);
|
||||
|
@ -7,7 +7,7 @@ class PairBench : public GpuDemo
|
||||
{
|
||||
|
||||
class GLInstancingRenderer* m_instancingRenderer;
|
||||
class btgWindowInterface* m_window;
|
||||
class b3gWindowInterface* m_window;
|
||||
|
||||
struct PairBenchInternalData* m_data;
|
||||
|
||||
|
@ -39,8 +39,8 @@ struct GwenInternalData
|
||||
Gwen::Controls::Label* m_leftStatusBar;
|
||||
|
||||
b3AlignedObjectArray<struct Gwen::Event::Handler*> m_handlers;
|
||||
btToggleButtonCallback m_toggleButtonCallback;
|
||||
btComboBoxCallback m_comboBoxCallback;
|
||||
b3ToggleButtonCallback m_toggleButtonCallback;
|
||||
b3ComboBoxCallback m_comboBoxCallback;
|
||||
|
||||
};
|
||||
GwenUserInterface::GwenUserInterface()
|
||||
@ -243,7 +243,7 @@ void GwenUserInterface::init(int width, int height,struct sth_stash* stash,float
|
||||
}
|
||||
|
||||
|
||||
void GwenUserInterface::setToggleButtonCallback(btToggleButtonCallback callback)
|
||||
void GwenUserInterface::setToggleButtonCallback(b3ToggleButtonCallback callback)
|
||||
{
|
||||
m_data->m_toggleButtonCallback = callback;
|
||||
}
|
||||
@ -269,7 +269,7 @@ void GwenUserInterface::registerToggleButton(int buttonId, const char* name)
|
||||
|
||||
}
|
||||
|
||||
void GwenUserInterface::setComboBoxCallback(btComboBoxCallback callback)
|
||||
void GwenUserInterface::setComboBoxCallback(b3ComboBoxCallback callback)
|
||||
{
|
||||
m_data->m_comboBoxCallback = callback;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
struct GwenInternalData;
|
||||
|
||||
typedef void (*btComboBoxCallback) (int combobox, const char* item);
|
||||
typedef void (*btToggleButtonCallback)(int button, int state);
|
||||
typedef void (*b3ComboBoxCallback) (int combobox, const char* item);
|
||||
typedef void (*b3ToggleButtonCallback)(int button, int state);
|
||||
|
||||
class GwenUserInterface
|
||||
{
|
||||
@ -25,10 +25,10 @@ class GwenUserInterface
|
||||
bool mouseMoveCallback( float x, float y);
|
||||
bool mouseButtonCallback(int button, int state, float x, float y);
|
||||
|
||||
void setToggleButtonCallback(btToggleButtonCallback callback);
|
||||
void setToggleButtonCallback(b3ToggleButtonCallback callback);
|
||||
void registerToggleButton(int buttonId, const char* name);
|
||||
|
||||
void setComboBoxCallback(btComboBoxCallback callback);
|
||||
void setComboBoxCallback(b3ComboBoxCallback callback);
|
||||
void registerComboBox(int buttonId, int numItems, const char** items);
|
||||
|
||||
void setStatusBarMessage(const char* message, bool isLeft=true);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
//#include "OpenGL3CoreRenderer.h"
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
//#include "btGpuDynamicsWorld.h"
|
||||
//#include "b3GpuDynamicsWorld.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "OpenGLTrueTypeFont/fontstash.h"
|
||||
@ -44,7 +44,7 @@ static void MyResizeCallback( float width, float height)
|
||||
g_OpenGLHeight = height;
|
||||
}
|
||||
|
||||
btgWindowInterface* window=0;
|
||||
b3gWindowInterface* window=0;
|
||||
GwenUserInterface* gui = 0;
|
||||
bool gPause = false;
|
||||
bool gReset = false;
|
||||
@ -161,7 +161,7 @@ static void MyMouseMoveCallback( float x, float y)
|
||||
{
|
||||
bool handled = gui ->mouseMoveCallback(x,y);
|
||||
if (!handled)
|
||||
btDefaultMouseMoveCallback(x,y);
|
||||
b3DefaultMouseMoveCallback(x,y);
|
||||
}
|
||||
}
|
||||
static void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
@ -170,18 +170,18 @@ static void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
bool handled = gui->mouseButtonCallback(button,state,x,y);
|
||||
if (!handled)
|
||||
btDefaultMouseButtonCallback(button,state,x,y);
|
||||
b3DefaultMouseButtonCallback(button,state,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MyKeyboardCallback(int key, int state)
|
||||
{
|
||||
if (key==BTG_ESCAPE && window)
|
||||
if (key==B3G_ESCAPE && window)
|
||||
{
|
||||
window->setRequestExit();
|
||||
}
|
||||
btDefaultKeyboardCallback(key,state);
|
||||
b3DefaultKeyboardCallback(key,state);
|
||||
}
|
||||
|
||||
|
||||
@ -440,14 +440,14 @@ int main(int argc, char* argv[])
|
||||
printf("Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex);
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
#ifndef BT_NO_PROFILE
|
||||
#ifndef B3_NO_PROFILE
|
||||
CProfileManager::Reset();
|
||||
#endif //BT_NO_PROFILE
|
||||
#endif //B3_NO_PROFILE
|
||||
|
||||
|
||||
window = new btgDefaultOpenGLWindow();
|
||||
window = new b3gDefaultOpenGLWindow();
|
||||
|
||||
btgWindowConstructionInfo wci(g_OpenGLWidth,g_OpenGLHeight);
|
||||
b3gWindowConstructionInfo wci(g_OpenGLWidth,g_OpenGLHeight);
|
||||
|
||||
window->createWindow(wci);
|
||||
window->setResizeCallback(MyResizeCallback);
|
||||
@ -535,7 +535,7 @@ int main(int argc, char* argv[])
|
||||
float dx=0;
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("font sth_draw_text");
|
||||
B3_PROFILE("font sth_draw_text");
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
GLint err = glGetError();
|
||||
@ -579,7 +579,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
|
||||
window->setWheelCallback(btDefaultWheelCallback);
|
||||
window->setWheelCallback(b3DefaultWheelCallback);
|
||||
|
||||
|
||||
|
||||
@ -654,7 +654,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (!gPause)
|
||||
{
|
||||
BT_PROFILE("clientMoveAndDisplay");
|
||||
B3_PROFILE("clientMoveAndDisplay");
|
||||
|
||||
demo->clientMoveAndDisplay();
|
||||
}
|
||||
@ -664,16 +664,16 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("renderScene");
|
||||
B3_PROFILE("renderScene");
|
||||
demo->renderScene();
|
||||
}
|
||||
|
||||
|
||||
/*if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getNumCollisionObjects())
|
||||
{
|
||||
BT_PROFILE("renderPhysicsWorld");
|
||||
b3AlignedObjectArray<btCollisionObject*> arr = demo->getDynamicsWorld()->getCollisionObjectArray();
|
||||
btCollisionObject** colObjArray = &arr[0];
|
||||
B3_PROFILE("renderPhysicsWorld");
|
||||
b3AlignedObjectArray<b3CollisionObject*> arr = demo->getDynamicsWorld()->getCollisionObjectArray();
|
||||
b3CollisionObject** colObjArray = &arr[0];
|
||||
|
||||
render.renderPhysicsWorld(demo->getDynamicsWorld()->getNumCollisionObjects(),colObjArray, syncOnly);
|
||||
syncOnly = true;
|
||||
@ -681,15 +681,15 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
*/
|
||||
{
|
||||
BT_PROFILE("gui->draw");
|
||||
B3_PROFILE("gui->draw");
|
||||
gui->draw(g_OpenGLWidth,g_OpenGLHeight);
|
||||
}
|
||||
{
|
||||
BT_PROFILE("window->endRendering");
|
||||
B3_PROFILE("window->endRendering");
|
||||
window->endRendering();
|
||||
}
|
||||
{
|
||||
BT_PROFILE("glFinish");
|
||||
B3_PROFILE("glFinish");
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,14 +65,14 @@ function createProject(vendor)
|
||||
"../../opencl/gpu_broadphase/host/b3GpuSapBroadphase.cpp",
|
||||
"../../opencl/gpu_narrowphase/host/**.cpp",
|
||||
"../../opencl/gpu_narrowphase/host/**.h",
|
||||
"../../opencl/parallel_primitives/host/btBoundSearchCL.cpp",
|
||||
"../../opencl/parallel_primitives/host/btBoundSearchCL.h",
|
||||
"../../opencl/parallel_primitives/host/btFillCL.cpp",
|
||||
"../../opencl/parallel_primitives/host/btFillCL.h",
|
||||
"../../opencl/parallel_primitives/host/btPrefixScanCL.cpp",
|
||||
"../../opencl/parallel_primitives/host/btPrefixScanCL.h",
|
||||
"../../opencl/parallel_primitives/host/btRadixSort32CL.cpp",
|
||||
"../../opencl/parallel_primitives/host/btRadixSort32CL.h",
|
||||
"../../opencl/parallel_primitives/host/b3BoundSearchCL.cpp",
|
||||
"../../opencl/parallel_primitives/host/b3BoundSearchCL.h",
|
||||
"../../opencl/parallel_primitives/host/b3FillCL.cpp",
|
||||
"../../opencl/parallel_primitives/host/b3FillCL.h",
|
||||
"../../opencl/parallel_primitives/host/b3PrefixScanCL.cpp",
|
||||
"../../opencl/parallel_primitives/host/b3PrefixScanCL.h",
|
||||
"../../opencl/parallel_primitives/host/b3RadixSort32CL.cpp",
|
||||
"../../opencl/parallel_primitives/host/b3RadixSort32CL.h",
|
||||
"../../opencl/gpu_rigidbody/host/**.cpp",
|
||||
"../../opencl/gpu_rigidbody/host/**.h",
|
||||
|
||||
|
@ -15,7 +15,7 @@ Bullet2FileDemo::~Bullet2FileDemo()
|
||||
|
||||
void Bullet2FileDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
btAssert(ci.m_instancingRenderer);
|
||||
b3Assert(ci.m_instancingRenderer);
|
||||
|
||||
const char* fileName="data/testFile.bullet";
|
||||
|
||||
@ -35,7 +35,7 @@ void Bullet2FileDemo::setupScene(const ConstructionInfo& ci)
|
||||
fclose(f);
|
||||
createScene(*ci.m_instancingRenderer,*m_data->m_np,*m_data->m_rigidBodyPipeline,relativeFileName);
|
||||
}
|
||||
// m_loader = new btBulletDataExtractor(*ci.m_instancingRenderer,*m_data->m_np,*m_data->m_rigidBodyPipeline);
|
||||
// m_loader = new b3BulletDataExtractor(*ci.m_instancingRenderer,*m_data->m_np,*m_data->m_rigidBodyPipeline);
|
||||
// m_loader->convertAllObjects(bulletFile);
|
||||
|
||||
b3Vector3 pos(-20,10,0);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
class Bullet2FileDemo : public GpuRigidBodyDemo
|
||||
{
|
||||
class btBulletDataExtractor* m_loader;
|
||||
class b3BulletDataExtractor* m_loader;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -9,7 +9,7 @@ float Y_GAP = 2.f;
|
||||
float Z_GAP = 2.3f;
|
||||
|
||||
#include "BulletDataExtractor.h"
|
||||
#include "Bullet3Serialize/Bullet2FileLoader/btBulletFile.h"
|
||||
#include "Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h"
|
||||
bool keepStaticObjects = true;
|
||||
extern bool enableExperimentalCpuConcaveCollision;
|
||||
|
||||
@ -19,7 +19,7 @@ extern bool enableExperimentalCpuConcaveCollision;
|
||||
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
//#include "LinearMath/btQuickprof.h"
|
||||
//#include "LinearMath/b3Quickprof.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "Bullet3Common/b3Matrix3x3.h"
|
||||
#include "gpu_narrowphase/host/b3ConvexUtility.h"
|
||||
@ -54,7 +54,7 @@ struct GraphicsShape
|
||||
|
||||
struct InstanceGroup
|
||||
{
|
||||
Bullet::btCollisionShapeData* m_shape;
|
||||
Bullet::b3CollisionShapeData* m_shape;
|
||||
int m_collisionShapeIndex;
|
||||
|
||||
b3AlignedObjectArray<bParse::bStructHandle*> m_rigidBodies;
|
||||
@ -80,7 +80,7 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
|
||||
|
||||
bool verboseDumpAllTypes = false;
|
||||
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
|
||||
bParse::b3BulletFile* bulletFile2 = new bParse::b3BulletFile(fileName);
|
||||
|
||||
bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
|
||||
|
||||
@ -107,7 +107,7 @@ void createScene( GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigi
|
||||
}
|
||||
|
||||
|
||||
btBulletDataExtractor extractor(renderer,np,rbWorld);
|
||||
b3BulletDataExtractor extractor(renderer,np,rbWorld);
|
||||
|
||||
extractor.convertAllObjects(bulletFile2);
|
||||
delete bulletFile2;
|
||||
@ -181,24 +181,24 @@ CONCAVE_SHAPES_END_HERE,
|
||||
|
||||
};
|
||||
|
||||
btBulletDataExtractor::btBulletDataExtractor(GLInstancingRenderer& renderer, b3GpuNarrowPhase& np, b3GpuRigidBodyPipeline& rbWorld)
|
||||
b3BulletDataExtractor::b3BulletDataExtractor(GLInstancingRenderer& renderer, b3GpuNarrowPhase& np, b3GpuRigidBodyPipeline& rbWorld)
|
||||
:m_renderer(renderer), m_np(np), m_rbPipeline(rbWorld)
|
||||
{
|
||||
}
|
||||
|
||||
btBulletDataExtractor::~btBulletDataExtractor()
|
||||
b3BulletDataExtractor::~b3BulletDataExtractor()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void btBulletDataExtractor::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
void b3BulletDataExtractor::convertAllObjects(bParse::b3BulletFile* bulletFile2)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionShapes.size();i++)
|
||||
{
|
||||
Bullet::btCollisionShapeData* shapeData = (Bullet::btCollisionShapeData*)bulletFile2->m_collisionShapes[i];
|
||||
Bullet::b3CollisionShapeData* shapeData = (Bullet::b3CollisionShapeData*)bulletFile2->m_collisionShapes[i];
|
||||
if (shapeData->m_name)
|
||||
printf("converting shape %s\n", shapeData->m_name);
|
||||
int shapeIndex = convertCollisionShape(shapeData);
|
||||
@ -216,8 +216,8 @@ void btBulletDataExtractor::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
|
||||
{
|
||||
|
||||
Bullet::btRigidBodyFloatData* colObjData = (Bullet::btRigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||
Bullet::btCollisionShapeData* shapeData = (Bullet::btCollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape;
|
||||
Bullet::b3RigidBodyFloatData* colObjData = (Bullet::b3RigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||
Bullet::b3CollisionShapeData* shapeData = (Bullet::b3CollisionShapeData*)colObjData->m_collisionObjectData.m_collisionShape;
|
||||
for (int j=0;j<m_instanceGroups.size();j++)
|
||||
{
|
||||
if (m_instanceGroups[j]->m_shape == shapeData)
|
||||
@ -237,10 +237,10 @@ void btBulletDataExtractor::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
|
||||
for (int j=0;j<m_instanceGroups[i]->m_rigidBodies.size();j++)
|
||||
{
|
||||
Bullet::btRigidBodyFloatData* colObjData = (Bullet::btRigidBodyFloatData*)m_instanceGroups[i]->m_rigidBodies[j];
|
||||
Bullet::b3RigidBodyFloatData* colObjData = (Bullet::b3RigidBodyFloatData*)m_instanceGroups[i]->m_rigidBodies[j];
|
||||
|
||||
b3Matrix3x3 mat;
|
||||
mat.deSerializeFloat((const btMatrix3x3FloatData&)colObjData->m_collisionObjectData.m_worldTransform.m_basis);
|
||||
mat.deSerializeFloat((const b3Matrix3x3FloatData&)colObjData->m_collisionObjectData.m_worldTransform.m_basis);
|
||||
b3Quaternion orn;
|
||||
mat.getRotation(orn);
|
||||
float quaternion[4] = {orn[0],orn[1],orn[2],orn[3]};
|
||||
@ -283,7 +283,7 @@ void btBulletDataExtractor::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
|
||||
|
||||
|
||||
int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData* shapeData )
|
||||
int b3BulletDataExtractor::convertCollisionShape( Bullet::b3CollisionShapeData* shapeData )
|
||||
{
|
||||
int shapeIndex = -1;
|
||||
|
||||
@ -291,7 +291,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
{
|
||||
case STATIC_PLANE_PROXYTYPE:
|
||||
{
|
||||
Bullet::btStaticPlaneShapeData* planeData = (Bullet::btStaticPlaneShapeData*)shapeData;
|
||||
Bullet::b3StaticPlaneShapeData* planeData = (Bullet::b3StaticPlaneShapeData*)shapeData;
|
||||
shapeIndex = createPlaneShape(planeData->m_planeNormal,planeData->m_planeConstant, planeData->m_localScaling);
|
||||
break;
|
||||
}
|
||||
@ -303,7 +303,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
Bullet::btConvexInternalShapeData* bsd = (Bullet::btConvexInternalShapeData*)shapeData;
|
||||
Bullet::b3ConvexInternalShapeData* bsd = (Bullet::b3ConvexInternalShapeData*)shapeData;
|
||||
|
||||
switch (shapeData->m_shapeType)
|
||||
{
|
||||
@ -319,10 +319,10 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
}
|
||||
case CONVEX_HULL_SHAPE_PROXYTYPE:
|
||||
{
|
||||
Bullet::btConvexHullShapeData* convexData = (Bullet::btConvexHullShapeData*)bsd;
|
||||
Bullet::b3ConvexHullShapeData* convexData = (Bullet::b3ConvexHullShapeData*)bsd;
|
||||
int numPoints = convexData->m_numUnscaledPoints;
|
||||
b3Vector3 localScaling;
|
||||
localScaling.deSerializeFloat((btVector3FloatData&)bsd->m_localScaling);
|
||||
localScaling.deSerializeFloat((b3Vector3FloatData&)bsd->m_localScaling);
|
||||
b3AlignedObjectArray<b3Vector3> tmpPoints;
|
||||
int i;
|
||||
if (convexData->m_unscaledPointsFloatPtr)
|
||||
@ -355,7 +355,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
#if 0
|
||||
case CAPSULE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btCapsuleShapeData* capData = (btCapsuleShapeData*)shapeData;
|
||||
b3CapsuleShapeData* capData = (b3CapsuleShapeData*)shapeData;
|
||||
switch (capData->m_upAxis)
|
||||
{
|
||||
case 0:
|
||||
@ -375,7 +375,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("error: wrong up axis for btCapsuleShape\n");
|
||||
printf("error: wrong up axis for b3CapsuleShape\n");
|
||||
}
|
||||
|
||||
};
|
||||
@ -384,7 +384,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
}
|
||||
case CYLINDER_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btCylinderShapeData* cylData = (btCylinderShapeData*) shapeData;
|
||||
b3CylinderShapeData* cylData = (b3CylinderShapeData*) shapeData;
|
||||
b3Vector3 halfExtents = implicitShapeDimensions+margin;
|
||||
switch (cylData->m_upAxis)
|
||||
{
|
||||
@ -416,7 +416,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
}
|
||||
case MULTI_SPHERE_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btMultiSphereShapeData* mss = (btMultiSphereShapeData*)bsd;
|
||||
b3MultiSphereShapeData* mss = (b3MultiSphereShapeData*)bsd;
|
||||
int numSpheres = mss->m_localPositionArraySize;
|
||||
int i;
|
||||
for ( i=0;i<numSpheres;i++)
|
||||
@ -424,7 +424,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
tmpPos[i].deSerializeFloat(mss->m_localPositionArrayPtr[i].m_pos);
|
||||
radii[i] = mss->m_localPositionArrayPtr[i].m_radius;
|
||||
}
|
||||
shape = new btMultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
|
||||
shape = new b3MultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -441,13 +441,13 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
|
||||
case TRIANGLE_MESH_SHAPE_PROXYTYPE:
|
||||
{
|
||||
Bullet::btTriangleMeshShapeData* trimesh = (Bullet::btTriangleMeshShapeData*)shapeData;
|
||||
Bullet::b3TriangleMeshShapeData* trimesh = (Bullet::b3TriangleMeshShapeData*)shapeData;
|
||||
printf("numparts = %d\n",trimesh->m_meshInterface.m_numMeshParts);
|
||||
if (trimesh->m_meshInterface.m_numMeshParts)
|
||||
{
|
||||
for (int i=0;i<trimesh->m_meshInterface.m_numMeshParts;i++)
|
||||
{
|
||||
Bullet::btMeshPartData& dat = trimesh->m_meshInterface.m_meshPartsPtr[i];
|
||||
Bullet::b3MeshPartData& dat = trimesh->m_meshInterface.m_meshPartsPtr[i];
|
||||
printf("numtris = %d, numverts = %d\n", dat.m_numTriangles,dat.m_numVertices);//,dat.m_vertices3f,dat.m_3indices16
|
||||
printf("scaling = %f,%f,%f\n", trimesh->m_meshInterface.m_scaling.m_floats[0],trimesh->m_meshInterface.m_scaling.m_floats[1],trimesh->m_meshInterface.m_scaling.m_floats[2]);
|
||||
// dat.
|
||||
@ -459,7 +459,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
//trimesh->m_meshInterface.m_scaling
|
||||
}
|
||||
//trimesh->m_meshInterface
|
||||
//btTriangleIndexVertexArray* meshInterface = createMeshInterface(trimesh->m_meshInterface);
|
||||
//b3TriangleIndexVertexArray* meshInterface = createMeshInterface(trimesh->m_meshInterface);
|
||||
|
||||
|
||||
//scaling
|
||||
@ -473,17 +473,17 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
#if 0
|
||||
case COMPOUND_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btCompoundShapeData* compoundData = (btCompoundShapeData*)shapeData;
|
||||
btCompoundShape* compoundShape = createCompoundShape();
|
||||
b3CompoundShapeData* compoundData = (b3CompoundShapeData*)shapeData;
|
||||
b3CompoundShape* compoundShape = createCompoundShape();
|
||||
|
||||
|
||||
b3AlignedObjectArray<btCollisionShape*> childShapes;
|
||||
b3AlignedObjectArray<b3CollisionShape*> childShapes;
|
||||
for (int i=0;i<compoundData->m_numChildShapes;i++)
|
||||
{
|
||||
btCollisionShape* childShape = convertCollisionShape(compoundData->m_childShapePtr[i].m_childShape);
|
||||
b3CollisionShape* childShape = convertCollisionShape(compoundData->m_childShapePtr[i].m_childShape);
|
||||
if (childShape)
|
||||
{
|
||||
btTransform localTransform;
|
||||
b3Transform localTransform;
|
||||
localTransform.deSerializeFloat(compoundData->m_childShapePtr[i].m_transform);
|
||||
compoundShape->addChildShape(localTransform,childShape);
|
||||
} else
|
||||
@ -499,11 +499,11 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
|
||||
case GIMPACT_SHAPE_PROXYTYPE:
|
||||
{
|
||||
btGImpactMeshShapeData* gimpactData = (btGImpactMeshShapeData*) shapeData;
|
||||
b3GImpactMeshShapeData* gimpactData = (b3GImpactMeshShapeData*) shapeData;
|
||||
if (gimpactData->m_gimpactSubType == CONST_GIMPACT_TRIMESH_SHAPE)
|
||||
{
|
||||
btTriangleIndexVertexArray* meshInterface = createMeshInterface(gimpactData->m_meshInterface);
|
||||
btGImpactMeshShape* gimpactShape = createGimpactShape(meshInterface);
|
||||
b3TriangleIndexVertexArray* meshInterface = createMeshInterface(gimpactData->m_meshInterface);
|
||||
b3GImpactMeshShape* gimpactShape = createGimpactShape(meshInterface);
|
||||
b3Vector3 localScaling;
|
||||
localScaling.deSerializeFloat(gimpactData->m_localScaling);
|
||||
gimpactShape->setLocalScaling(localScaling);
|
||||
@ -531,7 +531,7 @@ int btBulletDataExtractor::convertCollisionShape( Bullet::btCollisionShapeData*
|
||||
|
||||
}
|
||||
|
||||
int btBulletDataExtractor::createBoxShape( const Bullet::btVector3FloatData& halfDimensions, const Bullet::btVector3FloatData& localScaling, float collisionMargin)
|
||||
int b3BulletDataExtractor::createBoxShape( const Bullet::b3Vector3FloatData& halfDimensions, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin)
|
||||
{
|
||||
float cubeScaling[4] = {
|
||||
halfDimensions.m_floats[0]*localScaling.m_floats[0]+collisionMargin,
|
||||
@ -561,14 +561,14 @@ int btBulletDataExtractor::createBoxShape( const Bullet::btVector3FloatData& hal
|
||||
return cubeCollisionShapeIndex;
|
||||
}
|
||||
|
||||
int btBulletDataExtractor::createSphereShape( float radius, const Bullet::btVector3FloatData& localScaling, float collisionMargin)
|
||||
int b3BulletDataExtractor::createSphereShape( float radius, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin)
|
||||
{
|
||||
printf("createSphereShape with radius %f\n",radius);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int btBulletDataExtractor::createPlaneShape( const Bullet::btVector3FloatData& planeNormal, float planeConstant, const Bullet::btVector3FloatData& localScaling)
|
||||
int b3BulletDataExtractor::createPlaneShape( const Bullet::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet::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);
|
||||
return -1;
|
||||
@ -576,7 +576,7 @@ int btBulletDataExtractor::createPlaneShape( const Bullet::btVector3FloatData& p
|
||||
|
||||
|
||||
|
||||
GraphicsShape* btBulletDataExtractor::createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
{
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
{
|
||||
@ -701,7 +701,7 @@ GraphicsShape* btBulletDataExtractor::createGraphicsShapeFromWavefrontObj(objLoa
|
||||
}
|
||||
|
||||
|
||||
GraphicsShape* btBulletDataExtractor::createGraphicsShapeFromConvexHull(const b3Vector3* tmpPoints, int numPoints)
|
||||
GraphicsShape* b3BulletDataExtractor::createGraphicsShapeFromConvexHull(const b3Vector3* tmpPoints, int numPoints)
|
||||
{
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
bool merge = true;
|
||||
@ -714,7 +714,7 @@ GraphicsShape* btBulletDataExtractor::createGraphicsShapeFromConvexHull(const b3
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
for (int f=0;f<utilPtr->m_faces.size();f++)
|
||||
{
|
||||
const btMyFace& face = utilPtr->m_faces[f];
|
||||
const b3MyFace& face = utilPtr->m_faces[f];
|
||||
b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (face.m_indices.size()>2)
|
||||
{
|
||||
|
@ -14,10 +14,10 @@ void createScene(GLInstancingRenderer& renderer,b3GpuNarrowPhase& np, b3GpuRigid
|
||||
|
||||
namespace bParse
|
||||
{
|
||||
class btBulletFile;
|
||||
class b3BulletFile;
|
||||
};
|
||||
|
||||
class btBulletDataExtractor
|
||||
class b3BulletDataExtractor
|
||||
{
|
||||
GLInstancingRenderer& m_renderer;
|
||||
b3GpuNarrowPhase& m_np;
|
||||
@ -28,20 +28,20 @@ class btBulletDataExtractor
|
||||
b3AlignedObjectArray<struct InstanceGroup*> m_instanceGroups;
|
||||
b3AlignedObjectArray<struct GraphicsShape*> m_graphicsShapes;
|
||||
|
||||
btBulletDataExtractor(GLInstancingRenderer& renderer, b3GpuNarrowPhase& np, b3GpuRigidBodyPipeline& rbPipeline);
|
||||
b3BulletDataExtractor(GLInstancingRenderer& renderer, b3GpuNarrowPhase& np, b3GpuRigidBodyPipeline& rbPipeline);
|
||||
|
||||
virtual ~btBulletDataExtractor();
|
||||
virtual ~b3BulletDataExtractor();
|
||||
|
||||
virtual void convertAllObjects(bParse::btBulletFile* bulletFile);
|
||||
virtual void convertAllObjects(bParse::b3BulletFile* bulletFile);
|
||||
|
||||
//return -1 for invalid
|
||||
virtual int convertCollisionShape( Bullet::btCollisionShapeData* shapeData );
|
||||
virtual int convertCollisionShape( Bullet::b3CollisionShapeData* shapeData );
|
||||
|
||||
virtual int createPlaneShape( const Bullet::btVector3FloatData& planeNormal, float planeConstant, const Bullet::btVector3FloatData& localScaling);
|
||||
virtual int createPlaneShape( const Bullet::b3Vector3FloatData& planeNormal, float planeConstant, const Bullet::b3Vector3FloatData& localScaling);
|
||||
|
||||
virtual int createBoxShape( const Bullet::btVector3FloatData& halfDimensions, const Bullet::btVector3FloatData& localScaling, float collisionMargin);
|
||||
virtual int createBoxShape( const Bullet::b3Vector3FloatData& halfDimensions, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin);
|
||||
|
||||
virtual int createSphereShape( float radius, const Bullet::btVector3FloatData& localScaling, float collisionMargin);
|
||||
virtual int createSphereShape( float radius, const Bullet::b3Vector3FloatData& localScaling, float collisionMargin);
|
||||
|
||||
static GraphicsShape* createGraphicsShapeFromConvexHull(const b3Vector3* tmpPoints, int numPoints);
|
||||
static GraphicsShape* createGraphicsShapeFromWavefrontObj(class objLoader* obj);
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/btgWindowInterface.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "gpu_rigidbody/host/b3GpuRigidBodyPipeline.h"
|
||||
#include "gpu_rigidbody/host/b3GpuNarrowPhase.h"
|
||||
#include "gpu_rigidbody/host/b3Config.h"
|
||||
@ -216,7 +216,7 @@ 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);
|
||||
|
||||
btVector4 color(0.3,0.3,1,1.f);//0.5);//1.f
|
||||
b3Vector4 color(0.3,0.3,1,1.f);//0.5);//1.f
|
||||
|
||||
|
||||
{
|
||||
@ -256,7 +256,7 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
b3Vector3 shift1(0,-50,0);//0,230,80);//150,-100,-120);
|
||||
|
||||
btVector4 scaling(4,4,4,1);
|
||||
b3Vector4 scaling(4,4,4,1);
|
||||
|
||||
// createConcaveMesh(ci,"data/plane100.obj",shift1,scaling);
|
||||
//createConcaveMesh(ci,"data/plane100.obj",shift,scaling);
|
||||
@ -278,12 +278,12 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
int mask=1;
|
||||
int index=0;
|
||||
{
|
||||
btVector4 scaling(400,0.001,400,1);
|
||||
b3Vector4 scaling(400,0.001,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,-2,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color(0,0,1,1);
|
||||
b3Vector4 color(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);
|
||||
@ -320,15 +320,15 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
if (1)
|
||||
{
|
||||
int curColor = 0;
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,1,1,1),
|
||||
btVector4(1,1,0.3,1),
|
||||
btVector4(0.3,1,1,1),
|
||||
btVector4(0.3,0.3,1,1),
|
||||
b3Vector4(1,1,1,1),
|
||||
b3Vector4(1,1,0.3,1),
|
||||
b3Vector4(0.3,1,1,1),
|
||||
b3Vector4(0.3,0.3,1,1),
|
||||
};
|
||||
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
@ -342,7 +342,7 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
b3Vector3 position(-(ci.arraySizeX/2)*CONCAVE_GAPX+i*CONCAVE_GAPX,150+j*CONCAVE_GAPY,-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
|
||||
@ -379,7 +379,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
b3Vector3 shift(0,0,0);//0,230,80);//150,-100,-120);
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
FILE* f = 0;
|
||||
|
||||
char relativeFileName[1024];
|
||||
@ -427,12 +427,12 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertices;
|
||||
int stride2 = sizeof(GLInstanceVertex);
|
||||
btAssert(stride2 == strideInBytes);
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
|
||||
{
|
||||
|
||||
|
||||
b3AlignedObjectArray<btGpuChildShape> childShapes;
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
|
||||
int numChildShapes = objData->objectCount;
|
||||
|
||||
@ -448,7 +448,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
//for now, only support polyhedral child shapes
|
||||
btGpuChildShape child;
|
||||
b3GpuChildShape child;
|
||||
|
||||
b3Vector3 pos(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
@ -476,7 +476,7 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
}
|
||||
} else
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,12 +545,12 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
//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());
|
||||
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,0,1,1),
|
||||
btVector4(0,1,1,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,0,1,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@ -569,10 +569,10 @@ void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
// b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(0,0,1),1.8);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling(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);
|
||||
|
||||
@ -605,7 +605,7 @@ void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
GLInstanceVertex* cubeVerts = (GLInstanceVertex*)&cube_vertices[0];
|
||||
int stride2 = sizeof(GLInstanceVertex);
|
||||
btAssert(stride2 == strideInBytes);
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
|
||||
{
|
||||
int childColIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
@ -617,12 +617,12 @@ b3Vector3 childPositions[3] = {
|
||||
b3Vector3(0,0,2)
|
||||
};
|
||||
|
||||
b3AlignedObjectArray<btGpuChildShape> childShapes;
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
int numChildShapes = 3;
|
||||
for (int i=0;i<numChildShapes;i++)
|
||||
{
|
||||
//for now, only support polyhedral child shapes
|
||||
btGpuChildShape child;
|
||||
b3GpuChildShape child;
|
||||
child.m_shapeIndex = childColIndex;
|
||||
b3Vector3 pos = childPositions[i];
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
@ -662,12 +662,12 @@ b3Vector3 childPositions[3] = {
|
||||
//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());
|
||||
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,0,1,1),
|
||||
btVector4(0,1,1,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,0,1,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@ -684,10 +684,10 @@ b3Vector3 childPositions[3] = {
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(1,0,0),0.7);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling(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);
|
||||
|
||||
@ -713,12 +713,12 @@ void ConcaveSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,1,1,1),
|
||||
btVector4(1,1,0,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int index=0;
|
||||
@ -743,10 +743,10 @@ void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(radius,radius,radius,1);
|
||||
b3Vector4 scaling(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);
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/btgWindowInterface.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "gpu_rigidbody/host/b3GpuRigidBodyPipeline.h"
|
||||
#include "gpu_rigidbody/host/b3GpuNarrowPhase.h"
|
||||
#include "gpu_rigidbody/host/b3Config.h"
|
||||
@ -34,7 +34,7 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
GLInstanceVertex* cubeVerts = (GLInstanceVertex*)&cube_vertices[0];
|
||||
int stride2 = sizeof(GLInstanceVertex);
|
||||
btAssert(stride2 == strideInBytes);
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
int index=0;
|
||||
int colIndex = -1;
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
|
||||
@ -50,12 +50,12 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
};
|
||||
|
||||
|
||||
b3AlignedObjectArray<btGpuChildShape> childShapes;
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
int numChildShapes = 3;
|
||||
for (int i=0;i<numChildShapes;i++)
|
||||
{
|
||||
//for now, only support polyhedral child shapes
|
||||
btGpuChildShape child;
|
||||
b3GpuChildShape child;
|
||||
child.m_shapeIndex = childColIndex;
|
||||
b3Vector3 pos = childPositions[i];
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
@ -96,12 +96,12 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
//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());
|
||||
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,0,1,1),
|
||||
btVector4(0,1,1,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,0,1,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@ -117,10 +117,10 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(1,0,0),0.7);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling(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);
|
||||
|
||||
@ -179,7 +179,7 @@ void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,BT_GL_POINTS);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
if (radius>=10)
|
||||
@ -197,12 +197,12 @@ void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
}
|
||||
|
||||
}
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,1,1,1),
|
||||
btVector4(1,1,0,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 1;
|
||||
@ -217,10 +217,10 @@ void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(radius,radius,radius,1);
|
||||
b3Vector4 scaling(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);
|
||||
|
||||
@ -241,8 +241,8 @@ void GpuCompoundPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
// b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
btVector4 color(0,0,1,1);
|
||||
btVector4 scaling(100,0.01,100,1);
|
||||
b3Vector4 color(0,0,1,1);
|
||||
b3Vector4 scaling(100,0.01,100,1);
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/btgWindowInterface.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "gpu_rigidbody/host/b3GpuRigidBodyPipeline.h"
|
||||
#include "gpu_rigidbody/host/b3GpuNarrowPhase.h"
|
||||
#include "gpu_rigidbody/host/b3Config.h"
|
||||
@ -73,12 +73,12 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
|
||||
|
||||
{
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,1,1,1),
|
||||
btVector4(1,1,0,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@ -104,10 +104,10 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(1,1,1,1);
|
||||
b3Vector4 scaling(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);
|
||||
|
||||
@ -140,12 +140,12 @@ void GpuConvexScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
{
|
||||
btVector4 scaling(400,1,400,1);
|
||||
b3Vector4 scaling(400,1,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color(0,0,1,1);
|
||||
b3Vector4 color(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);
|
||||
@ -162,8 +162,8 @@ void GpuConvexPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
// b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
btVector4 color(0,0,1,1);
|
||||
btVector4 scaling(100,0.001,100,1);
|
||||
b3Vector4 color(0,0,1,1);
|
||||
b3Vector4 scaling(100,0.001,100,1);
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
@ -3,20 +3,20 @@
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/btgWindowInterface.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "gpu_rigidbody/host/b3GpuRigidBodyPipeline.h"
|
||||
#include "gpu_rigidbody/host/b3GpuNarrowPhase.h"
|
||||
#include "gpu_rigidbody/host/b3Config.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h"
|
||||
|
||||
static btKeyboardCallback oldCallback = 0;
|
||||
static b3KeyboardCallback oldCallback = 0;
|
||||
extern bool gReset;
|
||||
|
||||
#define MSTRINGIFY(A) #A
|
||||
@ -76,7 +76,7 @@ static void PairKeyboardCallback(int key, int state)
|
||||
gReset = true;
|
||||
}
|
||||
|
||||
//btDefaultKeyboardCallback(key,state);
|
||||
//b3DefaultKeyboardCallback(key,state);
|
||||
oldCallback(key,state);
|
||||
}
|
||||
|
||||
@ -156,21 +156,21 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
bool animate=true;
|
||||
int numObjects= m_data->m_rigidBodyPipeline->getNumBodies();
|
||||
//m_instancingRenderer->getInternalData()->m_totalNumInstances;
|
||||
btVector4* positions = 0;
|
||||
b3Vector4* positions = 0;
|
||||
if (animate && numObjects)
|
||||
{
|
||||
BT_PROFILE("gl2cl");
|
||||
B3_PROFILE("gl2cl");
|
||||
|
||||
if (!m_data->m_instancePosOrnColor)
|
||||
{
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(btVector4);
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(b3Vector4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
cl_bool blocking= CL_TRUE;
|
||||
positions= (btVector4*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_READ_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
positions= (b3Vector4*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_READ_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
m_data->m_instancePosOrnColor = new btOpenCLArray<btVector4>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_instancePosOrnColor = new b3OpenCLArray<b3Vector4>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_instancePosOrnColor->resize(3*numObjects);
|
||||
m_data->m_instancePosOrnColor->copyFromHostPointer(positions,3*numObjects,0);
|
||||
glUnmapBuffer( GL_ARRAY_BUFFER);
|
||||
@ -180,16 +180,16 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("stepSimulation");
|
||||
B3_PROFILE("stepSimulation");
|
||||
m_data->m_rigidBodyPipeline->stepSimulation(1./60.f);
|
||||
}
|
||||
|
||||
if (numObjects)
|
||||
{
|
||||
BT_PROFILE("cl2gl_convert");
|
||||
B3_PROFILE("cl2gl_convert");
|
||||
int ciErrNum = 0;
|
||||
cl_mem bodies = m_data->m_rigidBodyPipeline->getBodyBuffer();
|
||||
btLauncherCL launch(m_clData->m_clQueue,m_data->m_copyTransformsToVBOKernel);
|
||||
b3LauncherCL launch(m_clData->m_clQueue,m_data->m_copyTransformsToVBOKernel);
|
||||
launch.setBuffer(bodies);
|
||||
launch.setBuffer(m_data->m_instancePosOrnColor->getBufferCL());
|
||||
launch.setConst(numObjects);
|
||||
@ -199,14 +199,14 @@ void GpuRigidBodyDemo::clientMoveAndDisplay()
|
||||
|
||||
if (animate && numObjects)
|
||||
{
|
||||
BT_PROFILE("cl2gl_upload");
|
||||
B3_PROFILE("cl2gl_upload");
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(btVector4);
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(b3Vector4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
cl_bool blocking= CL_TRUE;
|
||||
positions= (btVector4*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_WRITE_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
positions= (b3Vector4*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_WRITE_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
m_data->m_instancePosOrnColor->copyToHostPointer(positions,3*numObjects,0);
|
||||
|
@ -7,7 +7,7 @@ class GpuRigidBodyDemo : public GpuDemo
|
||||
{
|
||||
protected:
|
||||
class GLInstancingRenderer* m_instancingRenderer;
|
||||
class btgWindowInterface* m_window;
|
||||
class b3gWindowInterface* m_window;
|
||||
|
||||
struct GpuRigidBodyDemoInternalData* m_data;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define GPU_RIGIDBODY_INTERNAL_DATA_H
|
||||
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
struct GpuRigidBodyDemoInternalData
|
||||
@ -10,7 +10,7 @@ struct GpuRigidBodyDemoInternalData
|
||||
|
||||
cl_kernel m_copyTransformsToVBOKernel;
|
||||
|
||||
btOpenCLArray<btVector4>* m_instancePosOrnColor;
|
||||
b3OpenCLArray<b3Vector4>* m_instancePosOrnColor;
|
||||
|
||||
class b3GpuRigidBodyPipeline* m_rigidBodyPipeline;
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/btgWindowInterface.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "gpu_rigidbody/host/b3GpuRigidBodyPipeline.h"
|
||||
#include "gpu_rigidbody/host/b3GpuNarrowPhase.h"
|
||||
#include "gpu_rigidbody/host/b3Config.h"
|
||||
@ -53,7 +53,7 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,BT_GL_POINTS);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
if (radius>=10)
|
||||
@ -71,12 +71,12 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
}
|
||||
|
||||
}
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,1,1,1),
|
||||
btVector4(1,1,0,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
@ -90,10 +90,10 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(radius,radius,radius,1);
|
||||
b3Vector4 scaling(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, writeInstanceToGpu);
|
||||
|
||||
@ -110,12 +110,12 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
|
||||
btVector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,1,1,1),
|
||||
btVector4(1,1,0,1),
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
|
||||
@ -147,10 +147,10 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
btVector4 color = colors[curColor];
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
btVector4 scaling(radius,radius,radius,1);
|
||||
b3Vector4 scaling(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, writeInstanceToGpu);
|
||||
|
||||
@ -163,7 +163,7 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
if (1)
|
||||
{
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
btVector4 scaling(0.5,0.5,0.5,1);//1,1,1,1);//0.1,0.1,0.1,1);
|
||||
b3Vector4 scaling(0.5,0.5,0.5,1);//1,1,1,1);//0.1,0.1,0.1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 normal(0,-1,0);
|
||||
float constant=2;
|
||||
@ -175,11 +175,11 @@ void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
//int i=0;int j=0;
|
||||
{
|
||||
//int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
btVector4 position(2*i,70+k*2,2*j+8,0);
|
||||
b3Vector4 position(2*i,70+k*2,2*j+8,0);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
|
||||
btVector4 color(0,0,1,1);
|
||||
b3Vector4 color(0,0,1,1);
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(1.f,position,orn,colIndex,index,false);
|
||||
|
@ -13,8 +13,8 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_OPENCL_INCLUDE_H
|
||||
#define BT_OPENCL_INCLUDE_H
|
||||
#ifndef B3_OPENCL_INCLUDE_H
|
||||
#define B3_OPENCL_INCLUDE_H
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -40,5 +40,5 @@ subject to the following restrictions:
|
||||
#define oclCHECKERROR(a, b) if((a)!=(b)) { printf("OCL Error : %d\n", (a)); assert((a) == (b)); }
|
||||
|
||||
|
||||
#endif //BT_OPENCL_INCLUDE_H
|
||||
#endif //B3_OPENCL_INCLUDE_H
|
||||
|
||||
|
@ -31,14 +31,14 @@ bool gDebugSkipLoadingBinary = false;
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BT_MAX_CL_DEVICES 16 //who needs 16 devices?
|
||||
#define B3_MAX_CL_DEVICES 16 //who needs 16 devices?
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#define btAssert assert
|
||||
#define b3Assert assert
|
||||
|
||||
|
||||
//Set the preferred platform vendor using the OpenCL SDK
|
||||
@ -78,14 +78,14 @@ void MyFatalBreakAPPLE( const char * errstr ,
|
||||
} else
|
||||
{
|
||||
printf("error\n");
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int btOpenCLUtils_getNumPlatforms(cl_int* pErrNum)
|
||||
int b3OpenCLUtils_getNumPlatforms(cl_int* pErrNum)
|
||||
{
|
||||
|
||||
cl_platform_id pPlatforms[10] = { 0 };
|
||||
@ -103,12 +103,12 @@ int btOpenCLUtils_getNumPlatforms(cl_int* pErrNum)
|
||||
|
||||
}
|
||||
|
||||
const char* btOpenCLUtils_getSdkVendorName()
|
||||
const char* b3OpenCLUtils_getSdkVendorName()
|
||||
{
|
||||
return spPlatformVendor;
|
||||
}
|
||||
|
||||
cl_platform_id btOpenCLUtils_getPlatform(int platformIndex0, cl_int* pErrNum)
|
||||
cl_platform_id b3OpenCLUtils_getPlatform(int platformIndex0, cl_int* pErrNum)
|
||||
{
|
||||
cl_platform_id platform = 0;
|
||||
unsigned int platformIndex = (unsigned int )platformIndex0;
|
||||
@ -134,20 +134,20 @@ cl_platform_id btOpenCLUtils_getPlatform(int platformIndex0, cl_int* pErrNum)
|
||||
return platform;
|
||||
}
|
||||
|
||||
void b3OpenCLUtils::getPlatformInfo(cl_platform_id platform, btOpenCLPlatformInfo* platformInfo)
|
||||
void b3OpenCLUtils::getPlatformInfo(cl_platform_id platform, b3OpenCLPlatformInfo* platformInfo)
|
||||
{
|
||||
cl_int ciErrNum;
|
||||
ciErrNum = clGetPlatformInfo( platform,CL_PLATFORM_VENDOR,BT_MAX_STRING_LENGTH,platformInfo->m_platformVendor,NULL);
|
||||
ciErrNum = clGetPlatformInfo( platform,CL_PLATFORM_VENDOR,B3_MAX_STRING_LENGTH,platformInfo->m_platformVendor,NULL);
|
||||
oclCHECKERROR(ciErrNum,CL_SUCCESS);
|
||||
ciErrNum = clGetPlatformInfo( platform,CL_PLATFORM_NAME,BT_MAX_STRING_LENGTH,platformInfo->m_platformName,NULL);
|
||||
ciErrNum = clGetPlatformInfo( platform,CL_PLATFORM_NAME,B3_MAX_STRING_LENGTH,platformInfo->m_platformName,NULL);
|
||||
oclCHECKERROR(ciErrNum,CL_SUCCESS);
|
||||
ciErrNum = clGetPlatformInfo( platform,CL_PLATFORM_VERSION,BT_MAX_STRING_LENGTH,platformInfo->m_platformVersion,NULL);
|
||||
ciErrNum = clGetPlatformInfo( platform,CL_PLATFORM_VERSION,B3_MAX_STRING_LENGTH,platformInfo->m_platformVersion,NULL);
|
||||
oclCHECKERROR(ciErrNum,CL_SUCCESS);
|
||||
}
|
||||
|
||||
void btOpenCLUtils_printPlatformInfo(cl_platform_id platform)
|
||||
void b3OpenCLUtils_printPlatformInfo(cl_platform_id platform)
|
||||
{
|
||||
btOpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLUtils::getPlatformInfo (platform, &platformInfo);
|
||||
printf("Platform info:\n");
|
||||
printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor);
|
||||
@ -157,12 +157,12 @@ void btOpenCLUtils_printPlatformInfo(cl_platform_id platform)
|
||||
|
||||
|
||||
|
||||
cl_context btOpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC, int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
cl_context b3OpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC, int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
{
|
||||
cl_context retContext = 0;
|
||||
cl_int ciErrNum=0;
|
||||
cl_uint num_entries;
|
||||
cl_device_id devices[BT_MAX_CL_DEVICES];
|
||||
cl_device_id devices[B3_MAX_CL_DEVICES];
|
||||
cl_uint num_devices;
|
||||
cl_context_properties* cprops;
|
||||
|
||||
@ -182,7 +182,7 @@ cl_context btOpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_d
|
||||
cps[5] = (cl_context_properties)pGLDC;
|
||||
}
|
||||
#endif //_WIN32
|
||||
num_entries = BT_MAX_CL_DEVICES;
|
||||
num_entries = B3_MAX_CL_DEVICES;
|
||||
|
||||
|
||||
num_devices=-1;
|
||||
@ -241,7 +241,7 @@ cl_context btOpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_d
|
||||
return retContext;
|
||||
}
|
||||
|
||||
cl_context btOpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC , int preferredDeviceIndex, int preferredPlatformIndex, cl_platform_id* retPlatformId)
|
||||
cl_context b3OpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC , int preferredDeviceIndex, int preferredPlatformIndex, cl_platform_id* retPlatformId)
|
||||
{
|
||||
cl_uint numPlatforms;
|
||||
cl_context retContext = 0;
|
||||
@ -303,12 +303,12 @@ cl_context btOpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int
|
||||
cl_platform_id platform = platforms[i];
|
||||
assert(platform);
|
||||
|
||||
retContext = btOpenCLUtils_createContextFromPlatform(platform,deviceType,pErrNum,pGLContext,pGLDC,preferredDeviceIndex,preferredPlatformIndex);
|
||||
retContext = b3OpenCLUtils_createContextFromPlatform(platform,deviceType,pErrNum,pGLContext,pGLDC,preferredDeviceIndex,preferredPlatformIndex);
|
||||
|
||||
if (retContext)
|
||||
{
|
||||
// printf("OpenCL platform details:\n");
|
||||
btOpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLPlatformInfo platformInfo;
|
||||
|
||||
b3OpenCLUtils::getPlatformInfo(platform, &platformInfo);
|
||||
|
||||
@ -332,7 +332,7 @@ cl_context btOpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int
|
||||
//! @param cxMainContext OpenCL context
|
||||
//! @param device_idx index of the device of interest
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
cl_device_id btOpenCLUtils_getDevice(cl_context cxMainContext, int deviceIndex)
|
||||
cl_device_id b3OpenCLUtils_getDevice(cl_context cxMainContext, int deviceIndex)
|
||||
{
|
||||
assert(cxMainContext);
|
||||
|
||||
@ -357,7 +357,7 @@ cl_device_id btOpenCLUtils_getDevice(cl_context cxMainContext, int deviceIndex)
|
||||
return device;
|
||||
}
|
||||
|
||||
int btOpenCLUtils_getNumDevices(cl_context cxMainContext)
|
||||
int b3OpenCLUtils_getNumDevices(cl_context cxMainContext)
|
||||
{
|
||||
size_t szParamDataBytes;
|
||||
int device_count;
|
||||
@ -368,16 +368,16 @@ int btOpenCLUtils_getNumDevices(cl_context cxMainContext)
|
||||
|
||||
|
||||
|
||||
void b3OpenCLUtils::getDeviceInfo(cl_device_id device, btOpenCLDeviceInfo* info)
|
||||
void b3OpenCLUtils::getDeviceInfo(cl_device_id device, b3OpenCLDeviceInfo* info)
|
||||
{
|
||||
// CL_DEVICE_NAME
|
||||
clGetDeviceInfo(device, CL_DEVICE_NAME, BT_MAX_STRING_LENGTH, &info->m_deviceName, NULL);
|
||||
clGetDeviceInfo(device, CL_DEVICE_NAME, B3_MAX_STRING_LENGTH, &info->m_deviceName, NULL);
|
||||
|
||||
// CL_DEVICE_VENDOR
|
||||
clGetDeviceInfo(device, CL_DEVICE_VENDOR, BT_MAX_STRING_LENGTH, &info->m_deviceVendor, NULL);
|
||||
clGetDeviceInfo(device, CL_DEVICE_VENDOR, B3_MAX_STRING_LENGTH, &info->m_deviceVendor, NULL);
|
||||
|
||||
// CL_DRIVER_VERSION
|
||||
clGetDeviceInfo(device, CL_DRIVER_VERSION, BT_MAX_STRING_LENGTH, &info->m_driverVersion, NULL);
|
||||
clGetDeviceInfo(device, CL_DRIVER_VERSION, B3_MAX_STRING_LENGTH, &info->m_driverVersion, NULL);
|
||||
|
||||
// CL_DEVICE_INFO
|
||||
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(cl_device_type), &info->m_deviceType, NULL);
|
||||
@ -438,7 +438,7 @@ void b3OpenCLUtils::getDeviceInfo(cl_device_id device, btOpenCLDeviceInfo* info)
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(size_t), &info->m_image3dMaxDepth, NULL);
|
||||
|
||||
// CL_DEVICE_EXTENSIONS: get device extensions, and if any then parse & log the string onto separate lines
|
||||
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, BT_MAX_STRING_LENGTH, &info->m_deviceExtensions, NULL);
|
||||
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, B3_MAX_STRING_LENGTH, &info->m_deviceExtensions, NULL);
|
||||
|
||||
// CL_DEVICE_PREFERRED_VECTOR_WIDTH_<type>
|
||||
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &info->m_vecWidthChar, NULL);
|
||||
@ -450,9 +450,9 @@ void b3OpenCLUtils::getDeviceInfo(cl_device_id device, btOpenCLDeviceInfo* info)
|
||||
}
|
||||
|
||||
|
||||
void btOpenCLUtils_printDeviceInfo(cl_device_id device)
|
||||
void b3OpenCLUtils_printDeviceInfo(cl_device_id device)
|
||||
{
|
||||
btOpenCLDeviceInfo info;
|
||||
b3OpenCLDeviceInfo info;
|
||||
b3OpenCLUtils::getDeviceInfo(device,&info);
|
||||
printf("Device Info:\n");
|
||||
printf(" CL_DEVICE_NAME: \t\t\t%s\n", info.m_deviceName);
|
||||
@ -521,7 +521,7 @@ static const char* strip2(const char* name, const char* pattern)
|
||||
return oriptr;
|
||||
}
|
||||
|
||||
cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_device_id device, const char* kernelSourceOrg, cl_int* pErrNum, const char* additionalMacrosArg , const char* clFileNameForCaching, bool disableBinaryCaching)
|
||||
cl_program b3OpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_device_id device, const char* kernelSourceOrg, cl_int* pErrNum, const char* additionalMacrosArg , const char* clFileNameForCaching, bool disableBinaryCaching)
|
||||
{
|
||||
const char* additionalMacros = additionalMacrosArg?additionalMacrosArg:"";
|
||||
|
||||
@ -534,7 +534,7 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
cl_int status;
|
||||
|
||||
#ifdef _WIN32
|
||||
char binaryFileName[BT_MAX_STRING_LENGTH];
|
||||
char binaryFileName[B3_MAX_STRING_LENGTH];
|
||||
char* bla=0;
|
||||
|
||||
if (clFileNameForCaching && !(disableBinaryCaching || gDebugSkipLoadingBinary||gDebugForceLoadingFromSource) )
|
||||
@ -556,7 +556,7 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
sprintf_s(binaryFileName,BT_MAX_STRING_LENGTH,"cache/%s.%s.%s.bin",strippedName, deviceName,driverVersion );
|
||||
sprintf_s(binaryFileName,B3_MAX_STRING_LENGTH,"cache/%s.%s.%s.bin",strippedName, deviceName,driverVersion );
|
||||
#else
|
||||
sprintf(binaryFileName,"cache/%s.%s.%s.bin",strippedName, deviceName,driverVersion );
|
||||
#endif
|
||||
@ -701,9 +701,9 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
fclose( file );
|
||||
|
||||
m_cpProgram = clCreateProgramWithBinary( clContext, 1,&device, &binarySize, (const unsigned char**)&binary, 0, &status );
|
||||
btAssert( status == CL_SUCCESS );
|
||||
b3Assert( status == CL_SUCCESS );
|
||||
status = clBuildProgram( m_cpProgram, 1, &device, additionalMacros, 0, 0 );
|
||||
btAssert( status == CL_SUCCESS );
|
||||
b3Assert( status == CL_SUCCESS );
|
||||
|
||||
if( status != CL_SUCCESS )
|
||||
{
|
||||
@ -715,7 +715,7 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
build_log[ret_val_size] = '\0';
|
||||
printf("%s\n", build_log);
|
||||
free (build_log);
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
m_cpProgram = 0;
|
||||
}
|
||||
free (binary);
|
||||
@ -825,7 +825,7 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
|
||||
cl_uint numAssociatedDevices;
|
||||
status = clGetProgramInfo( m_cpProgram, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &numAssociatedDevices, 0 );
|
||||
btAssert( status == CL_SUCCESS );
|
||||
b3Assert( status == CL_SUCCESS );
|
||||
if (numAssociatedDevices==1)
|
||||
{
|
||||
|
||||
@ -833,12 +833,12 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
char* binary ;
|
||||
|
||||
status = clGetProgramInfo( m_cpProgram, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &binarySize, 0 );
|
||||
btAssert( status == CL_SUCCESS );
|
||||
b3Assert( status == CL_SUCCESS );
|
||||
|
||||
binary = (char*)malloc(sizeof(char)*binarySize);
|
||||
|
||||
status = clGetProgramInfo( m_cpProgram, CL_PROGRAM_BINARIES, sizeof(char*), &binary, 0 );
|
||||
btAssert( status == CL_SUCCESS );
|
||||
b3Assert( status == CL_SUCCESS );
|
||||
|
||||
{
|
||||
FILE* file=0;
|
||||
@ -870,7 +870,7 @@ cl_program btOpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
}
|
||||
|
||||
|
||||
cl_kernel btOpenCLUtils_compileCLKernelFromString(cl_context clContext, cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum, cl_program prog, const char* additionalMacros )
|
||||
cl_kernel b3OpenCLUtils_compileCLKernelFromString(cl_context clContext, cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum, cl_program prog, const char* additionalMacros )
|
||||
{
|
||||
|
||||
cl_kernel kernel;
|
||||
@ -882,7 +882,7 @@ cl_kernel btOpenCLUtils_compileCLKernelFromString(cl_context clContext, cl_devic
|
||||
|
||||
if (!m_cpProgram)
|
||||
{
|
||||
m_cpProgram = btOpenCLUtils_compileCLProgramFromString(clContext,device,kernelSource,pErrNum, additionalMacros,0, false);
|
||||
m_cpProgram = b3OpenCLUtils_compileCLProgramFromString(clContext,device,kernelSource,pErrNum, additionalMacros,0, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,8 +16,8 @@ subject to the following restrictions:
|
||||
//original author: Roman Ponomarev
|
||||
//cleanup by Erwin Coumans
|
||||
|
||||
#ifndef BT_OPENCL_UTILS_H
|
||||
#define BT_OPENCL_UTILS_H
|
||||
#ifndef B3_OPENCL_UTILS_H
|
||||
#define B3_OPENCL_UTILS_H
|
||||
|
||||
#include "b3OpenCLInclude.h"
|
||||
|
||||
@ -30,42 +30,42 @@ extern "C" {
|
||||
|
||||
/// CL Context optionally takes a GL context. This is a generic type because we don't really want this code
|
||||
/// to have to understand GL types. It is a HGLRC in _WIN32 or a GLXContext otherwise.
|
||||
cl_context btOpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx , void* pGLDC , int preferredDeviceIndex , int preferredPlatformIndex, cl_platform_id* platformId);
|
||||
cl_context b3OpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx , void* pGLDC , int preferredDeviceIndex , int preferredPlatformIndex, cl_platform_id* platformId);
|
||||
|
||||
int btOpenCLUtils_getNumDevices(cl_context cxMainContext);
|
||||
int b3OpenCLUtils_getNumDevices(cl_context cxMainContext);
|
||||
|
||||
cl_device_id btOpenCLUtils_getDevice(cl_context cxMainContext, int nr);
|
||||
cl_device_id b3OpenCLUtils_getDevice(cl_context cxMainContext, int nr);
|
||||
|
||||
void btOpenCLUtils_printDeviceInfo(cl_device_id device);
|
||||
void b3OpenCLUtils_printDeviceInfo(cl_device_id device);
|
||||
|
||||
cl_kernel btOpenCLUtils_compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum, cl_program prog,const char* additionalMacros);
|
||||
cl_kernel b3OpenCLUtils_compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum, cl_program prog,const char* additionalMacros);
|
||||
|
||||
//optional
|
||||
cl_program btOpenCLUtils_compileCLProgramFromString( cl_context clContext,cl_device_id device, const char* kernelSource, cl_int* pErrNum,const char* additionalMacros , const char* srcFileNameForCaching, bool disableBinaryCaching);
|
||||
cl_program b3OpenCLUtils_compileCLProgramFromString( cl_context clContext,cl_device_id device, const char* kernelSource, cl_int* pErrNum,const char* additionalMacros , const char* srcFileNameForCaching, bool disableBinaryCaching);
|
||||
|
||||
//the following optional APIs provide access using specific platform information
|
||||
int btOpenCLUtils_getNumPlatforms(cl_int* pErrNum);
|
||||
int b3OpenCLUtils_getNumPlatforms(cl_int* pErrNum);
|
||||
|
||||
///get the nr'th platform, where nr is in the range [0..getNumPlatforms)
|
||||
cl_platform_id btOpenCLUtils_getPlatform(int nr, cl_int* pErrNum);
|
||||
cl_platform_id b3OpenCLUtils_getPlatform(int nr, cl_int* pErrNum);
|
||||
|
||||
void btOpenCLUtils_printPlatformInfo(cl_platform_id platform);
|
||||
void b3OpenCLUtils_printPlatformInfo(cl_platform_id platform);
|
||||
|
||||
const char* btOpenCLUtils_getSdkVendorName();
|
||||
const char* b3OpenCLUtils_getSdkVendorName();
|
||||
|
||||
cl_context btOpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx , void* pGLDC ,int preferredDeviceIndex , int preferredPlatformIndex);
|
||||
cl_context b3OpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx , void* pGLDC ,int preferredDeviceIndex , int preferredPlatformIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#define BT_MAX_STRING_LENGTH 1024
|
||||
#define B3_MAX_STRING_LENGTH 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char m_deviceName[BT_MAX_STRING_LENGTH];
|
||||
char m_deviceVendor[BT_MAX_STRING_LENGTH];
|
||||
char m_driverVersion[BT_MAX_STRING_LENGTH];
|
||||
char m_deviceExtensions[BT_MAX_STRING_LENGTH];
|
||||
char m_deviceName[B3_MAX_STRING_LENGTH];
|
||||
char m_deviceVendor[B3_MAX_STRING_LENGTH];
|
||||
char m_driverVersion[B3_MAX_STRING_LENGTH];
|
||||
char m_deviceExtensions[B3_MAX_STRING_LENGTH];
|
||||
|
||||
cl_device_type m_deviceType;
|
||||
cl_uint m_computeUnits;
|
||||
@ -99,14 +99,14 @@ typedef struct
|
||||
cl_uint m_vecWidthFloat;
|
||||
cl_uint m_vecWidthDouble;
|
||||
|
||||
} btOpenCLDeviceInfo;
|
||||
} b3OpenCLDeviceInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char m_platformVendor[BT_MAX_STRING_LENGTH];
|
||||
char m_platformName[BT_MAX_STRING_LENGTH];
|
||||
char m_platformVersion[BT_MAX_STRING_LENGTH];
|
||||
} btOpenCLPlatformInfo;
|
||||
char m_platformVendor[B3_MAX_STRING_LENGTH];
|
||||
char m_platformName[B3_MAX_STRING_LENGTH];
|
||||
char m_platformVersion[B3_MAX_STRING_LENGTH];
|
||||
} b3OpenCLPlatformInfo;
|
||||
|
||||
|
||||
///C++ API for OpenCL utilities: convenience functions
|
||||
@ -116,64 +116,64 @@ struct b3OpenCLUtils
|
||||
/// to have to understand GL types. It is a HGLRC in _WIN32 or a GLXContext otherwise.
|
||||
static inline cl_context createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0, int preferredDeviceIndex = -1, int preferredPlatformIndex= - 1, cl_platform_id* platformId=0)
|
||||
{
|
||||
return btOpenCLUtils_createContextFromType(deviceType, pErrNum, pGLCtx , pGLDC , preferredDeviceIndex, preferredPlatformIndex, platformId);
|
||||
return b3OpenCLUtils_createContextFromType(deviceType, pErrNum, pGLCtx , pGLDC , preferredDeviceIndex, preferredPlatformIndex, platformId);
|
||||
}
|
||||
|
||||
static inline int getNumDevices(cl_context cxMainContext)
|
||||
{
|
||||
return btOpenCLUtils_getNumDevices(cxMainContext);
|
||||
return b3OpenCLUtils_getNumDevices(cxMainContext);
|
||||
}
|
||||
static inline cl_device_id getDevice(cl_context cxMainContext, int nr)
|
||||
{
|
||||
return btOpenCLUtils_getDevice(cxMainContext,nr);
|
||||
return b3OpenCLUtils_getDevice(cxMainContext,nr);
|
||||
}
|
||||
|
||||
static void getDeviceInfo(cl_device_id device, btOpenCLDeviceInfo* info);
|
||||
static void getDeviceInfo(cl_device_id device, b3OpenCLDeviceInfo* info);
|
||||
|
||||
static inline void printDeviceInfo(cl_device_id device)
|
||||
{
|
||||
btOpenCLUtils_printDeviceInfo(device);
|
||||
b3OpenCLUtils_printDeviceInfo(device);
|
||||
}
|
||||
|
||||
static inline cl_kernel compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum=0, cl_program prog=0,const char* additionalMacros = "" )
|
||||
{
|
||||
return btOpenCLUtils_compileCLKernelFromString(clContext,device, kernelSource, kernelName, pErrNum, prog,additionalMacros);
|
||||
return b3OpenCLUtils_compileCLKernelFromString(clContext,device, kernelSource, kernelName, pErrNum, prog,additionalMacros);
|
||||
}
|
||||
|
||||
//optional
|
||||
static inline cl_program compileCLProgramFromString( cl_context clContext,cl_device_id device, const char* kernelSource, cl_int* pErrNum=0,const char* additionalMacros = "" , const char* srcFileNameForCaching=0, bool disableBinaryCaching=false)
|
||||
{
|
||||
return btOpenCLUtils_compileCLProgramFromString(clContext,device, kernelSource, pErrNum,additionalMacros, srcFileNameForCaching, disableBinaryCaching);
|
||||
return b3OpenCLUtils_compileCLProgramFromString(clContext,device, kernelSource, pErrNum,additionalMacros, srcFileNameForCaching, disableBinaryCaching);
|
||||
}
|
||||
|
||||
//the following optional APIs provide access using specific platform information
|
||||
static inline int getNumPlatforms(cl_int* pErrNum=0)
|
||||
{
|
||||
return btOpenCLUtils_getNumPlatforms(pErrNum);
|
||||
return b3OpenCLUtils_getNumPlatforms(pErrNum);
|
||||
}
|
||||
///get the nr'th platform, where nr is in the range [0..getNumPlatforms)
|
||||
static inline cl_platform_id getPlatform(int nr, cl_int* pErrNum=0)
|
||||
{
|
||||
return btOpenCLUtils_getPlatform(nr,pErrNum);
|
||||
return b3OpenCLUtils_getPlatform(nr,pErrNum);
|
||||
}
|
||||
|
||||
static void getPlatformInfo(cl_platform_id platform, btOpenCLPlatformInfo* platformInfo);
|
||||
static void getPlatformInfo(cl_platform_id platform, b3OpenCLPlatformInfo* platformInfo);
|
||||
|
||||
static inline void printPlatformInfo(cl_platform_id platform)
|
||||
{
|
||||
btOpenCLUtils_printPlatformInfo(platform);
|
||||
b3OpenCLUtils_printPlatformInfo(platform);
|
||||
}
|
||||
|
||||
static inline const char* getSdkVendorName()
|
||||
{
|
||||
return btOpenCLUtils_getSdkVendorName();
|
||||
return b3OpenCLUtils_getSdkVendorName();
|
||||
}
|
||||
static inline cl_context createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0,int preferredDeviceIndex = -1, int preferredPlatformIndex= -1)
|
||||
{
|
||||
return btOpenCLUtils_createContextFromPlatform(platform, deviceType, pErrNum, pGLCtx,pGLDC,preferredDeviceIndex, preferredPlatformIndex);
|
||||
return b3OpenCLUtils_createContextFromPlatform(platform, deviceType, pErrNum, pGLCtx,pGLDC,preferredDeviceIndex, preferredPlatformIndex);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
#endif // BT_OPENCL_UTILS_H
|
||||
#endif // B3_OPENCL_UTILS_H
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char* argv[])
|
||||
for (int i=0;i<numPlatforms;i++)
|
||||
{
|
||||
cl_platform_id platform = b3OpenCLUtils::getPlatform(i);
|
||||
btOpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLPlatformInfo platformInfo;
|
||||
b3OpenCLUtils::getPlatformInfo(platform,&platformInfo);
|
||||
printf("--------------------------------\n");
|
||||
printf("Platform info for platform nr %d:\n",i);
|
||||
@ -52,7 +52,7 @@ int main(int argc, char* argv[])
|
||||
for (int j=0;j<numDevices;j++)
|
||||
{
|
||||
cl_device_id dev = b3OpenCLUtils::getDevice(context,j);
|
||||
btOpenCLDeviceInfo devInfo;
|
||||
b3OpenCLDeviceInfo devInfo;
|
||||
b3OpenCLUtils::getDeviceInfo(dev,&devInfo);
|
||||
b3OpenCLUtils::printDeviceInfo(dev);
|
||||
}
|
||||
@ -77,7 +77,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
cl_device_id device;
|
||||
device = b3OpenCLUtils::getDevice(g_cxMainContext,i);
|
||||
btOpenCLDeviceInfo clInfo;
|
||||
b3OpenCLDeviceInfo clInfo;
|
||||
b3OpenCLUtils::getDeviceInfo(device,&clInfo);
|
||||
b3OpenCLUtils::printDeviceInfo(device);
|
||||
// create a command-queue
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include "b3GpuSapBroadphase.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
|
||||
@ -29,9 +29,9 @@ m_currentBuffer(-1)
|
||||
cl_int errNum=0;
|
||||
|
||||
cl_program sapProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,sapSrc,&errNum,"","opencl/gpu_broadphase/kernels/sap.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
cl_program sapFastProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,sapFastSrc,&errNum,"","opencl/gpu_broadphase/kernels/sapFast.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
|
||||
//m_sapKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,sapSrc, "computePairsKernelOriginal",&errNum,sapProg );
|
||||
@ -40,19 +40,19 @@ m_currentBuffer(-1)
|
||||
|
||||
|
||||
m_sap2Kernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,sapSrc, "computePairsKernelTwoArrays",&errNum,sapProg );
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
#if 0
|
||||
|
||||
m_sapKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,sapSrc, "computePairsKernelOriginal",&errNum,sapProg );
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
#else
|
||||
#ifndef __APPLE__
|
||||
m_sapKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,sapFastSrc, "computePairsKernel",&errNum,sapFastProg );
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
#else
|
||||
m_sapKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,sapSrc, "computePairsKernelLocalSharedMemory",&errNum,sapProg );
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -62,7 +62,7 @@ m_currentBuffer(-1)
|
||||
|
||||
m_scatterKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,sapSrc, "scatterKernel",&errNum,sapProg );
|
||||
|
||||
m_sorter = new btRadixSort32CL(m_context,m_device,m_queue);
|
||||
m_sorter = new b3RadixSort32CL(m_context,m_device,m_queue);
|
||||
}
|
||||
|
||||
b3GpuSapBroadphase::~b3GpuSapBroadphase()
|
||||
@ -125,7 +125,7 @@ void b3GpuSapBroadphase::init3dSap()
|
||||
}
|
||||
void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
{
|
||||
btAssert(m_currentBuffer>=0);
|
||||
b3Assert(m_currentBuffer>=0);
|
||||
if (m_currentBuffer<0)
|
||||
return;
|
||||
|
||||
@ -135,7 +135,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHostIncremental3Sap()
|
||||
{
|
||||
for (int buf=0;buf<2;buf++)
|
||||
{
|
||||
btAssert(m_sortedAxisCPU[axis][buf].size() == m_allAabbsCPU.size());
|
||||
b3Assert(m_sortedAxisCPU[axis][buf].size() == m_allAabbsCPU.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
|
||||
|
||||
int axis=0;
|
||||
|
||||
btAssert(m_allAabbsCPU.size() == m_allAabbsGPU.size());
|
||||
b3Assert(m_allAabbsCPU.size() == m_allAabbsGPU.size());
|
||||
|
||||
|
||||
|
||||
@ -192,7 +192,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
|
||||
}
|
||||
}
|
||||
|
||||
b3AlignedObjectArray<btInt2> hostPairs;
|
||||
b3AlignedObjectArray<b3Int2> hostPairs;
|
||||
|
||||
{
|
||||
int numSmallAabbs = m_smallAabbsCPU.size();
|
||||
@ -205,7 +205,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
|
||||
if (TestAabbAgainstAabb2((b3Vector3&)m_smallAabbsCPU[i].m_min, (b3Vector3&)m_smallAabbsCPU[i].m_max,
|
||||
(b3Vector3&)m_smallAabbsCPU[j].m_min,(b3Vector3&)m_smallAabbsCPU[j].m_max))
|
||||
{
|
||||
btInt2 pair;
|
||||
b3Int2 pair;
|
||||
pair.x = m_smallAabbsCPU[i].m_minIndices[3];//store the original index in the unsorted aabb array
|
||||
pair.y = m_smallAabbsCPU[j].m_minIndices[3];
|
||||
hostPairs.push_back(pair);
|
||||
@ -227,7 +227,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairsHost()
|
||||
if (TestAabbAgainstAabb2((b3Vector3&)m_smallAabbsCPU[i].m_min, (b3Vector3&)m_smallAabbsCPU[i].m_max,
|
||||
(b3Vector3&)m_largeAabbsCPU[j].m_min,(b3Vector3&)m_largeAabbsCPU[j].m_max))
|
||||
{
|
||||
btInt2 pair;
|
||||
b3Int2 pair;
|
||||
pair.x = m_largeAabbsCPU[j].m_minIndices[3];
|
||||
pair.y = m_smallAabbsCPU[i].m_minIndices[3];//store the original index in the unsorted aabb array
|
||||
hostPairs.push_back(pair);
|
||||
@ -261,7 +261,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
if (syncOnHost)
|
||||
{
|
||||
BT_PROFILE("Synchronize m_smallAabbsGPU (CPU/slow)");
|
||||
B3_PROFILE("Synchronize m_smallAabbsGPU (CPU/slow)");
|
||||
|
||||
m_allAabbsGPU.copyToHost(m_allAabbsCPU);
|
||||
|
||||
@ -284,14 +284,14 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
int numSmallAabbs = m_smallAabbsGPU.size();
|
||||
if (numSmallAabbs)
|
||||
{
|
||||
BT_PROFILE("copyAabbsKernelSmall");
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( m_allAabbsGPU.getBufferCL(), true ),
|
||||
btBufferInfoCL( m_smallAabbsGPU.getBufferCL()),
|
||||
B3_PROFILE("copyAabbsKernelSmall");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( m_allAabbsGPU.getBufferCL(), true ),
|
||||
b3BufferInfoCL( m_smallAabbsGPU.getBufferCL()),
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_copyAabbsKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_copyAabbsKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numSmallAabbs );
|
||||
int num = numSmallAabbs;
|
||||
launcher.launch1D( num);
|
||||
@ -302,7 +302,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
if (syncOnHost)
|
||||
{
|
||||
BT_PROFILE("Synchronize m_largeAabbsGPU (CPU/slow)");
|
||||
B3_PROFILE("Synchronize m_largeAabbsGPU (CPU/slow)");
|
||||
|
||||
m_allAabbsGPU.copyToHost(m_allAabbsCPU);
|
||||
|
||||
@ -325,14 +325,14 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
if (numLargeAabbs)
|
||||
{
|
||||
BT_PROFILE("copyAabbsKernelLarge");
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( m_allAabbsGPU.getBufferCL(), true ),
|
||||
btBufferInfoCL( m_largeAabbsGPU.getBufferCL()),
|
||||
B3_PROFILE("copyAabbsKernelLarge");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( m_allAabbsGPU.getBufferCL(), true ),
|
||||
b3BufferInfoCL( m_largeAabbsGPU.getBufferCL()),
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_copyAabbsKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_copyAabbsKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numLargeAabbs );
|
||||
int num = numLargeAabbs;
|
||||
launcher.launch1D( num);
|
||||
@ -343,7 +343,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
|
||||
|
||||
BT_PROFILE("GPU SAP");
|
||||
B3_PROFILE("GPU SAP");
|
||||
|
||||
int numSmallAabbs = m_smallAabbsGPU.size();
|
||||
m_gpuSmallSortData.resize(numSmallAabbs);
|
||||
@ -352,10 +352,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
#if 1
|
||||
if (m_smallAabbsGPU.size())
|
||||
{
|
||||
BT_PROFILE("flipFloatKernel");
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_smallAabbsGPU.getBufferCL(), true ), btBufferInfoCL( m_gpuSmallSortData.getBufferCL())};
|
||||
btLauncherCL launcher(m_queue, m_flipFloatKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
B3_PROFILE("flipFloatKernel");
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_smallAabbsGPU.getBufferCL(), true ), b3BufferInfoCL( m_gpuSmallSortData.getBufferCL())};
|
||||
b3LauncherCL launcher(m_queue, m_flipFloatKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numSmallAabbs );
|
||||
launcher.setConst( axis );
|
||||
|
||||
@ -365,7 +365,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("gpu radix sort\n");
|
||||
B3_PROFILE("gpu radix sort\n");
|
||||
m_sorter->execute(m_gpuSmallSortData);
|
||||
clFinish(m_queue);
|
||||
}
|
||||
@ -373,10 +373,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
m_gpuSmallSortedAabbs.resize(numSmallAabbs);
|
||||
if (numSmallAabbs)
|
||||
{
|
||||
BT_PROFILE("scatterKernel");
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_smallAabbsGPU.getBufferCL(), true ), btBufferInfoCL( m_gpuSmallSortData.getBufferCL(),true),btBufferInfoCL(m_gpuSmallSortedAabbs.getBufferCL())};
|
||||
btLauncherCL launcher(m_queue, m_scatterKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
B3_PROFILE("scatterKernel");
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_smallAabbsGPU.getBufferCL(), true ), b3BufferInfoCL( m_gpuSmallSortData.getBufferCL(),true),b3BufferInfoCL(m_gpuSmallSortedAabbs.getBufferCL())};
|
||||
b3LauncherCL launcher(m_queue, m_scatterKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numSmallAabbs);
|
||||
int num = numSmallAabbs;
|
||||
launcher.launch1D( num);
|
||||
@ -389,7 +389,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
int maxPairs = maxPairsPerBody * numSmallAabbs;//todo
|
||||
m_overlappingPairs.resize(maxPairs);
|
||||
|
||||
btOpenCLArray<int> pairCount(m_context, m_queue);
|
||||
b3OpenCLArray<int> pairCount(m_context, m_queue);
|
||||
pairCount.push_back(0);
|
||||
int numPairs=0;
|
||||
|
||||
@ -397,10 +397,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
int numLargeAabbs = m_largeAabbsGPU.size();
|
||||
if (numLargeAabbs && numSmallAabbs)
|
||||
{
|
||||
BT_PROFILE("sap2Kernel");
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_largeAabbsGPU.getBufferCL() ),btBufferInfoCL( m_gpuSmallSortedAabbs.getBufferCL() ), btBufferInfoCL( m_overlappingPairs.getBufferCL() ), btBufferInfoCL(pairCount.getBufferCL())};
|
||||
btLauncherCL launcher(m_queue, m_sap2Kernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
B3_PROFILE("sap2Kernel");
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_largeAabbsGPU.getBufferCL() ),b3BufferInfoCL( m_gpuSmallSortedAabbs.getBufferCL() ), b3BufferInfoCL( m_overlappingPairs.getBufferCL() ), b3BufferInfoCL(pairCount.getBufferCL())};
|
||||
b3LauncherCL launcher(m_queue, m_sap2Kernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numLargeAabbs );
|
||||
launcher.setConst( numSmallAabbs);
|
||||
launcher.setConst( axis );
|
||||
@ -416,10 +416,10 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
}
|
||||
if (m_gpuSmallSortedAabbs.size())
|
||||
{
|
||||
BT_PROFILE("sapKernel");
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_gpuSmallSortedAabbs.getBufferCL() ), btBufferInfoCL( m_overlappingPairs.getBufferCL() ), btBufferInfoCL(pairCount.getBufferCL())};
|
||||
btLauncherCL launcher(m_queue, m_sapKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
B3_PROFILE("sapKernel");
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_gpuSmallSortedAabbs.getBufferCL() ), b3BufferInfoCL( m_overlappingPairs.getBufferCL() ), b3BufferInfoCL(pairCount.getBufferCL())};
|
||||
b3LauncherCL launcher(m_queue, m_sapKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numSmallAabbs );
|
||||
launcher.setConst( axis );
|
||||
launcher.setConst( maxPairs );
|
||||
@ -461,7 +461,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
int numPairs = 0;
|
||||
|
||||
|
||||
btLauncherCL launcher(m_queue, m_sapKernel);
|
||||
b3LauncherCL launcher(m_queue, m_sapKernel);
|
||||
|
||||
const char* fileName = "m_sapKernelArgs.bin";
|
||||
FILE* f = fopen(fileName,"rb");
|
||||
@ -480,13 +480,13 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
int num = *(int*)&buf[serializedBytes];
|
||||
launcher.launch1D( num);
|
||||
|
||||
btOpenCLArray<int> pairCount(m_context, m_queue);
|
||||
b3OpenCLArray<int> pairCount(m_context, m_queue);
|
||||
int numElements = launcher.m_arrays[2]->size()/sizeof(int);
|
||||
pairCount.setFromOpenCLBuffer(launcher.m_arrays[2]->getBufferCL(),numElements);
|
||||
numPairs = pairCount.at(0);
|
||||
//printf("overlapping pairs = %d\n",numPairs);
|
||||
b3AlignedObjectArray<btInt2> hostOoverlappingPairs;
|
||||
btOpenCLArray<btInt2> tmpGpuPairs(m_context,m_queue);
|
||||
b3AlignedObjectArray<b3Int2> hostOoverlappingPairs;
|
||||
b3OpenCLArray<b3Int2> tmpGpuPairs(m_context,m_queue);
|
||||
tmpGpuPairs.setFromOpenCLBuffer(launcher.m_arrays[1]->getBufferCL(),numPairs );
|
||||
|
||||
tmpGpuPairs.copyToHost(hostOoverlappingPairs);
|
||||
@ -507,7 +507,7 @@ void b3GpuSapBroadphase::calculateOverlappingPairs()
|
||||
|
||||
m_overlappingPairs.resize(numPairs);
|
||||
|
||||
}//BT_PROFILE("GPU_RADIX SORT");
|
||||
}//B3_PROFILE("GPU_RADIX SORT");
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef BT_GPU_SAP_BROADPHASE_H
|
||||
#define BT_GPU_SAP_BROADPHASE_H
|
||||
#ifndef B3_GPU_SAP_BROADPHASE_H
|
||||
#define B3_GPU_SAP_BROADPHASE_H
|
||||
|
||||
#include "parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "parallel_primitives/host/btFillCL.h" //btInt2
|
||||
#include "parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "parallel_primitives/host/b3FillCL.h" //b3Int2
|
||||
class b3Vector3;
|
||||
#include "parallel_primitives/host/btRadixSort32CL.h"
|
||||
#include "parallel_primitives/host/b3RadixSort32CL.h"
|
||||
|
||||
#include "b3SapAabb.h"
|
||||
|
||||
@ -22,28 +22,28 @@ class b3GpuSapBroadphase
|
||||
cl_kernel m_sapKernel;
|
||||
cl_kernel m_sap2Kernel;
|
||||
|
||||
class btRadixSort32CL* m_sorter;
|
||||
class b3RadixSort32CL* m_sorter;
|
||||
|
||||
///test for 3d SAP
|
||||
b3AlignedObjectArray<btSortData> m_sortedAxisCPU[3][2];
|
||||
b3AlignedObjectArray<b3SortData> m_sortedAxisCPU[3][2];
|
||||
int m_currentBuffer;
|
||||
|
||||
public:
|
||||
|
||||
btOpenCLArray<b3SapAabb> m_allAabbsGPU;
|
||||
b3OpenCLArray<b3SapAabb> m_allAabbsGPU;
|
||||
b3AlignedObjectArray<b3SapAabb> m_allAabbsCPU;
|
||||
|
||||
btOpenCLArray<b3SapAabb> m_smallAabbsGPU;
|
||||
b3OpenCLArray<b3SapAabb> m_smallAabbsGPU;
|
||||
b3AlignedObjectArray<b3SapAabb> m_smallAabbsCPU;
|
||||
|
||||
btOpenCLArray<b3SapAabb> m_largeAabbsGPU;
|
||||
b3OpenCLArray<b3SapAabb> m_largeAabbsGPU;
|
||||
b3AlignedObjectArray<b3SapAabb> m_largeAabbsCPU;
|
||||
|
||||
btOpenCLArray<btInt2> m_overlappingPairs;
|
||||
b3OpenCLArray<b3Int2> m_overlappingPairs;
|
||||
|
||||
//temporary gpu work memory
|
||||
btOpenCLArray<btSortData> m_gpuSmallSortData;
|
||||
btOpenCLArray<b3SapAabb> m_gpuSmallSortedAabbs;
|
||||
b3OpenCLArray<b3SortData> m_gpuSmallSortData;
|
||||
b3OpenCLArray<b3SapAabb> m_gpuSmallSortedAabbs;
|
||||
|
||||
|
||||
b3GpuSapBroadphase(cl_context ctx,cl_device_id device, cl_command_queue q );
|
||||
@ -66,4 +66,4 @@ class b3GpuSapBroadphase
|
||||
cl_mem getOverlappingPairBuffer();
|
||||
};
|
||||
|
||||
#endif //BT_GPU_SAP_BROADPHASE_H
|
||||
#endif //B3_GPU_SAP_BROADPHASE_H
|
@ -1,5 +1,5 @@
|
||||
#ifndef BT_SAP_AABB_H
|
||||
#define BT_SAP_AABB_H
|
||||
#ifndef B3_SAP_AABB_H
|
||||
#define B3_SAP_AABB_H
|
||||
|
||||
struct b3SapAabb
|
||||
{
|
||||
@ -15,4 +15,4 @@ struct b3SapAabb
|
||||
};
|
||||
};
|
||||
|
||||
#endif //BT_SAP_AABB_H
|
||||
#endif //B3_SAP_AABB_H
|
||||
|
@ -30,12 +30,12 @@ static const char* sapFastCL= \
|
||||
" float m_maxElems[4];\n"
|
||||
" int m_maxIndices[4];\n"
|
||||
" };\n"
|
||||
"} btAabbCL;\n"
|
||||
"} b3AabbCL;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"/// conservative test for overlap between two aabbs\n"
|
||||
"bool TestAabbAgainstAabb2(const btAabbCL* aabb1, __local const btAabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2(const btAabbCL* aabb1, __local const btAabbCL* aabb2)\n"
|
||||
"bool TestAabbAgainstAabb2(const b3AabbCL* aabb1, __local const b3AabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2(const b3AabbCL* aabb1, __local const b3AabbCL* aabb2)\n"
|
||||
"{\n"
|
||||
"//skip pairs between static (mass=0) objects\n"
|
||||
" if ((aabb1->m_maxIndices[3]==0) && (aabb2->m_maxIndices[3] == 0))\n"
|
||||
@ -50,18 +50,18 @@ static const char* sapFastCL= \
|
||||
"\n"
|
||||
"\n"
|
||||
"//computePairsKernelBatchWrite\n"
|
||||
"__kernel void computePairsKernel( __global const btAabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"__kernel void computePairsKernel( __global const b3AabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" int localId = get_local_id(0);\n"
|
||||
"\n"
|
||||
" __local int numActiveWgItems[1];\n"
|
||||
" __local int breakRequest[1];\n"
|
||||
" __local btAabbCL localAabbs[128];// = aabbs[i];\n"
|
||||
" __local b3AabbCL localAabbs[128];// = aabbs[i];\n"
|
||||
" \n"
|
||||
" int2 myPairs[64];\n"
|
||||
" \n"
|
||||
" btAabbCL myAabb;\n"
|
||||
" b3AabbCL myAabb;\n"
|
||||
" \n"
|
||||
" myAabb = (i<numObjects)? aabbs[i]:aabbs[0];\n"
|
||||
" float testValue = myAabb.m_maxElems[axis];\n"
|
||||
|
@ -30,12 +30,12 @@ static const char* sapCL= \
|
||||
" float m_maxElems[4];\n"
|
||||
" int m_maxIndices[4];\n"
|
||||
" };\n"
|
||||
"} btAabbCL;\n"
|
||||
"} b3AabbCL;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"/// conservative test for overlap between two aabbs\n"
|
||||
"bool TestAabbAgainstAabb2(const btAabbCL* aabb1, __local const btAabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2(const btAabbCL* aabb1, __local const btAabbCL* aabb2)\n"
|
||||
"bool TestAabbAgainstAabb2(const b3AabbCL* aabb1, __local const b3AabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2(const b3AabbCL* aabb1, __local const b3AabbCL* aabb2)\n"
|
||||
"{\n"
|
||||
" bool overlap = true;\n"
|
||||
" overlap = (aabb1->m_min.x > aabb2->m_max.x || aabb1->m_max.x < aabb2->m_min.x) ? false : overlap;\n"
|
||||
@ -43,8 +43,8 @@ static const char* sapCL= \
|
||||
" overlap = (aabb1->m_min.y > aabb2->m_max.y || aabb1->m_max.y < aabb2->m_min.y) ? false : overlap;\n"
|
||||
" return overlap;\n"
|
||||
"}\n"
|
||||
"bool TestAabbAgainstAabb2GlobalGlobal(__global const btAabbCL* aabb1, __global const btAabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2GlobalGlobal(__global const btAabbCL* aabb1, __global const btAabbCL* aabb2)\n"
|
||||
"bool TestAabbAgainstAabb2GlobalGlobal(__global const b3AabbCL* aabb1, __global const b3AabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2GlobalGlobal(__global const b3AabbCL* aabb1, __global const b3AabbCL* aabb2)\n"
|
||||
"{\n"
|
||||
" bool overlap = true;\n"
|
||||
" overlap = (aabb1->m_min.x > aabb2->m_max.x || aabb1->m_max.x < aabb2->m_min.x) ? false : overlap;\n"
|
||||
@ -53,8 +53,8 @@ static const char* sapCL= \
|
||||
" return overlap;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"bool TestAabbAgainstAabb2Global(const btAabbCL* aabb1, __global const btAabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2Global(const btAabbCL* aabb1, __global const btAabbCL* aabb2)\n"
|
||||
"bool TestAabbAgainstAabb2Global(const b3AabbCL* aabb1, __global const b3AabbCL* aabb2);\n"
|
||||
"bool TestAabbAgainstAabb2Global(const b3AabbCL* aabb1, __global const b3AabbCL* aabb2)\n"
|
||||
"{\n"
|
||||
" bool overlap = true;\n"
|
||||
" overlap = (aabb1->m_min.x > aabb2->m_max.x || aabb1->m_max.x < aabb2->m_min.x) ? false : overlap;\n"
|
||||
@ -64,7 +64,7 @@ static const char* sapCL= \
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void computePairsKernelTwoArrays( __global const btAabbCL* unsortedAabbs, __global const btAabbCL* sortedAabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numUnsortedAabbs, int numSortedAabbs, int axis, int maxPairs)\n"
|
||||
"__kernel void computePairsKernelTwoArrays( __global const b3AabbCL* unsortedAabbs, __global const b3AabbCL* sortedAabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numUnsortedAabbs, int numSortedAabbs, int axis, int maxPairs)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" if (i>=numUnsortedAabbs)\n"
|
||||
@ -89,7 +89,7 @@ static const char* sapCL= \
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"__kernel void computePairsKernelOriginal( __global const btAabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"__kernel void computePairsKernelOriginal( __global const b3AabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" if (i>=numObjects)\n"
|
||||
@ -117,7 +117,7 @@ static const char* sapCL= \
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void computePairsKernelBarrier( __global const btAabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"__kernel void computePairsKernelBarrier( __global const b3AabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" int localId = get_local_id(0);\n"
|
||||
@ -181,16 +181,16 @@ static const char* sapCL= \
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void computePairsKernelLocalSharedMemory( __global const btAabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"__kernel void computePairsKernelLocalSharedMemory( __global const b3AabbCL* aabbs, volatile __global int2* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" int localId = get_local_id(0);\n"
|
||||
"\n"
|
||||
" __local int numActiveWgItems[1];\n"
|
||||
" __local int breakRequest[1];\n"
|
||||
" __local btAabbCL localAabbs[128];// = aabbs[i];\n"
|
||||
" __local b3AabbCL localAabbs[128];// = aabbs[i];\n"
|
||||
" \n"
|
||||
" btAabbCL myAabb;\n"
|
||||
" b3AabbCL myAabb;\n"
|
||||
" \n"
|
||||
" myAabb = (i<numObjects)? aabbs[i]:aabbs[0];\n"
|
||||
" float testValue = myAabb.m_maxElems[axis];\n"
|
||||
@ -289,7 +289,7 @@ static const char* sapCL= \
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void copyAabbsKernel( __global const btAabbCL* allAabbs, __global btAabbCL* destAabbs, int numObjects)\n"
|
||||
"__kernel void copyAabbsKernel( __global const b3AabbCL* allAabbs, __global b3AabbCL* destAabbs, int numObjects)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" if (i>=numObjects)\n"
|
||||
@ -300,7 +300,7 @@ static const char* sapCL= \
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void flipFloatKernel( __global const btAabbCL* aabbs, volatile __global int2* sortData, int numObjects, int axis)\n"
|
||||
"__kernel void flipFloatKernel( __global const b3AabbCL* aabbs, volatile __global int2* sortData, int numObjects, int axis)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" if (i>=numObjects)\n"
|
||||
@ -312,7 +312,7 @@ static const char* sapCL= \
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void scatterKernel( __global const btAabbCL* aabbs, volatile __global const int2* sortData, __global btAabbCL* sortedAabbs, int numObjects)\n"
|
||||
"__kernel void scatterKernel( __global const b3AabbCL* aabbs, volatile __global const int2* sortData, __global b3AabbCL* sortedAabbs, int numObjects)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" if (i>=numObjects)\n"
|
||||
|
@ -17,10 +17,10 @@ subject to the following restrictions:
|
||||
#include "../basic_initialize/b3OpenCLUtils.h"
|
||||
#include "../host/b3GpuSapBroadphase.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "parallel_primitives/host/btFillCL.h"
|
||||
#include "parallel_primitives/host/btBoundSearchCL.h"
|
||||
#include "parallel_primitives/host/btRadixSort32CL.h"
|
||||
#include "parallel_primitives/host/btPrefixScanCL.h"
|
||||
#include "parallel_primitives/host/b3FillCL.h"
|
||||
#include "parallel_primitives/host/b3BoundSearchCL.h"
|
||||
#include "parallel_primitives/host/b3RadixSort32CL.h"
|
||||
#include "parallel_primitives/host/b3PrefixScanCL.h"
|
||||
#include "Bullet3Common/b3CommandLineArgs.h"
|
||||
#include "Bullet3Common/b3MinMax.h"
|
||||
|
||||
@ -52,7 +52,7 @@ void initCL(int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
int numDev = b3OpenCLUtils::getNumDevices(g_context);
|
||||
if (numDev>0)
|
||||
{
|
||||
btOpenCLDeviceInfo info;
|
||||
b3OpenCLDeviceInfo info;
|
||||
g_device= b3OpenCLUtils::getDevice(g_context,0);
|
||||
g_queue = clCreateCommandQueue(g_context, g_device, 0, &ciErrNum);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#ifndef BT_COLLIDABLE_H
|
||||
#define BT_COLLIDABLE_H
|
||||
#ifndef B3_COLLIDABLE_H
|
||||
#define B3_COLLIDABLE_H
|
||||
|
||||
enum btShapeTypes
|
||||
enum b3ShapeTypes
|
||||
{
|
||||
SHAPE_HEIGHT_FIELD=1,
|
||||
|
||||
@ -25,14 +25,14 @@ struct b3Collidable
|
||||
int m_shapeIndex;
|
||||
};
|
||||
|
||||
struct btCollidableNew
|
||||
struct b3CollidableNew
|
||||
{
|
||||
short int m_shapeType;
|
||||
short int m_numShapes;
|
||||
int m_shapeIndex;
|
||||
};
|
||||
|
||||
struct btGpuChildShape
|
||||
struct b3GpuChildShape
|
||||
{
|
||||
float m_childPosition[4];
|
||||
float m_childOrientation[4];
|
||||
@ -42,7 +42,7 @@ struct btGpuChildShape
|
||||
int m_unused2;
|
||||
};
|
||||
|
||||
struct btCompoundOverlappingPair
|
||||
struct b3CompoundOverlappingPair
|
||||
{
|
||||
int m_bodyIndexA;
|
||||
int m_bodyIndexB;
|
||||
@ -50,4 +50,4 @@ struct btCompoundOverlappingPair
|
||||
int m_childShapeIndexA;
|
||||
int m_childShapeIndexB;
|
||||
};
|
||||
#endif //BT_COLLIDABLE_H
|
||||
#endif //B3_COLLIDABLE_H
|
||||
|
@ -18,19 +18,19 @@ subject to the following restrictions:
|
||||
///Separating axis rest based on work from Pierre Terdiman, see
|
||||
///And contact clipping based on work from Simon Hobbs
|
||||
|
||||
//#define BT_DEBUG_SAT_FACE
|
||||
//#define B3_DEBUG_SAT_FACE
|
||||
|
||||
#include "b3ConvexHullContact.h"
|
||||
#include <string.h>//memcpy
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
|
||||
|
||||
typedef b3AlignedObjectArray<b3Vector3> btVertexArray;
|
||||
typedef b3AlignedObjectArray<b3Vector3> b3VertexArray;
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
|
||||
#include <float.h> //for FLT_MAX
|
||||
#include "basic_initialize/b3OpenCLUtils.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
//#include "AdlQuaternion.h"
|
||||
|
||||
#include "../kernels/satKernels.h"
|
||||
@ -42,7 +42,7 @@ typedef b3AlignedObjectArray<b3Vector3> btVertexArray;
|
||||
#include "Bullet3Geometry/b3AabbUtil.h"
|
||||
|
||||
|
||||
#define dot3F4 btDot
|
||||
#define dot3F4 b3Dot
|
||||
|
||||
GpuSatCollision::GpuSatCollision(cl_context ctx,cl_device_id device, cl_command_queue q )
|
||||
:m_context(ctx),
|
||||
@ -65,22 +65,22 @@ m_totalContactsOut(m_context, m_queue)
|
||||
//#endif
|
||||
|
||||
cl_program satProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,src,&errNum,flags,"opencl/gpu_narrowphase/kernels/sat.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_findSeparatingAxisKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findSeparatingAxisKernel",&errNum,satProg );
|
||||
btAssert(m_findSeparatingAxisKernel);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(m_findSeparatingAxisKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_findConcaveSeparatingAxisKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findConcaveSeparatingAxisKernel",&errNum,satProg );
|
||||
btAssert(m_findConcaveSeparatingAxisKernel);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(m_findConcaveSeparatingAxisKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_findCompoundPairsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "findCompoundPairsKernel",&errNum,satProg );
|
||||
btAssert(m_findCompoundPairsKernel);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(m_findCompoundPairsKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
m_processCompoundPairsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,src, "processCompoundPairsKernel",&errNum,satProg );
|
||||
btAssert(m_processCompoundPairsKernel);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(m_processCompoundPairsKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
}
|
||||
|
||||
if (1)
|
||||
@ -93,30 +93,30 @@ m_totalContactsOut(m_context, m_queue)
|
||||
//#endif
|
||||
|
||||
cl_program satClipContactsProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,srcClip,&errNum,flags,"opencl/gpu_narrowphase/kernels/satClipHullContacts.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_clipHullHullKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipHullHullKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_clipCompoundsHullHullKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipCompoundsHullHullKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
|
||||
m_findClippingFacesKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "findClippingFacesKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_clipFacesAndContactReductionKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipFacesAndContactReductionKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_clipHullHullConcaveConvexKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "clipHullHullConcaveConvexKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_extractManifoldAndAddContactKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip, "extractManifoldAndAddContactKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_newContactReductionKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcClip,
|
||||
"newContactReductionKernel",&errNum,satClipContactsProg);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -133,28 +133,28 @@ m_totalContactsOut(m_context, m_queue)
|
||||
{
|
||||
const char* srcBvh = bvhTraversalKernelCL;
|
||||
cl_program bvhTraversalProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,srcBvh,&errNum,"","opencl/gpu_narrowphase/kernels/bvhTraversal.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_bvhTraversalKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,srcBvh, "bvhTraversalKernel",&errNum,bvhTraversalProg,"");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
const char* primitiveContactsSrc = primitiveContactsKernelsCL;
|
||||
cl_program primitiveContactsProg = b3OpenCLUtils::compileCLProgramFromString(m_context,m_device,primitiveContactsSrc,&errNum,"","opencl/gpu_narrowphase/kernels/primitiveContacts.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_primitiveContactsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "primitiveContactsKernel",&errNum,primitiveContactsProg,"");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
|
||||
m_findConcaveSphereContactsKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "findConcaveSphereContactsKernel",&errNum,primitiveContactsProg );
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
btAssert(m_findConcaveSphereContactsKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
b3Assert(m_findConcaveSphereContactsKernel);
|
||||
|
||||
m_processCompoundPairsPrimitivesKernel = b3OpenCLUtils::compileCLKernelFromString(m_context, m_device,primitiveContactsSrc, "processCompoundPairsPrimitivesKernel",&errNum,primitiveContactsProg,"");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
btAssert(m_processCompoundPairsPrimitivesKernel);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
b3Assert(m_processCompoundPairsPrimitivesKernel);
|
||||
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ GpuSatCollision::~GpuSatCollision()
|
||||
|
||||
}
|
||||
|
||||
struct MyTriangleCallback : public btNodeOverlapCallback
|
||||
struct MyTriangleCallback : public b3NodeOverlapCallback
|
||||
{
|
||||
int m_bodyIndexA;
|
||||
int m_bodyIndexB;
|
||||
@ -221,7 +221,7 @@ struct MyTriangleCallback : public btNodeOverlapCallback
|
||||
|
||||
|
||||
#define float4 b3Vector3
|
||||
#define make_float4(x,y,z,w) btVector4(x,y,z,w)
|
||||
#define make_float4(x,y,z,w) b3Vector4(x,y,z,w)
|
||||
|
||||
float signedDistanceFromPointToPlane(const float4& point, const float4& planeEqn, float4* closestPointOnFace)
|
||||
{
|
||||
@ -248,7 +248,7 @@ b3Vector3 transform(b3Vector3* v, const b3Vector3* pos, const b3Vector3* orn)
|
||||
|
||||
|
||||
inline bool IsPointInPolygon(const float4& p,
|
||||
const btGpuFace* face,
|
||||
const b3GpuFace* face,
|
||||
const float4* baseVertex,
|
||||
const int* convexIndices,
|
||||
float4* out)
|
||||
@ -277,10 +277,10 @@ inline bool IsPointInPolygon(const float4& p,
|
||||
ap = p-a;
|
||||
v = cross3(ab,plane);
|
||||
|
||||
if (btDot(ap, v) > 0.f)
|
||||
if (b3Dot(ap, v) > 0.f)
|
||||
{
|
||||
float ab_m2 = btDot(ab, ab);
|
||||
float rt = ab_m2 != 0.f ? btDot(ab, ap) / ab_m2 : 0.f;
|
||||
float ab_m2 = b3Dot(ab, ab);
|
||||
float rt = ab_m2 != 0.f ? b3Dot(ab, ap) / ab_m2 : 0.f;
|
||||
if (rt <= 0.f)
|
||||
{
|
||||
*out = a;
|
||||
@ -305,7 +305,7 @@ inline bool IsPointInPolygon(const float4& p,
|
||||
#define normalize3(a) (a.normalize())
|
||||
|
||||
|
||||
int extractManifoldSequentialGlobal( const float4* p, int nPoints, const float4& nearNormal, btInt4* contactIdx)
|
||||
int extractManifoldSequentialGlobal( const float4* p, int nPoints, const float4& nearNormal, b3Int4* contactIdx)
|
||||
{
|
||||
if( nPoints == 0 )
|
||||
return 0;
|
||||
@ -414,7 +414,7 @@ void computeContactPlaneConvex(int pairIndex,
|
||||
const b3ConvexPolyhedronCL* convexShapes,
|
||||
const b3Vector3* convexVertices,
|
||||
const int* convexIndices,
|
||||
const btGpuFace* faces,
|
||||
const b3GpuFace* faces,
|
||||
b3Contact4* globalContactsOut,
|
||||
int& nGlobalContactsOut,
|
||||
int maxContactCapacity)
|
||||
@ -459,7 +459,7 @@ void computeContactPlaneConvex(int pairIndex,
|
||||
b3Vector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
|
||||
int numPoints = 0;
|
||||
|
||||
btInt4 contactIdx;
|
||||
b3Int4 contactIdx;
|
||||
contactIdx.s[0] = 0;
|
||||
contactIdx.s[1] = 1;
|
||||
contactIdx.s[2] = 2;
|
||||
@ -547,14 +547,14 @@ void computeContactPlaneCompound(int pairIndex,
|
||||
const b3ConvexPolyhedronCL* convexShapes,
|
||||
const b3Vector3* convexVertices,
|
||||
const int* convexIndices,
|
||||
const btGpuFace* faces,
|
||||
const b3GpuFace* faces,
|
||||
b3Contact4* globalContactsOut,
|
||||
int& nGlobalContactsOut,
|
||||
int maxContactCapacity)
|
||||
{
|
||||
|
||||
int shapeTypeB = collidables[collidableIndexB].m_shapeType;
|
||||
btAssert(shapeTypeB == SHAPE_COMPOUND_OF_CONVEX_HULLS);
|
||||
b3Assert(shapeTypeB == SHAPE_COMPOUND_OF_CONVEX_HULLS);
|
||||
|
||||
|
||||
|
||||
@ -597,7 +597,7 @@ void computeContactPlaneCompound(int pairIndex,
|
||||
b3Vector3 contactPoints[MAX_PLANE_CONVEX_POINTS];
|
||||
int numPoints = 0;
|
||||
|
||||
btInt4 contactIdx;
|
||||
b3Int4 contactIdx;
|
||||
contactIdx.s[0] = 0;
|
||||
contactIdx.s[1] = 1;
|
||||
contactIdx.s[2] = 2;
|
||||
@ -686,7 +686,7 @@ void computeContactSphereConvex(int pairIndex,
|
||||
const b3ConvexPolyhedronCL* convexShapes,
|
||||
const b3Vector3* convexVertices,
|
||||
const int* convexIndices,
|
||||
const btGpuFace* faces,
|
||||
const b3GpuFace* faces,
|
||||
b3Contact4* globalContactsOut,
|
||||
int& nGlobalContactsOut,
|
||||
int maxContactCapacity)
|
||||
@ -722,7 +722,7 @@ void computeContactSphereConvex(int pairIndex,
|
||||
float4 localHitNormal;
|
||||
for ( int f = 0; f < numFaces; f++ )
|
||||
{
|
||||
btGpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];
|
||||
b3GpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];
|
||||
float4 planeEqn;
|
||||
float4 localPlaneNormal = make_float4(face.m_plane.getX(),face.m_plane.getY(),face.m_plane.getZ(),0.f);
|
||||
float4 n1 = localPlaneNormal;//quatRotate(quat,localPlaneNormal);
|
||||
@ -763,7 +763,7 @@ void computeContactSphereConvex(int pairIndex,
|
||||
b3Scalar l2 = tmp.length2();
|
||||
if (l2<radius*radius)
|
||||
{
|
||||
dist = btSqrt(l2);
|
||||
dist = b3Sqrt(l2);
|
||||
if (dist>minDist)
|
||||
{
|
||||
minDist = dist;
|
||||
@ -833,32 +833,32 @@ void computeContactSphereConvex(int pairIndex,
|
||||
}
|
||||
|
||||
|
||||
void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btInt2>* pairs, int nPairs,
|
||||
const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
btOpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
void GpuSatCollision::computeConvexConvexContactsGPUSAT( const b3OpenCLArray<b3Int2>* pairs, int nPairs,
|
||||
const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
int maxContactCapacity,
|
||||
const btOpenCLArray<b3ConvexPolyhedronCL>& convexData,
|
||||
const btOpenCLArray<b3Vector3>& gpuVertices,
|
||||
const btOpenCLArray<b3Vector3>& gpuUniqueEdges,
|
||||
const btOpenCLArray<btGpuFace>& gpuFaces,
|
||||
const btOpenCLArray<int>& gpuIndices,
|
||||
const btOpenCLArray<b3Collidable>& gpuCollidables,
|
||||
const btOpenCLArray<btGpuChildShape>& gpuChildShapes,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronCL>& convexData,
|
||||
const b3OpenCLArray<b3Vector3>& gpuVertices,
|
||||
const b3OpenCLArray<b3Vector3>& gpuUniqueEdges,
|
||||
const b3OpenCLArray<b3GpuFace>& gpuFaces,
|
||||
const b3OpenCLArray<int>& gpuIndices,
|
||||
const b3OpenCLArray<b3Collidable>& gpuCollidables,
|
||||
const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
|
||||
|
||||
const btOpenCLArray<btYetAnotherAabb>& clAabbsWS,
|
||||
btOpenCLArray<b3Vector3>& worldVertsB1GPU,
|
||||
btOpenCLArray<btInt4>& clippingFacesOutGPU,
|
||||
btOpenCLArray<b3Vector3>& worldNormalsAGPU,
|
||||
btOpenCLArray<b3Vector3>& worldVertsA1GPU,
|
||||
btOpenCLArray<b3Vector3>& worldVertsB2GPU,
|
||||
const b3OpenCLArray<b3YetAnotherAabb>& clAabbsWS,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
|
||||
b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
|
||||
b3OpenCLArray<b3Vector3>& worldNormalsAGPU,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsA1GPU,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsB2GPU,
|
||||
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
|
||||
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
|
||||
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
|
||||
btOpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU,
|
||||
b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU,
|
||||
b3OpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
|
||||
int numObjects,
|
||||
int maxTriConvexPairCapacity,
|
||||
btOpenCLArray<btInt4>& triangleConvexPairsOut,
|
||||
b3OpenCLArray<b3Int4>& triangleConvexPairsOut,
|
||||
int& numTriConvexPairsOut
|
||||
)
|
||||
{
|
||||
@ -868,9 +868,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
//#define CHECK_ON_HOST
|
||||
#ifdef CHECK_ON_HOST
|
||||
b3AlignedObjectArray<btYetAnotherAabb> hostAabbs;
|
||||
b3AlignedObjectArray<b3YetAnotherAabb> hostAabbs;
|
||||
clAabbsWS.copyToHost(hostAabbs);
|
||||
b3AlignedObjectArray<btInt2> hostPairs;
|
||||
b3AlignedObjectArray<b3Int2> hostPairs;
|
||||
pairs->copyToHost(hostPairs);
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodyBuf;
|
||||
@ -886,18 +886,18 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> hostUniqueEdges;
|
||||
gpuUniqueEdges.copyToHost(hostUniqueEdges);
|
||||
b3AlignedObjectArray<btGpuFace> hostFaces;
|
||||
b3AlignedObjectArray<b3GpuFace> hostFaces;
|
||||
gpuFaces.copyToHost(hostFaces);
|
||||
b3AlignedObjectArray<int> hostIndices;
|
||||
gpuIndices.copyToHost(hostIndices);
|
||||
b3AlignedObjectArray<b3Collidable> hostCollidables;
|
||||
gpuCollidables.copyToHost(hostCollidables);
|
||||
|
||||
b3AlignedObjectArray<btGpuChildShape> cpuChildShapes;
|
||||
b3AlignedObjectArray<b3GpuChildShape> cpuChildShapes;
|
||||
gpuChildShapes.copyToHost(cpuChildShapes);
|
||||
|
||||
|
||||
b3AlignedObjectArray<btInt4> hostTriangleConvexPairs;
|
||||
b3AlignedObjectArray<b3Int4> hostTriangleConvexPairs;
|
||||
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
if (nContacts)
|
||||
@ -984,22 +984,22 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
{
|
||||
m_totalContactsOut.copyFromHostPointer(&nContacts,1,0,true);
|
||||
|
||||
BT_PROFILE("primitiveContactsKernel");
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
B3_PROFILE("primitiveContactsKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_primitiveContactsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_primitiveContactsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
launcher.setConst(maxContactCapacity);
|
||||
int num = nPairs;
|
||||
@ -1013,33 +1013,33 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
#endif//CHECK_ON_HOST
|
||||
|
||||
BT_PROFILE("computeConvexConvexContactsGPUSAT");
|
||||
B3_PROFILE("computeConvexConvexContactsGPUSAT");
|
||||
// printf("nContacts = %d\n",nContacts);
|
||||
|
||||
btOpenCLArray<b3Vector3> sepNormals(m_context,m_queue);
|
||||
b3OpenCLArray<b3Vector3> sepNormals(m_context,m_queue);
|
||||
sepNormals.resize(nPairs);
|
||||
btOpenCLArray<int> hasSeparatingNormals(m_context,m_queue);
|
||||
b3OpenCLArray<int> hasSeparatingNormals(m_context,m_queue);
|
||||
hasSeparatingNormals.resize(nPairs);
|
||||
|
||||
int concaveCapacity=maxTriConvexPairCapacity;
|
||||
btOpenCLArray<b3Vector3> concaveSepNormals(m_context,m_queue);
|
||||
b3OpenCLArray<b3Vector3> concaveSepNormals(m_context,m_queue);
|
||||
concaveSepNormals.resize(concaveCapacity);
|
||||
|
||||
btOpenCLArray<int> numConcavePairsOut(m_context,m_queue);
|
||||
b3OpenCLArray<int> numConcavePairsOut(m_context,m_queue);
|
||||
numConcavePairsOut.push_back(0);
|
||||
|
||||
int compoundPairCapacity=65536*10;
|
||||
btOpenCLArray<btCompoundOverlappingPair> gpuCompoundPairs(m_context,m_queue);
|
||||
b3OpenCLArray<b3CompoundOverlappingPair> gpuCompoundPairs(m_context,m_queue);
|
||||
gpuCompoundPairs.resize(compoundPairCapacity);
|
||||
|
||||
btOpenCLArray<b3Vector3> gpuCompoundSepNormals(m_context,m_queue);
|
||||
b3OpenCLArray<b3Vector3> gpuCompoundSepNormals(m_context,m_queue);
|
||||
gpuCompoundSepNormals.resize(compoundPairCapacity);
|
||||
|
||||
|
||||
btOpenCLArray<int> gpuHasCompoundSepNormals(m_context,m_queue);
|
||||
b3OpenCLArray<int> gpuHasCompoundSepNormals(m_context,m_queue);
|
||||
gpuHasCompoundSepNormals.resize(compoundPairCapacity);
|
||||
|
||||
btOpenCLArray<int> numCompoundPairsOut(m_context,m_queue);
|
||||
b3OpenCLArray<int> numCompoundPairsOut(m_context,m_queue);
|
||||
numCompoundPairsOut.push_back(0);
|
||||
|
||||
int numCompoundPairs = 0;
|
||||
@ -1053,23 +1053,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
{
|
||||
|
||||
{
|
||||
BT_PROFILE("findSeparatingAxisKernel");
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
btBufferInfoCL( sepNormals.getBufferCL()),
|
||||
btBufferInfoCL( hasSeparatingNormals.getBufferCL())
|
||||
B3_PROFILE("findSeparatingAxisKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
b3BufferInfoCL( sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( hasSeparatingNormals.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_findSeparatingAxisKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_findSeparatingAxisKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
|
||||
int num = nPairs;
|
||||
@ -1086,9 +1086,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
if (treeNodesGPU->size() && treeNodesGPU->size())
|
||||
{
|
||||
BT_PROFILE("m_bvhTraversalKernel");
|
||||
B3_PROFILE("m_bvhTraversalKernel");
|
||||
numConcavePairs = numConcavePairsOut.at(0);
|
||||
btLauncherCL launcher(m_queue, m_bvhTraversalKernel);
|
||||
b3LauncherCL launcher(m_queue, m_bvhTraversalKernel);
|
||||
launcher.setBuffer( pairs->getBufferCL());
|
||||
launcher.setBuffer( bodyBuf->getBufferCL());
|
||||
launcher.setBuffer( gpuCollidables.getBufferCL());
|
||||
@ -1117,23 +1117,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
if (numConcavePairs)
|
||||
{
|
||||
//now perform a SAT test for each triangle-convex element (stored in triangleConvexPairsOut)
|
||||
BT_PROFILE("findConcaveSeparatingAxisKernel");
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
btBufferInfoCL( concaveSepNormals.getBufferCL())
|
||||
B3_PROFILE("findConcaveSeparatingAxisKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
b3BufferInfoCL( concaveSepNormals.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_findConcaveSeparatingAxisKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_findConcaveSeparatingAxisKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
|
||||
launcher.setConst( numConcavePairs );
|
||||
|
||||
@ -1143,7 +1143,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
// b3AlignedObjectArray<b3Vector3> cpuCompoundSepNormals;
|
||||
// concaveSepNormals.copyToHost(cpuCompoundSepNormals);
|
||||
// b3AlignedObjectArray<btInt4> cpuConcavePairs;
|
||||
// b3AlignedObjectArray<b3Int4> cpuConcavePairs;
|
||||
// triangleConvexPairsOut.copyToHost(cpuConcavePairs);
|
||||
|
||||
|
||||
@ -1156,25 +1156,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("findCompoundPairsKernel");
|
||||
btBufferInfoCL bInfo[] =
|
||||
B3_PROFILE("findCompoundPairsKernel");
|
||||
b3BufferInfoCL bInfo[] =
|
||||
{
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCompoundPairs.getBufferCL()),
|
||||
btBufferInfoCL( numCompoundPairsOut.getBufferCL())
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCompoundPairs.getBufferCL()),
|
||||
b3BufferInfoCL( numCompoundPairsOut.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_findCompoundPairsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_findCompoundPairsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
launcher.setConst( compoundPairCapacity);
|
||||
|
||||
@ -1197,25 +1197,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
if (numCompoundPairs)
|
||||
{
|
||||
#ifndef CHECK_ON_HOST
|
||||
BT_PROFILE("processCompoundPairsPrimitivesKernel");
|
||||
btBufferInfoCL bInfo[] =
|
||||
B3_PROFILE("processCompoundPairsPrimitivesKernel");
|
||||
b3BufferInfoCL bInfo[] =
|
||||
{
|
||||
btBufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_processCompoundPairsPrimitivesKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_processCompoundPairsPrimitivesKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numCompoundPairs );
|
||||
launcher.setConst(maxContactCapacity);
|
||||
|
||||
@ -1230,25 +1230,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
if (numCompoundPairs)
|
||||
{
|
||||
|
||||
BT_PROFILE("processCompoundPairsKernel");
|
||||
btBufferInfoCL bInfo[] =
|
||||
B3_PROFILE("processCompoundPairsKernel");
|
||||
b3BufferInfoCL bInfo[] =
|
||||
{
|
||||
btBufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCompoundSepNormals.getBufferCL()),
|
||||
btBufferInfoCL( gpuHasCompoundSepNormals.getBufferCL())
|
||||
b3BufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCompoundSepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( gpuHasCompoundSepNormals.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_processCompoundPairsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_processCompoundPairsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numCompoundPairs );
|
||||
|
||||
int num = numCompoundPairs;
|
||||
@ -1277,24 +1277,24 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
{
|
||||
if (numConcavePairs)
|
||||
{
|
||||
BT_PROFILE("findConcaveSphereContactsKernel");
|
||||
B3_PROFILE("findConcaveSphereContactsKernel");
|
||||
nContacts = m_totalContactsOut.at(0);
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( triangleConvexPairsOut.getBufferCL() ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( clAabbsWS.getBufferCL(),true),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_findConcaveSphereContactsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_findConcaveSphereContactsKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
|
||||
launcher.setConst( numConcavePairs );
|
||||
launcher.setConst(maxContactCapacity);
|
||||
@ -1317,7 +1317,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
if (contactClippingOnGpu)
|
||||
{
|
||||
//BT_PROFILE("clipHullHullKernel");
|
||||
//B3_PROFILE("clipHullHullKernel");
|
||||
|
||||
|
||||
m_totalContactsOut.copyFromHostPointer(&nContacts,1,0,true);
|
||||
@ -1330,24 +1330,24 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
// nContacts = m_totalContactsOut.at(0);
|
||||
// printf("nContacts before = %d\n", nContacts);
|
||||
|
||||
BT_PROFILE("clipHullHullConcaveConvexKernel");
|
||||
B3_PROFILE("clipHullHullConcaveConvexKernel");
|
||||
nContacts = m_totalContactsOut.at(0);
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( triangleConvexPairsOut.getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
btBufferInfoCL( concaveSepNormals.getBufferCL()),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( triangleConvexPairsOut.getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
b3BufferInfoCL( concaveSepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
btLauncherCL launcher(m_queue, m_clipHullHullConcaveConvexKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_clipHullHullConcaveConvexKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( numConcavePairs );
|
||||
int num = numConcavePairs;
|
||||
launcher.launch1D( num);
|
||||
@ -1364,7 +1364,7 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
//convex-convex contact clipping
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("clipHullHullKernel");
|
||||
B3_PROFILE("clipHullHullKernel");
|
||||
bool breakupKernel = false;
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -1396,26 +1396,26 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("findClippingFacesKernel");
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( sepNormals.getBufferCL()),
|
||||
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
btBufferInfoCL( clippingFacesOutGPU.getBufferCL()),
|
||||
btBufferInfoCL( worldVertsA1GPU.getBufferCL()),
|
||||
btBufferInfoCL( worldNormalsAGPU.getBufferCL()),
|
||||
btBufferInfoCL( worldVertsB1GPU.getBufferCL())
|
||||
B3_PROFILE("findClippingFacesKernel");
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( clippingFacesOutGPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldVertsA1GPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldNormalsAGPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldVertsB1GPU.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_findClippingFacesKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_findClippingFacesKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( vertexFaceCapacity);
|
||||
launcher.setConst( nPairs );
|
||||
int num = nPairs;
|
||||
@ -1431,26 +1431,26 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
///clip face B against face A, reduce contacts and append them to a global contact array
|
||||
if (1)
|
||||
{
|
||||
BT_PROFILE("clipFacesAndContactReductionKernel");
|
||||
B3_PROFILE("clipFacesAndContactReductionKernel");
|
||||
//nContacts = m_totalContactsOut.at(0);
|
||||
//int h = hasSeparatingNormals.at(0);
|
||||
//int4 p = clippingFacesOutGPU.at(0);
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( sepNormals.getBufferCL()),
|
||||
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( clippingFacesOutGPU.getBufferCL()),
|
||||
btBufferInfoCL( worldVertsA1GPU.getBufferCL()),
|
||||
btBufferInfoCL( worldNormalsAGPU.getBufferCL()),
|
||||
btBufferInfoCL( worldVertsB1GPU.getBufferCL()),
|
||||
btBufferInfoCL( worldVertsB2GPU.getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( clippingFacesOutGPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldVertsA1GPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldNormalsAGPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldVertsB1GPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldVertsB2GPU.getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_clipFacesAndContactReductionKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_clipFacesAndContactReductionKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst(vertexFaceCapacity);
|
||||
|
||||
launcher.setConst( nPairs );
|
||||
@ -1479,21 +1479,21 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
contactOut->reserve(nContacts+nPairs);
|
||||
|
||||
{
|
||||
BT_PROFILE("newContactReductionKernel");
|
||||
btBufferInfoCL bInfo[] =
|
||||
B3_PROFILE("newContactReductionKernel");
|
||||
b3BufferInfoCL bInfo[] =
|
||||
{
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( sepNormals.getBufferCL()),
|
||||
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( clippingFacesOutGPU.getBufferCL()),
|
||||
btBufferInfoCL( worldVertsB2GPU.getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( clippingFacesOutGPU.getBufferCL()),
|
||||
b3BufferInfoCL( worldVertsB2GPU.getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
|
||||
btLauncherCL launcher(m_queue, m_newContactReductionKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_newContactReductionKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst(vertexFaceCapacity);
|
||||
launcher.setConst( nPairs );
|
||||
int num = nPairs;
|
||||
@ -1514,22 +1514,22 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
if (nPairs)
|
||||
{
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( pairs->getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( sepNormals.getBufferCL()),
|
||||
btBufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( pairs->getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( sepNormals.getBufferCL()),
|
||||
b3BufferInfoCL( hasSeparatingNormals.getBufferCL()),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
btLauncherCL launcher(m_queue, m_clipHullHullKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_clipHullHullKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nPairs );
|
||||
int num = nPairs;
|
||||
launcher.launch1D( num);
|
||||
@ -1543,23 +1543,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray<btI
|
||||
|
||||
if (nCompoundsPairs)
|
||||
{
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
|
||||
btBufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
btBufferInfoCL( convexData.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuCompoundSepNormals.getBufferCL(),true),
|
||||
btBufferInfoCL( gpuHasCompoundSepNormals.getBufferCL(),true),
|
||||
btBufferInfoCL( contactOut->getBufferCL()),
|
||||
btBufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( gpuCompoundPairs.getBufferCL(), true ),
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCollidables.getBufferCL(),true),
|
||||
b3BufferInfoCL( convexData.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuVertices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuUniqueEdges.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuFaces.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuIndices.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuChildShapes.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuCompoundSepNormals.getBufferCL(),true),
|
||||
b3BufferInfoCL( gpuHasCompoundSepNormals.getBufferCL(),true),
|
||||
b3BufferInfoCL( contactOut->getBufferCL()),
|
||||
b3BufferInfoCL( m_totalContactsOut.getBufferCL())
|
||||
};
|
||||
btLauncherCL launcher(m_queue, m_clipCompoundsHullHullKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher(m_queue, m_clipCompoundsHullHullKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( nCompoundsPairs );
|
||||
launcher.setConst(maxContactCapacity);
|
||||
|
||||
|
@ -2,22 +2,22 @@
|
||||
#ifndef _CONVEX_HULL_CONTACT_H
|
||||
#define _CONVEX_HULL_CONTACT_H
|
||||
|
||||
#include "parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "b3ConvexUtility.h"
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
#include "b3Collidable.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
#include "parallel_primitives/host/btInt2.h"
|
||||
#include "parallel_primitives/host/btInt4.h"
|
||||
#include "parallel_primitives/host/b3Int2.h"
|
||||
#include "parallel_primitives/host/b3Int4.h"
|
||||
#include "b3OptimizedBvh.h"
|
||||
#include "b3BvhInfo.h"
|
||||
|
||||
//#include "../../dynamics/basic_demo/Stubs/ChNarrowPhase.h"
|
||||
|
||||
|
||||
struct btYetAnotherAabb
|
||||
struct b3YetAnotherAabb
|
||||
{
|
||||
union
|
||||
{
|
||||
@ -59,37 +59,37 @@ struct GpuSatCollision
|
||||
cl_kernel m_processCompoundPairsPrimitivesKernel;
|
||||
|
||||
|
||||
btOpenCLArray<int> m_totalContactsOut;
|
||||
b3OpenCLArray<int> m_totalContactsOut;
|
||||
|
||||
GpuSatCollision(cl_context ctx,cl_device_id device, cl_command_queue q );
|
||||
virtual ~GpuSatCollision();
|
||||
|
||||
|
||||
void computeConvexConvexContactsGPUSAT( const btOpenCLArray<btInt2>* pairs, int nPairs,
|
||||
const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
btOpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
void computeConvexConvexContactsGPUSAT( const b3OpenCLArray<b3Int2>* pairs, int nPairs,
|
||||
const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
|
||||
int maxContactCapacity,
|
||||
const btOpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
|
||||
const btOpenCLArray<b3Vector3>& vertices,
|
||||
const btOpenCLArray<b3Vector3>& uniqueEdges,
|
||||
const btOpenCLArray<btGpuFace>& faces,
|
||||
const btOpenCLArray<int>& indices,
|
||||
const btOpenCLArray<b3Collidable>& gpuCollidables,
|
||||
const btOpenCLArray<btGpuChildShape>& gpuChildShapes,
|
||||
const b3OpenCLArray<b3ConvexPolyhedronCL>& hostConvexData,
|
||||
const b3OpenCLArray<b3Vector3>& vertices,
|
||||
const b3OpenCLArray<b3Vector3>& uniqueEdges,
|
||||
const b3OpenCLArray<b3GpuFace>& faces,
|
||||
const b3OpenCLArray<int>& indices,
|
||||
const b3OpenCLArray<b3Collidable>& gpuCollidables,
|
||||
const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
|
||||
|
||||
const btOpenCLArray<btYetAnotherAabb>& clAabbs,
|
||||
btOpenCLArray<b3Vector3>& worldVertsB1GPU,
|
||||
btOpenCLArray<btInt4>& clippingFacesOutGPU,
|
||||
btOpenCLArray<b3Vector3>& worldNormalsAGPU,
|
||||
btOpenCLArray<b3Vector3>& worldVertsA1GPU,
|
||||
btOpenCLArray<b3Vector3>& worldVertsB2GPU,
|
||||
const b3OpenCLArray<b3YetAnotherAabb>& clAabbs,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
|
||||
b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
|
||||
b3OpenCLArray<b3Vector3>& worldNormalsAGPU,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsA1GPU,
|
||||
b3OpenCLArray<b3Vector3>& worldVertsB2GPU,
|
||||
b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
|
||||
btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU,
|
||||
btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU,
|
||||
btOpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU,
|
||||
b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU,
|
||||
b3OpenCLArray<b3BvhInfo>* bvhInfo,
|
||||
int numObjects,
|
||||
int maxTriConvexPairCapacity,
|
||||
btOpenCLArray<btInt4>& triangleConvexPairs,
|
||||
b3OpenCLArray<b3Int4>& triangleConvexPairs,
|
||||
int& numTriConvexPairsOut
|
||||
);
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
|
||||
struct btGpuFace
|
||||
struct b3GpuFace
|
||||
{
|
||||
btVector4 m_plane;
|
||||
b3Vector4 m_plane;
|
||||
int m_indexOffset;
|
||||
int m_numIndices;
|
||||
};
|
||||
@ -45,7 +45,7 @@ ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL
|
||||
//b3Vector3 pt = trans * vertices[m_vertexOffset+i];
|
||||
//b3Scalar dp = pt.dot(dir);
|
||||
b3Scalar dp = vertices[m_vertexOffset+i].dot(localDir);
|
||||
//btAssert(dp==dpL);
|
||||
//b3Assert(dp==dpL);
|
||||
if(dp < min) min = dp;
|
||||
if(dp > max) max = dp;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
b3ConvexHullComputer* convexUtil = &conv;
|
||||
|
||||
|
||||
b3AlignedObjectArray<btMyFace> tmpFaces;
|
||||
b3AlignedObjectArray<b3MyFace> tmpFaces;
|
||||
tmpFaces.resize(numFaces);
|
||||
|
||||
int numVertices = convexUtil->vertices.size();
|
||||
@ -96,7 +96,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
}
|
||||
else
|
||||
{
|
||||
btAssert(0);//degenerate?
|
||||
b3Assert(0);//degenerate?
|
||||
faceNormals[i].setZero();
|
||||
}
|
||||
|
||||
@ -124,14 +124,14 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
int refFace = todoFaces[todoFaces.size()-1];
|
||||
|
||||
coplanarFaceGroup.push_back(refFace);
|
||||
btMyFace& faceA = tmpFaces[refFace];
|
||||
b3MyFace& faceA = tmpFaces[refFace];
|
||||
todoFaces.pop_back();
|
||||
|
||||
b3Vector3 faceNormalA(faceA.m_plane[0],faceA.m_plane[1],faceA.m_plane[2]);
|
||||
for (int j=todoFaces.size()-1;j>=0;j--)
|
||||
{
|
||||
int i = todoFaces[j];
|
||||
btMyFace& faceB = tmpFaces[i];
|
||||
b3MyFace& faceB = tmpFaces[i];
|
||||
b3Vector3 faceNormalB(faceB.m_plane[0],faceB.m_plane[1],faceB.m_plane[2]);
|
||||
if (faceNormalA.dot(faceNormalB)>faceWeldThreshold)
|
||||
{
|
||||
@ -153,7 +153,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
{
|
||||
// m_polyhedron->m_faces.push_back(tmpFaces[coplanarFaceGroup[i]]);
|
||||
|
||||
btMyFace& face = tmpFaces[coplanarFaceGroup[i]];
|
||||
b3MyFace& face = tmpFaces[coplanarFaceGroup[i]];
|
||||
b3Vector3 faceNormal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
averageFaceNormal+=faceNormal;
|
||||
for (int f=0;f<face.m_indices.size();f++)
|
||||
@ -179,7 +179,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
|
||||
|
||||
|
||||
btMyFace combinedFace;
|
||||
b3MyFace combinedFace;
|
||||
for (int i=0;i<4;i++)
|
||||
combinedFace.m_plane[i] = tmpFaces[coplanarFaceGroup[0]].m_plane[i];
|
||||
|
||||
@ -212,7 +212,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
// this vertex is rejected -- is anybody else using this vertex?
|
||||
for(int j = 0; j < tmpFaces.size(); j++) {
|
||||
|
||||
btMyFace& face = tmpFaces[j];
|
||||
b3MyFace& face = tmpFaces[j];
|
||||
// is this a face of the current coplanar group?
|
||||
bool is_in_current_group = false;
|
||||
for(int k = 0; k < coplanarFaceGroup.size(); k++) {
|
||||
@ -249,7 +249,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices,
|
||||
{
|
||||
for (int i=0;i<coplanarFaceGroup.size();i++)
|
||||
{
|
||||
btMyFace face = tmpFaces[coplanarFaceGroup[i]];
|
||||
b3MyFace face = tmpFaces[coplanarFaceGroup[i]];
|
||||
m_faces.push_back(face);
|
||||
}
|
||||
|
||||
@ -275,14 +275,14 @@ inline bool IsAlmostZero(const b3Vector3& v)
|
||||
return true;
|
||||
}
|
||||
|
||||
struct btInternalVertexPair
|
||||
struct b3InternalVertexPair
|
||||
{
|
||||
btInternalVertexPair(short int v0,short int v1)
|
||||
b3InternalVertexPair(short int v0,short int v1)
|
||||
:m_v0(v0),
|
||||
m_v1(v1)
|
||||
{
|
||||
if (m_v1>m_v0)
|
||||
btSwap(m_v0,m_v1);
|
||||
b3Swap(m_v0,m_v1);
|
||||
}
|
||||
short int m_v0;
|
||||
short int m_v1;
|
||||
@ -290,15 +290,15 @@ struct btInternalVertexPair
|
||||
{
|
||||
return m_v0+(m_v1<<16);
|
||||
}
|
||||
bool equals(const btInternalVertexPair& other) const
|
||||
bool equals(const b3InternalVertexPair& other) const
|
||||
{
|
||||
return m_v0==other.m_v0 && m_v1==other.m_v1;
|
||||
}
|
||||
};
|
||||
|
||||
struct btInternalEdge
|
||||
struct b3InternalEdge
|
||||
{
|
||||
btInternalEdge()
|
||||
b3InternalEdge()
|
||||
:m_face0(-1),
|
||||
m_face1(-1)
|
||||
{
|
||||
@ -339,7 +339,7 @@ bool b3ConvexUtility::testContainment() const
|
||||
void b3ConvexUtility::initialize()
|
||||
{
|
||||
|
||||
b3HashMap<btInternalVertexPair,btInternalEdge> edges;
|
||||
b3HashMap<b3InternalVertexPair,b3InternalEdge> edges;
|
||||
|
||||
b3Scalar TotalArea = 0.0f;
|
||||
|
||||
@ -351,8 +351,8 @@ void b3ConvexUtility::initialize()
|
||||
for(int j=0;j<NbTris;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
btInternalEdge* edptr = edges.find(vp);
|
||||
b3InternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
b3InternalEdge* edptr = edges.find(vp);
|
||||
b3Vector3 edge = m_vertices[vp.m_v1]-m_vertices[vp.m_v0];
|
||||
edge.normalize();
|
||||
|
||||
@ -383,12 +383,12 @@ void b3ConvexUtility::initialize()
|
||||
if (edptr)
|
||||
{
|
||||
//TBD: figure out why I added this assert
|
||||
// btAssert(edptr->m_face0>=0);
|
||||
// btAssert(edptr->m_face1<0);
|
||||
// b3Assert(edptr->m_face0>=0);
|
||||
// b3Assert(edptr->m_face1<0);
|
||||
edptr->m_face1 = i;
|
||||
} else
|
||||
{
|
||||
btInternalEdge ed;
|
||||
b3InternalEdge ed;
|
||||
ed.m_face0 = i;
|
||||
edges.insert(vp,ed);
|
||||
}
|
||||
@ -404,11 +404,11 @@ void b3ConvexUtility::initialize()
|
||||
for(int j=0;j<numVertices;j++)
|
||||
{
|
||||
int k = (j+1)%numVertices;
|
||||
btInternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
btInternalEdge* edptr = edges.find(vp);
|
||||
btAssert(edptr);
|
||||
btAssert(edptr->m_face0>=0);
|
||||
btAssert(edptr->m_face1>=0);
|
||||
b3InternalVertexPair vp(m_faces[i].m_indices[j],m_faces[i].m_indices[k]);
|
||||
b3InternalEdge* edptr = edges.find(vp);
|
||||
b3Assert(edptr);
|
||||
b3Assert(edptr->m_face0>=0);
|
||||
b3Assert(edptr->m_face1>=0);
|
||||
|
||||
int connectedFace = (edptr->m_face0==i)?edptr->m_face1:edptr->m_face0;
|
||||
m_faces[i].m_connectedFaces[j] = connectedFace;
|
||||
@ -445,7 +445,7 @@ void b3ConvexUtility::initialize()
|
||||
for(int i=0;i<m_faces.size();i++)
|
||||
{
|
||||
const b3Vector3 Normal(m_faces[i].m_plane[0], m_faces[i].m_plane[1], m_faces[i].m_plane[2]);
|
||||
const b3Scalar dist = btFabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
|
||||
const b3Scalar dist = b3Fabs(m_localCenter.dot(Normal) + m_faces[i].m_plane[3]);
|
||||
if(dist<m_radius)
|
||||
m_radius = dist;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
#include "b3ConvexPolyhedronCL.h"
|
||||
|
||||
|
||||
struct btMyFace
|
||||
struct b3MyFace
|
||||
{
|
||||
b3AlignedObjectArray<int> m_indices;
|
||||
b3Scalar m_plane[4];
|
||||
@ -32,7 +32,7 @@ struct btMyFace
|
||||
ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3Vector3 m_localCenter;
|
||||
b3Vector3 m_extents;
|
||||
@ -41,7 +41,7 @@ ATTRIBUTE_ALIGNED16(class) b3ConvexUtility
|
||||
b3Scalar m_radius;
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> m_vertices;
|
||||
b3AlignedObjectArray<btMyFace> m_faces;
|
||||
b3AlignedObjectArray<b3MyFace> m_faces;
|
||||
b3AlignedObjectArray<b3Vector3> m_uniqueEdges;
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
|
||||
|
||||
// NodeArray triangleNodes;
|
||||
|
||||
struct NodeTriangleCallback : public btInternalTriangleIndexCallback
|
||||
struct NodeTriangleCallback : public b3InternalTriangleIndexCallback
|
||||
{
|
||||
|
||||
NodeArray& m_triangleNodes;
|
||||
@ -53,10 +53,10 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
|
||||
|
||||
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
|
||||
{
|
||||
btOptimizedBvhNode node;
|
||||
b3OptimizedBvhNode node;
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
|
||||
aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
|
||||
aabbMin.setMin(triangle[0]);
|
||||
aabbMax.setMax(triangle[0]);
|
||||
aabbMin.setMin(triangle[1]);
|
||||
@ -76,7 +76,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
|
||||
m_triangleNodes.push_back(node);
|
||||
}
|
||||
};
|
||||
struct QuantizedNodeTriangleCallback : public btInternalTriangleIndexCallback
|
||||
struct QuantizedNodeTriangleCallback : public b3InternalTriangleIndexCallback
|
||||
{
|
||||
QuantizedNodeArray& m_triangleNodes;
|
||||
const b3QuantizedBvh* m_optimizedTree; // for quantization
|
||||
@ -96,15 +96,15 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
|
||||
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
|
||||
{
|
||||
// The partId and triangle index must fit in the same (positive) integer
|
||||
btAssert(partId < (1<<MAX_NUM_PARTS_IN_BITS));
|
||||
btAssert(triangleIndex < (1<<(31-MAX_NUM_PARTS_IN_BITS)));
|
||||
b3Assert(partId < (1<<MAX_NUM_PARTS_IN_BITS));
|
||||
b3Assert(triangleIndex < (1<<(31-MAX_NUM_PARTS_IN_BITS)));
|
||||
//negative indices are reserved for escapeIndex
|
||||
btAssert(triangleIndex>=0);
|
||||
b3Assert(triangleIndex>=0);
|
||||
|
||||
btQuantizedBvhNode node;
|
||||
b3QuantizedBvhNode node;
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
|
||||
aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
|
||||
aabbMin.setMin(triangle[0]);
|
||||
aabbMax.setMax(triangle[0]);
|
||||
aabbMin.setMin(triangle[1]);
|
||||
@ -167,8 +167,8 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
|
||||
{
|
||||
NodeTriangleCallback callback(m_leafNodes);
|
||||
|
||||
b3Vector3 aabbMin(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
|
||||
b3Vector3 aabbMax(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
|
||||
b3Vector3 aabbMin(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
|
||||
b3Vector3 aabbMax(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
|
||||
|
||||
triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
|
||||
|
||||
@ -185,7 +185,7 @@ void b3OptimizedBvh::build(b3StridingMeshInterface* triangles, bool useQuantized
|
||||
///if the entire tree is small then subtree size, we need to create a header info for the tree
|
||||
if(m_useQuantization && !m_SubtreeHeaders.size())
|
||||
{
|
||||
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]);
|
||||
subtree.m_rootNodeIndex = 0;
|
||||
subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex();
|
||||
@ -216,7 +216,7 @@ void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const b3Vector
|
||||
int i;
|
||||
for (i=0;i<m_SubtreeHeaders.size();i++)
|
||||
{
|
||||
btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||
subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[subtree.m_rootNodeIndex]);
|
||||
}
|
||||
|
||||
@ -232,15 +232,15 @@ void b3OptimizedBvh::refit(b3StridingMeshInterface* meshInterface,const b3Vector
|
||||
void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const b3Vector3& aabbMin,const b3Vector3& aabbMax)
|
||||
{
|
||||
//incrementally initialize quantization values
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
btAssert(aabbMin.getX() > m_bvhAabbMin.getX());
|
||||
btAssert(aabbMin.getY() > m_bvhAabbMin.getY());
|
||||
btAssert(aabbMin.getZ() > m_bvhAabbMin.getZ());
|
||||
b3Assert(aabbMin.getX() > m_bvhAabbMin.getX());
|
||||
b3Assert(aabbMin.getY() > m_bvhAabbMin.getY());
|
||||
b3Assert(aabbMin.getZ() > m_bvhAabbMin.getZ());
|
||||
|
||||
btAssert(aabbMax.getX() < m_bvhAabbMax.getX());
|
||||
btAssert(aabbMax.getY() < m_bvhAabbMax.getY());
|
||||
btAssert(aabbMax.getZ() < m_bvhAabbMax.getZ());
|
||||
b3Assert(aabbMax.getX() < m_bvhAabbMax.getX());
|
||||
b3Assert(aabbMax.getY() < m_bvhAabbMax.getY());
|
||||
b3Assert(aabbMax.getZ() < m_bvhAabbMax.getZ());
|
||||
|
||||
///we should update all quantization values, using updateBvhNodes(meshInterface);
|
||||
///but we only update chunks that overlap the given aabb
|
||||
@ -254,7 +254,7 @@ void b3OptimizedBvh::refitPartial(b3StridingMeshInterface* meshInterface,const b
|
||||
int i;
|
||||
for (i=0;i<this->m_SubtreeHeaders.size();i++)
|
||||
{
|
||||
btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||
|
||||
//PCK: unsigned instead of bool
|
||||
unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);
|
||||
@ -272,7 +272,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
|
||||
{
|
||||
(void)index;
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
int curNodeSubPart=-1;
|
||||
|
||||
@ -295,7 +295,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
|
||||
{
|
||||
|
||||
|
||||
btQuantizedBvhNode& curNode = m_quantizedContiguousNodes[i];
|
||||
b3QuantizedBvhNode& curNode = m_quantizedContiguousNodes[i];
|
||||
if (curNode.isLeafNode())
|
||||
{
|
||||
//recalc aabb from triangle data
|
||||
@ -308,7 +308,7 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
|
||||
meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase,numverts, type,stride,&indexbase,indexstride,numfaces,indicestype,nodeSubPart);
|
||||
|
||||
curNodeSubPart = nodeSubPart;
|
||||
btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
||||
b3Assert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
|
||||
}
|
||||
//triangles->getLockedReadOnlyVertexIndexBase(vertexBase,numVerts,
|
||||
|
||||
@ -336,8 +336,8 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
|
||||
|
||||
|
||||
|
||||
aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
|
||||
aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
|
||||
aabbMin.setMin(triangleVerts[0]);
|
||||
aabbMax.setMax(triangleVerts[0]);
|
||||
aabbMin.setMin(triangleVerts[1]);
|
||||
@ -352,9 +352,9 @@ void b3OptimizedBvh::updateBvhNodes(b3StridingMeshInterface* meshInterface,int f
|
||||
{
|
||||
//combine aabb from both children
|
||||
|
||||
btQuantizedBvhNode* leftChildNode = &m_quantizedContiguousNodes[i+1];
|
||||
b3QuantizedBvhNode* leftChildNode = &m_quantizedContiguousNodes[i+1];
|
||||
|
||||
btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? &m_quantizedContiguousNodes[i+2] :
|
||||
b3QuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? &m_quantizedContiguousNodes[i+2] :
|
||||
&m_quantizedContiguousNodes[i+1+leftChildNode->getEscapeIndex()];
|
||||
|
||||
|
||||
|
@ -15,8 +15,8 @@ subject to the following restrictions:
|
||||
|
||||
///Contains contributions from Disney Studio's
|
||||
|
||||
#ifndef BT_OPTIMIZED_BVH_H
|
||||
#define BT_OPTIMIZED_BVH_H
|
||||
#ifndef B3_OPTIMIZED_BVH_H
|
||||
#define B3_OPTIMIZED_BVH_H
|
||||
|
||||
#include "b3QuantizedBvh.h"
|
||||
|
||||
@ -28,7 +28,7 @@ ATTRIBUTE_ALIGNED16(class) b3OptimizedBvh : public b3QuantizedBvh
|
||||
{
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
protected:
|
||||
|
||||
@ -60,6 +60,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //BT_OPTIMIZED_BVH_H
|
||||
#endif //B3_OPTIMIZED_BVH_H
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ subject to the following restrictions:
|
||||
#define RAYAABB2
|
||||
|
||||
b3QuantizedBvh::b3QuantizedBvh() :
|
||||
m_bulletVersion(BT_BULLET_VERSION),
|
||||
m_bulletVersion(B3_BULLET_VERSION),
|
||||
m_useQuantization(false),
|
||||
m_traversalMode(TRAVERSAL_STACKLESS_CACHE_FRIENDLY)
|
||||
//m_traversalMode(TRAVERSAL_STACKLESS)
|
||||
@ -58,7 +58,7 @@ void b3QuantizedBvh::buildInternal()
|
||||
///if the entire tree is small then subtree size, we need to create a header info for the tree
|
||||
if(m_useQuantization && !m_SubtreeHeaders.size())
|
||||
{
|
||||
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
subtree.setAabbFromQuantizeNode(m_quantizedContiguousNodes[0]);
|
||||
subtree.m_rootNodeIndex = 0;
|
||||
subtree.m_subtreeSize = m_quantizedContiguousNodes[0].isLeafNode() ? 1 : m_quantizedContiguousNodes[0].getEscapeIndex();
|
||||
@ -123,7 +123,7 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
|
||||
int numIndices =endIndex-startIndex;
|
||||
int curIndex = m_curNodeIndex;
|
||||
|
||||
btAssert(numIndices>0);
|
||||
b3Assert(numIndices>0);
|
||||
|
||||
if (numIndices==1)
|
||||
{
|
||||
@ -178,7 +178,7 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
|
||||
if (m_useQuantization)
|
||||
{
|
||||
//escapeIndex is the number of nodes of this subtree
|
||||
const int sizeQuantizedNode =sizeof(btQuantizedBvhNode);
|
||||
const int sizeQuantizedNode =sizeof(b3QuantizedBvhNode);
|
||||
const int treeSizeInBytes = escapeIndex * sizeQuantizedNode;
|
||||
if (treeSizeInBytes > MAX_SUBTREE_SIZE_IN_BYTES)
|
||||
{
|
||||
@ -195,19 +195,19 @@ void b3QuantizedBvh::buildTree (int startIndex,int endIndex)
|
||||
|
||||
void b3QuantizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex)
|
||||
{
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
btQuantizedBvhNode& leftChildNode = m_quantizedContiguousNodes[leftChildNodexIndex];
|
||||
b3QuantizedBvhNode& leftChildNode = m_quantizedContiguousNodes[leftChildNodexIndex];
|
||||
int leftSubTreeSize = leftChildNode.isLeafNode() ? 1 : leftChildNode.getEscapeIndex();
|
||||
int leftSubTreeSizeInBytes = leftSubTreeSize * static_cast<int>(sizeof(btQuantizedBvhNode));
|
||||
int leftSubTreeSizeInBytes = leftSubTreeSize * static_cast<int>(sizeof(b3QuantizedBvhNode));
|
||||
|
||||
btQuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex];
|
||||
b3QuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex];
|
||||
int rightSubTreeSize = rightChildNode.isLeafNode() ? 1 : rightChildNode.getEscapeIndex();
|
||||
int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast<int>(sizeof(btQuantizedBvhNode));
|
||||
int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast<int>(sizeof(b3QuantizedBvhNode));
|
||||
|
||||
if(leftSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES)
|
||||
{
|
||||
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
subtree.setAabbFromQuantizeNode(leftChildNode);
|
||||
subtree.m_rootNodeIndex = leftChildNodexIndex;
|
||||
subtree.m_subtreeSize = leftSubTreeSize;
|
||||
@ -215,7 +215,7 @@ void b3QuantizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChild
|
||||
|
||||
if(rightSubTreeSizeInBytes <= MAX_SUBTREE_SIZE_IN_BYTES)
|
||||
{
|
||||
btBvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
b3BvhSubtreeInfo& subtree = m_SubtreeHeaders.expand();
|
||||
subtree.setAabbFromQuantizeNode(rightChildNode);
|
||||
subtree.m_rootNodeIndex = rightChildNodexIndex;
|
||||
subtree.m_subtreeSize = rightSubTreeSize;
|
||||
@ -274,7 +274,7 @@ int b3QuantizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int sp
|
||||
|
||||
bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
|
||||
(void)unbal;
|
||||
btAssert(!unbal);
|
||||
b3Assert(!unbal);
|
||||
|
||||
return splitIndex;
|
||||
}
|
||||
@ -309,7 +309,7 @@ int b3QuantizedBvh::calcSplittingAxis(int startIndex,int endIndex)
|
||||
|
||||
|
||||
|
||||
void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
void b3QuantizedBvh::reportAabbOverlappingNodex(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
{
|
||||
//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
|
||||
|
||||
@ -331,13 +331,13 @@ void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
|
||||
break;
|
||||
case TRAVERSAL_RECURSIVE:
|
||||
{
|
||||
const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[0];
|
||||
const b3QuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[0];
|
||||
walkRecursiveQuantizedTreeAgainstQueryAabb(rootNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//unsupported
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
}
|
||||
} else
|
||||
{
|
||||
@ -349,11 +349,11 @@ void b3QuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
|
||||
int maxIterations = 0;
|
||||
|
||||
|
||||
void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
void b3QuantizedBvh::walkStacklessTree(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
{
|
||||
btAssert(!m_useQuantization);
|
||||
b3Assert(!m_useQuantization);
|
||||
|
||||
const btOptimizedBvhNode* rootNode = &m_contiguousNodes[0];
|
||||
const b3OptimizedBvhNode* rootNode = &m_contiguousNodes[0];
|
||||
int escapeIndex, curIndex = 0;
|
||||
int walkIterations = 0;
|
||||
bool isLeafNode;
|
||||
@ -363,7 +363,7 @@ void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const
|
||||
while (curIndex < m_curNodeIndex)
|
||||
{
|
||||
//catch bugs in tree data
|
||||
btAssert (walkIterations < m_curNodeIndex);
|
||||
b3Assert (walkIterations < m_curNodeIndex);
|
||||
|
||||
walkIterations++;
|
||||
aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg);
|
||||
@ -394,7 +394,7 @@ void b3QuantizedBvh::walkStacklessTree(btNodeOverlapCallback* nodeCallback,const
|
||||
|
||||
/*
|
||||
///this was the original recursive traversal, before we optimized towards stackless traversal
|
||||
void b3QuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
void b3QuantizedBvh::walkTree(b3OptimizedBvhNode* rootNode,b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
{
|
||||
bool isLeafNode, aabbOverlap = TestAabbAgainstAabb2(aabbMin,aabbMax,rootNode->m_aabbMin,rootNode->m_aabbMax);
|
||||
if (aabbOverlap)
|
||||
@ -413,9 +413,9 @@ void b3QuantizedBvh::walkTree(btOptimizedBvhNode* rootNode,btNodeOverlapCallback
|
||||
}
|
||||
*/
|
||||
|
||||
void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
|
||||
void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const b3QuantizedBvhNode* currentNode,b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
|
||||
{
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
bool isLeafNode;
|
||||
//PCK: unsigned instead of bool
|
||||
@ -434,10 +434,10 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantize
|
||||
} else
|
||||
{
|
||||
//process left and right children
|
||||
const btQuantizedBvhNode* leftChildNode = currentNode+1;
|
||||
const b3QuantizedBvhNode* leftChildNode = currentNode+1;
|
||||
walkRecursiveQuantizedTreeAgainstQueryAabb(leftChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
|
||||
|
||||
const btQuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? leftChildNode+1:leftChildNode+leftChildNode->getEscapeIndex();
|
||||
const b3QuantizedBvhNode* rightChildNode = leftChildNode->isLeafNode() ? leftChildNode+1:leftChildNode+leftChildNode->getEscapeIndex();
|
||||
walkRecursiveQuantizedTreeAgainstQueryAabb(rightChildNode,nodeCallback,quantizedQueryAabbMin,quantizedQueryAabbMax);
|
||||
}
|
||||
}
|
||||
@ -445,11 +445,11 @@ void b3QuantizedBvh::walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantize
|
||||
|
||||
|
||||
|
||||
void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
|
||||
void b3QuantizedBvh::walkStacklessTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
|
||||
{
|
||||
btAssert(!m_useQuantization);
|
||||
b3Assert(!m_useQuantization);
|
||||
|
||||
const btOptimizedBvhNode* rootNode = &m_contiguousNodes[0];
|
||||
const b3OptimizedBvhNode* rootNode = &m_contiguousNodes[0];
|
||||
int escapeIndex, curIndex = 0;
|
||||
int walkIterations = 0;
|
||||
bool isLeafNode;
|
||||
@ -474,9 +474,9 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
|
||||
lambda_max = rayDir.dot(rayTarget-raySource);
|
||||
///what about division by zero? --> just set rayDirection[i] to 1.0
|
||||
b3Vector3 rayDirectionInverse;
|
||||
rayDirectionInverse[0] = rayDir[0] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[0];
|
||||
rayDirectionInverse[1] = rayDir[1] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[1];
|
||||
rayDirectionInverse[2] = rayDir[2] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[2];
|
||||
rayDirectionInverse[0] = rayDir[0] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[0];
|
||||
rayDirectionInverse[1] = rayDir[1] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[1];
|
||||
rayDirectionInverse[2] = rayDir[2] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDir[2];
|
||||
unsigned int sign[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0};
|
||||
#endif
|
||||
|
||||
@ -486,7 +486,7 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
|
||||
{
|
||||
b3Scalar param = 1.0;
|
||||
//catch bugs in tree data
|
||||
btAssert (walkIterations < m_curNodeIndex);
|
||||
b3Assert (walkIterations < m_curNodeIndex);
|
||||
|
||||
walkIterations++;
|
||||
|
||||
@ -503,11 +503,11 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
|
||||
///careful with this check: need to check division by zero (above) and fix the unQuantize method
|
||||
///thanks Joerg/hiker for the reproduction case!
|
||||
///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
|
||||
rayBoxOverlap = aabbOverlap ? btRayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false;
|
||||
rayBoxOverlap = aabbOverlap ? b3RayAabb2 (raySource, rayDirectionInverse, sign, bounds, param, 0.0f, lambda_max) : false;
|
||||
|
||||
#else
|
||||
b3Vector3 normal;
|
||||
rayBoxOverlap = btRayAabb(raySource, rayTarget,bounds[0],bounds[1],param, normal);
|
||||
rayBoxOverlap = b3RayAabb(raySource, rayTarget,bounds[0],bounds[1],param, normal);
|
||||
#endif
|
||||
|
||||
isLeafNode = rootNode->m_escapeIndex == -1;
|
||||
@ -537,16 +537,16 @@ void b3QuantizedBvh::walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCall
|
||||
|
||||
|
||||
|
||||
void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
|
||||
void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const
|
||||
{
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
int curIndex = startNodeIndex;
|
||||
int walkIterations = 0;
|
||||
int subTreeSize = endNodeIndex - startNodeIndex;
|
||||
(void)subTreeSize;
|
||||
|
||||
const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
|
||||
const b3QuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
|
||||
int escapeIndex;
|
||||
|
||||
bool isLeafNode;
|
||||
@ -561,9 +561,9 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
||||
rayDirection.normalize ();
|
||||
lambda_max = rayDirection.dot(rayTarget-raySource);
|
||||
///what about division by zero? --> just set rayDirection[i] to 1.0
|
||||
rayDirection[0] = rayDirection[0] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[0];
|
||||
rayDirection[1] = rayDirection[1] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[1];
|
||||
rayDirection[2] = rayDirection[2] == b3Scalar(0.0) ? b3Scalar(BT_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[2];
|
||||
rayDirection[0] = rayDirection[0] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[0];
|
||||
rayDirection[1] = rayDirection[1] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[1];
|
||||
rayDirection[2] = rayDirection[2] == b3Scalar(0.0) ? b3Scalar(B3_LARGE_FLOAT) : b3Scalar(1.0) / rayDirection[2];
|
||||
unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0};
|
||||
#endif
|
||||
|
||||
@ -590,7 +590,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
||||
//some code snippet to debugDraw aabb, to visually analyze bvh structure
|
||||
static int drawPatch = 0;
|
||||
//need some global access to a debugDrawer
|
||||
extern btIDebugDraw* debugDrawerPtr;
|
||||
extern b3IDebugDraw* debugDrawerPtr;
|
||||
if (curIndex==drawPatch)
|
||||
{
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
@ -602,7 +602,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
||||
#endif//VISUALLY_ANALYZE_BVH
|
||||
|
||||
//catch bugs in tree data
|
||||
btAssert (walkIterations < subTreeSize);
|
||||
b3Assert (walkIterations < subTreeSize);
|
||||
|
||||
walkIterations++;
|
||||
//PCK: unsigned instead of bool
|
||||
@ -621,8 +621,8 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
||||
bounds[1] -= aabbMin;
|
||||
b3Vector3 normal;
|
||||
#if 0
|
||||
bool ra2 = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);
|
||||
bool ra = btRayAabb (raySource, rayTarget, bounds[0], bounds[1], param, normal);
|
||||
bool ra2 = b3RayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);
|
||||
bool ra = b3RayAabb (raySource, rayTarget, bounds[0], bounds[1], param, normal);
|
||||
if (ra2 != ra)
|
||||
{
|
||||
printf("functions don't match\n");
|
||||
@ -633,11 +633,11 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
||||
///thanks Joerg/hiker for the reproduction case!
|
||||
///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
|
||||
|
||||
//BT_PROFILE("btRayAabb2");
|
||||
rayBoxOverlap = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max);
|
||||
//B3_PROFILE("b3RayAabb2");
|
||||
rayBoxOverlap = b3RayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max);
|
||||
|
||||
#else
|
||||
rayBoxOverlap = true;//btRayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
|
||||
rayBoxOverlap = true;//b3RayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -663,16 +663,16 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
||||
|
||||
}
|
||||
|
||||
void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const
|
||||
void b3QuantizedBvh::walkStacklessQuantizedTree(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const
|
||||
{
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
int curIndex = startNodeIndex;
|
||||
int walkIterations = 0;
|
||||
int subTreeSize = endNodeIndex - startNodeIndex;
|
||||
(void)subTreeSize;
|
||||
|
||||
const btQuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
|
||||
const b3QuantizedBvhNode* rootNode = &m_quantizedContiguousNodes[startNodeIndex];
|
||||
int escapeIndex;
|
||||
|
||||
bool isLeafNode;
|
||||
@ -687,7 +687,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
|
||||
//some code snippet to debugDraw aabb, to visually analyze bvh structure
|
||||
static int drawPatch = 0;
|
||||
//need some global access to a debugDrawer
|
||||
extern btIDebugDraw* debugDrawerPtr;
|
||||
extern b3IDebugDraw* debugDrawerPtr;
|
||||
if (curIndex==drawPatch)
|
||||
{
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
@ -699,7 +699,7 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
|
||||
#endif//VISUALLY_ANALYZE_BVH
|
||||
|
||||
//catch bugs in tree data
|
||||
btAssert (walkIterations < subTreeSize);
|
||||
b3Assert (walkIterations < subTreeSize);
|
||||
|
||||
walkIterations++;
|
||||
//PCK: unsigned instead of bool
|
||||
@ -729,16 +729,16 @@ void b3QuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallb
|
||||
}
|
||||
|
||||
//This traversal can be called from Playstation 3 SPU
|
||||
void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
|
||||
void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const
|
||||
{
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
for (i=0;i<this->m_SubtreeHeaders.size();i++)
|
||||
{
|
||||
const btBvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||
const b3BvhSubtreeInfo& subtree = m_SubtreeHeaders[i];
|
||||
|
||||
//PCK: unsigned instead of bool
|
||||
unsigned overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);
|
||||
@ -752,13 +752,13 @@ void b3QuantizedBvh::walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallba
|
||||
}
|
||||
|
||||
|
||||
void b3QuantizedBvh::reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const
|
||||
void b3QuantizedBvh::reportRayOverlappingNodex (b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const
|
||||
{
|
||||
reportBoxCastOverlappingNodex(nodeCallback,raySource,rayTarget,b3Vector3(0,0,0),b3Vector3(0,0,0));
|
||||
}
|
||||
|
||||
|
||||
void b3QuantizedBvh::reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
void b3QuantizedBvh::reportBoxCastOverlappingNodex(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
{
|
||||
//always use stackless
|
||||
|
||||
@ -790,12 +790,12 @@ void b3QuantizedBvh::swapLeafNodes(int i,int splitIndex)
|
||||
{
|
||||
if (m_useQuantization)
|
||||
{
|
||||
btQuantizedBvhNode tmp = m_quantizedLeafNodes[i];
|
||||
b3QuantizedBvhNode tmp = m_quantizedLeafNodes[i];
|
||||
m_quantizedLeafNodes[i] = m_quantizedLeafNodes[splitIndex];
|
||||
m_quantizedLeafNodes[splitIndex] = tmp;
|
||||
} else
|
||||
{
|
||||
btOptimizedBvhNode tmp = m_leafNodes[i];
|
||||
b3OptimizedBvhNode tmp = m_leafNodes[i];
|
||||
m_leafNodes[i] = m_leafNodes[splitIndex];
|
||||
m_leafNodes[splitIndex] = tmp;
|
||||
}
|
||||
@ -833,23 +833,23 @@ unsigned int b3QuantizedBvh::getAlignmentSerializationPadding()
|
||||
unsigned b3QuantizedBvh::calculateSerializeBufferSize() const
|
||||
{
|
||||
unsigned baseSize = sizeof(b3QuantizedBvh) + getAlignmentSerializationPadding();
|
||||
baseSize += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
|
||||
baseSize += sizeof(b3BvhSubtreeInfo) * m_subtreeHeaderCount;
|
||||
if (m_useQuantization)
|
||||
{
|
||||
return baseSize + m_curNodeIndex * sizeof(btQuantizedBvhNode);
|
||||
return baseSize + m_curNodeIndex * sizeof(b3QuantizedBvhNode);
|
||||
}
|
||||
return baseSize + m_curNodeIndex * sizeof(btOptimizedBvhNode);
|
||||
return baseSize + m_curNodeIndex * sizeof(b3OptimizedBvhNode);
|
||||
}
|
||||
|
||||
bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBufferSize */, bool i_swapEndian) const
|
||||
{
|
||||
btAssert(m_subtreeHeaderCount == m_SubtreeHeaders.size());
|
||||
b3Assert(m_subtreeHeaderCount == m_SubtreeHeaders.size());
|
||||
m_subtreeHeaderCount = m_SubtreeHeaders.size();
|
||||
|
||||
/* if (i_dataBufferSize < calculateSerializeBufferSize() || o_alignedDataBuffer == NULL || (((unsigned)o_alignedDataBuffer & BVH_ALIGNMENT_MASK) != 0))
|
||||
{
|
||||
///check alignedment for buffer?
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
@ -862,15 +862,15 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
|
||||
if (i_swapEndian)
|
||||
{
|
||||
targetBvh->m_curNodeIndex = static_cast<int>(btSwapEndian(m_curNodeIndex));
|
||||
targetBvh->m_curNodeIndex = static_cast<int>(b3SwapEndian(m_curNodeIndex));
|
||||
|
||||
|
||||
btSwapVector3Endian(m_bvhAabbMin,targetBvh->m_bvhAabbMin);
|
||||
btSwapVector3Endian(m_bvhAabbMax,targetBvh->m_bvhAabbMax);
|
||||
btSwapVector3Endian(m_bvhQuantization,targetBvh->m_bvhQuantization);
|
||||
b3SwapVector3Endian(m_bvhAabbMin,targetBvh->m_bvhAabbMin);
|
||||
b3SwapVector3Endian(m_bvhAabbMax,targetBvh->m_bvhAabbMax);
|
||||
b3SwapVector3Endian(m_bvhQuantization,targetBvh->m_bvhQuantization);
|
||||
|
||||
targetBvh->m_traversalMode = (btTraversalMode)btSwapEndian(m_traversalMode);
|
||||
targetBvh->m_subtreeHeaderCount = static_cast<int>(btSwapEndian(m_subtreeHeaderCount));
|
||||
targetBvh->m_traversalMode = (b3TraversalMode)b3SwapEndian(m_traversalMode);
|
||||
targetBvh->m_subtreeHeaderCount = static_cast<int>(b3SwapEndian(m_subtreeHeaderCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -900,15 +900,15 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
{
|
||||
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
|
||||
{
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
|
||||
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
|
||||
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
|
||||
targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(b3SwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -929,7 +929,7 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
|
||||
}
|
||||
}
|
||||
nodeData += sizeof(btQuantizedBvhNode) * nodeCount;
|
||||
nodeData += sizeof(b3QuantizedBvhNode) * nodeCount;
|
||||
|
||||
// this clears the pointer in the member variable it doesn't really do anything to the data
|
||||
// it does call the destructor on the contained objects, but they are all classes with no destructor defined
|
||||
@ -944,12 +944,12 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
{
|
||||
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
|
||||
{
|
||||
btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMinOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
|
||||
btSwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMaxOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
|
||||
b3SwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMinOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
|
||||
b3SwapVector3Endian(m_contiguousNodes[nodeIndex].m_aabbMaxOrg, targetBvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
|
||||
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex));
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_subPart));
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(btSwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex));
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(b3SwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex));
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(b3SwapEndian(m_contiguousNodes[nodeIndex].m_subPart));
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(b3SwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -964,7 +964,7 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = m_contiguousNodes[nodeIndex].m_triangleIndex;
|
||||
}
|
||||
}
|
||||
nodeData += sizeof(btOptimizedBvhNode) * nodeCount;
|
||||
nodeData += sizeof(b3OptimizedBvhNode) * nodeCount;
|
||||
|
||||
// this clears the pointer in the member variable it doesn't really do anything to the data
|
||||
// it does call the destructor on the contained objects, but they are all classes with no destructor defined
|
||||
@ -981,16 +981,16 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
{
|
||||
for (int i = 0; i < m_subtreeHeaderCount; i++)
|
||||
{
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
|
||||
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
|
||||
targetBvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = b3SwapEndian(m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
|
||||
|
||||
targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(btSwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex));
|
||||
targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(btSwapEndian(m_SubtreeHeaders[i].m_subtreeSize));
|
||||
targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(b3SwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex));
|
||||
targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(b3SwapEndian(m_SubtreeHeaders[i].m_subtreeSize));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1014,7 +1014,7 @@ bool b3QuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBuffe
|
||||
targetBvh->m_SubtreeHeaders[i].m_padding[2] = 0;
|
||||
}
|
||||
}
|
||||
nodeData += sizeof(btBvhSubtreeInfo) * m_subtreeHeaderCount;
|
||||
nodeData += sizeof(b3BvhSubtreeInfo) * m_subtreeHeaderCount;
|
||||
|
||||
// this clears the pointer in the member variable it doesn't really do anything to the data
|
||||
// it does call the destructor on the contained objects, but they are all classes with no destructor defined
|
||||
@ -1038,18 +1038,18 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
|
||||
|
||||
if (i_swapEndian)
|
||||
{
|
||||
bvh->m_curNodeIndex = static_cast<int>(btSwapEndian(bvh->m_curNodeIndex));
|
||||
bvh->m_curNodeIndex = static_cast<int>(b3SwapEndian(bvh->m_curNodeIndex));
|
||||
|
||||
btUnSwapVector3Endian(bvh->m_bvhAabbMin);
|
||||
btUnSwapVector3Endian(bvh->m_bvhAabbMax);
|
||||
btUnSwapVector3Endian(bvh->m_bvhQuantization);
|
||||
b3UnSwapVector3Endian(bvh->m_bvhAabbMin);
|
||||
b3UnSwapVector3Endian(bvh->m_bvhAabbMax);
|
||||
b3UnSwapVector3Endian(bvh->m_bvhQuantization);
|
||||
|
||||
bvh->m_traversalMode = (btTraversalMode)btSwapEndian(bvh->m_traversalMode);
|
||||
bvh->m_subtreeHeaderCount = static_cast<int>(btSwapEndian(bvh->m_subtreeHeaderCount));
|
||||
bvh->m_traversalMode = (b3TraversalMode)b3SwapEndian(bvh->m_traversalMode);
|
||||
bvh->m_subtreeHeaderCount = static_cast<int>(b3SwapEndian(bvh->m_subtreeHeaderCount));
|
||||
}
|
||||
|
||||
unsigned int calculatedBufSize = bvh->calculateSerializeBufferSize();
|
||||
btAssert(calculatedBufSize <= i_dataBufferSize);
|
||||
b3Assert(calculatedBufSize <= i_dataBufferSize);
|
||||
|
||||
if (calculatedBufSize > i_dataBufferSize)
|
||||
{
|
||||
@ -1076,18 +1076,18 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
|
||||
{
|
||||
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
|
||||
{
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[1]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[2]);
|
||||
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[1]);
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2] = b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[2]);
|
||||
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
|
||||
bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast<int>(b3SwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex));
|
||||
}
|
||||
}
|
||||
nodeData += sizeof(btQuantizedBvhNode) * nodeCount;
|
||||
nodeData += sizeof(b3QuantizedBvhNode) * nodeCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1097,15 +1097,15 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
|
||||
{
|
||||
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
|
||||
{
|
||||
btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
|
||||
btUnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
|
||||
b3UnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMinOrg);
|
||||
b3UnSwapVector3Endian(bvh->m_contiguousNodes[nodeIndex].m_aabbMaxOrg);
|
||||
|
||||
bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex));
|
||||
bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart));
|
||||
bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex));
|
||||
bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast<int>(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex));
|
||||
bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast<int>(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart));
|
||||
bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast<int>(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex));
|
||||
}
|
||||
}
|
||||
nodeData += sizeof(btOptimizedBvhNode) * nodeCount;
|
||||
nodeData += sizeof(b3OptimizedBvhNode) * nodeCount;
|
||||
}
|
||||
|
||||
sizeToAdd = 0;//(BVH_ALIGNMENT-((unsigned)nodeData & BVH_ALIGNMENT_MASK))&BVH_ALIGNMENT_MASK;
|
||||
@ -1117,16 +1117,16 @@ b3QuantizedBvh *b3QuantizedBvh::deSerializeInPlace(void *i_alignedDataBuffer, un
|
||||
{
|
||||
for (int i = 0; i < bvh->m_subtreeHeaderCount; i++)
|
||||
{
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[0]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[1]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMin[2]);
|
||||
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = btSwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[0]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[1]);
|
||||
bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2] = b3SwapEndian(bvh->m_SubtreeHeaders[i].m_quantizedAabbMax[2]);
|
||||
|
||||
bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(btSwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex));
|
||||
bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(btSwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize));
|
||||
bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast<int>(b3SwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex));
|
||||
bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast<int>(b3SwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1138,12 +1138,12 @@ b3QuantizedBvh::b3QuantizedBvh(b3QuantizedBvh &self, bool /* ownsMemory */) :
|
||||
m_bvhAabbMin(self.m_bvhAabbMin),
|
||||
m_bvhAabbMax(self.m_bvhAabbMax),
|
||||
m_bvhQuantization(self.m_bvhQuantization),
|
||||
m_bulletVersion(BT_BULLET_VERSION)
|
||||
m_bulletVersion(B3_BULLET_VERSION)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData)
|
||||
void b3QuantizedBvh::deSerializeFloat(struct b3QuantizedBvhFloatData& quantizedBvhFloatData)
|
||||
{
|
||||
m_bvhAabbMax.deSerializeFloat(quantizedBvhFloatData.m_bvhAabbMax);
|
||||
m_bvhAabbMin.deSerializeFloat(quantizedBvhFloatData.m_bvhAabbMin);
|
||||
@ -1158,7 +1158,7 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
|
||||
|
||||
if (numElem)
|
||||
{
|
||||
btOptimizedBvhNodeFloatData* memPtr = quantizedBvhFloatData.m_contiguousNodesPtr;
|
||||
b3OptimizedBvhNodeFloatData* memPtr = quantizedBvhFloatData.m_contiguousNodesPtr;
|
||||
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
@ -1177,7 +1177,7 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
|
||||
|
||||
if (numElem)
|
||||
{
|
||||
btQuantizedBvhNodeData* memPtr = quantizedBvhFloatData.m_quantizedContiguousNodesPtr;
|
||||
b3QuantizedBvhNodeData* memPtr = quantizedBvhFloatData.m_quantizedContiguousNodesPtr;
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex = memPtr->m_escapeIndexOrTriangleIndex;
|
||||
@ -1191,14 +1191,14 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
|
||||
}
|
||||
}
|
||||
|
||||
m_traversalMode = btTraversalMode(quantizedBvhFloatData.m_traversalMode);
|
||||
m_traversalMode = b3TraversalMode(quantizedBvhFloatData.m_traversalMode);
|
||||
|
||||
{
|
||||
int numElem = quantizedBvhFloatData.m_numSubtreeHeaders;
|
||||
m_SubtreeHeaders.resize(numElem);
|
||||
if (numElem)
|
||||
{
|
||||
btBvhSubtreeInfoData* memPtr = quantizedBvhFloatData.m_subTreeInfoPtr;
|
||||
b3BvhSubtreeInfoData* memPtr = quantizedBvhFloatData.m_subTreeInfoPtr;
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
m_SubtreeHeaders[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0] ;
|
||||
@ -1214,7 +1214,7 @@ void b3QuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedB
|
||||
}
|
||||
}
|
||||
|
||||
void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData)
|
||||
void b3QuantizedBvh::deSerializeDouble(struct b3QuantizedBvhDoubleData& quantizedBvhDoubleData)
|
||||
{
|
||||
m_bvhAabbMax.deSerializeDouble(quantizedBvhDoubleData.m_bvhAabbMax);
|
||||
m_bvhAabbMin.deSerializeDouble(quantizedBvhDoubleData.m_bvhAabbMin);
|
||||
@ -1229,7 +1229,7 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
|
||||
|
||||
if (numElem)
|
||||
{
|
||||
btOptimizedBvhNodeDoubleData* memPtr = quantizedBvhDoubleData.m_contiguousNodesPtr;
|
||||
b3OptimizedBvhNodeDoubleData* memPtr = quantizedBvhDoubleData.m_contiguousNodesPtr;
|
||||
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
@ -1248,7 +1248,7 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
|
||||
|
||||
if (numElem)
|
||||
{
|
||||
btQuantizedBvhNodeData* memPtr = quantizedBvhDoubleData.m_quantizedContiguousNodesPtr;
|
||||
b3QuantizedBvhNodeData* memPtr = quantizedBvhDoubleData.m_quantizedContiguousNodesPtr;
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex = memPtr->m_escapeIndexOrTriangleIndex;
|
||||
@ -1262,14 +1262,14 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
|
||||
}
|
||||
}
|
||||
|
||||
m_traversalMode = btTraversalMode(quantizedBvhDoubleData.m_traversalMode);
|
||||
m_traversalMode = b3TraversalMode(quantizedBvhDoubleData.m_traversalMode);
|
||||
|
||||
{
|
||||
int numElem = quantizedBvhDoubleData.m_numSubtreeHeaders;
|
||||
m_SubtreeHeaders.resize(numElem);
|
||||
if (numElem)
|
||||
{
|
||||
btBvhSubtreeInfoData* memPtr = quantizedBvhDoubleData.m_subTreeInfoPtr;
|
||||
b3BvhSubtreeInfoData* memPtr = quantizedBvhDoubleData.m_subTreeInfoPtr;
|
||||
for (int i=0;i<numElem;i++,memPtr++)
|
||||
{
|
||||
m_SubtreeHeaders[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0] ;
|
||||
@ -1289,9 +1289,9 @@ void b3QuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantize
|
||||
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
const char* b3QuantizedBvh::serialize(void* dataBuffer, btSerializer* serializer) const
|
||||
const char* b3QuantizedBvh::serialize(void* dataBuffer, b3Serializer* serializer) const
|
||||
{
|
||||
btAssert(0);
|
||||
b3Assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,10 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_QUANTIZED_BVH_H
|
||||
#define BT_QUANTIZED_BVH_H
|
||||
#ifndef B3_QUANTIZED_BVH_H
|
||||
#define B3_QUANTIZED_BVH_H
|
||||
|
||||
class btSerializer;
|
||||
class b3Serializer;
|
||||
|
||||
//#define DEBUG_CHECK_DEQUANTIZATION 1
|
||||
#ifdef DEBUG_CHECK_DEQUANTIZATION
|
||||
@ -31,14 +31,14 @@ class btSerializer;
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "Bullet3Common/b3AlignedAllocator.h"
|
||||
|
||||
#ifdef BT_USE_DOUBLE_PRECISION
|
||||
#define btQuantizedBvhData btQuantizedBvhDoubleData
|
||||
#define btOptimizedBvhNodeData btOptimizedBvhNodeDoubleData
|
||||
#define btQuantizedBvhDataName "btQuantizedBvhDoubleData"
|
||||
#ifdef B3_USE_DOUBLE_PRECISION
|
||||
#define b3QuantizedBvhData b3QuantizedBvhDoubleData
|
||||
#define b3OptimizedBvhNodeData b3OptimizedBvhNodeDoubleData
|
||||
#define b3QuantizedBvhDataName "b3QuantizedBvhDoubleData"
|
||||
#else
|
||||
#define btQuantizedBvhData btQuantizedBvhFloatData
|
||||
#define btOptimizedBvhNodeData btOptimizedBvhNodeFloatData
|
||||
#define btQuantizedBvhDataName "btQuantizedBvhFloatData"
|
||||
#define b3QuantizedBvhData b3QuantizedBvhFloatData
|
||||
#define b3OptimizedBvhNodeData b3OptimizedBvhNodeFloatData
|
||||
#define b3QuantizedBvhDataName "b3QuantizedBvhFloatData"
|
||||
#endif
|
||||
|
||||
|
||||
@ -53,11 +53,11 @@ class btSerializer;
|
||||
// actually) triangles each (since the sign bit is reserved
|
||||
#define MAX_NUM_PARTS_IN_BITS 10
|
||||
|
||||
///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
|
||||
///b3QuantizedBvhNode is a compressed aabb node, 16 bytes.
|
||||
///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
|
||||
ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
||||
ATTRIBUTE_ALIGNED16 (struct) b3QuantizedBvhNode
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//12 bytes
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
@ -72,12 +72,12 @@ ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
||||
}
|
||||
int getEscapeIndex() const
|
||||
{
|
||||
btAssert(!isLeafNode());
|
||||
b3Assert(!isLeafNode());
|
||||
return -m_escapeIndexOrTriangleIndex;
|
||||
}
|
||||
int getTriangleIndex() const
|
||||
{
|
||||
btAssert(isLeafNode());
|
||||
b3Assert(isLeafNode());
|
||||
unsigned int x=0;
|
||||
unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);
|
||||
// Get only the lower bits where the triangle index is stored
|
||||
@ -85,18 +85,18 @@ ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
||||
}
|
||||
int getPartId() const
|
||||
{
|
||||
btAssert(isLeafNode());
|
||||
b3Assert(isLeafNode());
|
||||
// Get only the highest bits where the part index is stored
|
||||
return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
/// btOptimizedBvhNode contains both internal and leaf node information.
|
||||
/// b3OptimizedBvhNode contains both internal and leaf node information.
|
||||
/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
|
||||
ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
|
||||
ATTRIBUTE_ALIGNED16 (struct) b3OptimizedBvhNode
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//32 bytes
|
||||
b3Vector3 m_aabbMinOrg;
|
||||
@ -115,11 +115,11 @@ ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
|
||||
};
|
||||
|
||||
|
||||
///btBvhSubtreeInfo provides info to gather a subtree of limited size
|
||||
ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo
|
||||
///b3BvhSubtreeInfo provides info to gather a subtree of limited size
|
||||
ATTRIBUTE_ALIGNED16(class) b3BvhSubtreeInfo
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//12 bytes
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
@ -130,13 +130,13 @@ public:
|
||||
int m_subtreeSize;
|
||||
int m_padding[3];
|
||||
|
||||
btBvhSubtreeInfo()
|
||||
b3BvhSubtreeInfo()
|
||||
{
|
||||
//memset(&m_padding[0], 0, sizeof(m_padding));
|
||||
}
|
||||
|
||||
|
||||
void setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
|
||||
void setAabbFromQuantizeNode(const b3QuantizedBvhNode& quantizedNode)
|
||||
{
|
||||
m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0];
|
||||
m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1];
|
||||
@ -149,10 +149,10 @@ public:
|
||||
;
|
||||
|
||||
|
||||
class btNodeOverlapCallback
|
||||
class b3NodeOverlapCallback
|
||||
{
|
||||
public:
|
||||
virtual ~btNodeOverlapCallback() {};
|
||||
virtual ~b3NodeOverlapCallback() {};
|
||||
|
||||
virtual void processNode(int subPart, int triangleIndex) = 0;
|
||||
};
|
||||
@ -163,18 +163,18 @@ public:
|
||||
|
||||
|
||||
///for code readability:
|
||||
typedef b3AlignedObjectArray<btOptimizedBvhNode> NodeArray;
|
||||
typedef b3AlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
|
||||
typedef b3AlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
|
||||
typedef b3AlignedObjectArray<b3OptimizedBvhNode> NodeArray;
|
||||
typedef b3AlignedObjectArray<b3QuantizedBvhNode> QuantizedNodeArray;
|
||||
typedef b3AlignedObjectArray<b3BvhSubtreeInfo> BvhSubtreeInfoArray;
|
||||
|
||||
|
||||
///The b3QuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
|
||||
///It is used by the btBvhTriangleMeshShape as midphase, and by the btMultiSapBroadphase.
|
||||
///It is used by the b3BvhTriangleMeshShape as midphase, and by the b3MultiSapBroadphase.
|
||||
///It is recommended to use quantization for better performance and lower memory requirements.
|
||||
ATTRIBUTE_ALIGNED16(class) b3QuantizedBvh
|
||||
{
|
||||
public:
|
||||
enum btTraversalMode
|
||||
enum b3TraversalMode
|
||||
{
|
||||
TRAVERSAL_STACKLESS = 0,
|
||||
TRAVERSAL_STACKLESS_CACHE_FRIENDLY,
|
||||
@ -202,7 +202,7 @@ protected:
|
||||
QuantizedNodeArray m_quantizedLeafNodes;
|
||||
QuantizedNodeArray m_quantizedContiguousNodes;
|
||||
|
||||
btTraversalMode m_traversalMode;
|
||||
b3TraversalMode m_traversalMode;
|
||||
BvhSubtreeInfoArray m_SubtreeHeaders;
|
||||
|
||||
//This is only used for serialization so we don't have to add serialization directly to b3AlignedObjectArray
|
||||
@ -310,20 +310,20 @@ protected:
|
||||
|
||||
int sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis);
|
||||
|
||||
void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
void walkStacklessTree(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
|
||||
void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessQuantizedTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessQuantizedTree(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessTreeAgainstRay(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin, const b3Vector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
|
||||
|
||||
///tree traversal designed for small-memory processors like PS3 SPU
|
||||
void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
|
||||
void walkStacklessQuantizedTreeCacheFriendly(b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
|
||||
|
||||
///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
|
||||
void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
|
||||
void walkRecursiveQuantizedTreeAgainstQueryAabb(const b3QuantizedBvhNode* currentNode,b3NodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
|
||||
|
||||
///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
|
||||
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA,const btQuantizedBvhNode* treeNodeB,btNodeOverlapCallback* nodeCallback) const;
|
||||
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const b3QuantizedBvhNode* treeNodeA,const b3QuantizedBvhNode* treeNodeB,b3NodeOverlapCallback* nodeCallback) const;
|
||||
|
||||
|
||||
|
||||
@ -332,7 +332,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3QuantizedBvh();
|
||||
|
||||
@ -346,22 +346,22 @@ public:
|
||||
void buildInternal();
|
||||
///***************************************** expert/internal use only *************************
|
||||
|
||||
void reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const;
|
||||
void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
void reportAabbOverlappingNodex(b3NodeOverlapCallback* nodeCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
void reportRayOverlappingNodex (b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget) const;
|
||||
void reportBoxCastOverlappingNodex(b3NodeOverlapCallback* nodeCallback, const b3Vector3& raySource, const b3Vector3& rayTarget, const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
|
||||
SIMD_FORCE_INLINE void quantize(unsigned short* out, const b3Vector3& point,int isMax) const
|
||||
{
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
btAssert(point.getX() <= m_bvhAabbMax.getX());
|
||||
btAssert(point.getY() <= m_bvhAabbMax.getY());
|
||||
btAssert(point.getZ() <= m_bvhAabbMax.getZ());
|
||||
b3Assert(point.getX() <= m_bvhAabbMax.getX());
|
||||
b3Assert(point.getY() <= m_bvhAabbMax.getY());
|
||||
b3Assert(point.getZ() <= m_bvhAabbMax.getZ());
|
||||
|
||||
btAssert(point.getX() >= m_bvhAabbMin.getX());
|
||||
btAssert(point.getY() >= m_bvhAabbMin.getY());
|
||||
btAssert(point.getZ() >= m_bvhAabbMin.getZ());
|
||||
b3Assert(point.getX() >= m_bvhAabbMin.getX());
|
||||
b3Assert(point.getY() >= m_bvhAabbMin.getY());
|
||||
b3Assert(point.getZ() >= m_bvhAabbMin.getZ());
|
||||
|
||||
b3Vector3 v = (point - m_bvhAabbMin) * m_bvhQuantization;
|
||||
///Make sure rounding is done in a way that unQuantize(quantizeWithClamp(...)) is conservative
|
||||
@ -420,7 +420,7 @@ public:
|
||||
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const b3Vector3& point2,int isMax) const
|
||||
{
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
b3Assert(m_useQuantization);
|
||||
|
||||
b3Vector3 clampedPoint(point2);
|
||||
clampedPoint.setMax(m_bvhAabbMin);
|
||||
@ -442,7 +442,7 @@ public:
|
||||
}
|
||||
|
||||
///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.
|
||||
void setTraversalMode(btTraversalMode traversalMode)
|
||||
void setTraversalMode(b3TraversalMode traversalMode)
|
||||
{
|
||||
m_traversalMode = traversalMode;
|
||||
}
|
||||
@ -477,11 +477,11 @@ public:
|
||||
virtual int calculateSerializeBufferSizeNew() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
virtual const char* serialize(void* dataBuffer, b3Serializer* serializer) const;
|
||||
|
||||
virtual void deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData);
|
||||
virtual void deSerializeFloat(struct b3QuantizedBvhFloatData& quantizedBvhFloatData);
|
||||
|
||||
virtual void deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData);
|
||||
virtual void deSerializeDouble(struct b3QuantizedBvhDoubleData& quantizedBvhDoubleData);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -501,7 +501,7 @@ private:
|
||||
;
|
||||
|
||||
|
||||
struct btBvhSubtreeInfoData
|
||||
struct b3BvhSubtreeInfoData
|
||||
{
|
||||
int m_rootNodeIndex;
|
||||
int m_subtreeSize;
|
||||
@ -509,20 +509,20 @@ struct btBvhSubtreeInfoData
|
||||
unsigned short m_quantizedAabbMax[3];
|
||||
};
|
||||
|
||||
struct btOptimizedBvhNodeFloatData
|
||||
struct b3OptimizedBvhNodeFloatData
|
||||
{
|
||||
btVector3FloatData m_aabbMinOrg;
|
||||
btVector3FloatData m_aabbMaxOrg;
|
||||
b3Vector3FloatData m_aabbMinOrg;
|
||||
b3Vector3FloatData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
char m_pad[4];
|
||||
};
|
||||
|
||||
struct btOptimizedBvhNodeDoubleData
|
||||
struct b3OptimizedBvhNodeDoubleData
|
||||
{
|
||||
btVector3DoubleData m_aabbMinOrg;
|
||||
btVector3DoubleData m_aabbMaxOrg;
|
||||
b3Vector3DoubleData m_aabbMinOrg;
|
||||
b3Vector3DoubleData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
@ -530,53 +530,53 @@ struct btOptimizedBvhNodeDoubleData
|
||||
};
|
||||
|
||||
|
||||
struct btQuantizedBvhNodeData
|
||||
struct b3QuantizedBvhNodeData
|
||||
{
|
||||
unsigned short m_quantizedAabbMin[3];
|
||||
unsigned short m_quantizedAabbMax[3];
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
};
|
||||
|
||||
struct btQuantizedBvhFloatData
|
||||
struct b3QuantizedBvhFloatData
|
||||
{
|
||||
btVector3FloatData m_bvhAabbMin;
|
||||
btVector3FloatData m_bvhAabbMax;
|
||||
btVector3FloatData m_bvhQuantization;
|
||||
b3Vector3FloatData m_bvhAabbMin;
|
||||
b3Vector3FloatData m_bvhAabbMax;
|
||||
b3Vector3FloatData m_bvhQuantization;
|
||||
int m_curNodeIndex;
|
||||
int m_useQuantization;
|
||||
int m_numContiguousLeafNodes;
|
||||
int m_numQuantizedContiguousNodes;
|
||||
btOptimizedBvhNodeFloatData *m_contiguousNodesPtr;
|
||||
btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
|
||||
btBvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
b3OptimizedBvhNodeFloatData *m_contiguousNodesPtr;
|
||||
b3QuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
|
||||
b3BvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
int m_traversalMode;
|
||||
int m_numSubtreeHeaders;
|
||||
|
||||
};
|
||||
|
||||
struct btQuantizedBvhDoubleData
|
||||
struct b3QuantizedBvhDoubleData
|
||||
{
|
||||
btVector3DoubleData m_bvhAabbMin;
|
||||
btVector3DoubleData m_bvhAabbMax;
|
||||
btVector3DoubleData m_bvhQuantization;
|
||||
b3Vector3DoubleData m_bvhAabbMin;
|
||||
b3Vector3DoubleData m_bvhAabbMax;
|
||||
b3Vector3DoubleData m_bvhQuantization;
|
||||
int m_curNodeIndex;
|
||||
int m_useQuantization;
|
||||
int m_numContiguousLeafNodes;
|
||||
int m_numQuantizedContiguousNodes;
|
||||
btOptimizedBvhNodeDoubleData *m_contiguousNodesPtr;
|
||||
btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
|
||||
b3OptimizedBvhNodeDoubleData *m_contiguousNodesPtr;
|
||||
b3QuantizedBvhNodeData *m_quantizedContiguousNodesPtr;
|
||||
|
||||
int m_traversalMode;
|
||||
int m_numSubtreeHeaders;
|
||||
btBvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
b3BvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int b3QuantizedBvh::calculateSerializeBufferSizeNew() const
|
||||
{
|
||||
return sizeof(btQuantizedBvhData);
|
||||
return sizeof(b3QuantizedBvhData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //BT_QUANTIZED_BVH_H
|
||||
#endif //B3_QUANTIZED_BVH_H
|
||||
|
@ -22,7 +22,7 @@ b3StridingMeshInterface::~b3StridingMeshInterface()
|
||||
}
|
||||
|
||||
|
||||
void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
void b3StridingMeshInterface::InternalProcessAllTriangles(b3InternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const
|
||||
{
|
||||
(void)aabbMin;
|
||||
(void)aabbMax;
|
||||
@ -104,7 +104,7 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
||||
break;
|
||||
}
|
||||
default:
|
||||
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
|
||||
b3Assert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -161,12 +161,12 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
||||
break;
|
||||
}
|
||||
default:
|
||||
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
|
||||
b3Assert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
btAssert((type == PHY_FLOAT) || (type == PHY_DOUBLE));
|
||||
b3Assert((type == PHY_FLOAT) || (type == PHY_DOUBLE));
|
||||
}
|
||||
|
||||
unLockReadOnlyVertexBase(part);
|
||||
@ -176,15 +176,15 @@ void b3StridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
||||
void b3StridingMeshInterface::calculateAabbBruteForce(b3Vector3& aabbMin,b3Vector3& aabbMax)
|
||||
{
|
||||
|
||||
struct AabbCalculationCallback : public btInternalTriangleIndexCallback
|
||||
struct AabbCalculationCallback : public b3InternalTriangleIndexCallback
|
||||
{
|
||||
b3Vector3 m_aabbMin;
|
||||
b3Vector3 m_aabbMax;
|
||||
|
||||
AabbCalculationCallback()
|
||||
{
|
||||
m_aabbMin.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
|
||||
m_aabbMax.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
|
||||
m_aabbMin.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
|
||||
m_aabbMax.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
|
||||
}
|
||||
|
||||
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex)
|
||||
@ -203,8 +203,8 @@ void b3StridingMeshInterface::calculateAabbBruteForce(b3Vector3& aabbMin,b3Vecto
|
||||
|
||||
//first calculate the total aabb for all triangles
|
||||
AabbCalculationCallback aabbCallback;
|
||||
aabbMin.setValue(b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT),b3Scalar(-BT_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT),b3Scalar(BT_LARGE_FLOAT));
|
||||
aabbMin.setValue(b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT),b3Scalar(-B3_LARGE_FLOAT));
|
||||
aabbMax.setValue(b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT),b3Scalar(B3_LARGE_FLOAT));
|
||||
InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax);
|
||||
|
||||
aabbMin = aabbCallback.m_aabbMin;
|
||||
|
@ -13,12 +13,12 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_STRIDING_MESHINTERFACE_H
|
||||
#define BT_STRIDING_MESHINTERFACE_H
|
||||
#ifndef B3_STRIDING_MESHINTERFACE_H
|
||||
#define B3_STRIDING_MESHINTERFACE_H
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "b3TriangleCallback.h"
|
||||
//#include "btConcaveShape.h"
|
||||
//#include "b3ConcaveShape.h"
|
||||
|
||||
|
||||
enum PHY_ScalarType {
|
||||
@ -27,7 +27,7 @@ enum PHY_ScalarType {
|
||||
};
|
||||
|
||||
|
||||
/// The b3StridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
|
||||
/// The b3StridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with b3BvhTriangleMeshShape and some other collision shapes.
|
||||
/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
|
||||
/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
|
||||
ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
|
||||
@ -37,7 +37,7 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
|
||||
b3Vector3 m_scaling;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3StridingMeshInterface() :m_scaling(b3Scalar(1.),b3Scalar(1.),b3Scalar(1.))
|
||||
{
|
||||
@ -48,7 +48,7 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
|
||||
|
||||
|
||||
|
||||
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
virtual void InternalProcessAllTriangles(b3InternalTriangleIndexCallback* callback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) const;
|
||||
|
||||
///brute force method to calculate aabb
|
||||
void calculateAabbBruteForce(b3Vector3& aabbMin,b3Vector3& aabbMax);
|
||||
@ -99,29 +99,29 @@ ATTRIBUTE_ALIGNED16(class ) b3StridingMeshInterface
|
||||
virtual int calculateSerializeBufferSize() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
//virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
//virtual const char* serialize(void* dataBuffer, b3Serializer* serializer) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct btIntIndexData
|
||||
struct b3IntIndexData
|
||||
{
|
||||
int m_value;
|
||||
};
|
||||
|
||||
struct btShortIntIndexData
|
||||
struct b3ShortIntIndexData
|
||||
{
|
||||
short m_value;
|
||||
char m_pad[2];
|
||||
};
|
||||
|
||||
struct btShortIntIndexTripletData
|
||||
struct b3ShortIntIndexTripletData
|
||||
{
|
||||
short m_values[3];
|
||||
char m_pad[2];
|
||||
};
|
||||
|
||||
struct btCharIndexTripletData
|
||||
struct b3CharIndexTripletData
|
||||
{
|
||||
unsigned char m_values[3];
|
||||
char m_pad;
|
||||
@ -129,16 +129,16 @@ struct btCharIndexTripletData
|
||||
|
||||
|
||||
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
|
||||
struct btMeshPartData
|
||||
struct b3MeshPartData
|
||||
{
|
||||
btVector3FloatData *m_vertices3f;
|
||||
btVector3DoubleData *m_vertices3d;
|
||||
b3Vector3FloatData *m_vertices3f;
|
||||
b3Vector3DoubleData *m_vertices3d;
|
||||
|
||||
btIntIndexData *m_indices32;
|
||||
btShortIntIndexTripletData *m_3indices16;
|
||||
btCharIndexTripletData *m_3indices8;
|
||||
b3IntIndexData *m_indices32;
|
||||
b3ShortIntIndexTripletData *m_3indices16;
|
||||
b3CharIndexTripletData *m_3indices8;
|
||||
|
||||
btShortIntIndexData *m_indices16;//backwards compatibility
|
||||
b3ShortIntIndexData *m_indices16;//backwards compatibility
|
||||
|
||||
int m_numTriangles;//length of m_indices = m_numTriangles
|
||||
int m_numVertices;
|
||||
@ -146,10 +146,10 @@ struct btMeshPartData
|
||||
|
||||
|
||||
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
|
||||
struct btStridingMeshInterfaceData
|
||||
struct b3StridingMeshInterfaceData
|
||||
{
|
||||
btMeshPartData *m_meshPartsPtr;
|
||||
btVector3FloatData m_scaling;
|
||||
b3MeshPartData *m_meshPartsPtr;
|
||||
b3Vector3FloatData m_scaling;
|
||||
int m_numMeshParts;
|
||||
char m_padding[4];
|
||||
};
|
||||
@ -159,9 +159,9 @@ struct btStridingMeshInterfaceData
|
||||
|
||||
SIMD_FORCE_INLINE int b3StridingMeshInterface::calculateSerializeBufferSize() const
|
||||
{
|
||||
return sizeof(btStridingMeshInterfaceData);
|
||||
return sizeof(b3StridingMeshInterfaceData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //BT_STRIDING_MESHINTERFACE_H
|
||||
#endif //B3_STRIDING_MESHINTERFACE_H
|
||||
|
@ -21,7 +21,7 @@ b3TriangleCallback::~b3TriangleCallback()
|
||||
}
|
||||
|
||||
|
||||
btInternalTriangleIndexCallback::~btInternalTriangleIndexCallback()
|
||||
b3InternalTriangleIndexCallback::~b3InternalTriangleIndexCallback()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_TRIANGLE_CALLBACK_H
|
||||
#define BT_TRIANGLE_CALLBACK_H
|
||||
#ifndef B3_TRIANGLE_CALLBACK_H
|
||||
#define B3_TRIANGLE_CALLBACK_H
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
|
||||
///The b3TriangleCallback provides a callback for each overlapping triangle when calling processAllTriangles.
|
||||
///This callback is called by processAllTriangles for all btConcaveShape derived class, such as btBvhTriangleMeshShape, btStaticPlaneShape and btHeightfieldTerrainShape.
|
||||
///This callback is called by processAllTriangles for all b3ConcaveShape derived class, such as b3BvhTriangleMeshShape, b3StaticPlaneShape and b3HeightfieldTerrainShape.
|
||||
class b3TriangleCallback
|
||||
{
|
||||
public:
|
||||
@ -29,14 +29,14 @@ public:
|
||||
virtual void processTriangle(b3Vector3* triangle, int partId, int triangleIndex) = 0;
|
||||
};
|
||||
|
||||
class btInternalTriangleIndexCallback
|
||||
class b3InternalTriangleIndexCallback
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~btInternalTriangleIndexCallback();
|
||||
virtual ~b3InternalTriangleIndexCallback();
|
||||
virtual void internalProcessTriangleIndex(b3Vector3* triangle,int partId,int triangleIndex) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //BT_TRIANGLE_CALLBACK_H
|
||||
#endif //B3_TRIANGLE_CALLBACK_H
|
||||
|
@ -18,7 +18,7 @@ subject to the following restrictions:
|
||||
b3TriangleIndexVertexArray::b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,b3Scalar* vertexBase,int vertexStride)
|
||||
: m_hasAabb(0)
|
||||
{
|
||||
btIndexedMesh mesh;
|
||||
b3IndexedMesh mesh;
|
||||
|
||||
mesh.m_numTriangles = numTriangles;
|
||||
mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
|
||||
@ -38,9 +38,9 @@ b3TriangleIndexVertexArray::~b3TriangleIndexVertexArray()
|
||||
|
||||
void b3TriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
|
||||
{
|
||||
btAssert(subpart< getNumSubParts() );
|
||||
b3Assert(subpart< getNumSubParts() );
|
||||
|
||||
btIndexedMesh& mesh = m_indexedMeshes[subpart];
|
||||
b3IndexedMesh& mesh = m_indexedMeshes[subpart];
|
||||
|
||||
numverts = mesh.m_numVertices;
|
||||
(*vertexbase) = (unsigned char *) mesh.m_vertexBase;
|
||||
@ -58,7 +58,7 @@ void b3TriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertex
|
||||
|
||||
void b3TriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const
|
||||
{
|
||||
const btIndexedMesh& mesh = m_indexedMeshes[subpart];
|
||||
const b3IndexedMesh& mesh = m_indexedMeshes[subpart];
|
||||
|
||||
numverts = mesh.m_numVertices;
|
||||
(*vertexbase) = (const unsigned char *)mesh.m_vertexBase;
|
||||
|
@ -13,19 +13,19 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
|
||||
#define BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
|
||||
#ifndef B3_TRIANGLE_INDEX_VERTEX_ARRAY_H
|
||||
#define B3_TRIANGLE_INDEX_VERTEX_ARRAY_H
|
||||
|
||||
#include "b3StridingMeshInterface.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Common/b3Scalar.h"
|
||||
|
||||
|
||||
///The btIndexedMesh indexes a single vertex and index array. Multiple btIndexedMesh objects can be passed into a b3TriangleIndexVertexArray using addIndexedMesh.
|
||||
///The b3IndexedMesh indexes a single vertex and index array. Multiple b3IndexedMesh objects can be passed into a b3TriangleIndexVertexArray using addIndexedMesh.
|
||||
///Instead of the number of indices, we pass the number of triangles.
|
||||
ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
|
||||
ATTRIBUTE_ALIGNED16( struct) b3IndexedMesh
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
int m_numTriangles;
|
||||
const unsigned char * m_triangleIndexBase;
|
||||
@ -46,20 +46,20 @@ ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
|
||||
PHY_ScalarType m_vertexType;
|
||||
|
||||
|
||||
btIndexedMesh()
|
||||
b3IndexedMesh()
|
||||
:m_indexType(PHY_INTEGER),
|
||||
#ifdef BT_USE_DOUBLE_PRECISION
|
||||
#ifdef B3_USE_DOUBLE_PRECISION
|
||||
m_vertexType(PHY_DOUBLE)
|
||||
#else // BT_USE_DOUBLE_PRECISION
|
||||
#else // B3_USE_DOUBLE_PRECISION
|
||||
m_vertexType(PHY_FLOAT)
|
||||
#endif // BT_USE_DOUBLE_PRECISION
|
||||
#endif // B3_USE_DOUBLE_PRECISION
|
||||
{
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
typedef b3AlignedObjectArray<btIndexedMesh> IndexedMeshArray;
|
||||
typedef b3AlignedObjectArray<b3IndexedMesh> IndexedMeshArray;
|
||||
|
||||
///The b3TriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing triangle/index arrays.
|
||||
///Additional meshes can be added using addIndexedMesh
|
||||
@ -76,7 +76,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3TriangleIndexVertexArray() : m_hasAabb(0)
|
||||
{
|
||||
@ -87,7 +87,7 @@ public:
|
||||
//just to be backwards compatible
|
||||
b3TriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,b3Scalar* vertexBase,int vertexStride);
|
||||
|
||||
void addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
|
||||
void addIndexedMesh(const b3IndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
|
||||
{
|
||||
m_indexedMeshes.push_back(mesh);
|
||||
m_indexedMeshes[m_indexedMeshes.size()-1].m_indexType = indexType;
|
||||
@ -130,4 +130,4 @@ public:
|
||||
}
|
||||
;
|
||||
|
||||
#endif //BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
|
||||
#endif //B3_TRIANGLE_INDEX_VERTEX_ARRAY_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* bvhTraversalKernelCL= \
|
||||
"//keep this enum in sync with the CPU version (in btCollidable.h)\n"
|
||||
"//keep this enum in sync with the CPU version (in b3Collidable.h)\n"
|
||||
"//written by Erwin Coumans\n"
|
||||
"\n"
|
||||
"#define SHAPE_CONVEX_HULL 3\n"
|
||||
@ -13,7 +13,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
"\n"
|
||||
"#define MAX_NUM_PARTS_IN_BITS 10\n"
|
||||
"\n"
|
||||
"///btQuantizedBvhNode is a compressed aabb node, 16 bytes.\n"
|
||||
"///b3QuantizedBvhNode is a compressed aabb node, 16 bytes.\n"
|
||||
"///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
@ -22,7 +22,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
" unsigned short int m_quantizedAabbMax[3];\n"
|
||||
" //4 bytes\n"
|
||||
" int m_escapeIndexOrTriangleIndex;\n"
|
||||
"} btQuantizedBvhNode;\n"
|
||||
"} b3QuantizedBvhNode;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
@ -44,12 +44,12 @@ static const char* bvhTraversalKernelCL= \
|
||||
" }\n"
|
||||
" int getEscapeIndex() const\n"
|
||||
" {\n"
|
||||
" btAssert(!isLeafNode());\n"
|
||||
" b3Assert(!isLeafNode());\n"
|
||||
" return -m_escapeIndexOrTriangleIndex;\n"
|
||||
" }\n"
|
||||
" int getTriangleIndex() const\n"
|
||||
" {\n"
|
||||
" btAssert(isLeafNode());\n"
|
||||
" b3Assert(isLeafNode());\n"
|
||||
" unsigned int x=0;\n"
|
||||
" unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);\n"
|
||||
" // Get only the lower bits where the triangle index is stored\n"
|
||||
@ -57,13 +57,13 @@ static const char* bvhTraversalKernelCL= \
|
||||
" }\n"
|
||||
" int getPartId() const\n"
|
||||
" {\n"
|
||||
" btAssert(isLeafNode());\n"
|
||||
" b3Assert(isLeafNode());\n"
|
||||
" // Get only the highest bits where the part index is stored\n"
|
||||
" return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));\n"
|
||||
" }\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"int getTriangleIndex(const btQuantizedBvhNode* rootNode)\n"
|
||||
"int getTriangleIndex(const b3QuantizedBvhNode* rootNode)\n"
|
||||
"{\n"
|
||||
" unsigned int x=0;\n"
|
||||
" unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);\n"
|
||||
@ -71,13 +71,13 @@ static const char* bvhTraversalKernelCL= \
|
||||
" return (rootNode->m_escapeIndexOrTriangleIndex&~(y));\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"int isLeaf(const btQuantizedBvhNode* rootNode)\n"
|
||||
"int isLeaf(const b3QuantizedBvhNode* rootNode)\n"
|
||||
"{\n"
|
||||
" //skipindex is negative (internal node), triangleindex >=0 (leafnode)\n"
|
||||
" return (rootNode->m_escapeIndexOrTriangleIndex >= 0)? 1 : 0;\n"
|
||||
"}\n"
|
||||
" \n"
|
||||
"int getEscapeIndex(const btQuantizedBvhNode* rootNode)\n"
|
||||
"int getEscapeIndex(const b3QuantizedBvhNode* rootNode)\n"
|
||||
"{\n"
|
||||
" return -rootNode->m_escapeIndexOrTriangleIndex;\n"
|
||||
"}\n"
|
||||
@ -92,9 +92,9 @@ static const char* bvhTraversalKernelCL= \
|
||||
" //4 bytes\n"
|
||||
" int m_subtreeSize;\n"
|
||||
" int m_padding[3];\n"
|
||||
"} btBvhSubtreeInfo;\n"
|
||||
"} b3BvhSubtreeInfo;\n"
|
||||
"\n"
|
||||
"///keep this in sync with btCollidable.h\n"
|
||||
"///keep this in sync with b3Collidable.h\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
" int m_numChildShapes;\n"
|
||||
@ -102,7 +102,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
" int m_shapeType;\n"
|
||||
" int m_shapeIndex;\n"
|
||||
" \n"
|
||||
"} btCollidableGpu;\n"
|
||||
"} b3CollidableGpu;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
@ -112,7 +112,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
" int m_unused0;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"} btGpuChildShape;\n"
|
||||
"} b3GpuChildShape;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
@ -142,7 +142,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
" float m_maxElems[4];\n"
|
||||
" int m_maxIndices[4];\n"
|
||||
" };\n"
|
||||
"} btAabbCL;\n"
|
||||
"} b3AabbCL;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"int testQuantizedAabbAgainstQuantizedAabb(\n"
|
||||
@ -196,12 +196,12 @@ static const char* bvhTraversalKernelCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void bvhTraversalKernel( __global const int2* pairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global int4* concavePairsOut,\n"
|
||||
" __global volatile int* numConcavePairsOut,\n"
|
||||
" __global const btBvhSubtreeInfo* subtreeHeadersRoot,\n"
|
||||
" __global const btQuantizedBvhNode* quantizedNodesRoot,\n"
|
||||
" __global const b3BvhSubtreeInfo* subtreeHeadersRoot,\n"
|
||||
" __global const b3QuantizedBvhNode* quantizedNodesRoot,\n"
|
||||
" __global const b3BvhInfo* bvhInfos,\n"
|
||||
" int numPairs,\n"
|
||||
" int maxNumConcavePairsCapacity)\n"
|
||||
@ -238,8 +238,8 @@ static const char* bvhTraversalKernelCL= \
|
||||
" float4 bvhAabbMax = bvhInfo.m_aabbMax;\n"
|
||||
" float4 bvhQuantization = bvhInfo.m_quantization;\n"
|
||||
" int numSubtreeHeaders = bvhInfo.m_numSubTrees;\n"
|
||||
" __global const btBvhSubtreeInfo* subtreeHeaders = &subtreeHeadersRoot[bvhInfo.m_subTreeOffset];\n"
|
||||
" __global const btQuantizedBvhNode* quantizedNodes = &quantizedNodesRoot[bvhInfo.m_nodeOffset];\n"
|
||||
" __global const b3BvhSubtreeInfo* subtreeHeaders = &subtreeHeadersRoot[bvhInfo.m_subTreeOffset];\n"
|
||||
" __global const b3QuantizedBvhNode* quantizedNodes = &quantizedNodesRoot[bvhInfo.m_nodeOffset];\n"
|
||||
" \n"
|
||||
"\n"
|
||||
" unsigned short int quantizedQueryAabbMin[3];\n"
|
||||
@ -249,7 +249,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
" \n"
|
||||
" for (int i=0;i<numSubtreeHeaders;i++)\n"
|
||||
" {\n"
|
||||
" btBvhSubtreeInfo subtree = subtreeHeaders[i];\n"
|
||||
" b3BvhSubtreeInfo subtree = subtreeHeaders[i];\n"
|
||||
" \n"
|
||||
" int overlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,subtree.m_quantizedAabbMin,subtree.m_quantizedAabbMax);\n"
|
||||
" if (overlap != 0)\n"
|
||||
@ -262,7 +262,7 @@ static const char* bvhTraversalKernelCL= \
|
||||
" int aabbOverlap;\n"
|
||||
" while (curIndex < endNodeIndex)\n"
|
||||
" {\n"
|
||||
" btQuantizedBvhNode rootNode = quantizedNodes[curIndex];\n"
|
||||
" b3QuantizedBvhNode rootNode = quantizedNodes[curIndex];\n"
|
||||
" aabbOverlap = testQuantizedAabbAgainstQuantizedAabb(quantizedQueryAabbMin,quantizedQueryAabbMax,rootNode.m_quantizedAabbMin,rootNode.m_quantizedAabbMax);\n"
|
||||
" isLeafNode = isLeaf(&rootNode);\n"
|
||||
" if (aabbOverlap)\n"
|
||||
|
@ -67,9 +67,9 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" float m_maxElems[4];\n"
|
||||
" int m_maxIndices[4];\n"
|
||||
" };\n"
|
||||
"} btAabbCL;\n"
|
||||
"} b3AabbCL;\n"
|
||||
"\n"
|
||||
"///keep this in sync with btCollidable.h\n"
|
||||
"///keep this in sync with b3Collidable.h\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
" int m_numChildShapes;\n"
|
||||
@ -77,7 +77,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" int m_shapeType;\n"
|
||||
" int m_shapeIndex;\n"
|
||||
" \n"
|
||||
"} btCollidableGpu;\n"
|
||||
"} b3CollidableGpu;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
@ -87,7 +87,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" int m_unused0;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"} btGpuChildShape;\n"
|
||||
"} b3GpuChildShape;\n"
|
||||
"\n"
|
||||
"#define GET_NPOINTS(x) (x).m_worldNormal.w\n"
|
||||
"\n"
|
||||
@ -129,7 +129,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" float4 m_plane;\n"
|
||||
" int m_indexOffset;\n"
|
||||
" int m_numIndices;\n"
|
||||
"} btGpuFace;\n"
|
||||
"} b3GpuFace;\n"
|
||||
"\n"
|
||||
"#define SELECT_UINT4( b, a, condition ) select( b,a,condition )\n"
|
||||
"\n"
|
||||
@ -290,7 +290,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
"\n"
|
||||
"\n"
|
||||
"inline bool IsPointInPolygon(float4 p, \n"
|
||||
" const btGpuFace* face,\n"
|
||||
" const b3GpuFace* face,\n"
|
||||
" __global const float4* baseVertex,\n"
|
||||
" __global const int* convexIndices,\n"
|
||||
" float4* out)\n"
|
||||
@ -352,11 +352,11 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" int bodyIndexA, int bodyIndexB, \n"
|
||||
" int collidableIndexA, int collidableIndexB, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes,\n"
|
||||
" __global const float4* convexVertices,\n"
|
||||
" __global const int* convexIndices,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
" int maxContactCapacity,\n"
|
||||
@ -383,7 +383,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
"\n"
|
||||
" for ( int f = 0; f < numFaces; f++ )\n"
|
||||
" {\n"
|
||||
" btGpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];\n"
|
||||
" b3GpuFace face = faces[convexShapes[shapeIndex].m_faceOffset+f];\n"
|
||||
"\n"
|
||||
" // set up a plane equation \n"
|
||||
" float4 planeEqn;\n"
|
||||
@ -594,11 +594,11 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" int bodyIndexA, int bodyIndexB, \n"
|
||||
" int collidableIndexA, int collidableIndexB, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu*collidables,\n"
|
||||
" __global const b3CollidableGpu*collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes,\n"
|
||||
" __global const float4* convexVertices,\n"
|
||||
" __global const int* convexIndices,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
" int maxContactCapacity,\n"
|
||||
@ -733,8 +733,8 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" int bodyIndexA, int bodyIndexB, \n"
|
||||
" int collidableIndexA, int collidableIndexB, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
" int maxContactCapacity)\n"
|
||||
@ -793,11 +793,11 @@ static const char* primitiveContactsKernelsCL= \
|
||||
"\n"
|
||||
"__kernel void primitiveContactsKernel( __global const int2* pairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
@ -972,14 +972,14 @@ static const char* primitiveContactsKernelsCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void processCompoundPairsPrimitivesKernel( __global const int4* gpuCompoundPairs,\n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global const btGpuChildShape* gpuChildShapes,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global const b3GpuChildShape* gpuChildShapes,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
" int numCompoundPairs, int maxContactCapacity\n"
|
||||
@ -1157,7 +1157,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" int bodyIndexA, int bodyIndexB,\n"
|
||||
" int collidableIndexA, int collidableIndexB, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" const float4* triangleVertices,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
@ -1299,13 +1299,13 @@ static const char* primitiveContactsKernelsCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void findConcaveSphereContactsKernel( __global int4* concavePairs,\n"
|
||||
" __global const BodyData* rigidBodies,\n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
" int numConcavePairs, int maxContactCapacity\n"
|
||||
@ -1329,7 +1329,7 @@ static const char* primitiveContactsKernelsCL= \
|
||||
" if (collidables[collidableIndexB].m_shapeType==SHAPE_SPHERE)\n"
|
||||
" {\n"
|
||||
" int f = concavePairs[i].z;\n"
|
||||
" btGpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
|
||||
" b3GpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
|
||||
" \n"
|
||||
" float4 verticesA[3];\n"
|
||||
" for (int i=0;i<3;i++)\n"
|
||||
|
@ -55,7 +55,7 @@ static const char* satClipKernelsCL= \
|
||||
"} Contact4;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"///keep this in sync with btCollidable.h\n"
|
||||
"///keep this in sync with b3Collidable.h\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
" int m_numChildShapes;\n"
|
||||
@ -63,7 +63,7 @@ static const char* satClipKernelsCL= \
|
||||
" int m_shapeType;\n"
|
||||
" int m_shapeIndex;\n"
|
||||
" \n"
|
||||
"} btCollidableGpu;\n"
|
||||
"} b3CollidableGpu;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
@ -73,7 +73,7 @@ static const char* satClipKernelsCL= \
|
||||
" int m_unused0;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"} btGpuChildShape;\n"
|
||||
"} b3GpuChildShape;\n"
|
||||
"\n"
|
||||
"#define GET_NPOINTS(x) (x).m_worldNormal.w\n"
|
||||
"\n"
|
||||
@ -115,7 +115,7 @@ static const char* satClipKernelsCL= \
|
||||
" float4 m_plane;\n"
|
||||
" int m_indexOffset;\n"
|
||||
" int m_numIndices;\n"
|
||||
"} btGpuFace;\n"
|
||||
"} b3GpuFace;\n"
|
||||
"\n"
|
||||
"#define SELECT_UINT4( b, a, condition ) select( b,a,condition )\n"
|
||||
"\n"
|
||||
@ -357,7 +357,7 @@ static const char* satClipKernelsCL= \
|
||||
" float4* worldVertsB2, int capacityWorldVertsB2,\n"
|
||||
" const float minDist, float maxDist,\n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" float4* contactsOut,\n"
|
||||
" int contactCapacity)\n"
|
||||
@ -392,7 +392,7 @@ static const char* satClipKernelsCL= \
|
||||
" if (closestFaceA<0)\n"
|
||||
" return numContactsOut;\n"
|
||||
"\n"
|
||||
" btGpuFace polyA = faces[hullA->m_faceOffset+closestFaceA];\n"
|
||||
" b3GpuFace polyA = faces[hullA->m_faceOffset+closestFaceA];\n"
|
||||
"\n"
|
||||
" // clip polygon to back of planes of all faces of hull A that are adjacent to witness face\n"
|
||||
" int numVerticesA = polyA.m_numIndices;\n"
|
||||
@ -416,7 +416,7 @@ static const char* satClipKernelsCL= \
|
||||
" //clipFace(*pVtxIn, *pVtxOut,planeNormalWS,planeEqWS);\n"
|
||||
" numVertsOut = clipFace(pVtxIn, numVertsIn, planeNormalWS,planeEqWS, pVtxOut);\n"
|
||||
"\n"
|
||||
" //btSwap(pVtxIn,pVtxOut);\n"
|
||||
" //b3Swap(pVtxIn,pVtxOut);\n"
|
||||
" float4* tmp = pVtxOut;\n"
|
||||
" pVtxOut = pVtxIn;\n"
|
||||
" pVtxIn = tmp;\n"
|
||||
@ -458,10 +458,10 @@ static const char* satClipKernelsCL= \
|
||||
" float4* worldVertsB2, int capacityWorldVertsB2,\n"
|
||||
" const float minDist, float maxDist,\n"
|
||||
" const float4* verticesA,\n"
|
||||
" const btGpuFace* facesA,\n"
|
||||
" const b3GpuFace* facesA,\n"
|
||||
" const int* indicesA,\n"
|
||||
" __global const float4* verticesB,\n"
|
||||
" __global const btGpuFace* facesB,\n"
|
||||
" __global const b3GpuFace* facesB,\n"
|
||||
" __global const int* indicesB,\n"
|
||||
" float4* contactsOut,\n"
|
||||
" int contactCapacity)\n"
|
||||
@ -496,7 +496,7 @@ static const char* satClipKernelsCL= \
|
||||
" if (closestFaceA<0)\n"
|
||||
" return numContactsOut;\n"
|
||||
"\n"
|
||||
" btGpuFace polyA = facesA[hullA->m_faceOffset+closestFaceA];\n"
|
||||
" b3GpuFace polyA = facesA[hullA->m_faceOffset+closestFaceA];\n"
|
||||
"\n"
|
||||
" // clip polygon to back of planes of all faces of hull A that are adjacent to witness face\n"
|
||||
" int numVerticesA = polyA.m_numIndices;\n"
|
||||
@ -520,7 +520,7 @@ static const char* satClipKernelsCL= \
|
||||
" //clipFace(*pVtxIn, *pVtxOut,planeNormalWS,planeEqWS);\n"
|
||||
" numVertsOut = clipFace(pVtxIn, numVertsIn, planeNormalWS,planeEqWS, pVtxOut);\n"
|
||||
"\n"
|
||||
" //btSwap(pVtxIn,pVtxOut);\n"
|
||||
" //b3Swap(pVtxIn,pVtxOut);\n"
|
||||
" float4* tmp = pVtxOut;\n"
|
||||
" pVtxOut = pVtxIn;\n"
|
||||
" pVtxIn = tmp;\n"
|
||||
@ -561,7 +561,7 @@ static const char* satClipKernelsCL= \
|
||||
" float4* worldVertsB1, float4* worldVertsB2, int capacityWorldVerts,\n"
|
||||
" const float minDist, float maxDist,\n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" float4* localContactsOut,\n"
|
||||
" int localContactCapacity)\n"
|
||||
@ -589,7 +589,7 @@ static const char* satClipKernelsCL= \
|
||||
" }\n"
|
||||
"\n"
|
||||
" {\n"
|
||||
" const btGpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
|
||||
" const b3GpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
|
||||
" const int numVertices = polyB.m_numIndices;\n"
|
||||
" for(int e0=0;e0<numVertices;e0++)\n"
|
||||
" {\n"
|
||||
@ -617,10 +617,10 @@ static const char* satClipKernelsCL= \
|
||||
" float4* worldVertsB1, float4* worldVertsB2, int capacityWorldVerts,\n"
|
||||
" const float minDist, float maxDist,\n"
|
||||
" const float4* verticesA,\n"
|
||||
" const btGpuFace* facesA,\n"
|
||||
" const b3GpuFace* facesA,\n"
|
||||
" const int* indicesA,\n"
|
||||
" __global const float4* verticesB,\n"
|
||||
" __global const btGpuFace* facesB,\n"
|
||||
" __global const b3GpuFace* facesB,\n"
|
||||
" __global const int* indicesB,\n"
|
||||
" float4* localContactsOut,\n"
|
||||
" int localContactCapacity)\n"
|
||||
@ -648,7 +648,7 @@ static const char* satClipKernelsCL= \
|
||||
" }\n"
|
||||
"\n"
|
||||
" {\n"
|
||||
" const btGpuFace polyB = facesB[hullB->m_faceOffset+closestFaceB];\n"
|
||||
" const b3GpuFace polyB = facesB[hullB->m_faceOffset+closestFaceB];\n"
|
||||
" const int numVertices = polyB.m_numIndices;\n"
|
||||
" for(int e0=0;e0<numVertices;e0++)\n"
|
||||
" {\n"
|
||||
@ -956,11 +956,11 @@ static const char* satClipKernelsCL= \
|
||||
"\n"
|
||||
"__kernel void clipHullHullKernel( __global const int2* pairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global const float4* separatingNormals,\n"
|
||||
" __global const int* hasSeparatingAxis,\n"
|
||||
@ -1053,13 +1053,13 @@ static const char* satClipKernelsCL= \
|
||||
"\n"
|
||||
"__kernel void clipCompoundsHullHullKernel( __global const int4* gpuCompoundPairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global const btGpuChildShape* gpuChildShapes,\n"
|
||||
" __global const b3GpuChildShape* gpuChildShapes,\n"
|
||||
" __global const float4* gpuCompoundSepNormalsOut,\n"
|
||||
" __global const int* gpuHasCompoundSepNormalsOut,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
@ -1185,7 +1185,7 @@ static const char* satClipKernelsCL= \
|
||||
"\n"
|
||||
"__kernel void sphereSphereCollisionKernel( __global const int2* pairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const float4* separatingNormals,\n"
|
||||
" __global const int* hasSeparatingAxis,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
@ -1252,13 +1252,13 @@ static const char* satClipKernelsCL= \
|
||||
"\n"
|
||||
"__kernel void clipHullHullConcaveConvexKernel( __global int4* concavePairsIn,\n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global const btGpuChildShape* gpuChildShapes,\n"
|
||||
" __global const b3GpuChildShape* gpuChildShapes,\n"
|
||||
" __global const float4* separatingNormals,\n"
|
||||
" __global Contact4* restrict globalContactsOut,\n"
|
||||
" counter32_t nGlobalContactsOut,\n"
|
||||
@ -1306,7 +1306,7 @@ static const char* satClipKernelsCL= \
|
||||
" convexPolyhedronA.m_vertexOffset = 0;\n"
|
||||
" float4 localCenter = make_float4(0.f,0.f,0.f,0.f);\n"
|
||||
"\n"
|
||||
" btGpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
|
||||
" b3GpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
|
||||
" \n"
|
||||
" float4 verticesA[3];\n"
|
||||
" for (int i=0;i<3;i++)\n"
|
||||
@ -1335,7 +1335,7 @@ static const char* satClipKernelsCL= \
|
||||
" \n"
|
||||
" float4 normal = make_float4(face.m_plane.x,face.m_plane.y,face.m_plane.z,0.f);\n"
|
||||
" \n"
|
||||
" btGpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
|
||||
" b3GpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
|
||||
" int indicesA[3+3+2+2+2];\n"
|
||||
" int curUsedIndices=0;\n"
|
||||
" int fidx=0;\n"
|
||||
@ -1496,7 +1496,7 @@ static const char* satClipKernelsCL= \
|
||||
" int capacityWorldVerts,\n"
|
||||
" const float minDist, float maxDist,\n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global int4* clippingFaces, int pairIndex)\n"
|
||||
"{\n"
|
||||
@ -1523,7 +1523,7 @@ static const char* satClipKernelsCL= \
|
||||
" }\n"
|
||||
" \n"
|
||||
" {\n"
|
||||
" const btGpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
|
||||
" const b3GpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n"
|
||||
" const int numVertices = polyB.m_numIndices;\n"
|
||||
" for(int e0=0;e0<numVertices;e0++)\n"
|
||||
" {\n"
|
||||
@ -1664,11 +1664,11 @@ static const char* satClipKernelsCL= \
|
||||
"\n"
|
||||
"__kernel void findClippingFacesKernel( __global const int2* pairs,\n"
|
||||
" __global const BodyData* rigidBodies,\n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes,\n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global const float4* separatingNormals,\n"
|
||||
" __global const int* hasSeparatingAxis,\n"
|
||||
|
@ -1,6 +1,6 @@
|
||||
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
||||
static const char* satKernelsCL= \
|
||||
"//keep this enum in sync with the CPU version (in btCollidable.h)\n"
|
||||
"//keep this enum in sync with the CPU version (in b3Collidable.h)\n"
|
||||
"//written by Erwin Coumans\n"
|
||||
"\n"
|
||||
"\n"
|
||||
@ -13,7 +13,7 @@ static const char* satKernelsCL= \
|
||||
"\n"
|
||||
"typedef unsigned int u32;\n"
|
||||
"\n"
|
||||
"///keep this in sync with btCollidable.h\n"
|
||||
"///keep this in sync with b3Collidable.h\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
" int m_numChildShapes;\n"
|
||||
@ -21,7 +21,7 @@ static const char* satKernelsCL= \
|
||||
" int m_shapeType;\n"
|
||||
" int m_shapeIndex;\n"
|
||||
" \n"
|
||||
"} btCollidableGpu;\n"
|
||||
"} b3CollidableGpu;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
@ -31,7 +31,7 @@ static const char* satKernelsCL= \
|
||||
" int m_unused0;\n"
|
||||
" int m_unused1;\n"
|
||||
" int m_unused2;\n"
|
||||
"} btGpuChildShape;\n"
|
||||
"} b3GpuChildShape;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
@ -80,14 +80,14 @@ static const char* satKernelsCL= \
|
||||
" float m_maxElems[4];\n"
|
||||
" int m_maxIndices[4];\n"
|
||||
" };\n"
|
||||
"} btAabbCL;\n"
|
||||
"} b3AabbCL;\n"
|
||||
"\n"
|
||||
"typedef struct\n"
|
||||
"{\n"
|
||||
" float4 m_plane;\n"
|
||||
" int m_indexOffset;\n"
|
||||
" int m_numIndices;\n"
|
||||
"} btGpuFace;\n"
|
||||
"} b3GpuFace;\n"
|
||||
"\n"
|
||||
"#define make_float4 (float4)\n"
|
||||
"\n"
|
||||
@ -296,12 +296,12 @@ static const char* satKernelsCL= \
|
||||
" \n"
|
||||
" const float4* verticesA, \n"
|
||||
" const float4* uniqueEdgesA, \n"
|
||||
" const btGpuFace* facesA,\n"
|
||||
" const b3GpuFace* facesA,\n"
|
||||
" const int* indicesA,\n"
|
||||
"\n"
|
||||
" __global const float4* verticesB, \n"
|
||||
" __global const float4* uniqueEdgesB, \n"
|
||||
" __global const btGpuFace* facesB,\n"
|
||||
" __global const b3GpuFace* facesB,\n"
|
||||
" __global const int* indicesB,\n"
|
||||
" float4* sep,\n"
|
||||
" float* dmin)\n"
|
||||
@ -348,11 +348,11 @@ static const char* satKernelsCL= \
|
||||
" const float4 DeltaC2,\n"
|
||||
" __global const float4* verticesA, \n"
|
||||
" __global const float4* uniqueEdgesA, \n"
|
||||
" __global const btGpuFace* facesA,\n"
|
||||
" __global const b3GpuFace* facesA,\n"
|
||||
" __global const int* indicesA,\n"
|
||||
" const float4* verticesB,\n"
|
||||
" const float4* uniqueEdgesB, \n"
|
||||
" const btGpuFace* facesB,\n"
|
||||
" const b3GpuFace* facesB,\n"
|
||||
" const int* indicesB,\n"
|
||||
" float4* sep,\n"
|
||||
" float* dmin)\n"
|
||||
@ -401,11 +401,11 @@ static const char* satKernelsCL= \
|
||||
" const float4 DeltaC2,\n"
|
||||
" const float4* verticesA, \n"
|
||||
" const float4* uniqueEdgesA, \n"
|
||||
" const btGpuFace* facesA,\n"
|
||||
" const b3GpuFace* facesA,\n"
|
||||
" const int* indicesA,\n"
|
||||
" __global const float4* verticesB, \n"
|
||||
" __global const float4* uniqueEdgesB, \n"
|
||||
" __global const btGpuFace* facesB,\n"
|
||||
" __global const b3GpuFace* facesB,\n"
|
||||
" __global const int* indicesB,\n"
|
||||
" float4* sep,\n"
|
||||
" float* dmin)\n"
|
||||
@ -507,7 +507,7 @@ static const char* satKernelsCL= \
|
||||
" const float4 DeltaC2,\n"
|
||||
" __global const float4* vertices, \n"
|
||||
" __global const float4* uniqueEdges, \n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" float4* sep,\n"
|
||||
" float* dmin)\n"
|
||||
@ -566,7 +566,7 @@ static const char* satKernelsCL= \
|
||||
" const float4 DeltaC2,\n"
|
||||
" __global const float4* vertices, \n"
|
||||
" __global const float4* uniqueEdges, \n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" float4* sep,\n"
|
||||
" float* dmin)\n"
|
||||
@ -643,14 +643,14 @@ static const char* satKernelsCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void processCompoundPairsKernel( __global const int4* gpuCompoundPairs,\n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global const btGpuChildShape* gpuChildShapes,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global const b3GpuChildShape* gpuChildShapes,\n"
|
||||
" __global volatile float4* gpuCompoundSepNormalsOut,\n"
|
||||
" __global volatile int* gpuHasCompoundSepNormalsOut,\n"
|
||||
" int numCompoundPairs\n"
|
||||
@ -760,14 +760,14 @@ static const char* satKernelsCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void findCompoundPairsKernel( __global const int2* pairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global const btGpuChildShape* gpuChildShapes,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global const b3GpuChildShape* gpuChildShapes,\n"
|
||||
" __global volatile int4* gpuCompoundPairsOut,\n"
|
||||
" __global volatile int* numCompoundPairsOut,\n"
|
||||
" int numPairs,\n"
|
||||
@ -942,13 +942,13 @@ static const char* satKernelsCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void findSeparatingAxisKernel( __global const int2* pairs, \n"
|
||||
" __global const BodyData* rigidBodies, \n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global volatile float4* separatingNormals,\n"
|
||||
" __global volatile int* hasSeparatingAxis,\n"
|
||||
" int numPairs\n"
|
||||
@ -1056,14 +1056,14 @@ static const char* satKernelsCL= \
|
||||
"// work-in-progress\n"
|
||||
"__kernel void findConcaveSeparatingAxisKernel( __global int4* concavePairs,\n"
|
||||
" __global const BodyData* rigidBodies,\n"
|
||||
" __global const btCollidableGpu* collidables,\n"
|
||||
" __global const b3CollidableGpu* collidables,\n"
|
||||
" __global const ConvexPolyhedronCL* convexShapes, \n"
|
||||
" __global const float4* vertices,\n"
|
||||
" __global const float4* uniqueEdges,\n"
|
||||
" __global const btGpuFace* faces,\n"
|
||||
" __global const b3GpuFace* faces,\n"
|
||||
" __global const int* indices,\n"
|
||||
" __global const btGpuChildShape* gpuChildShapes,\n"
|
||||
" __global btAabbCL* aabbs,\n"
|
||||
" __global const b3GpuChildShape* gpuChildShapes,\n"
|
||||
" __global b3AabbCL* aabbs,\n"
|
||||
" __global float4* concaveSeparatingNormalsOut,\n"
|
||||
" int numConcavePairs\n"
|
||||
" )\n"
|
||||
@ -1106,9 +1106,9 @@ static const char* satKernelsCL= \
|
||||
" convexPolyhedronA.m_vertexOffset = 0;\n"
|
||||
" float4 localCenter = make_float4(0.f,0.f,0.f,0.f);\n"
|
||||
"\n"
|
||||
" btGpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
|
||||
" b3GpuFace face = faces[convexShapes[shapeIndexA].m_faceOffset+f];\n"
|
||||
" float4 triMinAabb, triMaxAabb;\n"
|
||||
" btAabbCL triAabb;\n"
|
||||
" b3AabbCL triAabb;\n"
|
||||
" triAabb.m_min = make_float4(1e30f,1e30f,1e30f,0.f);\n"
|
||||
" triAabb.m_max = make_float4(-1e30f,-1e30f,-1e30f,0.f);\n"
|
||||
" \n"
|
||||
@ -1153,7 +1153,7 @@ static const char* satKernelsCL= \
|
||||
" \n"
|
||||
" float4 normal = make_float4(face.m_plane.x,face.m_plane.y,face.m_plane.z,0.f);\n"
|
||||
" \n"
|
||||
" btGpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
|
||||
" b3GpuFace facesA[TRIANGLE_NUM_CONVEX_FACES];\n"
|
||||
" int indicesA[3+3+2+2+2];\n"
|
||||
" int curUsedIndices=0;\n"
|
||||
" int fidx=0;\n"
|
||||
|
@ -18,10 +18,10 @@ subject to the following restrictions:
|
||||
#include "../host/b3ConvexHullContact.h"
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "parallel_primitives/host/btFillCL.h"
|
||||
#include "parallel_primitives/host/btBoundSearchCL.h"
|
||||
#include "parallel_primitives/host/btRadixSort32CL.h"
|
||||
#include "parallel_primitives/host/btPrefixScanCL.h"
|
||||
#include "parallel_primitives/host/b3FillCL.h"
|
||||
#include "parallel_primitives/host/b3BoundSearchCL.h"
|
||||
#include "parallel_primitives/host/b3RadixSort32CL.h"
|
||||
#include "parallel_primitives/host/b3PrefixScanCL.h"
|
||||
#include "Bullet3Common/b3CommandLineArgs.h"
|
||||
#include "../host/b3ConvexHullContact.h"
|
||||
|
||||
@ -54,7 +54,7 @@ void initCL(int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
int numDev = b3OpenCLUtils::getNumDevices(g_context);
|
||||
if (numDev>0)
|
||||
{
|
||||
btOpenCLDeviceInfo info;
|
||||
b3OpenCLDeviceInfo info;
|
||||
g_device= b3OpenCLUtils::getDevice(g_context,0);
|
||||
g_queue = clCreateCommandQueue(g_context, g_device, 0, &ciErrNum);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef BT_CONFIG_H
|
||||
#define BT_CONFIG_H
|
||||
#ifndef B3_CONFIG_H
|
||||
#define B3_CONFIG_H
|
||||
|
||||
struct b3Config
|
||||
{
|
||||
@ -36,5 +36,5 @@ struct b3Config
|
||||
};
|
||||
|
||||
|
||||
#endif//BT_CONFIG_H
|
||||
#endif//B3_CONFIG_H
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
#include "b3GpuBatchingPgsSolver.h"
|
||||
#include "../../parallel_primitives/host/btRadixSort32CL.h"
|
||||
#include "../../parallel_primitives/host/b3RadixSort32CL.h"
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
#include "../../parallel_primitives/host/btLauncherCL.h"
|
||||
#include "../../parallel_primitives/host/btBoundSearchCL.h"
|
||||
#include "../../parallel_primitives/host/btPrefixScanCL.h"
|
||||
#include "../../parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "../../parallel_primitives/host/b3BoundSearchCL.h"
|
||||
#include "../../parallel_primitives/host/b3PrefixScanCL.h"
|
||||
#include <string.h>
|
||||
#include "../../basic_initialize/b3OpenCLUtils.h"
|
||||
#include "../host/b3Config.h"
|
||||
@ -30,10 +30,10 @@
|
||||
|
||||
enum
|
||||
{
|
||||
BT_SOLVER_N_SPLIT = 16,
|
||||
BT_SOLVER_N_BATCHES = 4,
|
||||
BT_SOLVER_N_OBJ_PER_SPLIT = 10,
|
||||
BT_SOLVER_N_TASKS_PER_BATCH = BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT,
|
||||
B3_SOLVER_N_SPLIT = 16,
|
||||
B3_SOLVER_N_BATCHES = 4,
|
||||
B3_SOLVER_N_OBJ_PER_SPLIT = 10,
|
||||
B3_SOLVER_N_TASKS_PER_BATCH = B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT,
|
||||
};
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ bool gpuBatchContacts = true;//true;
|
||||
bool gpuSolveConstraint = true;//true;
|
||||
|
||||
|
||||
struct btGpuBatchingPgsSolverInternalData
|
||||
struct b3GpuBatchingPgsSolverInternalData
|
||||
{
|
||||
cl_context m_context;
|
||||
cl_device_id m_device;
|
||||
@ -49,9 +49,9 @@ struct btGpuBatchingPgsSolverInternalData
|
||||
int m_pairCapacity;
|
||||
int m_nIterations;
|
||||
|
||||
btOpenCLArray<b3GpuConstraint4>* m_contactCGPU;
|
||||
btOpenCLArray<unsigned int>* m_numConstraints;
|
||||
btOpenCLArray<unsigned int>* m_offsets;
|
||||
b3OpenCLArray<b3GpuConstraint4>* m_contactCGPU;
|
||||
b3OpenCLArray<unsigned int>* m_numConstraints;
|
||||
b3OpenCLArray<unsigned int>* m_offsets;
|
||||
|
||||
b3Solver* m_solverGPU;
|
||||
|
||||
@ -64,20 +64,20 @@ struct btGpuBatchingPgsSolverInternalData
|
||||
cl_kernel m_reorderContactKernel;
|
||||
cl_kernel m_copyConstraintKernel;
|
||||
|
||||
class btRadixSort32CL* m_sort32;
|
||||
class btBoundSearchCL* m_search;
|
||||
class btPrefixScanCL* m_scan;
|
||||
class b3RadixSort32CL* m_sort32;
|
||||
class b3BoundSearchCL* m_search;
|
||||
class b3PrefixScanCL* m_scan;
|
||||
|
||||
btOpenCLArray<btSortData>* m_sortDataBuffer;
|
||||
btOpenCLArray<b3Contact4>* m_contactBuffer;
|
||||
b3OpenCLArray<b3SortData>* m_sortDataBuffer;
|
||||
b3OpenCLArray<b3Contact4>* m_contactBuffer;
|
||||
|
||||
btOpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
|
||||
btOpenCLArray<btInertiaCL>* m_inertiaBufferGPU;
|
||||
btOpenCLArray<b3Contact4>* m_pBufContactOutGPU;
|
||||
b3OpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
|
||||
b3OpenCLArray<b3InertiaCL>* m_inertiaBufferGPU;
|
||||
b3OpenCLArray<b3Contact4>* m_pBufContactOutGPU;
|
||||
|
||||
|
||||
b3AlignedObjectArray<unsigned int> m_idxBuffer;
|
||||
b3AlignedObjectArray<btSortData> m_sortData;
|
||||
b3AlignedObjectArray<b3SortData> m_sortData;
|
||||
b3AlignedObjectArray<b3Contact4> m_old;
|
||||
};
|
||||
|
||||
@ -85,35 +85,35 @@ struct btGpuBatchingPgsSolverInternalData
|
||||
|
||||
b3GpuBatchingPgsSolver::b3GpuBatchingPgsSolver(cl_context ctx,cl_device_id device, cl_command_queue q,int pairCapacity)
|
||||
{
|
||||
m_data = new btGpuBatchingPgsSolverInternalData;
|
||||
m_data = new b3GpuBatchingPgsSolverInternalData;
|
||||
m_data->m_context = ctx;
|
||||
m_data->m_device = device;
|
||||
m_data->m_queue = q;
|
||||
m_data->m_pairCapacity = pairCapacity;
|
||||
m_data->m_nIterations = 4;
|
||||
|
||||
m_data->m_bodyBufferGPU = new btOpenCLArray<b3RigidBodyCL>(ctx,q);
|
||||
m_data->m_inertiaBufferGPU = new btOpenCLArray<btInertiaCL>(ctx,q);
|
||||
m_data->m_pBufContactOutGPU = new btOpenCLArray<b3Contact4>(ctx,q);
|
||||
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyCL>(ctx,q);
|
||||
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaCL>(ctx,q);
|
||||
m_data->m_pBufContactOutGPU = new b3OpenCLArray<b3Contact4>(ctx,q);
|
||||
|
||||
m_data->m_solverGPU = new b3Solver(ctx,device,q,512*1024);
|
||||
|
||||
m_data->m_sort32 = new btRadixSort32CL(ctx,device,m_data->m_queue);
|
||||
m_data->m_scan = new btPrefixScanCL(ctx,device,m_data->m_queue,BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
|
||||
m_data->m_search = new btBoundSearchCL(ctx,device,m_data->m_queue,BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
|
||||
m_data->m_sort32 = new b3RadixSort32CL(ctx,device,m_data->m_queue);
|
||||
m_data->m_scan = new b3PrefixScanCL(ctx,device,m_data->m_queue,B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
|
||||
m_data->m_search = new b3BoundSearchCL(ctx,device,m_data->m_queue,B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
|
||||
|
||||
const int sortSize = BTNEXTMULTIPLEOF( pairCapacity, 512 );
|
||||
const int sortSize = B3NEXTMULTIPLEOF( pairCapacity, 512 );
|
||||
|
||||
m_data->m_sortDataBuffer = new btOpenCLArray<btSortData>(ctx,m_data->m_queue,sortSize);
|
||||
m_data->m_contactBuffer = new btOpenCLArray<b3Contact4>(ctx,m_data->m_queue);
|
||||
m_data->m_sortDataBuffer = new b3OpenCLArray<b3SortData>(ctx,m_data->m_queue,sortSize);
|
||||
m_data->m_contactBuffer = new b3OpenCLArray<b3Contact4>(ctx,m_data->m_queue);
|
||||
|
||||
m_data->m_numConstraints = new btOpenCLArray<unsigned int>(ctx,m_data->m_queue,BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT );
|
||||
m_data->m_numConstraints->resize(BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
|
||||
m_data->m_numConstraints = new b3OpenCLArray<unsigned int>(ctx,m_data->m_queue,B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT );
|
||||
m_data->m_numConstraints->resize(B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
|
||||
|
||||
m_data->m_contactCGPU = new btOpenCLArray<b3GpuConstraint4>(ctx,q,pairCapacity);
|
||||
m_data->m_contactCGPU = new b3OpenCLArray<b3GpuConstraint4>(ctx,q,pairCapacity);
|
||||
|
||||
m_data->m_offsets = new btOpenCLArray<unsigned int>( ctx,m_data->m_queue, BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT );
|
||||
m_data->m_offsets->resize(BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
|
||||
m_data->m_offsets = new b3OpenCLArray<unsigned int>( ctx,m_data->m_queue, B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT );
|
||||
m_data->m_offsets->resize(B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
|
||||
const char* additionalMacros = "";
|
||||
const char* srcFileNameForCaching="";
|
||||
|
||||
@ -132,54 +132,54 @@ b3GpuBatchingPgsSolver::b3GpuBatchingPgsSolver(cl_context ctx,cl_device_id devic
|
||||
{
|
||||
|
||||
cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, SOLVER_CONTACT_KERNEL_PATH);
|
||||
btAssert(solveContactProg);
|
||||
b3Assert(solveContactProg);
|
||||
|
||||
cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, SOLVER_FRICTION_KERNEL_PATH);
|
||||
btAssert(solveFrictionProg);
|
||||
b3Assert(solveFrictionProg);
|
||||
|
||||
cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, SOLVER_SETUP2_KERNEL_PATH);
|
||||
btAssert(solverSetup2Prog);
|
||||
b3Assert(solverSetup2Prog);
|
||||
|
||||
|
||||
cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, SOLVER_SETUP_KERNEL_PATH);
|
||||
btAssert(solverSetupProg);
|
||||
b3Assert(solverSetupProg);
|
||||
|
||||
|
||||
m_data->m_solveFrictionKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveFrictionSource, "BatchSolveKernelFriction", &pErrNum, solveFrictionProg,additionalMacros );
|
||||
btAssert(m_data->m_solveFrictionKernel);
|
||||
b3Assert(m_data->m_solveFrictionKernel);
|
||||
|
||||
m_data->m_solveContactKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveContactSource, "BatchSolveKernelContact", &pErrNum, solveContactProg,additionalMacros );
|
||||
btAssert(m_data->m_solveContactKernel);
|
||||
b3Assert(m_data->m_solveContactKernel);
|
||||
|
||||
m_data->m_contactToConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetupSource, "ContactToConstraintKernel", &pErrNum, solverSetupProg,additionalMacros );
|
||||
btAssert(m_data->m_contactToConstraintKernel);
|
||||
b3Assert(m_data->m_contactToConstraintKernel);
|
||||
|
||||
m_data->m_setSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "SetSortDataKernel", &pErrNum, solverSetup2Prog,additionalMacros );
|
||||
btAssert(m_data->m_setSortDataKernel);
|
||||
b3Assert(m_data->m_setSortDataKernel);
|
||||
|
||||
m_data->m_reorderContactKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "ReorderContactKernel", &pErrNum, solverSetup2Prog,additionalMacros );
|
||||
btAssert(m_data->m_reorderContactKernel);
|
||||
b3Assert(m_data->m_reorderContactKernel);
|
||||
|
||||
|
||||
m_data->m_copyConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "CopyConstraintKernel", &pErrNum, solverSetup2Prog,additionalMacros );
|
||||
btAssert(m_data->m_copyConstraintKernel);
|
||||
b3Assert(m_data->m_copyConstraintKernel);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
cl_program batchingProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelSource, &pErrNum,additionalMacros, BATCHING_PATH);
|
||||
btAssert(batchingProg);
|
||||
b3Assert(batchingProg);
|
||||
|
||||
m_data->m_batchingKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelSource, "CreateBatches", &pErrNum, batchingProg,additionalMacros );
|
||||
btAssert(m_data->m_batchingKernel);
|
||||
b3Assert(m_data->m_batchingKernel);
|
||||
}
|
||||
|
||||
{
|
||||
cl_program batchingNewProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelNewSource, &pErrNum,additionalMacros, BATCHING_NEW_PATH);
|
||||
btAssert(batchingNewProg);
|
||||
b3Assert(batchingNewProg);
|
||||
|
||||
m_data->m_batchingKernelNew = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelNewSource, "CreateBatchesNew", &pErrNum, batchingNewProg,additionalMacros );
|
||||
btAssert(m_data->m_batchingKernelNew);
|
||||
b3Assert(m_data->m_batchingKernelNew);
|
||||
}
|
||||
|
||||
|
||||
@ -216,9 +216,9 @@ b3GpuBatchingPgsSolver::~b3GpuBatchingPgsSolver()
|
||||
|
||||
|
||||
|
||||
struct btConstraintCfg
|
||||
struct b3ConstraintCfg
|
||||
{
|
||||
btConstraintCfg( float dt = 0.f ): m_positionDrift( 0.005f ), m_positionConstraintCoeff( 0.2f ), m_dt(dt), m_staticIdx(0) {}
|
||||
b3ConstraintCfg( float dt = 0.f ): m_positionDrift( 0.005f ), m_positionConstraintCoeff( 0.2f ), m_dt(dt), m_staticIdx(0) {}
|
||||
|
||||
float m_positionDrift;
|
||||
float m_positionConstraintCoeff;
|
||||
@ -232,34 +232,34 @@ struct btConstraintCfg
|
||||
|
||||
|
||||
|
||||
void b3GpuBatchingPgsSolver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations)
|
||||
void b3GpuBatchingPgsSolver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations)
|
||||
{
|
||||
|
||||
|
||||
btInt4 cdata = btMakeInt4( n, 0, 0, 0 );
|
||||
b3Int4 cdata = b3MakeInt4( n, 0, 0, 0 );
|
||||
{
|
||||
|
||||
const int nn = BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT;
|
||||
const int nn = B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT;
|
||||
|
||||
cdata.x = 0;
|
||||
cdata.y = maxNumBatches;//250;
|
||||
|
||||
|
||||
int numWorkItems = 64*nn/BT_SOLVER_N_BATCHES;
|
||||
int numWorkItems = 64*nn/B3_SOLVER_N_BATCHES;
|
||||
#ifdef DEBUG_ME
|
||||
SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems];
|
||||
adl::btOpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
|
||||
adl::b3OpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
BT_PROFILE("m_batchSolveKernel iterations");
|
||||
B3_PROFILE("m_batchSolveKernel iterations");
|
||||
for(int iter=0; iter<numIterations; iter++)
|
||||
{
|
||||
for(int ib=0; ib<BT_SOLVER_N_BATCHES; ib++)
|
||||
for(int ib=0; ib<B3_SOLVER_N_BATCHES; ib++)
|
||||
{
|
||||
#ifdef DEBUG_ME
|
||||
memset(debugInfo,0,sizeof(SolverDebugInfo)*numWorkItems);
|
||||
@ -268,26 +268,26 @@ void b3GpuBatchingPgsSolver::solveContactConstraint( const btOpenCLArray<b3Rigi
|
||||
|
||||
|
||||
cdata.z = ib;
|
||||
cdata.w = BT_SOLVER_N_SPLIT;
|
||||
cdata.w = B3_SOLVER_N_SPLIT;
|
||||
|
||||
btLauncherCL launcher( m_data->m_queue, m_data->m_solveContactKernel );
|
||||
b3LauncherCL launcher( m_data->m_queue, m_data->m_solveContactKernel );
|
||||
#if 1
|
||||
|
||||
btBufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
|
||||
btBufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
btBufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
btBufferInfoCL( constraint->getBufferCL() ),
|
||||
btBufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
|
||||
btBufferInfoCL( m_data->m_offsets->getBufferCL() )
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( constraint->getBufferCL() ),
|
||||
b3BufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
|
||||
b3BufferInfoCL( m_data->m_offsets->getBufferCL() )
|
||||
#ifdef DEBUG_ME
|
||||
, btBufferInfoCL(&gpuDebugInfo)
|
||||
, b3BufferInfoCL(&gpuDebugInfo)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
//launcher.setConst( cdata.x );
|
||||
launcher.setConst( cdata.y );
|
||||
launcher.setConst( cdata.z );
|
||||
@ -352,32 +352,32 @@ void b3GpuBatchingPgsSolver::solveContactConstraint( const btOpenCLArray<b3Rigi
|
||||
bool applyFriction=true;
|
||||
if (applyFriction)
|
||||
{
|
||||
BT_PROFILE("m_batchSolveKernel iterations2");
|
||||
B3_PROFILE("m_batchSolveKernel iterations2");
|
||||
for(int iter=0; iter<numIterations; iter++)
|
||||
{
|
||||
for(int ib=0; ib<BT_SOLVER_N_BATCHES; ib++)
|
||||
for(int ib=0; ib<B3_SOLVER_N_BATCHES; ib++)
|
||||
{
|
||||
cdata.z = ib;
|
||||
cdata.w = BT_SOLVER_N_SPLIT;
|
||||
cdata.w = B3_SOLVER_N_SPLIT;
|
||||
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
btBufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
btBufferInfoCL( constraint->getBufferCL() ),
|
||||
btBufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
|
||||
btBufferInfoCL( m_data->m_offsets->getBufferCL() )
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( constraint->getBufferCL() ),
|
||||
b3BufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
|
||||
b3BufferInfoCL( m_data->m_offsets->getBufferCL() )
|
||||
#ifdef DEBUG_ME
|
||||
,btBufferInfoCL(&gpuDebugInfo)
|
||||
,b3BufferInfoCL(&gpuDebugInfo)
|
||||
#endif //DEBUG_ME
|
||||
};
|
||||
btLauncherCL launcher( m_data->m_queue, m_data->m_solveFrictionKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher( m_data->m_queue, m_data->m_solveFrictionKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
//launcher.setConst( cdata.x );
|
||||
launcher.setConst( cdata.y );
|
||||
launcher.setConst( cdata.z );
|
||||
launcher.setConst( cdata.w );
|
||||
|
||||
launcher.launch1D( 64*nn/BT_SOLVER_N_BATCHES, 64 );
|
||||
launcher.launch1D( 64*nn/B3_SOLVER_N_BATCHES, 64 );
|
||||
}
|
||||
}
|
||||
clFinish(m_data->m_queue);
|
||||
@ -417,17 +417,17 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
if (useSolver)
|
||||
{
|
||||
float dt=1./60.;
|
||||
btConstraintCfg csCfg( dt );
|
||||
b3ConstraintCfg csCfg( dt );
|
||||
csCfg.m_enableParallelSolve = true;
|
||||
csCfg.m_averageExtent = .2f;//@TODO m_averageObjExtent;
|
||||
csCfg.m_staticIdx = 0;//m_static0Index;//m_planeBodyIndex;
|
||||
|
||||
|
||||
btOpenCLArray<b3RigidBodyCL>* bodyBuf = m_data->m_bodyBufferGPU;
|
||||
b3OpenCLArray<b3RigidBodyCL>* bodyBuf = m_data->m_bodyBufferGPU;
|
||||
|
||||
void* additionalData = 0;//m_data->m_frictionCGPU;
|
||||
const btOpenCLArray<btInertiaCL>* shapeBuf = m_data->m_inertiaBufferGPU;
|
||||
btOpenCLArray<b3GpuConstraint4>* contactConstraintOut = m_data->m_contactCGPU;
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf = m_data->m_inertiaBufferGPU;
|
||||
b3OpenCLArray<b3GpuConstraint4>* contactConstraintOut = m_data->m_contactCGPU;
|
||||
int nContacts = nContactOut;
|
||||
|
||||
|
||||
@ -442,7 +442,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
if( m_data->m_solverGPU->m_contactBuffer2 == 0 )
|
||||
{
|
||||
m_data->m_solverGPU->m_contactBuffer2 = new btOpenCLArray<b3Contact4>(m_data->m_context,m_data->m_queue, nContacts );
|
||||
m_data->m_solverGPU->m_contactBuffer2 = new b3OpenCLArray<b3Contact4>(m_data->m_context,m_data->m_queue, nContacts );
|
||||
m_data->m_solverGPU->m_contactBuffer2->resize(nContacts);
|
||||
}
|
||||
|
||||
@ -451,31 +451,31 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("batching");
|
||||
B3_PROFILE("batching");
|
||||
//@todo: just reserve it, without copy of original contact (unless we use warmstarting)
|
||||
|
||||
|
||||
|
||||
const btOpenCLArray<b3RigidBodyCL>* bodyNative = bodyBuf;
|
||||
const b3OpenCLArray<b3RigidBodyCL>* bodyNative = bodyBuf;
|
||||
|
||||
|
||||
{
|
||||
|
||||
//btOpenCLArray<b3RigidBodyCL>* bodyNative = btOpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, bodyBuf );
|
||||
//btOpenCLArray<b3Contact4>* contactNative = btOpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, contactsIn );
|
||||
//b3OpenCLArray<b3RigidBodyCL>* bodyNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, bodyBuf );
|
||||
//b3OpenCLArray<b3Contact4>* contactNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, contactsIn );
|
||||
|
||||
const int sortAlignment = 512; // todo. get this out of sort
|
||||
if( csCfg.m_enableParallelSolve )
|
||||
{
|
||||
|
||||
|
||||
int sortSize = BTNEXTMULTIPLEOF( nContacts, sortAlignment );
|
||||
int sortSize = B3NEXTMULTIPLEOF( nContacts, sortAlignment );
|
||||
|
||||
btOpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
|
||||
btOpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
|
||||
b3OpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
|
||||
b3OpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
|
||||
|
||||
{ // 2. set cell idx
|
||||
BT_PROFILE("GPU set cell idx");
|
||||
B3_PROFILE("GPU set cell idx");
|
||||
struct CB
|
||||
{
|
||||
int m_nContacts;
|
||||
@ -484,19 +484,19 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
int m_nSplit;
|
||||
};
|
||||
|
||||
btAssert( sortSize%64 == 0 );
|
||||
b3Assert( sortSize%64 == 0 );
|
||||
CB cdata;
|
||||
cdata.m_nContacts = nContacts;
|
||||
cdata.m_staticIdx = csCfg.m_staticIdx;
|
||||
cdata.m_scale = 1.f/(BT_SOLVER_N_OBJ_PER_SPLIT*csCfg.m_averageExtent);
|
||||
cdata.m_nSplit = BT_SOLVER_N_SPLIT;
|
||||
cdata.m_scale = 1.f/(B3_SOLVER_N_OBJ_PER_SPLIT*csCfg.m_averageExtent);
|
||||
cdata.m_nSplit = B3_SOLVER_N_SPLIT;
|
||||
|
||||
m_data->m_solverGPU->m_sortDataBuffer->resize(nContacts);
|
||||
|
||||
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), btBufferInfoCL( bodyBuf->getBufferCL()), btBufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
|
||||
btLauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_setSortDataKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), b3BufferInfoCL( bodyBuf->getBufferCL()), b3BufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
|
||||
b3LauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_setSortDataKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( cdata.m_nContacts );
|
||||
launcher.setConst( cdata.m_scale );
|
||||
launcher.setConst(cdata.m_nSplit);
|
||||
@ -509,17 +509,17 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
bool gpuRadixSort=true;
|
||||
if (gpuRadixSort)
|
||||
{ // 3. sort by cell idx
|
||||
BT_PROFILE("gpuRadixSort");
|
||||
int n = BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT;
|
||||
B3_PROFILE("gpuRadixSort");
|
||||
int n = B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT;
|
||||
int sortBit = 32;
|
||||
//if( n <= 0xffff ) sortBit = 16;
|
||||
//if( n <= 0xff ) sortBit = 8;
|
||||
//adl::RadixSort<adl::TYPE_CL>::execute( data->m_sort, *data->m_sortDataBuffer, sortSize );
|
||||
//adl::RadixSort32<adl::TYPE_CL>::execute( data->m_sort32, *data->m_sortDataBuffer, sortSize );
|
||||
btOpenCLArray<btSortData>& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer);
|
||||
b3OpenCLArray<b3SortData>& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer);
|
||||
this->m_data->m_solverGPU->m_sort32->execute(keyValuesInOut);
|
||||
|
||||
/*b3AlignedObjectArray<btSortData> hostValues;
|
||||
/*b3AlignedObjectArray<b3SortData> hostValues;
|
||||
keyValuesInOut.copyToHost(hostValues);
|
||||
printf("hostValues.size=%d\n",hostValues.size());
|
||||
*/
|
||||
@ -528,17 +528,17 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
{
|
||||
// 4. find entries
|
||||
BT_PROFILE("gpuBoundSearch");
|
||||
B3_PROFILE("gpuBoundSearch");
|
||||
|
||||
m_data->m_solverGPU->m_search->execute(*m_data->m_solverGPU->m_sortDataBuffer,nContacts,*countsNative,
|
||||
BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT,btBoundSearchCL::COUNT);
|
||||
B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT,b3BoundSearchCL::COUNT);
|
||||
|
||||
|
||||
//adl::BoundSearch<adl::TYPE_CL>::execute( data->m_search, *data->m_sortDataBuffer, nContacts, *countsNative,
|
||||
// BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT, adl::BoundSearchBase::COUNT );
|
||||
// B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT, adl::BoundSearchBase::COUNT );
|
||||
|
||||
//unsigned int sum;
|
||||
m_data->m_solverGPU->m_scan->execute(*countsNative,*offsetsNative, BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);//,&sum );
|
||||
m_data->m_solverGPU->m_scan->execute(*countsNative,*offsetsNative, B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);//,&sum );
|
||||
//printf("sum = %d\n",sum);
|
||||
}
|
||||
|
||||
@ -548,15 +548,15 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
if (nContacts)
|
||||
{ // 5. sort constraints by cellIdx
|
||||
{
|
||||
BT_PROFILE("gpu m_reorderContactKernel");
|
||||
B3_PROFILE("gpu m_reorderContactKernel");
|
||||
|
||||
btInt4 cdata;
|
||||
b3Int4 cdata;
|
||||
cdata.x = nContacts;
|
||||
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), btBufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL())
|
||||
, btBufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
|
||||
btLauncherCL launcher(m_data->m_queue,m_data->m_solverGPU->m_reorderContactKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), b3BufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL())
|
||||
, b3BufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
|
||||
b3LauncherCL launcher(m_data->m_queue,m_data->m_solverGPU->m_reorderContactKernel);
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( cdata );
|
||||
launcher.launch1D( nContacts, 64 );
|
||||
}
|
||||
@ -574,11 +574,11 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
if (nContacts)
|
||||
{
|
||||
BT_PROFILE("gpu m_copyConstraintKernel");
|
||||
btInt4 cdata; cdata.x = nContacts;
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL() ), btBufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ) };
|
||||
btLauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_copyConstraintKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
B3_PROFILE("gpu m_copyConstraintKernel");
|
||||
b3Int4 cdata; cdata.x = nContacts;
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL() ), b3BufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ) };
|
||||
b3LauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_copyConstraintKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( cdata );
|
||||
launcher.launch1D( nContacts, 64 );
|
||||
clFinish(m_data->m_queue);
|
||||
@ -590,24 +590,24 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
{
|
||||
if (gpuBatchContacts)
|
||||
{
|
||||
BT_PROFILE("gpu batchContacts");
|
||||
B3_PROFILE("gpu batchContacts");
|
||||
maxNumBatches = 50;//250;
|
||||
m_data->m_solverGPU->batchContacts( m_data->m_pBufContactOutGPU, nContacts, m_data->m_solverGPU->m_numConstraints, m_data->m_solverGPU->m_offsets, csCfg.m_staticIdx );
|
||||
} else
|
||||
{
|
||||
BT_PROFILE("cpu batchContacts");
|
||||
B3_PROFILE("cpu batchContacts");
|
||||
b3AlignedObjectArray<b3Contact4> cpuContacts;
|
||||
btOpenCLArray<b3Contact4>* contactsIn = m_data->m_solverGPU->m_contactBuffer2;
|
||||
b3OpenCLArray<b3Contact4>* contactsIn = m_data->m_solverGPU->m_contactBuffer2;
|
||||
contactsIn->copyToHost(cpuContacts);
|
||||
|
||||
btOpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
|
||||
btOpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
|
||||
b3OpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
|
||||
b3OpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
|
||||
|
||||
b3AlignedObjectArray<unsigned int> nNativeHost;
|
||||
b3AlignedObjectArray<unsigned int> offsetsNativeHost;
|
||||
|
||||
{
|
||||
BT_PROFILE("countsNative/offsetsNative copyToHost");
|
||||
B3_PROFILE("countsNative/offsetsNative copyToHost");
|
||||
countsNative->copyToHost(nNativeHost);
|
||||
offsetsNative->copyToHost(offsetsNativeHost);
|
||||
}
|
||||
@ -616,8 +616,8 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
int numNonzeroGrid=0;
|
||||
|
||||
{
|
||||
BT_PROFILE("batch grid");
|
||||
for(int i=0; i<BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT; i++)
|
||||
B3_PROFILE("batch grid");
|
||||
for(int i=0; i<B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT; i++)
|
||||
{
|
||||
int n = (nNativeHost)[i];
|
||||
int offset = (offsetsNativeHost)[i];
|
||||
@ -633,7 +633,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
int numBatches = sortConstraintByBatch3( &cpuContacts[0]+offset, n, simdWidth,csCfg.m_staticIdx ,numBodies); // on GPU
|
||||
|
||||
|
||||
maxNumBatches = btMax(numBatches,maxNumBatches);
|
||||
maxNumBatches = b3Max(numBatches,maxNumBatches);
|
||||
static int globalMaxBatch = 0;
|
||||
if (maxNumBatches>globalMaxBatch )
|
||||
{
|
||||
@ -647,7 +647,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
}
|
||||
}
|
||||
{
|
||||
BT_PROFILE("m_contactBuffer->copyFromHost");
|
||||
B3_PROFILE("m_contactBuffer->copyFromHost");
|
||||
m_data->m_solverGPU->m_contactBuffer2->copyFromHost((b3AlignedObjectArray<b3Contact4>&)cpuContacts);
|
||||
}
|
||||
|
||||
@ -660,7 +660,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
|
||||
if (nContacts)
|
||||
{
|
||||
//BT_PROFILE("gpu convertToConstraints");
|
||||
//B3_PROFILE("gpu convertToConstraints");
|
||||
m_data->m_solverGPU->convertToConstraints( bodyBuf,
|
||||
shapeBuf, m_data->m_solverGPU->m_contactBuffer2,
|
||||
contactConstraintOut,
|
||||
@ -682,7 +682,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
m_data->m_solverGPU->m_nIterations = 4;//10
|
||||
if (gpuSolveConstraint)
|
||||
{
|
||||
BT_PROFILE("GPU solveContactConstraint");
|
||||
B3_PROFILE("GPU solveContactConstraint");
|
||||
|
||||
m_data->m_solverGPU->solveContactConstraint(
|
||||
m_data->m_bodyBufferGPU,
|
||||
@ -693,7 +693,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
}
|
||||
else
|
||||
{
|
||||
BT_PROFILE("Host solveContactConstraint");
|
||||
B3_PROFILE("Host solveContactConstraint");
|
||||
|
||||
m_data->m_solverGPU->solveContactConstraintHost(m_data->m_bodyBufferGPU, m_data->m_inertiaBufferGPU, m_data->m_contactCGPU,0, nContactOut ,maxNumBatches);
|
||||
}
|
||||
@ -705,7 +705,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
#if 0
|
||||
if (0)
|
||||
{
|
||||
BT_PROFILE("read body velocities back to CPU");
|
||||
B3_PROFILE("read body velocities back to CPU");
|
||||
//read body updated linear/angular velocities back to CPU
|
||||
m_data->m_bodyBufferGPU->read(
|
||||
m_data->m_bodyBufferCPU->m_ptr,numOfConvexRBodies);
|
||||
@ -718,13 +718,13 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
|
||||
}
|
||||
|
||||
|
||||
void b3GpuBatchingPgsSolver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* n, btOpenCLArray<unsigned int>* offsets, int staticIdx )
|
||||
void b3GpuBatchingPgsSolver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* n, b3OpenCLArray<unsigned int>* offsets, int staticIdx )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool sortfnc(const btSortData& a,const btSortData& b)
|
||||
static bool sortfnc(const b3SortData& a,const b3SortData& b)
|
||||
{
|
||||
return (a.m_key<b.m_key);
|
||||
}
|
||||
@ -737,14 +737,14 @@ static bool sortfnc(const btSortData& a,const btSortData& b)
|
||||
|
||||
|
||||
b3AlignedObjectArray<unsigned int> idxBuffer;
|
||||
b3AlignedObjectArray<btSortData> sortData;
|
||||
b3AlignedObjectArray<b3SortData> sortData;
|
||||
b3AlignedObjectArray<b3Contact4> old;
|
||||
|
||||
|
||||
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies)
|
||||
{
|
||||
|
||||
BT_PROFILE("sortConstraintByBatch");
|
||||
B3_PROFILE("sortConstraintByBatch");
|
||||
int numIter = 0;
|
||||
|
||||
sortData.resize(n);
|
||||
@ -769,7 +769,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
|
||||
int batchIdx = 0;
|
||||
|
||||
{
|
||||
BT_PROFILE("cpu batch innerloop");
|
||||
B3_PROFILE("cpu batch innerloop");
|
||||
while( nIdxSrc )
|
||||
{
|
||||
numIter++;
|
||||
@ -782,7 +782,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
|
||||
for(int i=0; i<nIdxSrc; i++)
|
||||
{
|
||||
int idx = idxSrc[i];
|
||||
btAssert( idx < n );
|
||||
b3Assert( idx < n );
|
||||
// check if it can go
|
||||
int bodyAS = cs[idx].m_bodyAPtrAndSignBit;
|
||||
int bodyBS = cs[idx].m_bodyBPtrAndSignBit;
|
||||
@ -830,19 +830,19 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
|
||||
idxDst[nIdxDst++] = idx;
|
||||
}
|
||||
}
|
||||
btSwap( idxSrc, idxDst );
|
||||
btSwap( nIdxSrc, nIdxDst );
|
||||
b3Swap( idxSrc, idxDst );
|
||||
b3Swap( nIdxSrc, nIdxDst );
|
||||
batchIdx ++;
|
||||
}
|
||||
}
|
||||
{
|
||||
BT_PROFILE("quickSort");
|
||||
B3_PROFILE("quickSort");
|
||||
sortData.quickSort(sortfnc);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("reorder");
|
||||
B3_PROFILE("reorder");
|
||||
// reorder
|
||||
|
||||
memcpy( &old[0], cs, sizeof(b3Contact4)*n);
|
||||
@ -858,7 +858,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
|
||||
// debugPrintf( "nBatches: %d\n", batchIdx );
|
||||
for(int i=0; i<n; i++)
|
||||
{
|
||||
btAssert( cs[i].getBatchIdx() != -1 );
|
||||
b3Assert( cs[i].getBatchIdx() != -1 );
|
||||
}
|
||||
#endif
|
||||
return batchIdx;
|
||||
@ -870,7 +870,7 @@ b3AlignedObjectArray<int> bodyUsed2;
|
||||
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies)
|
||||
{
|
||||
|
||||
BT_PROFILE("sortConstraintByBatch2");
|
||||
B3_PROFILE("sortConstraintByBatch2");
|
||||
|
||||
|
||||
|
||||
@ -903,7 +903,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("cpu batch innerloop");
|
||||
B3_PROFILE("cpu batch innerloop");
|
||||
|
||||
while( numValidConstraints < numConstraints)
|
||||
{
|
||||
@ -917,7 +917,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
|
||||
for(int i=numValidConstraints; i<numConstraints; i++)
|
||||
{
|
||||
int idx = idxSrc[i];
|
||||
btAssert( idx < numConstraints );
|
||||
b3Assert( idx < numConstraints );
|
||||
// check if it can go
|
||||
int bodyAS = cs[idx].m_bodyAPtrAndSignBit;
|
||||
int bodyBS = cs[idx].m_bodyBPtrAndSignBit;
|
||||
@ -968,7 +968,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
|
||||
|
||||
if (i!=numValidConstraints)
|
||||
{
|
||||
btSwap(idxSrc[i], idxSrc[numValidConstraints]);
|
||||
b3Swap(idxSrc[i], idxSrc[numValidConstraints]);
|
||||
}
|
||||
|
||||
numValidConstraints++;
|
||||
@ -991,19 +991,19 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
|
||||
}
|
||||
}
|
||||
{
|
||||
BT_PROFILE("quickSort");
|
||||
B3_PROFILE("quickSort");
|
||||
//m_data->m_sortData.quickSort(sortfnc);
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("reorder");
|
||||
B3_PROFILE("reorder");
|
||||
// reorder
|
||||
|
||||
memcpy( &m_data->m_old[0], cs, sizeof(b3Contact4)*numConstraints);
|
||||
|
||||
for(int i=0; i<numConstraints; i++)
|
||||
{
|
||||
btAssert(m_data->m_sortData[idxSrc[i]].m_value == idxSrc[i]);
|
||||
b3Assert(m_data->m_sortData[idxSrc[i]].m_value == idxSrc[i]);
|
||||
int idx = m_data->m_sortData[idxSrc[i]].m_value;
|
||||
cs[i] = m_data->m_old[idx];
|
||||
}
|
||||
@ -1013,7 +1013,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
|
||||
// debugPrintf( "nBatches: %d\n", batchIdx );
|
||||
for(int i=0; i<numConstraints; i++)
|
||||
{
|
||||
btAssert( cs[i].getBatchIdx() != -1 );
|
||||
b3Assert( cs[i].getBatchIdx() != -1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1029,7 +1029,7 @@ b3AlignedObjectArray<int> curUsed;
|
||||
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies)
|
||||
{
|
||||
|
||||
BT_PROFILE("sortConstraintByBatch3");
|
||||
B3_PROFILE("sortConstraintByBatch3");
|
||||
|
||||
static int maxSwaps = 0;
|
||||
int numSwaps = 0;
|
||||
@ -1071,7 +1071,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("cpu batch innerloop");
|
||||
B3_PROFILE("cpu batch innerloop");
|
||||
|
||||
while( numValidConstraints < numConstraints)
|
||||
{
|
||||
@ -1086,7 +1086,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
|
||||
for(int i=numValidConstraints; i<numConstraints; i++)
|
||||
{
|
||||
int idx = i;
|
||||
btAssert( idx < numConstraints );
|
||||
b3Assert( idx < numConstraints );
|
||||
// check if it can go
|
||||
int bodyAS = cs[idx].m_bodyAPtrAndSignBit;
|
||||
int bodyBS = cs[idx].m_bodyBPtrAndSignBit;
|
||||
@ -1123,7 +1123,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
|
||||
|
||||
if (i!=numValidConstraints)
|
||||
{
|
||||
btSwap(cs[i],cs[numValidConstraints]);
|
||||
b3Swap(cs[i],cs[numValidConstraints]);
|
||||
numSwaps++;
|
||||
}
|
||||
|
||||
@ -1148,7 +1148,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
|
||||
// debugPrintf( "nBatches: %d\n", batchIdx );
|
||||
for(int i=0; i<numConstraints; i++)
|
||||
{
|
||||
btAssert( cs[i].getBatchIdx() != -1 );
|
||||
b3Assert( cs[i].getBatchIdx() != -1 );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
#ifndef BT_GPU_BATCHING_PGS_SOLVER_H
|
||||
#define BT_GPU_BATCHING_PGS_SOLVER_H
|
||||
#ifndef B3_GPU_BATCHING_PGS_SOLVER_H
|
||||
#define B3_GPU_BATCHING_PGS_SOLVER_H
|
||||
|
||||
#include "../../basic_initialize/b3OpenCLInclude.h"
|
||||
#include "../../parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "../../parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
#include "b3GpuConstraint4.h"
|
||||
@ -14,9 +14,9 @@ protected:
|
||||
|
||||
|
||||
|
||||
struct btGpuBatchingPgsSolverInternalData* m_data;
|
||||
struct b3GpuBatchingPgsSolverInternalData* m_data;
|
||||
|
||||
void batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* n, btOpenCLArray<unsigned int>* offsets, int staticIdx );
|
||||
void batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* n, b3OpenCLArray<unsigned int>* offsets, int staticIdx );
|
||||
|
||||
inline int sortConstraintByBatch( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies);
|
||||
inline int sortConstraintByBatch2( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies);
|
||||
@ -24,8 +24,8 @@ protected:
|
||||
|
||||
|
||||
|
||||
void solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations);
|
||||
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations);
|
||||
|
||||
public:
|
||||
|
||||
@ -36,5 +36,5 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_GPU_BATCHING_PGS_SOLVER_H
|
||||
#endif //B3_GPU_BATCHING_PGS_SOLVER_H
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
#ifndef BT_CONSTRAINT4_h
|
||||
#define BT_CONSTRAINT4_h
|
||||
#ifndef B3_CONSTRAINT4_h
|
||||
#define B3_CONSTRAINT4_h
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
B3_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
b3Vector3 m_linear;//normal?
|
||||
b3Vector3 m_worldPos[4];
|
||||
@ -25,5 +25,5 @@ ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
|
||||
inline float getFrictionCoeff() const { return m_linear[3]; }
|
||||
};
|
||||
|
||||
#endif //BT_CONSTRAINT4_h
|
||||
#endif //B3_CONSTRAINT4_h
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "b3GpuNarrowPhase.h"
|
||||
|
||||
|
||||
#include "parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "../../gpu_narrowphase/host/b3ConvexPolyhedronCL.h"
|
||||
#include "../../gpu_narrowphase/host/b3ConvexHullContact.h"
|
||||
#include "../../gpu_broadphase/host/b3SapAabb.h"
|
||||
@ -12,7 +12,7 @@
|
||||
#include "Bullet3Geometry/b3AabbUtil.h"
|
||||
#include "../../gpu_narrowphase/host/b3BvhInfo.h"
|
||||
|
||||
struct btGpuNarrowPhaseInternalData
|
||||
struct b3GpuNarrowPhaseInternalData
|
||||
{
|
||||
b3AlignedObjectArray<b3ConvexUtility*>* m_convexData;
|
||||
|
||||
@ -21,59 +21,59 @@ struct btGpuNarrowPhaseInternalData
|
||||
b3AlignedObjectArray<b3Vector3> m_convexVertices;
|
||||
b3AlignedObjectArray<int> m_convexIndices;
|
||||
|
||||
btOpenCLArray<b3ConvexPolyhedronCL>* m_convexPolyhedraGPU;
|
||||
btOpenCLArray<b3Vector3>* m_uniqueEdgesGPU;
|
||||
btOpenCLArray<b3Vector3>* m_convexVerticesGPU;
|
||||
btOpenCLArray<int>* m_convexIndicesGPU;
|
||||
b3OpenCLArray<b3ConvexPolyhedronCL>* m_convexPolyhedraGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_uniqueEdgesGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_convexVerticesGPU;
|
||||
b3OpenCLArray<int>* m_convexIndicesGPU;
|
||||
|
||||
btOpenCLArray<b3Vector3>* m_worldVertsB1GPU;
|
||||
btOpenCLArray<btInt4>* m_clippingFacesOutGPU;
|
||||
btOpenCLArray<b3Vector3>* m_worldNormalsAGPU;
|
||||
btOpenCLArray<b3Vector3>* m_worldVertsA1GPU;
|
||||
btOpenCLArray<b3Vector3>* m_worldVertsB2GPU;
|
||||
b3OpenCLArray<b3Vector3>* m_worldVertsB1GPU;
|
||||
b3OpenCLArray<b3Int4>* m_clippingFacesOutGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_worldNormalsAGPU;
|
||||
b3OpenCLArray<b3Vector3>* m_worldVertsA1GPU;
|
||||
b3OpenCLArray<b3Vector3>* m_worldVertsB2GPU;
|
||||
|
||||
b3AlignedObjectArray<btGpuChildShape> m_cpuChildShapes;
|
||||
btOpenCLArray<btGpuChildShape>* m_gpuChildShapes;
|
||||
b3AlignedObjectArray<b3GpuChildShape> m_cpuChildShapes;
|
||||
b3OpenCLArray<b3GpuChildShape>* m_gpuChildShapes;
|
||||
|
||||
b3AlignedObjectArray<btGpuFace> m_convexFaces;
|
||||
btOpenCLArray<btGpuFace>* m_convexFacesGPU;
|
||||
b3AlignedObjectArray<b3GpuFace> m_convexFaces;
|
||||
b3OpenCLArray<b3GpuFace>* m_convexFacesGPU;
|
||||
|
||||
GpuSatCollision* m_gpuSatCollision;
|
||||
|
||||
b3AlignedObjectArray<btInt2>* m_pBufPairsCPU;
|
||||
b3AlignedObjectArray<b3Int2>* m_pBufPairsCPU;
|
||||
|
||||
btOpenCLArray<btInt2>* m_convexPairsOutGPU;
|
||||
btOpenCLArray<btInt2>* m_planePairs;
|
||||
b3OpenCLArray<b3Int2>* m_convexPairsOutGPU;
|
||||
b3OpenCLArray<b3Int2>* m_planePairs;
|
||||
|
||||
btOpenCLArray<b3Contact4>* m_pBufContactOutGPU;
|
||||
b3OpenCLArray<b3Contact4>* m_pBufContactOutGPU;
|
||||
b3AlignedObjectArray<b3Contact4>* m_pBufContactOutCPU;
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL>* m_bodyBufferCPU;
|
||||
btOpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
|
||||
b3OpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
|
||||
|
||||
b3AlignedObjectArray<btInertiaCL>* m_inertiaBufferCPU;
|
||||
btOpenCLArray<btInertiaCL>* m_inertiaBufferGPU;
|
||||
b3AlignedObjectArray<b3InertiaCL>* m_inertiaBufferCPU;
|
||||
b3OpenCLArray<b3InertiaCL>* m_inertiaBufferGPU;
|
||||
|
||||
int m_numAcceleratedShapes;
|
||||
int m_numAcceleratedRigidBodies;
|
||||
|
||||
b3AlignedObjectArray<b3Collidable> m_collidablesCPU;
|
||||
btOpenCLArray<b3Collidable>* m_collidablesGPU;
|
||||
b3OpenCLArray<b3Collidable>* m_collidablesGPU;
|
||||
|
||||
btOpenCLArray<b3SapAabb>* m_localShapeAABBGPU;
|
||||
b3OpenCLArray<b3SapAabb>* m_localShapeAABBGPU;
|
||||
b3AlignedObjectArray<b3SapAabb>* m_localShapeAABBCPU;
|
||||
|
||||
b3AlignedObjectArray<class b3OptimizedBvh*> m_bvhData;
|
||||
|
||||
b3AlignedObjectArray<btQuantizedBvhNode> m_treeNodesCPU;
|
||||
b3AlignedObjectArray<btBvhSubtreeInfo> m_subTreesCPU;
|
||||
b3AlignedObjectArray<b3QuantizedBvhNode> m_treeNodesCPU;
|
||||
b3AlignedObjectArray<b3BvhSubtreeInfo> m_subTreesCPU;
|
||||
|
||||
b3AlignedObjectArray<b3BvhInfo> m_bvhInfoCPU;
|
||||
btOpenCLArray<b3BvhInfo>* m_bvhInfoGPU;
|
||||
b3OpenCLArray<b3BvhInfo>* m_bvhInfoGPU;
|
||||
|
||||
btOpenCLArray<btQuantizedBvhNode>* m_treeNodesGPU;
|
||||
btOpenCLArray<btBvhSubtreeInfo>* m_subTreesGPU;
|
||||
b3OpenCLArray<b3QuantizedBvhNode>* m_treeNodesGPU;
|
||||
b3OpenCLArray<b3BvhSubtreeInfo>* m_subTreesGPU;
|
||||
|
||||
|
||||
b3Config m_config;
|
||||
@ -91,52 +91,52 @@ m_device(device),
|
||||
m_queue(queue)
|
||||
{
|
||||
|
||||
m_data = new btGpuNarrowPhaseInternalData();
|
||||
memset(m_data,0,sizeof(btGpuNarrowPhaseInternalData));
|
||||
m_data = new b3GpuNarrowPhaseInternalData();
|
||||
memset(m_data,0,sizeof(b3GpuNarrowPhaseInternalData));
|
||||
|
||||
m_data->m_config = config;
|
||||
|
||||
m_data->m_gpuSatCollision = new GpuSatCollision(ctx,device,queue);
|
||||
m_data->m_pBufPairsCPU = new b3AlignedObjectArray<btInt2>;
|
||||
m_data->m_pBufPairsCPU = new b3AlignedObjectArray<b3Int2>;
|
||||
m_data->m_pBufPairsCPU->resize(config.m_maxBroadphasePairs);
|
||||
|
||||
m_data->m_convexPairsOutGPU = new btOpenCLArray<btInt2>(ctx,queue,config.m_maxBroadphasePairs,false);
|
||||
m_data->m_planePairs = new btOpenCLArray<btInt2>(ctx,queue,config.m_maxBroadphasePairs,false);
|
||||
m_data->m_convexPairsOutGPU = new b3OpenCLArray<b3Int2>(ctx,queue,config.m_maxBroadphasePairs,false);
|
||||
m_data->m_planePairs = new b3OpenCLArray<b3Int2>(ctx,queue,config.m_maxBroadphasePairs,false);
|
||||
|
||||
m_data->m_pBufContactOutCPU = new b3AlignedObjectArray<b3Contact4>();
|
||||
m_data->m_pBufContactOutCPU->resize(config.m_maxBroadphasePairs);
|
||||
m_data->m_bodyBufferCPU = new b3AlignedObjectArray<b3RigidBodyCL>();
|
||||
m_data->m_bodyBufferCPU->resize(config.m_maxConvexBodies);
|
||||
|
||||
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<btInertiaCL>();
|
||||
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<b3InertiaCL>();
|
||||
m_data->m_inertiaBufferCPU->resize(config.m_maxConvexBodies);
|
||||
|
||||
m_data->m_pBufContactOutGPU = new btOpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
|
||||
m_data->m_pBufContactOutGPU = new b3OpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
|
||||
|
||||
m_data->m_inertiaBufferGPU = new btOpenCLArray<btInertiaCL>(ctx,queue,config.m_maxConvexBodies,false);
|
||||
m_data->m_collidablesGPU = new btOpenCLArray<b3Collidable>(ctx,queue,config.m_maxConvexShapes);
|
||||
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaCL>(ctx,queue,config.m_maxConvexBodies,false);
|
||||
m_data->m_collidablesGPU = new b3OpenCLArray<b3Collidable>(ctx,queue,config.m_maxConvexShapes);
|
||||
|
||||
m_data->m_localShapeAABBCPU = new b3AlignedObjectArray<b3SapAabb>;
|
||||
m_data->m_localShapeAABBGPU = new btOpenCLArray<b3SapAabb>(ctx,queue,config.m_maxConvexShapes);
|
||||
m_data->m_localShapeAABBGPU = new b3OpenCLArray<b3SapAabb>(ctx,queue,config.m_maxConvexShapes);
|
||||
|
||||
|
||||
//m_data->m_solverDataGPU = adl::Solver<adl::TYPE_CL>::allocate(ctx,queue, config.m_maxBroadphasePairs,false);
|
||||
m_data->m_bodyBufferGPU = new btOpenCLArray<b3RigidBodyCL>(ctx,queue, config.m_maxConvexBodies,false);
|
||||
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyCL>(ctx,queue, config.m_maxConvexBodies,false);
|
||||
|
||||
m_data->m_convexFacesGPU = new btOpenCLArray<btGpuFace>(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false);
|
||||
m_data->m_gpuChildShapes = new btOpenCLArray<btGpuChildShape>(ctx,queue,config.m_maxCompoundChildShapes,false);
|
||||
m_data->m_convexFacesGPU = new b3OpenCLArray<b3GpuFace>(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false);
|
||||
m_data->m_gpuChildShapes = new b3OpenCLArray<b3GpuChildShape>(ctx,queue,config.m_maxCompoundChildShapes,false);
|
||||
|
||||
m_data->m_convexPolyhedraGPU = new btOpenCLArray<b3ConvexPolyhedronCL>(ctx,queue,config.m_maxConvexShapes,false);
|
||||
m_data->m_uniqueEdgesGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
|
||||
m_data->m_convexVerticesGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexVertices,true);
|
||||
m_data->m_convexIndicesGPU = new btOpenCLArray<int>(ctx,queue,config.m_maxConvexIndices,true);
|
||||
m_data->m_convexPolyhedraGPU = new b3OpenCLArray<b3ConvexPolyhedronCL>(ctx,queue,config.m_maxConvexShapes,false);
|
||||
m_data->m_uniqueEdgesGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
|
||||
m_data->m_convexVerticesGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexVertices,true);
|
||||
m_data->m_convexIndicesGPU = new b3OpenCLArray<int>(ctx,queue,config.m_maxConvexIndices,true);
|
||||
|
||||
|
||||
m_data->m_worldVertsB1GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
|
||||
m_data->m_clippingFacesOutGPU = new btOpenCLArray<btInt4>(ctx,queue,config.m_maxConvexBodies);
|
||||
m_data->m_worldNormalsAGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies);
|
||||
m_data->m_worldVertsA1GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
|
||||
m_data->m_worldVertsB2GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
|
||||
m_data->m_worldVertsB1GPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
|
||||
m_data->m_clippingFacesOutGPU = new b3OpenCLArray<b3Int4>(ctx,queue,config.m_maxConvexBodies);
|
||||
m_data->m_worldNormalsAGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies);
|
||||
m_data->m_worldVertsA1GPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
|
||||
m_data->m_worldVertsB2GPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
|
||||
|
||||
|
||||
|
||||
@ -150,12 +150,12 @@ m_queue(queue)
|
||||
m_data->m_numAcceleratedRigidBodies = 0;
|
||||
|
||||
|
||||
m_data->m_subTreesGPU = new btOpenCLArray<btBvhSubtreeInfo>(this->m_context,this->m_queue);
|
||||
m_data->m_treeNodesGPU = new btOpenCLArray<btQuantizedBvhNode>(this->m_context,this->m_queue);
|
||||
m_data->m_bvhInfoGPU = new btOpenCLArray<b3BvhInfo>(this->m_context,this->m_queue);
|
||||
m_data->m_subTreesGPU = new b3OpenCLArray<b3BvhSubtreeInfo>(this->m_context,this->m_queue);
|
||||
m_data->m_treeNodesGPU = new b3OpenCLArray<b3QuantizedBvhNode>(this->m_context,this->m_queue);
|
||||
m_data->m_bvhInfoGPU = new b3OpenCLArray<b3BvhInfo>(this->m_context,this->m_queue);
|
||||
|
||||
//m_data->m_contactCGPU = new btOpenCLArray<Constraint4>(ctx,queue,config.m_maxBroadphasePairs,false);
|
||||
//m_data->m_frictionCGPU = new btOpenCLArray<adl::Solver<adl::TYPE_CL>::allocateFrictionConstraint( m_data->m_deviceCL, config.m_maxBroadphasePairs);
|
||||
//m_data->m_contactCGPU = new b3OpenCLArray<Constraint4>(ctx,queue,config.m_maxBroadphasePairs,false);
|
||||
//m_data->m_frictionCGPU = new b3OpenCLArray<adl::Solver<adl::TYPE_CL>::allocateFrictionConstraint( m_data->m_deviceCL, config.m_maxBroadphasePairs);
|
||||
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ int b3GpuNarrowPhase::registerSphereShape(float radius)
|
||||
int b3GpuNarrowPhase::registerFace(const b3Vector3& faceNormal, float faceConstant)
|
||||
{
|
||||
int faceOffset = m_data->m_convexFaces.size();
|
||||
btGpuFace& face = m_data->m_convexFaces.expand();
|
||||
b3GpuFace& face = m_data->m_convexFaces.expand();
|
||||
face.m_plane[0] = faceNormal.getX();
|
||||
face.m_plane[1] = faceNormal.getY();
|
||||
face.m_plane[2] = faceNormal.getZ();
|
||||
@ -426,7 +426,7 @@ int b3GpuNarrowPhase::registerConvexHullShape(b3ConvexUtility* utilPtr)
|
||||
|
||||
}
|
||||
|
||||
int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes)
|
||||
int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes)
|
||||
{
|
||||
|
||||
int collidableIndex = allocateCollidable();
|
||||
@ -435,7 +435,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShap
|
||||
|
||||
col.m_shapeIndex = m_data->m_cpuChildShapes.size();
|
||||
{
|
||||
btAssert(col.m_shapeIndex+childShapes->size()<m_data->m_config.m_maxCompoundChildShapes);
|
||||
b3Assert(col.m_shapeIndex+childShapes->size()<m_data->m_config.m_maxCompoundChildShapes);
|
||||
for (int i=0;i<childShapes->size();i++)
|
||||
{
|
||||
m_data->m_cpuChildShapes.push_back(childShapes->at(i));
|
||||
@ -474,7 +474,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShap
|
||||
childShapes->at(i).m_childOrientation[1],
|
||||
childShapes->at(i).m_childOrientation[2],
|
||||
childShapes->at(i).m_childOrientation[3]));
|
||||
btTransformAabb(childLocalAabbMin,childLocalAabbMax,margin,childTr,aMin,aMax);
|
||||
b3TransformAabb(childLocalAabbMin,childLocalAabbMax,margin,childTr,aMin,aMax);
|
||||
myAabbMin.setMin(aMin);
|
||||
myAabbMax.setMax(aMax);
|
||||
}
|
||||
@ -539,7 +539,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vert
|
||||
|
||||
bool useQuantizedAabbCompression = true;
|
||||
b3TriangleIndexVertexArray* meshInterface=new b3TriangleIndexVertexArray();
|
||||
btIndexedMesh mesh;
|
||||
b3IndexedMesh mesh;
|
||||
mesh.m_numTriangles = indices->size()/3;
|
||||
mesh.m_numVertices = vertices->size();
|
||||
mesh.m_vertexBase = (const unsigned char *)&vertices->at(0).getX();
|
||||
@ -551,7 +551,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vert
|
||||
bvh->build(meshInterface, useQuantizedAabbCompression, (b3Vector3&)aabb.m_min, (b3Vector3&)aabb.m_max);
|
||||
m_data->m_bvhData.push_back(bvh);
|
||||
int numNodes = bvh->getQuantizedNodeArray().size();
|
||||
//btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU = new btOpenCLArray<btQuantizedBvhNode>(this->m_context,this->m_queue,numNodes);
|
||||
//b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU = new b3OpenCLArray<b3QuantizedBvhNode>(this->m_context,this->m_queue,numNodes);
|
||||
//treeNodesGPU->copyFromHost(bvh->getQuantizedNodeArray());
|
||||
int numSubTrees = bvh->getSubtreeInfoArray().size();
|
||||
|
||||
@ -582,7 +582,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vert
|
||||
m_data->m_treeNodesCPU.push_back(bvh->getQuantizedNodeArray()[i]);
|
||||
}
|
||||
|
||||
//btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU = new btOpenCLArray<btBvhSubtreeInfo>(this->m_context,this->m_queue,numSubTrees);
|
||||
//b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU = new b3OpenCLArray<b3BvhSubtreeInfo>(this->m_context,this->m_queue,numSubTrees);
|
||||
//subTreesGPU->copyFromHost(bvh->getSubtreeInfoArray());
|
||||
|
||||
m_data->m_treeNodesGPU->copyFromHost(m_data->m_treeNodesCPU);
|
||||
@ -741,12 +741,12 @@ void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphase
|
||||
int nContactOut = 0;
|
||||
|
||||
int maxTriConvexPairCapacity = m_data->m_config.m_maxTriConvexPairCapacity;
|
||||
btOpenCLArray<btInt4> triangleConvexPairs(m_context,m_queue, maxTriConvexPairCapacity);
|
||||
b3OpenCLArray<b3Int4> triangleConvexPairs(m_context,m_queue, maxTriConvexPairCapacity);
|
||||
int numTriConvexPairsOut=0;
|
||||
|
||||
btOpenCLArray<btInt2> broadphasePairsGPU(m_context,m_queue);
|
||||
b3OpenCLArray<b3Int2> broadphasePairsGPU(m_context,m_queue);
|
||||
broadphasePairsGPU.setFromOpenCLBuffer(broadphasePairs,numBroadphasePairs);
|
||||
btOpenCLArray<btYetAnotherAabb> clAabbArray(this->m_context,this->m_queue);
|
||||
b3OpenCLArray<b3YetAnotherAabb> clAabbArray(this->m_context,this->m_queue);
|
||||
clAabbArray.setFromOpenCLBuffer(aabbsWS,numObjects);
|
||||
|
||||
m_data->m_gpuSatCollision->computeConvexConvexContactsGPUSAT(
|
||||
@ -794,7 +794,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
|
||||
b3Vector3 aabbMin(aabbMinPtr[0],aabbMinPtr[1],aabbMinPtr[2]);
|
||||
b3Vector3 aabbMax (aabbMaxPtr[0],aabbMaxPtr[1],aabbMaxPtr[2]);
|
||||
|
||||
btAssert(m_data->m_numAcceleratedRigidBodies< (m_data->m_config.m_maxConvexBodies-1));
|
||||
b3Assert(m_data->m_numAcceleratedRigidBodies< (m_data->m_config.m_maxConvexBodies-1));
|
||||
|
||||
m_data->m_bodyBufferGPU->resize(m_data->m_numAcceleratedRigidBodies+1);
|
||||
|
||||
@ -828,7 +828,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
|
||||
m_data->m_bodyBufferGPU->copyFromHostPointer(&body,1,m_data->m_numAcceleratedRigidBodies);
|
||||
}
|
||||
|
||||
btInertiaCL& shapeInfo = m_data->m_inertiaBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
|
||||
b3InertiaCL& shapeInfo = m_data->m_inertiaBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
|
||||
|
||||
if (mass==0.f)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef BT_GPU_NARROWPHASE_H
|
||||
#define BT_GPU_NARROWPHASE_H
|
||||
#ifndef B3_GPU_NARROWPHASE_H
|
||||
#define B3_GPU_NARROWPHASE_H
|
||||
|
||||
#include "../../gpu_narrowphase/host/b3Collidable.h"
|
||||
#include "basic_initialize/b3OpenCLInclude.h"
|
||||
@ -10,7 +10,7 @@ class b3GpuNarrowPhase
|
||||
{
|
||||
protected:
|
||||
|
||||
struct btGpuNarrowPhaseInternalData* m_data;
|
||||
struct b3GpuNarrowPhaseInternalData* m_data;
|
||||
int m_acceleratedCompanionShapeIndex;
|
||||
int m_planeBodyIndex;
|
||||
int m_static0Index;
|
||||
@ -34,7 +34,7 @@ public:
|
||||
int registerSphereShape(float radius);
|
||||
int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
|
||||
|
||||
int registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes);
|
||||
int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
|
||||
int registerFace(const b3Vector3& faceNormal, float faceConstant);
|
||||
|
||||
int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices,const float* scaling);
|
||||
@ -82,5 +82,5 @@ public:
|
||||
const struct b3SapAabb& getLocalSpaceAabb(int collidableIndex) const;
|
||||
};
|
||||
|
||||
#endif //BT_GPU_NARROWPHASE_H
|
||||
#endif //B3_GPU_NARROWPHASE_H
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "Bullet3Geometry/b3AabbUtil.h"
|
||||
#include "../../gpu_broadphase/host/b3SapAabb.h"
|
||||
#include "../../gpu_broadphase/host/b3GpuSapBroadphase.h"
|
||||
#include "parallel_primitives/host/btLauncherCL.h"
|
||||
#include "parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h"
|
||||
|
||||
#include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h"
|
||||
@ -20,7 +20,7 @@ bool useBullet2CpuSolver = true;//false;
|
||||
bool dumpContactStats = false;
|
||||
|
||||
#ifdef TEST_OTHER_GPU_SOLVER
|
||||
#include "btGpuJacobiSolver.h"
|
||||
#include "b3GpuJacobiSolver.h"
|
||||
#endif //TEST_OTHER_GPU_SOLVER
|
||||
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
@ -43,11 +43,11 @@ b3GpuRigidBodyPipeline::b3GpuRigidBodyPipeline(cl_context ctx,cl_device_id devic
|
||||
|
||||
m_data->m_solver = new b3PgsJacobiSolver();
|
||||
b3Config config;
|
||||
m_data->m_allAabbsGPU = new btOpenCLArray<b3SapAabb>(ctx,q,config.m_maxConvexBodies);
|
||||
m_data->m_overlappingPairsGPU = new btOpenCLArray<btBroadphasePair>(ctx,q,config.m_maxBroadphasePairs);
|
||||
m_data->m_allAabbsGPU = new b3OpenCLArray<b3SapAabb>(ctx,q,config.m_maxConvexBodies);
|
||||
m_data->m_overlappingPairsGPU = new b3OpenCLArray<b3BroadphasePair>(ctx,q,config.m_maxBroadphasePairs);
|
||||
|
||||
#ifdef TEST_OTHER_GPU_SOLVER
|
||||
m_data->m_solver3 = new btGpuJacobiSolver(ctx,device,q,config.m_maxBroadphasePairs);
|
||||
m_data->m_solver3 = new b3GpuJacobiSolver(ctx,device,q,config.m_maxBroadphasePairs);
|
||||
#endif // TEST_OTHER_GPU_SOLVER
|
||||
|
||||
m_data->m_solver2 = new b3GpuBatchingPgsSolver(ctx,device,q,config.m_maxBroadphasePairs);
|
||||
@ -61,16 +61,16 @@ b3GpuRigidBodyPipeline::b3GpuRigidBodyPipeline(cl_context ctx,cl_device_id devic
|
||||
|
||||
{
|
||||
cl_program prog = b3OpenCLUtils::compileCLProgramFromString(m_data->m_context,m_data->m_device,integrateKernelCL,&errNum,"","opencl/gpu_rigidbody/kernels/integrateKernel.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
m_data->m_integrateTransformsKernel = b3OpenCLUtils::compileCLKernelFromString(m_data->m_context, m_data->m_device,integrateKernelCL, "integrateTransformsKernel",&errNum,prog);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
clReleaseProgram(prog);
|
||||
}
|
||||
{
|
||||
cl_program prog = b3OpenCLUtils::compileCLProgramFromString(m_data->m_context,m_data->m_device,updateAabbsKernelCL,&errNum,"","opencl/gpu_rigidbody/kernels/updateAabbsKernel.cl");
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
m_data->m_updateAabbsKernel = b3OpenCLUtils::compileCLKernelFromString(m_data->m_context, m_data->m_device,updateAabbsKernelCL, "initializeGpuAabbsFull",&errNum,prog);
|
||||
btAssert(errNum==CL_SUCCESS);
|
||||
b3Assert(errNum==CL_SUCCESS);
|
||||
clReleaseProgram(prog);
|
||||
}
|
||||
|
||||
@ -116,11 +116,11 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
if (useDbvt)
|
||||
{
|
||||
{
|
||||
BT_PROFILE("setAabb");
|
||||
B3_PROFILE("setAabb");
|
||||
m_data->m_allAabbsGPU->copyToHost(m_data->m_allAabbsCPU);
|
||||
for (int i=0;i<m_data->m_allAabbsCPU.size();i++)
|
||||
{
|
||||
btBroadphaseProxy* proxy = &m_data->m_broadphaseDbvt->m_proxies[i];
|
||||
b3BroadphaseProxy* proxy = &m_data->m_broadphaseDbvt->m_proxies[i];
|
||||
b3Vector3 aabbMin(m_data->m_allAabbsCPU[i].m_min[0],m_data->m_allAabbsCPU[i].m_min[1],m_data->m_allAabbsCPU[i].m_min[2]);
|
||||
b3Vector3 aabbMax(m_data->m_allAabbsCPU[i].m_max[0],m_data->m_allAabbsCPU[i].m_max[1],m_data->m_allAabbsCPU[i].m_max[2]);
|
||||
m_data->m_broadphaseDbvt->setAabb(proxy,aabbMin,aabbMax,0);
|
||||
@ -128,7 +128,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("calculateOverlappingPairs");
|
||||
B3_PROFILE("calculateOverlappingPairs");
|
||||
m_data->m_broadphaseDbvt->calculateOverlappingPairs();
|
||||
}
|
||||
numPairs = m_data->m_broadphaseDbvt->getOverlappingPairCache()->getNumOverlappingPairs();
|
||||
@ -153,7 +153,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
cl_mem aabbsWS =0;
|
||||
if (useDbvt)
|
||||
{
|
||||
BT_PROFILE("m_overlappingPairsGPU->copyFromHost");
|
||||
B3_PROFILE("m_overlappingPairsGPU->copyFromHost");
|
||||
m_data->m_overlappingPairsGPU->copyFromHost(m_data->m_broadphaseDbvt->getOverlappingPairCache()->getOverlappingPairArray());
|
||||
pairs = m_data->m_overlappingPairsGPU->getBufferCL();
|
||||
aabbsWS = m_data->m_allAabbsGPU->getBufferCL();
|
||||
@ -190,11 +190,11 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
|
||||
//solve constraints
|
||||
|
||||
btOpenCLArray<b3RigidBodyCL> gpuBodies(m_data->m_context,m_data->m_queue,0,true);
|
||||
b3OpenCLArray<b3RigidBodyCL> gpuBodies(m_data->m_context,m_data->m_queue,0,true);
|
||||
gpuBodies.setFromOpenCLBuffer(m_data->m_narrowphase->getBodiesGpu(),m_data->m_narrowphase->getNumBodiesGpu());
|
||||
btOpenCLArray<btInertiaCL> gpuInertias(m_data->m_context,m_data->m_queue,0,true);
|
||||
b3OpenCLArray<b3InertiaCL> gpuInertias(m_data->m_context,m_data->m_queue,0,true);
|
||||
gpuInertias.setFromOpenCLBuffer(m_data->m_narrowphase->getBodyInertiasGpu(),m_data->m_narrowphase->getNumBodiesGpu());
|
||||
btOpenCLArray<b3Contact4> gpuContacts(m_data->m_context,m_data->m_queue,0,true);
|
||||
b3OpenCLArray<b3Contact4> gpuContacts(m_data->m_context,m_data->m_queue,0,true);
|
||||
gpuContacts.setFromOpenCLBuffer(m_data->m_narrowphase->getContactsGpu(),m_data->m_narrowphase->getNumContactsGpu());
|
||||
|
||||
if (useBullet2CpuSolver)
|
||||
@ -202,7 +202,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
|
||||
gpuBodies.copyToHost(hostBodies);
|
||||
b3AlignedObjectArray<btInertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3InertiaCL> hostInertias;
|
||||
gpuInertias.copyToHost(hostInertias);
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
gpuContacts.copyToHost(hostContacts);
|
||||
@ -230,36 +230,36 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
if (forceHost)
|
||||
{
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
|
||||
b3AlignedObjectArray<btInertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3InertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
|
||||
{
|
||||
BT_PROFILE("copyToHost");
|
||||
B3_PROFILE("copyToHost");
|
||||
gpuBodies.copyToHost(hostBodies);
|
||||
gpuInertias.copyToHost(hostInertias);
|
||||
gpuContacts.copyToHost(hostContacts);
|
||||
}
|
||||
|
||||
{
|
||||
btJacobiSolverInfo solverInfo;
|
||||
b3JacobiSolverInfo solverInfo;
|
||||
m_data->m_solver3->solveGroupHost(&hostBodies[0], &hostInertias[0], hostBodies.size(),&hostContacts[0],hostContacts.size(),0,0,solverInfo);
|
||||
|
||||
|
||||
}
|
||||
{
|
||||
BT_PROFILE("copyFromHost");
|
||||
B3_PROFILE("copyFromHost");
|
||||
gpuBodies.copyFromHost(hostBodies);
|
||||
}
|
||||
} else
|
||||
{
|
||||
btJacobiSolverInfo solverInfo;
|
||||
b3JacobiSolverInfo solverInfo;
|
||||
m_data->m_solver3->solveGroup(&gpuBodies, &gpuInertias, &gpuContacts,solverInfo);
|
||||
}
|
||||
} else
|
||||
{
|
||||
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
|
||||
gpuBodies.copyToHost(hostBodies);
|
||||
b3AlignedObjectArray<btInertiaCL> hostInertias;
|
||||
b3AlignedObjectArray<b3InertiaCL> hostInertias;
|
||||
gpuInertias.copyToHost(hostInertias);
|
||||
b3AlignedObjectArray<b3Contact4> hostContacts;
|
||||
gpuContacts.copyToHost(hostContacts);
|
||||
@ -279,9 +279,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
|
||||
|
||||
|
||||
/*m_data->m_solver3->solveContactConstraintHost(
|
||||
(btOpenCLArray<RigidBodyBase::Body>*)&gpuBodies,
|
||||
(btOpenCLArray<RigidBodyBase::Inertia>*)&gpuInertias,
|
||||
(btOpenCLArray<Constraint4>*) &gpuContacts,
|
||||
(b3OpenCLArray<RigidBodyBase::Body>*)&gpuBodies,
|
||||
(b3OpenCLArray<RigidBodyBase::Inertia>*)&gpuInertias,
|
||||
(b3OpenCLArray<Constraint4>*) &gpuContacts,
|
||||
0,numContacts,256);
|
||||
*/
|
||||
}
|
||||
@ -295,7 +295,7 @@ void b3GpuRigidBodyPipeline::integrate(float timeStep)
|
||||
{
|
||||
//integrate
|
||||
|
||||
btLauncherCL launcher(m_data->m_queue,m_data->m_integrateTransformsKernel);
|
||||
b3LauncherCL launcher(m_data->m_queue,m_data->m_integrateTransformsKernel);
|
||||
launcher.setBuffer(m_data->m_narrowphase->getBodiesGpu());
|
||||
int numBodies = m_data->m_narrowphase->getNumBodiesGpu();
|
||||
launcher.setConst(numBodies);
|
||||
@ -319,8 +319,8 @@ void b3GpuRigidBodyPipeline::setupGpuAabbsFull()
|
||||
if (!numBodies)
|
||||
return;
|
||||
|
||||
//__kernel void initializeGpuAabbsFull( const int numNodes, __global Body* gBodies,__global Collidable* collidables, __global btAABBCL* plocalShapeAABB, __global btAABBCL* pAABB)
|
||||
btLauncherCL launcher(m_data->m_queue,m_data->m_updateAabbsKernel);
|
||||
//__kernel void initializeGpuAabbsFull( const int numNodes, __global Body* gBodies,__global Collidable* collidables, __global b3AABBCL* plocalShapeAABB, __global b3AABBCL* pAABB)
|
||||
b3LauncherCL launcher(m_data->m_queue,m_data->m_updateAabbsKernel);
|
||||
launcher.setConst(numBodies);
|
||||
cl_mem bodies = m_data->m_narrowphase->getBodiesGpu();
|
||||
launcher.setBuffer(bodies);
|
||||
@ -379,7 +379,7 @@ int b3GpuRigidBodyPipeline::registerPhysicsInstance(float mass, const float* po
|
||||
t.setIdentity();
|
||||
t.setOrigin(b3Vector3(position[0],position[1],position[2]));
|
||||
t.setRotation(b3Quaternion(orientation[0],orientation[1],orientation[2],orientation[3]));
|
||||
btTransformAabb(localAabbMin,localAabbMax, margin,t,aabbMin,aabbMax);
|
||||
b3TransformAabb(localAabbMin,localAabbMax, margin,t,aabbMin,aabbMax);
|
||||
if (useDbvt)
|
||||
{
|
||||
m_data->m_broadphaseDbvt->createProxy(aabbMin,aabbMax,bodyIndex,0,1,1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef BT_GPU_RIGIDBODY_PIPELINE_H
|
||||
#define BT_GPU_RIGIDBODY_PIPELINE_H
|
||||
#ifndef B3_GPU_RIGIDBODY_PIPELINE_H
|
||||
#define B3_GPU_RIGIDBODY_PIPELINE_H
|
||||
|
||||
#include "../../basic_initialize/b3OpenCLInclude.h"
|
||||
|
||||
@ -27,7 +27,7 @@ public:
|
||||
//int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
|
||||
|
||||
//int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
|
||||
//int registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes);
|
||||
//int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
|
||||
|
||||
|
||||
int registerPhysicsInstance(float mass, const float* position, const float* orientation, int collisionShapeIndex, int userData, bool writeInstanceToGpu);
|
||||
@ -42,4 +42,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_GPU_RIGIDBODY_PIPELINE_H
|
||||
#endif //B3_GPU_RIGIDBODY_PIPELINE_H
|
@ -1,10 +1,10 @@
|
||||
#ifndef BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
|
||||
#define BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
|
||||
#ifndef B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
|
||||
#define B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
|
||||
|
||||
#include "../../basic_initialize/b3OpenCLInclude.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
|
||||
#include "../../parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "../../parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "../../gpu_narrowphase/host/b3Collidable.h"
|
||||
|
||||
#include "gpu_broadphase/host/b3SapAabb.h"
|
||||
@ -26,19 +26,19 @@ struct b3GpuRigidBodyPipelineInternalData
|
||||
|
||||
class b3PgsJacobiSolver* m_solver;
|
||||
class b3GpuBatchingPgsSolver* m_solver2;
|
||||
class btGpuJacobiSolver* m_solver3;
|
||||
class b3GpuJacobiSolver* m_solver3;
|
||||
|
||||
class b3GpuSapBroadphase* m_broadphaseSap;
|
||||
|
||||
class b3DynamicBvhBroadphase* m_broadphaseDbvt;
|
||||
btOpenCLArray<b3SapAabb>* m_allAabbsGPU;
|
||||
b3OpenCLArray<b3SapAabb>* m_allAabbsGPU;
|
||||
b3AlignedObjectArray<b3SapAabb> m_allAabbsCPU;
|
||||
btOpenCLArray<btBroadphasePair>* m_overlappingPairsGPU;
|
||||
b3OpenCLArray<b3BroadphasePair>* m_overlappingPairsGPU;
|
||||
|
||||
b3AlignedObjectArray<b3TypedConstraint*> m_joints;
|
||||
class b3GpuNarrowPhase* m_narrowphase;
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
|
||||
#endif //B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
|
||||
|
||||
|
@ -40,7 +40,7 @@ bool useNewBatchingKernel = true;
|
||||
|
||||
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
#include "../../parallel_primitives/host/btLauncherCL.h"
|
||||
#include "../../parallel_primitives/host/b3LauncherCL.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
struct SolverDebugInfo
|
||||
@ -80,8 +80,8 @@ class SolverDeviceInl
|
||||
public:
|
||||
struct ParallelSolveData
|
||||
{
|
||||
btOpenCLArray<unsigned int>* m_numConstraints;
|
||||
btOpenCLArray<unsigned int>* m_offsets;
|
||||
b3OpenCLArray<unsigned int>* m_numConstraints;
|
||||
b3OpenCLArray<unsigned int>* m_offsets;
|
||||
};
|
||||
};
|
||||
|
||||
@ -93,19 +93,19 @@ b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue,
|
||||
m_device(device),
|
||||
m_queue(queue)
|
||||
{
|
||||
m_sort32 = new btRadixSort32CL(ctx,device,queue);
|
||||
m_scan = new btPrefixScanCL(ctx,device,queue,N_SPLIT*N_SPLIT);
|
||||
m_search = new btBoundSearchCL(ctx,device,queue,N_SPLIT*N_SPLIT);
|
||||
m_sort32 = new b3RadixSort32CL(ctx,device,queue);
|
||||
m_scan = new b3PrefixScanCL(ctx,device,queue,N_SPLIT*N_SPLIT);
|
||||
m_search = new b3BoundSearchCL(ctx,device,queue,N_SPLIT*N_SPLIT);
|
||||
|
||||
const int sortSize = BTNEXTMULTIPLEOF( pairCapacity, 512 );
|
||||
const int sortSize = B3NEXTMULTIPLEOF( pairCapacity, 512 );
|
||||
|
||||
m_sortDataBuffer = new btOpenCLArray<btSortData>(ctx,queue,sortSize);
|
||||
m_contactBuffer2 = new btOpenCLArray<b3Contact4>(ctx,queue);
|
||||
m_sortDataBuffer = new b3OpenCLArray<b3SortData>(ctx,queue,sortSize);
|
||||
m_contactBuffer2 = new b3OpenCLArray<b3Contact4>(ctx,queue);
|
||||
|
||||
m_numConstraints = new btOpenCLArray<unsigned int>(ctx,queue,N_SPLIT*N_SPLIT );
|
||||
m_numConstraints = new b3OpenCLArray<unsigned int>(ctx,queue,N_SPLIT*N_SPLIT );
|
||||
m_numConstraints->resize(N_SPLIT*N_SPLIT);
|
||||
|
||||
m_offsets = new btOpenCLArray<unsigned int>( ctx,queue, N_SPLIT*N_SPLIT );
|
||||
m_offsets = new b3OpenCLArray<unsigned int>( ctx,queue, N_SPLIT*N_SPLIT );
|
||||
m_offsets->resize(N_SPLIT*N_SPLIT);
|
||||
const char* additionalMacros = "";
|
||||
const char* srcFileNameForCaching="";
|
||||
@ -126,54 +126,54 @@ b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue,
|
||||
{
|
||||
|
||||
cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, SOLVER_CONTACT_KERNEL_PATH);
|
||||
btAssert(solveContactProg);
|
||||
b3Assert(solveContactProg);
|
||||
|
||||
cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, SOLVER_FRICTION_KERNEL_PATH);
|
||||
btAssert(solveFrictionProg);
|
||||
b3Assert(solveFrictionProg);
|
||||
|
||||
cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, SOLVER_SETUP2_KERNEL_PATH);
|
||||
btAssert(solverSetup2Prog);
|
||||
b3Assert(solverSetup2Prog);
|
||||
|
||||
|
||||
cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, SOLVER_SETUP_KERNEL_PATH);
|
||||
btAssert(solverSetupProg);
|
||||
b3Assert(solverSetupProg);
|
||||
|
||||
|
||||
m_solveFrictionKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveFrictionSource, "BatchSolveKernelFriction", &pErrNum, solveFrictionProg,additionalMacros );
|
||||
btAssert(m_solveFrictionKernel);
|
||||
b3Assert(m_solveFrictionKernel);
|
||||
|
||||
m_solveContactKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveContactSource, "BatchSolveKernelContact", &pErrNum, solveContactProg,additionalMacros );
|
||||
btAssert(m_solveContactKernel);
|
||||
b3Assert(m_solveContactKernel);
|
||||
|
||||
m_contactToConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetupSource, "ContactToConstraintKernel", &pErrNum, solverSetupProg,additionalMacros );
|
||||
btAssert(m_contactToConstraintKernel);
|
||||
b3Assert(m_contactToConstraintKernel);
|
||||
|
||||
m_setSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "SetSortDataKernel", &pErrNum, solverSetup2Prog,additionalMacros );
|
||||
btAssert(m_setSortDataKernel);
|
||||
b3Assert(m_setSortDataKernel);
|
||||
|
||||
m_reorderContactKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "ReorderContactKernel", &pErrNum, solverSetup2Prog,additionalMacros );
|
||||
btAssert(m_reorderContactKernel);
|
||||
b3Assert(m_reorderContactKernel);
|
||||
|
||||
|
||||
m_copyConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "CopyConstraintKernel", &pErrNum, solverSetup2Prog,additionalMacros );
|
||||
btAssert(m_copyConstraintKernel);
|
||||
b3Assert(m_copyConstraintKernel);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
cl_program batchingProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelSource, &pErrNum,additionalMacros, BATCHING_PATH);
|
||||
btAssert(batchingProg);
|
||||
b3Assert(batchingProg);
|
||||
|
||||
m_batchingKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelSource, "CreateBatches", &pErrNum, batchingProg,additionalMacros );
|
||||
btAssert(m_batchingKernel);
|
||||
b3Assert(m_batchingKernel);
|
||||
}
|
||||
{
|
||||
cl_program batchingNewProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelNewSource, &pErrNum,additionalMacros, BATCHING_NEW_PATH);
|
||||
btAssert(batchingNewProg);
|
||||
b3Assert(batchingNewProg);
|
||||
|
||||
m_batchingKernelNew = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelNewSource, "CreateBatchesNew", &pErrNum, batchingNewProg,additionalMacros );
|
||||
//m_batchingKernelNew = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelNewSource, "CreateBatchesBruteForce", &pErrNum, batchingNewProg,additionalMacros );
|
||||
btAssert(m_batchingKernelNew);
|
||||
b3Assert(m_batchingKernelNew);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,9 +204,9 @@ b3Solver::~b3Solver()
|
||||
|
||||
|
||||
|
||||
/*void b3Solver::reorderConvertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3Contact4>* contactsIn, btOpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
/*void b3Solver::reorderConvertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
int nContacts, const b3Solver::ConstraintCfg& cfg )
|
||||
{
|
||||
if( m_contactBuffer )
|
||||
@ -215,8 +215,8 @@ b3Solver::~b3Solver()
|
||||
}
|
||||
if( m_contactBuffer == 0 )
|
||||
{
|
||||
BT_PROFILE("new m_contactBuffer;");
|
||||
m_contactBuffer = new btOpenCLArray<b3Contact4>(m_context,m_queue,nContacts );
|
||||
B3_PROFILE("new m_contactBuffer;");
|
||||
m_contactBuffer = new b3OpenCLArray<b3Contact4>(m_context,m_queue,nContacts );
|
||||
m_contactBuffer->resize(nContacts);
|
||||
}
|
||||
|
||||
@ -233,47 +233,47 @@ b3Solver::~b3Solver()
|
||||
|
||||
// contactsIn -> m_contactBuffer
|
||||
{
|
||||
BT_PROFILE("sortContacts");
|
||||
B3_PROFILE("sortContacts");
|
||||
sortContacts( bodyBuf, contactsIn, additionalData, nContacts, cfg );
|
||||
clFinish(m_queue);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("m_copyConstraintKernel");
|
||||
B3_PROFILE("m_copyConstraintKernel");
|
||||
|
||||
|
||||
|
||||
btInt4 cdata; cdata.x = nContacts;
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_contactBuffer->getBufferCL() ), btBufferInfoCL( contactsIn->getBufferCL() ) };
|
||||
// btLauncherCL launcher( m_queue, data->m_device->getKernel( PATH, "CopyConstraintKernel", "-I ..\\..\\ -Wf,--c++", 0 ) );
|
||||
btLauncherCL launcher( m_queue, m_copyConstraintKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3Int4 cdata; cdata.x = nContacts;
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_contactBuffer->getBufferCL() ), b3BufferInfoCL( contactsIn->getBufferCL() ) };
|
||||
// b3LauncherCL launcher( m_queue, data->m_device->getKernel( PATH, "CopyConstraintKernel", "-I ..\\..\\ -Wf,--c++", 0 ) );
|
||||
b3LauncherCL launcher( m_queue, m_copyConstraintKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( cdata );
|
||||
launcher.launch1D( nContacts, 64 );
|
||||
clFinish(m_queue);
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("batchContacts");
|
||||
B3_PROFILE("batchContacts");
|
||||
b3Solver::batchContacts( contactsIn, nContacts, m_numConstraints, m_offsets, cfg.m_staticIdx );
|
||||
|
||||
}
|
||||
}
|
||||
{
|
||||
BT_PROFILE("waitForCompletion (batchContacts)");
|
||||
B3_PROFILE("waitForCompletion (batchContacts)");
|
||||
clFinish(m_queue);
|
||||
}
|
||||
|
||||
//================
|
||||
|
||||
{
|
||||
BT_PROFILE("convertToConstraints");
|
||||
B3_PROFILE("convertToConstraints");
|
||||
b3Solver::convertToConstraints( bodyBuf, shapeBuf, contactsIn, contactCOut, additionalData, nContacts, cfg );
|
||||
}
|
||||
|
||||
{
|
||||
BT_PROFILE("convertToConstraints waitForCompletion");
|
||||
B3_PROFILE("convertToConstraints waitForCompletion");
|
||||
clFinish(m_queue);
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ b3Solver::~b3Solver()
|
||||
float calcRelVel(const b3Vector3& l0, const b3Vector3& l1, const b3Vector3& a0, const b3Vector3& a1,
|
||||
const b3Vector3& linVel0, const b3Vector3& angVel0, const b3Vector3& linVel1, const b3Vector3& angVel1)
|
||||
{
|
||||
return btDot(l0, linVel0) + btDot(a0, angVel0) + btDot(l1, linVel1) + btDot(a1, angVel1);
|
||||
return b3Dot(l0, linVel0) + b3Dot(a0, angVel0) + b3Dot(l1, linVel1) + b3Dot(a1, angVel1);
|
||||
}
|
||||
|
||||
|
||||
@ -295,8 +295,8 @@ b3Solver::~b3Solver()
|
||||
b3Vector3& linear, b3Vector3& angular0, b3Vector3& angular1)
|
||||
{
|
||||
linear = -n;
|
||||
angular0 = -btCross(r0, n);
|
||||
angular1 = btCross(r1, n);
|
||||
angular0 = -b3Cross(r0, n);
|
||||
angular1 = b3Cross(r1, n);
|
||||
}
|
||||
|
||||
|
||||
@ -333,8 +333,8 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
float prevSum = cs.m_appliedRambdaDt[ic];
|
||||
float updated = prevSum;
|
||||
updated += rambdaDt;
|
||||
updated = btMax( updated, minRambdaDt[ic] );
|
||||
updated = btMin( updated, maxRambdaDt[ic] );
|
||||
updated = b3Max( updated, minRambdaDt[ic] );
|
||||
updated = b3Min( updated, maxRambdaDt[ic] );
|
||||
rambdaDt = updated - prevSum;
|
||||
cs.m_appliedRambdaDt[ic] = updated;
|
||||
}
|
||||
@ -344,8 +344,8 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
|
||||
b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
|
||||
#ifdef _WIN32
|
||||
btAssert(_finite(linImp0.getX()));
|
||||
btAssert(_finite(linImp1.getX()));
|
||||
b3Assert(_finite(linImp0.getX()));
|
||||
b3Assert(_finite(linImp1.getX()));
|
||||
#endif
|
||||
if( JACOBI )
|
||||
{
|
||||
@ -393,7 +393,7 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
|
||||
b3Vector3 tangent[2];
|
||||
#if 1
|
||||
btPlaneSpace1 (n, tangent[0],tangent[1]);
|
||||
b3PlaneSpace1 (n, tangent[0],tangent[1]);
|
||||
#else
|
||||
b3Vector3 r = cs.m_worldPos[0]-center;
|
||||
tangent[0] = cross3( n, r );
|
||||
@ -416,8 +416,8 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
float prevSum = cs.m_fAppliedRambdaDt[i];
|
||||
float updated = prevSum;
|
||||
updated += rambdaDt;
|
||||
updated = btMax( updated, minRambdaDt[i] );
|
||||
updated = btMin( updated, maxRambdaDt[i] );
|
||||
updated = b3Max( updated, minRambdaDt[i] );
|
||||
updated = b3Min( updated, maxRambdaDt[i] );
|
||||
rambdaDt = updated - prevSum;
|
||||
cs.m_fAppliedRambdaDt[i] = updated;
|
||||
}
|
||||
@ -427,8 +427,8 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
|
||||
b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
|
||||
#ifdef _WIN32
|
||||
btAssert(_finite(linImp0.getX()));
|
||||
btAssert(_finite(linImp1.getX()));
|
||||
b3Assert(_finite(linImp0.getX()));
|
||||
b3Assert(_finite(linImp1.getX()));
|
||||
#endif
|
||||
linVelA += linImp0;
|
||||
angVelA += angImp0;
|
||||
@ -439,10 +439,10 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
{ // angular damping for point constraint
|
||||
b3Vector3 ab = ( posB - posA ).normalized();
|
||||
b3Vector3 ac = ( center - posA ).normalized();
|
||||
if( btDot( ab, ac ) > 0.95f || (invMassA == 0.f || invMassB == 0.f))
|
||||
if( b3Dot( ab, ac ) > 0.95f || (invMassA == 0.f || invMassB == 0.f))
|
||||
{
|
||||
float angNA = btDot( n, angVelA );
|
||||
float angNB = btDot( n, angVelB );
|
||||
float angNA = b3Dot( n, angVelA );
|
||||
float angNB = b3Dot( n, angVelB );
|
||||
|
||||
angVelA -= (angNA*0.1f)*n;
|
||||
angVelB -= (angNB*0.1f)*n;
|
||||
@ -454,7 +454,7 @@ void solveContact(b3GpuConstraint4& cs,
|
||||
|
||||
struct SolveTask// : public ThreadPool::Task
|
||||
{
|
||||
SolveTask(b3AlignedObjectArray<b3RigidBodyCL>& bodies, b3AlignedObjectArray<btInertiaCL>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
|
||||
SolveTask(b3AlignedObjectArray<b3RigidBodyCL>& bodies, b3AlignedObjectArray<b3InertiaCL>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
|
||||
int start, int nConstraints)
|
||||
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ), m_start( start ), m_nConstraints( nConstraints ),
|
||||
m_solveFriction( true ){}
|
||||
@ -513,7 +513,7 @@ struct SolveTask// : public ThreadPool::Task
|
||||
}
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL>& m_bodies;
|
||||
b3AlignedObjectArray<btInertiaCL>& m_shapes;
|
||||
b3AlignedObjectArray<b3InertiaCL>& m_shapes;
|
||||
b3AlignedObjectArray<b3GpuConstraint4>& m_constraints;
|
||||
int m_start;
|
||||
int m_nConstraints;
|
||||
@ -521,13 +521,13 @@ struct SolveTask// : public ThreadPool::Task
|
||||
};
|
||||
|
||||
|
||||
void b3Solver::solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBuf, btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
|
||||
void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<b3RigidBodyCL> bodyNative;
|
||||
bodyBuf->copyToHost(bodyNative);
|
||||
b3AlignedObjectArray<btInertiaCL> shapeNative;
|
||||
b3AlignedObjectArray<b3InertiaCL> shapeNative;
|
||||
shapeBuf->copyToHost(shapeNative);
|
||||
b3AlignedObjectArray<b3GpuConstraint4> constraintNative;
|
||||
constraint->copyToHost(constraintNative);
|
||||
@ -553,12 +553,12 @@ void b3Solver::solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBu
|
||||
|
||||
}
|
||||
|
||||
void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
|
||||
void b3Solver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
|
||||
{
|
||||
|
||||
|
||||
btInt4 cdata = btMakeInt4( n, 0, 0, 0 );
|
||||
b3Int4 cdata = b3MakeInt4( n, 0, 0, 0 );
|
||||
{
|
||||
|
||||
const int nn = N_SPLIT*N_SPLIT;
|
||||
@ -570,14 +570,14 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
|
||||
int numWorkItems = 64*nn/N_BATCHES;
|
||||
#ifdef DEBUG_ME
|
||||
SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems];
|
||||
adl::btOpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
|
||||
adl::b3OpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
BT_PROFILE("m_batchSolveKernel iterations");
|
||||
B3_PROFILE("m_batchSolveKernel iterations");
|
||||
for(int iter=0; iter<m_nIterations; iter++)
|
||||
{
|
||||
for(int ib=0; ib<N_BATCHES; ib++)
|
||||
@ -591,24 +591,24 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
|
||||
cdata.z = ib;
|
||||
cdata.w = N_SPLIT;
|
||||
|
||||
btLauncherCL launcher( m_queue, m_solveContactKernel );
|
||||
b3LauncherCL launcher( m_queue, m_solveContactKernel );
|
||||
#if 1
|
||||
|
||||
btBufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
|
||||
btBufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
btBufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
btBufferInfoCL( constraint->getBufferCL() ),
|
||||
btBufferInfoCL( m_numConstraints->getBufferCL() ),
|
||||
btBufferInfoCL( m_offsets->getBufferCL() )
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( constraint->getBufferCL() ),
|
||||
b3BufferInfoCL( m_numConstraints->getBufferCL() ),
|
||||
b3BufferInfoCL( m_offsets->getBufferCL() )
|
||||
#ifdef DEBUG_ME
|
||||
, btBufferInfoCL(&gpuDebugInfo)
|
||||
, b3BufferInfoCL(&gpuDebugInfo)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
//launcher.setConst( cdata.x );
|
||||
launcher.setConst( cdata.y );
|
||||
launcher.setConst( cdata.z );
|
||||
@ -673,7 +673,7 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
|
||||
bool applyFriction=true;
|
||||
if (applyFriction)
|
||||
{
|
||||
BT_PROFILE("m_batchSolveKernel iterations2");
|
||||
B3_PROFILE("m_batchSolveKernel iterations2");
|
||||
for(int iter=0; iter<m_nIterations; iter++)
|
||||
{
|
||||
for(int ib=0; ib<N_BATCHES; ib++)
|
||||
@ -681,18 +681,18 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
|
||||
cdata.z = ib;
|
||||
cdata.w = N_SPLIT;
|
||||
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
btBufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
btBufferInfoCL( constraint->getBufferCL() ),
|
||||
btBufferInfoCL( m_numConstraints->getBufferCL() ),
|
||||
btBufferInfoCL( m_offsets->getBufferCL() )
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( bodyBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( shapeBuf->getBufferCL() ),
|
||||
b3BufferInfoCL( constraint->getBufferCL() ),
|
||||
b3BufferInfoCL( m_numConstraints->getBufferCL() ),
|
||||
b3BufferInfoCL( m_offsets->getBufferCL() )
|
||||
#ifdef DEBUG_ME
|
||||
,btBufferInfoCL(&gpuDebugInfo)
|
||||
,b3BufferInfoCL(&gpuDebugInfo)
|
||||
#endif //DEBUG_ME
|
||||
};
|
||||
btLauncherCL launcher( m_queue, m_solveFrictionKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3LauncherCL launcher( m_queue, m_solveFrictionKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
//launcher.setConst( cdata.x );
|
||||
launcher.setConst( cdata.y );
|
||||
launcher.setConst( cdata.z );
|
||||
@ -712,12 +712,12 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
|
||||
|
||||
}
|
||||
|
||||
void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3Contact4>* contactsIn, btOpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
int nContacts, const ConstraintCfg& cfg )
|
||||
{
|
||||
btOpenCLArray<b3GpuConstraint4>* constraintNative =0;
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraintNative =0;
|
||||
|
||||
struct CB
|
||||
{
|
||||
@ -728,7 +728,7 @@ void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf
|
||||
};
|
||||
|
||||
{
|
||||
BT_PROFILE("m_contactToConstraintKernel");
|
||||
B3_PROFILE("m_contactToConstraintKernel");
|
||||
CB cdata;
|
||||
cdata.m_nContacts = nContacts;
|
||||
cdata.m_dt = cfg.m_dt;
|
||||
@ -736,10 +736,10 @@ void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf
|
||||
cdata.m_positionConstraintCoeff = cfg.m_positionConstraintCoeff;
|
||||
|
||||
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( contactsIn->getBufferCL() ), btBufferInfoCL( bodyBuf->getBufferCL() ), btBufferInfoCL( shapeBuf->getBufferCL()),
|
||||
btBufferInfoCL( contactCOut->getBufferCL() )};
|
||||
btLauncherCL launcher( m_queue, m_contactToConstraintKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( contactsIn->getBufferCL() ), b3BufferInfoCL( bodyBuf->getBufferCL() ), b3BufferInfoCL( shapeBuf->getBufferCL()),
|
||||
b3BufferInfoCL( contactCOut->getBufferCL() )};
|
||||
b3LauncherCL launcher( m_queue, m_contactToConstraintKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
//launcher.setConst( cdata );
|
||||
|
||||
launcher.setConst(cdata.m_nContacts);
|
||||
@ -756,8 +756,8 @@ void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf
|
||||
}
|
||||
|
||||
/*
|
||||
void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
btOpenCLArray<b3Contact4>* contactsIn, void* additionalData,
|
||||
void b3Solver::sortContacts( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, void* additionalData,
|
||||
int nContacts, const b3Solver::ConstraintCfg& cfg )
|
||||
{
|
||||
|
||||
@ -770,8 +770,8 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
|
||||
int sortSize = NEXTMULTIPLEOF( nContacts, sortAlignment );
|
||||
|
||||
btOpenCLArray<unsigned int>* countsNative = m_numConstraints;//BufferUtils::map<TYPE_CL, false>( data->m_device, &countsHost );
|
||||
btOpenCLArray<unsigned int>* offsetsNative = m_offsets;//BufferUtils::map<TYPE_CL, false>( data->m_device, &offsetsHost );
|
||||
b3OpenCLArray<unsigned int>* countsNative = m_numConstraints;//BufferUtils::map<TYPE_CL, false>( data->m_device, &countsHost );
|
||||
b3OpenCLArray<unsigned int>* offsetsNative = m_offsets;//BufferUtils::map<TYPE_CL, false>( data->m_device, &offsetsHost );
|
||||
|
||||
{ // 2. set cell idx
|
||||
struct CB
|
||||
@ -782,7 +782,7 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
int m_nSplit;
|
||||
};
|
||||
|
||||
btAssert( sortSize%64 == 0 );
|
||||
b3Assert( sortSize%64 == 0 );
|
||||
CB cdata;
|
||||
cdata.m_nContacts = nContacts;
|
||||
cdata.m_staticIdx = cfg.m_staticIdx;
|
||||
@ -790,9 +790,9 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
cdata.m_nSplit = N_SPLIT;
|
||||
|
||||
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( contactsIn->getBufferCL() ), btBufferInfoCL( bodyBuf->getBufferCL() ), btBufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
|
||||
btLauncherCL launcher( m_queue, m_setSortDataKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( contactsIn->getBufferCL() ), b3BufferInfoCL( bodyBuf->getBufferCL() ), b3BufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
|
||||
b3LauncherCL launcher( m_queue, m_setSortDataKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( cdata );
|
||||
launcher.launch1D( sortSize, 64 );
|
||||
}
|
||||
@ -805,23 +805,23 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
m_sort32->execute(*m_sortDataBuffer,sortSize);
|
||||
}
|
||||
{ // 4. find entries
|
||||
m_search->execute( *m_sortDataBuffer, nContacts, *countsNative, N_SPLIT*N_SPLIT, btBoundSearchCL::COUNT);
|
||||
m_search->execute( *m_sortDataBuffer, nContacts, *countsNative, N_SPLIT*N_SPLIT, b3BoundSearchCL::COUNT);
|
||||
|
||||
m_scan->execute( *countsNative, *offsetsNative, N_SPLIT*N_SPLIT );
|
||||
}
|
||||
|
||||
{ // 5. sort constraints by cellIdx
|
||||
// todo. preallocate this
|
||||
// btAssert( contactsIn->getType() == TYPE_HOST );
|
||||
// btOpenCLArray<b3Contact4>* out = BufferUtils::map<TYPE_CL, false>( data->m_device, contactsIn ); // copying contacts to this buffer
|
||||
// b3Assert( contactsIn->getType() == TYPE_HOST );
|
||||
// b3OpenCLArray<b3Contact4>* out = BufferUtils::map<TYPE_CL, false>( data->m_device, contactsIn ); // copying contacts to this buffer
|
||||
|
||||
{
|
||||
|
||||
|
||||
btInt4 cdata; cdata.x = nContacts;
|
||||
btBufferInfoCL bInfo[] = { btBufferInfoCL( contactsIn->getBufferCL() ), btBufferInfoCL( m_contactBuffer->getBufferCL() ), btBufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
|
||||
btLauncherCL launcher( m_queue, m_reorderContactKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
|
||||
b3Int4 cdata; cdata.x = nContacts;
|
||||
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( contactsIn->getBufferCL() ), b3BufferInfoCL( m_contactBuffer->getBufferCL() ), b3BufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
|
||||
b3LauncherCL launcher( m_queue, m_reorderContactKernel );
|
||||
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
|
||||
launcher.setConst( cdata );
|
||||
launcher.launch1D( nContacts, 64 );
|
||||
}
|
||||
@ -834,14 +834,14 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
|
||||
*/
|
||||
|
||||
void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* nNative, btOpenCLArray<unsigned int>* offsetsNative, int staticIdx )
|
||||
void b3Solver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* nNative, b3OpenCLArray<unsigned int>* offsetsNative, int staticIdx )
|
||||
{
|
||||
|
||||
int numWorkItems = 64*N_SPLIT*N_SPLIT;
|
||||
{
|
||||
BT_PROFILE("batch generation");
|
||||
B3_PROFILE("batch generation");
|
||||
|
||||
btInt4 cdata;
|
||||
b3Int4 cdata;
|
||||
cdata.x = nContacts;
|
||||
cdata.y = 0;
|
||||
cdata.z = staticIdx;
|
||||
@ -849,7 +849,7 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
|
||||
|
||||
#ifdef BATCH_DEBUG
|
||||
SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems];
|
||||
adl::btOpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
|
||||
adl::b3OpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
|
||||
memset(debugInfo,0,sizeof(SolverDebugInfo)*numWorkItems);
|
||||
gpuDebugInfo.write(debugInfo,numWorkItems);
|
||||
#endif
|
||||
@ -857,13 +857,13 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
|
||||
|
||||
|
||||
|
||||
btBufferInfoCL bInfo[] = {
|
||||
btBufferInfoCL( contacts->getBufferCL() ),
|
||||
btBufferInfoCL( m_contactBuffer2->getBufferCL()),
|
||||
btBufferInfoCL( nNative->getBufferCL() ),
|
||||
btBufferInfoCL( offsetsNative->getBufferCL() ),
|
||||
b3BufferInfoCL bInfo[] = {
|
||||
b3BufferInfoCL( contacts->getBufferCL() ),
|
||||
b3BufferInfoCL( m_contactBuffer2->getBufferCL()),
|
||||
b3BufferInfoCL( nNative->getBufferCL() ),
|
||||
b3BufferInfoCL( offsetsNative->getBufferCL() ),
|
||||
#ifdef BATCH_DEBUG
|
||||
, btBufferInfoCL(&gpuDebugInfo)
|
||||
, b3BufferInfoCL(&gpuDebugInfo)
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -871,11 +871,11 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
|
||||
|
||||
|
||||
{
|
||||
BT_PROFILE("batchingKernel");
|
||||
//btLauncherCL launcher( m_queue, m_batchingKernel);
|
||||
B3_PROFILE("batchingKernel");
|
||||
//b3LauncherCL launcher( m_queue, m_batchingKernel);
|
||||
cl_kernel k = useNewBatchingKernel ? m_batchingKernelNew : m_batchingKernel;
|
||||
|
||||
btLauncherCL launcher( m_queue, k);
|
||||
b3LauncherCL launcher( m_queue, k);
|
||||
if (!useNewBatchingKernel )
|
||||
{
|
||||
launcher.setBuffer( contacts->getBufferCL() );
|
||||
@ -927,7 +927,7 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
|
||||
}
|
||||
|
||||
// copy buffer to buffer
|
||||
//btAssert(m_contactBuffer->size()==nContacts);
|
||||
//b3Assert(m_contactBuffer->size()==nContacts);
|
||||
//contacts->copyFromOpenCLArray( *m_contactBuffer);
|
||||
//clFinish(m_queue);//needed?
|
||||
|
||||
|
@ -17,20 +17,20 @@ subject to the following restrictions:
|
||||
#ifndef __ADL_SOLVER_H
|
||||
#define __ADL_SOLVER_H
|
||||
|
||||
#include "../../parallel_primitives/host/btOpenCLArray.h"
|
||||
#include "../../parallel_primitives/host/b3OpenCLArray.h"
|
||||
#include "../host/b3GpuConstraint4.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
|
||||
|
||||
#include "../host/b3GpuConstraint4.h"
|
||||
#include "../../parallel_primitives/host/btPrefixScanCL.h"
|
||||
#include "../../parallel_primitives/host/btRadixSort32CL.h"
|
||||
#include "../../parallel_primitives/host/btBoundSearchCL.h"
|
||||
#include "../../parallel_primitives/host/b3PrefixScanCL.h"
|
||||
#include "../../parallel_primitives/host/b3RadixSort32CL.h"
|
||||
#include "../../parallel_primitives/host/b3BoundSearchCL.h"
|
||||
|
||||
#include "../../basic_initialize/b3OpenCLUtils.h"
|
||||
|
||||
|
||||
#define BTNEXTMULTIPLEOF(num, alignment) (((num)/(alignment) + (((num)%(alignment)==0)?0:1))*(alignment))
|
||||
#define B3NEXTMULTIPLEOF(num, alignment) (((num)/(alignment) + (((num)%(alignment)==0)?0:1))*(alignment))
|
||||
|
||||
class b3SolverBase
|
||||
{
|
||||
@ -69,8 +69,8 @@ class b3Solver : public b3SolverBase
|
||||
cl_command_queue m_queue;
|
||||
|
||||
|
||||
btOpenCLArray<unsigned int>* m_numConstraints;
|
||||
btOpenCLArray<unsigned int>* m_offsets;
|
||||
b3OpenCLArray<unsigned int>* m_numConstraints;
|
||||
b3OpenCLArray<unsigned int>* m_offsets;
|
||||
|
||||
|
||||
int m_nIterations;
|
||||
@ -83,12 +83,12 @@ class b3Solver : public b3SolverBase
|
||||
cl_kernel m_reorderContactKernel;
|
||||
cl_kernel m_copyConstraintKernel;
|
||||
|
||||
class btRadixSort32CL* m_sort32;
|
||||
class btBoundSearchCL* m_search;
|
||||
class btPrefixScanCL* m_scan;
|
||||
class b3RadixSort32CL* m_sort32;
|
||||
class b3BoundSearchCL* m_search;
|
||||
class b3PrefixScanCL* m_scan;
|
||||
|
||||
btOpenCLArray<btSortData>* m_sortDataBuffer;
|
||||
btOpenCLArray<b3Contact4>* m_contactBuffer2;
|
||||
b3OpenCLArray<b3SortData>* m_sortDataBuffer;
|
||||
b3OpenCLArray<b3Contact4>* m_contactBuffer2;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -102,19 +102,19 @@ class b3Solver : public b3SolverBase
|
||||
|
||||
virtual ~b3Solver();
|
||||
|
||||
void solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* inertiaBuf,
|
||||
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
|
||||
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* inertiaBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
|
||||
|
||||
void solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBuf, btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
|
||||
void solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
|
||||
|
||||
|
||||
void convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const btOpenCLArray<btInertiaCL>* shapeBuf,
|
||||
btOpenCLArray<b3Contact4>* contactsIn, btOpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
void convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
|
||||
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
|
||||
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
|
||||
int nContacts, const ConstraintCfg& cfg );
|
||||
|
||||
void batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* n, btOpenCLArray<unsigned int>* offsets, int staticIdx );
|
||||
void batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* n, b3OpenCLArray<unsigned int>* offsets, int staticIdx );
|
||||
|
||||
};
|
||||
|
||||
|
@ -210,7 +210,7 @@ static const char* batchingKernelsNewCL= \
|
||||
"\n"
|
||||
" if (i!=numValidConstraints)\n"
|
||||
" {\n"
|
||||
" //btSwap(cs[i],cs[numValidConstraints]);\n"
|
||||
" //b3Swap(cs[i],cs[numValidConstraints]);\n"
|
||||
" \n"
|
||||
" Contact4 tmp = cs[i];\n"
|
||||
" cs[i] = cs[numValidConstraints];\n"
|
||||
|
@ -47,7 +47,7 @@ static const char* integrateKernelCL= \
|
||||
" integrateTransformsKernel( __global Body* bodies,const int numNodes, float timeStep, float angularDamping, float4 gravityAcceleration)\n"
|
||||
"{\n"
|
||||
" int nodeID = get_global_id(0);\n"
|
||||
" float BT_GPU_ANGULAR_MOTION_THRESHOLD = (0.25f * 3.14159254f);\n"
|
||||
" float B3_GPU_ANGULAR_MOTION_THRESHOLD = (0.25f * 3.14159254f);\n"
|
||||
" if( nodeID < numNodes && (bodies[nodeID].m_invMass != 0.f))\n"
|
||||
" {\n"
|
||||
" //angular velocity\n"
|
||||
@ -61,9 +61,9 @@ static const char* integrateKernelCL= \
|
||||
" float4 angvel = bodies[nodeID].m_angVel;\n"
|
||||
" float fAngle = native_sqrt(dot(angvel, angvel));\n"
|
||||
" //limit the angular motion\n"
|
||||
" if(fAngle*timeStep > BT_GPU_ANGULAR_MOTION_THRESHOLD)\n"
|
||||
" if(fAngle*timeStep > B3_GPU_ANGULAR_MOTION_THRESHOLD)\n"
|
||||
" {\n"
|
||||
" fAngle = BT_GPU_ANGULAR_MOTION_THRESHOLD / timeStep;\n"
|
||||
" fAngle = B3_GPU_ANGULAR_MOTION_THRESHOLD / timeStep;\n"
|
||||
" }\n"
|
||||
" if(fAngle < 0.001f)\n"
|
||||
" {\n"
|
||||
|
@ -313,8 +313,8 @@ static const char* solveContactCL= \
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void btPlaneSpace1 (const float4* n, float4* p, float4* q);\n"
|
||||
" void btPlaneSpace1 (const float4* n, float4* p, float4* q)\n"
|
||||
"void b3PlaneSpace1 (const float4* n, float4* p, float4* q);\n"
|
||||
" void b3PlaneSpace1 (const float4* n, float4* p, float4* q)\n"
|
||||
"{\n"
|
||||
" if (fabs(n[0].z) > 0.70710678f) {\n"
|
||||
" // choose p in y-z plane\n"
|
||||
|
@ -265,8 +265,8 @@ static const char* solveFrictionCL= \
|
||||
" float jmj3 = dot3F4(mtMul3(angular1,*invInertia1), angular1);\n"
|
||||
" return -1.f/(jmj0+jmj1+jmj2+jmj3);\n"
|
||||
"}\n"
|
||||
"void btPlaneSpace1 (const float4* n, float4* p, float4* q);\n"
|
||||
" void btPlaneSpace1 (const float4* n, float4* p, float4* q)\n"
|
||||
"void b3PlaneSpace1 (const float4* n, float4* p, float4* q);\n"
|
||||
" void b3PlaneSpace1 (const float4* n, float4* p, float4* q)\n"
|
||||
"{\n"
|
||||
" if (fabs(n[0].z) > 0.70710678f) {\n"
|
||||
" // choose p in y-z plane\n"
|
||||
@ -347,7 +347,7 @@ static const char* solveFrictionCL= \
|
||||
" float4 n = -cs->m_linear;\n"
|
||||
" \n"
|
||||
" float4 tangent[2];\n"
|
||||
" btPlaneSpace1(&n,&tangent[0],&tangent[1]);\n"
|
||||
" b3PlaneSpace1(&n,&tangent[0],&tangent[1]);\n"
|
||||
" float4 angular0, angular1, linear;\n"
|
||||
" float4 r0 = center - posA;\n"
|
||||
" float4 r1 = center - posB;\n"
|
||||
|
@ -489,8 +489,8 @@ static const char* solverSetupCL= \
|
||||
"} ConstBufferSSD;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"void btPlaneSpace1 (float4 n, float4* p, float4* q);\n"
|
||||
" void btPlaneSpace1 (float4 n, float4* p, float4* q)\n"
|
||||
"void b3PlaneSpace1 (float4 n, float4* p, float4* q);\n"
|
||||
" void b3PlaneSpace1 (float4 n, float4* p, float4* q)\n"
|
||||
"{\n"
|
||||
" if (fabs(n.z) > 0.70710678f) {\n"
|
||||
" // choose p in y-z plane\n"
|
||||
@ -577,7 +577,7 @@ static const char* solverSetupCL= \
|
||||
" center /= (float)src->m_worldNormal.w;\n"
|
||||
"\n"
|
||||
" float4 tangent[2];\n"
|
||||
" btPlaneSpace1(src->m_worldNormal,&tangent[0],&tangent[1]);\n"
|
||||
" b3PlaneSpace1(src->m_worldNormal,&tangent[0],&tangent[1]);\n"
|
||||
" \n"
|
||||
" float4 r[2];\n"
|
||||
" r[0] = center - posA;\n"
|
||||
|
@ -488,8 +488,8 @@ static const char* solverUtilsCL= \
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"void btPlaneSpace1 (float4 n, float4* p, float4* q);\n"
|
||||
" void btPlaneSpace1 (float4 n, float4* p, float4* q)\n"
|
||||
"void b3PlaneSpace1 (float4 n, float4* p, float4* q);\n"
|
||||
" void b3PlaneSpace1 (float4 n, float4* p, float4* q)\n"
|
||||
"{\n"
|
||||
" if (fabs(n.z) > 0.70710678f) {\n"
|
||||
" // choose p in y-z plane\n"
|
||||
@ -739,7 +739,7 @@ static const char* solverUtilsCL= \
|
||||
" float4 n = -cs->m_linear;\n"
|
||||
" \n"
|
||||
" float4 tangent[2];\n"
|
||||
" btPlaneSpace1(n,&tangent[0],&tangent[1]);\n"
|
||||
" b3PlaneSpace1(n,&tangent[0],&tangent[1]);\n"
|
||||
" float4 angular0, angular1, linear;\n"
|
||||
" float4 r0 = center - posA;\n"
|
||||
" float4 r1 = center - posB;\n"
|
||||
@ -896,7 +896,7 @@ static const char* solverUtilsCL= \
|
||||
" center /= (float)src->m_worldNormal.w;\n"
|
||||
"\n"
|
||||
" float4 tangent[2];\n"
|
||||
" btPlaneSpace1(src->m_worldNormal,&tangent[0],&tangent[1]);\n"
|
||||
" b3PlaneSpace1(src->m_worldNormal,&tangent[0],&tangent[1]);\n"
|
||||
" \n"
|
||||
" float4 r[2];\n"
|
||||
" r[0] = center - posA;\n"
|
||||
|
@ -120,7 +120,7 @@ static const char* updateAabbsKernelCL= \
|
||||
" float fy;\n"
|
||||
" float fz;\n"
|
||||
" int uw;\n"
|
||||
"} btAABBCL;\n"
|
||||
"} b3AABBCL;\n"
|
||||
"\n"
|
||||
"__inline\n"
|
||||
"Matrix3x3 mtTranspose(Matrix3x3 m)\n"
|
||||
@ -156,7 +156,7 @@ static const char* updateAabbsKernelCL= \
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"__kernel void initializeGpuAabbsFull( const int numNodes, __global Body* gBodies,__global Collidable* collidables, __global btAABBCL* plocalShapeAABB, __global btAABBCL* pAABB)\n"
|
||||
"__kernel void initializeGpuAabbsFull( const int numNodes, __global Body* gBodies,__global Collidable* collidables, __global b3AABBCL* plocalShapeAABB, __global b3AABBCL* pAABB)\n"
|
||||
"{\n"
|
||||
" int nodeID = get_global_id(0);\n"
|
||||
" \n"
|
||||
@ -171,8 +171,8 @@ static const char* updateAabbsKernelCL= \
|
||||
" \n"
|
||||
" if (shapeIndex>=0)\n"
|
||||
" {\n"
|
||||
" btAABBCL minAabb = plocalShapeAABB[collidableIndex*2];\n"
|
||||
" btAABBCL maxAabb = plocalShapeAABB[collidableIndex*2+1];\n"
|
||||
" b3AABBCL minAabb = plocalShapeAABB[collidableIndex*2];\n"
|
||||
" b3AABBCL maxAabb = plocalShapeAABB[collidableIndex*2+1];\n"
|
||||
" \n"
|
||||
" float4 halfExtents = ((float4)(maxAabb.fx - minAabb.fx,maxAabb.fy - minAabb.fy,maxAabb.fz - minAabb.fz,0.f))*0.5f;\n"
|
||||
" float4 localCenter = ((float4)(maxAabb.fx + minAabb.fx,maxAabb.fy + minAabb.fy,maxAabb.fz + minAabb.fz,0.f))*0.5f;\n"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user