From 7366e262fd73f82f5adc5b535a2805bb5938834b Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Sun, 28 Apr 2013 23:11:10 -0700 Subject: [PATCH] bt -> b3 and BT -> B3 rename for content and filenames --- btgui/GwenOpenGLTest/OpenGLSample.cpp | 8 +- btgui/OpenGLTrueTypeFont/main.cpp | 128 ++-- btgui/OpenGLTrueTypeFont/stb_image_write.h | 2 +- btgui/OpenGLWindow/GLInstancingRenderer.cpp | 70 +-- btgui/OpenGLWindow/GLInstancingRenderer.h | 16 +- btgui/OpenGLWindow/MacOpenGLWindow.h | 32 +- btgui/OpenGLWindow/Win32InternalWindowData.h | 10 +- btgui/OpenGLWindow/Win32OpenGLWindow.cpp | 2 +- btgui/OpenGLWindow/Win32OpenGLWindow.h | 4 +- btgui/OpenGLWindow/Win32Window.cpp | 56 +- btgui/OpenGLWindow/Win32Window.h | 20 +- btgui/OpenGLWindow/X11OpenGLWindow.cpp | 56 +- btgui/OpenGLWindow/X11OpenGLWindow.h | 20 +- btgui/OpenGLWindow/b3gWindowInterface.h | 109 ++++ btgui/OpenGLWindow/btgWindowInterface.h | 109 ---- btgui/OpenGLWindow/main.cpp | 22 +- btgui/OpenGLWindow/renderscene.cpp | 2 +- demo/donttouch/Bullet2GpuDemo.cpp | 18 +- demo/donttouch/Bullet2GpuDemo.h | 2 +- demo/donttouch/GpuDemo.cpp | 146 ++--- demo/donttouch/GpuDemo.h | 20 +- demo/donttouch/OpenGL3CoreRenderer.cpp | 68 +-- demo/donttouch/OpenGL3CoreRenderer.h | 4 +- demo/donttouch/b3CpuDynamicsWorld.cpp | 17 + demo/donttouch/b3CpuDynamicsWorld.h | 24 + ...namicsWorld.cpp => b3GpuDynamicsWorld.cpp} | 82 +-- demo/donttouch/b3GpuDynamicsWorld.h | 109 ++++ demo/donttouch/btCpuDynamicsWorld.cpp | 17 - demo/donttouch/btCpuDynamicsWorld.h | 24 - demo/donttouch/btGpuDynamicsWorld.h | 109 ---- demo/gpu_initialize/main.cpp | 22 +- demo/gpudemo/GpuDemo.cpp | 6 +- demo/gpudemo/GpuDemo.h | 2 +- demo/gpudemo/ParticleDemo.cpp | 70 +-- demo/gpudemo/broadphase/PairBench.cpp | 40 +- demo/gpudemo/broadphase/PairBench.h | 2 +- demo/gpudemo/gwenUserInterface.cpp | 8 +- demo/gpudemo/gwenUserInterface.h | 8 +- demo/gpudemo/main_opengl3core.cpp | 40 +- demo/gpudemo/premake4.lua | 16 +- demo/gpudemo/rigidbody/Bullet2FileDemo.cpp | 4 +- demo/gpudemo/rigidbody/Bullet2FileDemo.h | 2 +- .../gpudemo/rigidbody/BulletDataExtractor.cpp | 80 +-- demo/gpudemo/rigidbody/BulletDataExtractor.h | 18 +- demo/gpudemo/rigidbody/ConcaveScene.cpp | 84 +-- demo/gpudemo/rigidbody/GpuCompoundScene.cpp | 44 +- demo/gpudemo/rigidbody/GpuConvexScene.cpp | 26 +- demo/gpudemo/rigidbody/GpuRigidBodyDemo.cpp | 30 +- demo/gpudemo/rigidbody/GpuRigidBodyDemo.h | 2 +- .../rigidbody/GpuRigidBodyDemoInternalData.h | 4 +- demo/gpudemo/rigidbody/GpuSphereScene.cpp | 40 +- opencl/basic_initialize/b3OpenCLInclude.h | 6 +- opencl/basic_initialize/b3OpenCLUtils.cpp | 76 +-- opencl/basic_initialize/b3OpenCLUtils.h | 74 +-- opencl/basic_initialize/main.cpp | 6 +- .../host/b3GpuSapBroadphase.cpp | 104 ++-- .../gpu_broadphase/host/b3GpuSapBroadphase.h | 28 +- opencl/gpu_broadphase/host/b3SapAabb.h | 6 +- .../gpu_broadphase/kernels/sapFastKernels.h | 12 +- opencl/gpu_broadphase/kernels/sapKernels.h | 32 +- opencl/gpu_broadphase/test/main.cpp | 10 +- opencl/gpu_narrowphase/host/b3Collidable.h | 14 +- .../host/b3ConvexHullContact.cpp | 564 +++++++++--------- .../host/b3ConvexHullContact.h | 50 +- .../host/b3ConvexPolyhedronCL.h | 6 +- .../gpu_narrowphase/host/b3ConvexUtility.cpp | 52 +- opencl/gpu_narrowphase/host/b3ConvexUtility.h | 6 +- .../gpu_narrowphase/host/b3OptimizedBvh.cpp | 60 +- opencl/gpu_narrowphase/host/b3OptimizedBvh.h | 8 +- .../gpu_narrowphase/host/b3QuantizedBvh.cpp | 268 ++++----- opencl/gpu_narrowphase/host/b3QuantizedBvh.h | 158 ++--- .../host/b3StridingMeshInterface.cpp | 18 +- .../host/b3StridingMeshInterface.h | 46 +- .../host/b3TriangleCallback.cpp | 2 +- .../gpu_narrowphase/host/b3TriangleCallback.h | 12 +- .../host/b3TriangleIndexVertexArray.cpp | 8 +- .../host/b3TriangleIndexVertexArray.h | 26 +- opencl/gpu_narrowphase/kernels/bvhTraversal.h | 44 +- .../kernels/primitiveContacts.h | 48 +- .../kernels/satClipHullContacts.h | 62 +- opencl/gpu_narrowphase/kernels/satKernels.h | 64 +- opencl/gpu_narrowphase/test/main.cpp | 10 +- opencl/gpu_rigidbody/host/b3Config.h | 6 +- .../host/b3GpuBatchingPgsSolver.cpp | 318 +++++----- .../host/b3GpuBatchingPgsSolver.h | 16 +- opencl/gpu_rigidbody/host/b3GpuConstraint4.h | 8 +- .../gpu_rigidbody/host/b3GpuNarrowPhase.cpp | 136 ++--- opencl/gpu_rigidbody/host/b3GpuNarrowPhase.h | 10 +- .../host/b3GpuRigidBodyPipeline.cpp | 60 +- .../host/b3GpuRigidBodyPipeline.h | 8 +- .../host/b3GpuRigidBodyPipelineInternalData.h | 14 +- opencl/gpu_rigidbody/host/b3Solver.cpp | 246 ++++---- opencl/gpu_rigidbody/host/b3Solver.h | 40 +- .../kernels/batchingKernelsNew.h | 2 +- .../gpu_rigidbody/kernels/integrateKernel.h | 6 +- opencl/gpu_rigidbody/kernels/solveContact.h | 4 +- opencl/gpu_rigidbody/kernels/solveFriction.h | 6 +- opencl/gpu_rigidbody/kernels/solverSetup.h | 6 +- opencl/gpu_rigidbody/kernels/solverUtils.h | 8 +- .../gpu_rigidbody/kernels/updateAabbsKernel.h | 8 +- opencl/lds_bank_conflict/main.cpp | 26 +- .../benchmark/premake4.lua | 6 +- .../benchmark/test_large_problem_sorting.cpp | 30 +- ...tBoundSearchCL.cpp => b3BoundSearchCL.cpp} | 72 +-- .../{btBoundSearchCL.h => b3BoundSearchCL.h} | 30 +- .../parallel_primitives/host/b3BufferInfoCL.h | 19 + .../host/{btFillCL.cpp => b3FillCL.cpp} | 56 +- opencl/parallel_primitives/host/b3FillCL.h | 63 ++ .../parallel_primitives/host/b3Int2.h | 8 +- .../host/{btInt4.h => b3Int4.h} | 22 +- .../host/{btLauncherCL.h => b3LauncherCL.h} | 82 +-- .../host/{btOpenCLArray.h => b3OpenCLArray.h} | 60 +- ...{btPrefixScanCL.cpp => b3PrefixScanCL.cpp} | 58 +- .../{btPrefixScanCL.h => b3PrefixScanCL.h} | 20 +- ...tRadixSort32CL.cpp => b3RadixSort32CL.cpp} | 174 +++--- .../host/b3RadixSort32CL.h | 85 +++ .../parallel_primitives/host/btBufferInfoCL.h | 19 - opencl/parallel_primitives/host/btFillCL.h | 63 -- .../host/btRadixSort32CL.h | 85 --- opencl/parallel_primitives/test/main.cpp | 64 +- opencl/parallel_primitives/test/premake4.lua | 16 +- opencl/reduce/main.cpp | 12 +- opencl/vector_add/main.cpp | 4 +- opencl/vector_add_simplified/main.cpp | 12 +- .../b3BroadphaseCallback.h | 12 +- .../BroadPhaseCollision/b3DynamicBvh.cpp | 316 +++++----- .../BroadPhaseCollision/b3DynamicBvh.h | 304 +++++----- .../b3DynamicBvhBroadphase.cpp | 192 +++--- .../b3DynamicBvhBroadphase.h | 70 +-- .../BroadPhaseCollision/b3OverlappingPair.h | 16 +- .../b3OverlappingPairCache.cpp | 150 ++--- .../b3OverlappingPairCache.h | 190 +++--- .../NarrowPhaseCollision/b3Contact4.h | 12 +- .../NarrowPhaseCollision/b3RigidBodyCL.h | 10 +- src/Bullet3Common/b3AlignedAllocator.cpp | 60 +- src/Bullet3Common/b3AlignedAllocator.h | 52 +- src/Bullet3Common/b3AlignedObjectArray.h | 68 +-- src/Bullet3Common/b3HashMap.h | 74 +-- .../btInt2.h => src/Bullet3Common/b3Int2.h | 8 +- src/Bullet3Common/b3Matrix3x3.h | 338 +++++------ src/Bullet3Common/b3MinMax.h | 18 +- src/Bullet3Common/b3PoolAllocator.h | 10 +- src/Bullet3Common/b3QuadWord.h | 46 +- src/Bullet3Common/b3Quaternion.h | 228 +++---- src/Bullet3Common/b3Quickprof.cpp | 42 +- src/Bullet3Common/b3Quickprof.h | 34 +- src/Bullet3Common/b3Random.h | 6 +- src/Bullet3Common/b3Scalar.h | 340 +++++------ src/Bullet3Common/b3StackAlloc.h | 34 +- src/Bullet3Common/b3Transform.h | 46 +- src/Bullet3Common/b3TransformUtil.h | 22 +- src/Bullet3Common/b3Vector3.cpp | 32 +- src/Bullet3Common/b3Vector3.h | 402 ++++++------- .../ConstraintSolver/b3ContactSolverInfo.h | 18 +- .../ConstraintSolver/b3PgsJacobiSolver.cpp | 164 ++--- .../ConstraintSolver/b3PgsJacobiSolver.h | 62 +- .../b3Point2PointConstraint.cpp | 46 +- .../b3Point2PointConstraint.h | 68 +-- .../ConstraintSolver/b3SolverBody.h | 40 +- .../ConstraintSolver/b3SolverConstraint.h | 24 +- .../ConstraintSolver/b3TypedConstraint.cpp | 30 +- .../ConstraintSolver/b3TypedConstraint.h | 80 +-- src/Bullet3Geometry/b3AabbUtil.h | 42 +- src/Bullet3Geometry/b3ConvexHullComputer.cpp | 138 ++--- src/Bullet3Geometry/b3ConvexHullComputer.h | 6 +- src/Bullet3Geometry/b3GeometryUtil.cpp | 6 +- src/Bullet3Geometry/b3GeometryUtil.h | 6 +- .../b3GrahamScan2dConvexHull.h | 12 +- .../Bullet2FileLoader/autogenerated/bullet2.h | 518 ++++++++-------- .../{btBulletFile.cpp => b3BulletFile.cpp} | 92 +-- .../{btBulletFile.h => b3BulletFile.h} | 18 +- .../{btSerializer.cpp => b3Serializer.cpp} | 0 .../{btSerializer.h => b3Serializer.h} | 180 +++--- .../Bullet2FileLoader/bCommon.h | 2 +- .../Bullet2FileLoader/bDNA.cpp | 4 +- src/Bullet3Serialize/Bullet2FileLoader/bDNA.h | 4 +- .../Bullet2FileLoader/bFile.cpp | 20 +- .../Bullet2FileLoader/bFile.h | 2 +- 178 files changed, 5218 insertions(+), 5218 deletions(-) create mode 100644 btgui/OpenGLWindow/b3gWindowInterface.h delete mode 100644 btgui/OpenGLWindow/btgWindowInterface.h create mode 100644 demo/donttouch/b3CpuDynamicsWorld.cpp create mode 100644 demo/donttouch/b3CpuDynamicsWorld.h rename demo/donttouch/{btGpuDynamicsWorld.cpp => b3GpuDynamicsWorld.cpp} (77%) create mode 100644 demo/donttouch/b3GpuDynamicsWorld.h delete mode 100644 demo/donttouch/btCpuDynamicsWorld.cpp delete mode 100644 demo/donttouch/btCpuDynamicsWorld.h delete mode 100644 demo/donttouch/btGpuDynamicsWorld.h rename opencl/parallel_primitives/host/{btBoundSearchCL.cpp => b3BoundSearchCL.cpp} (69%) rename opencl/parallel_primitives/host/{btBoundSearchCL.h => b3BoundSearchCL.h} (73%) create mode 100644 opencl/parallel_primitives/host/b3BufferInfoCL.h rename opencl/parallel_primitives/host/{btFillCL.cpp => b3FillCL.cpp} (61%) create mode 100644 opencl/parallel_primitives/host/b3FillCL.h rename src/Bullet3Common/btInt2.h => opencl/parallel_primitives/host/b3Int2.h (72%) rename opencl/parallel_primitives/host/{btInt4.h => b3Int4.h} (53%) rename opencl/parallel_primitives/host/{btLauncherCL.h => b3LauncherCL.h} (83%) rename opencl/parallel_primitives/host/{btOpenCLArray.h => b3OpenCLArray.h} (82%) rename opencl/parallel_primitives/host/{btPrefixScanCL.cpp => b3PrefixScanCL.cpp} (56%) rename opencl/parallel_primitives/host/{btPrefixScanCL.h => b3PrefixScanCL.h} (55%) rename opencl/parallel_primitives/host/{btRadixSort32CL.cpp => b3RadixSort32CL.cpp} (77%) create mode 100644 opencl/parallel_primitives/host/b3RadixSort32CL.h delete mode 100644 opencl/parallel_primitives/host/btBufferInfoCL.h delete mode 100644 opencl/parallel_primitives/host/btFillCL.h delete mode 100644 opencl/parallel_primitives/host/btRadixSort32CL.h rename opencl/parallel_primitives/host/btInt2.h => src/Bullet3Common/b3Int2.h (72%) rename src/Bullet3Serialize/Bullet2FileLoader/{btBulletFile.cpp => b3BulletFile.cpp} (78%) rename src/Bullet3Serialize/Bullet2FileLoader/{btBulletFile.h => b3BulletFile.h} (86%) rename src/Bullet3Serialize/Bullet2FileLoader/{btSerializer.cpp => b3Serializer.cpp} (100%) rename src/Bullet3Serialize/Bullet2FileLoader/{btSerializer.h => b3Serializer.h} (70%) diff --git a/btgui/GwenOpenGLTest/OpenGLSample.cpp b/btgui/GwenOpenGLTest/OpenGLSample.cpp index 7a556e91e..1289ec995 100644 --- a/btgui/GwenOpenGLTest/OpenGLSample.cpp +++ b/btgui/GwenOpenGLTest/OpenGLSample.cpp @@ -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; diff --git a/btgui/OpenGLTrueTypeFont/main.cpp b/btgui/OpenGLTrueTypeFont/main.cpp index 545ccb266..984fed884 100644 --- a/btgui/OpenGLTrueTypeFont/main.cpp +++ b/btgui/OpenGLTrueTypeFont/main.cpp @@ -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); } diff --git a/btgui/OpenGLTrueTypeFont/stb_image_write.h b/btgui/OpenGLTrueTypeFont/stb_image_write.h index b9f7aaebc..41b703388 100644 --- a/btgui/OpenGLTrueTypeFont/stb_image_write.h +++ b/btgui/OpenGLTrueTypeFont/stb_image_write.h @@ -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; diff --git a/btgui/OpenGLWindow/GLInstancingRenderer.cpp b/btgui/OpenGLWindow/GLInstancingRenderer.cpp index 23ca672f9..500bdb06d 100644 --- a/btgui/OpenGLWindow/GLInstancingRenderer.cpp +++ b/btgui/OpenGLWindow/GLInstancingRenderer.cpp @@ -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;km_numGraphicsInstances; } @@ -581,7 +581,7 @@ void GLInstancingRenderer::writeTransforms() for (int k=0;km_numGraphicsInstances; } @@ -590,7 +590,7 @@ void GLInstancingRenderer::writeTransforms() for (int k=0;km_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;im_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); diff --git a/btgui/OpenGLWindow/GLInstancingRenderer.h b/btgui/OpenGLWindow/GLInstancingRenderer.h index e5f8040cd..1433b4bca 100644 --- a/btgui/OpenGLWindow/GLInstancingRenderer.h +++ b/btgui/OpenGLWindow/GLInstancingRenderer.h @@ -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 m_graphicsInstances; + b3AlignedObjectArray 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); diff --git a/btgui/OpenGLWindow/MacOpenGLWindow.h b/btgui/OpenGLWindow/MacOpenGLWindow.h index b2c23a1ed..5fd0a28dc 100644 --- a/btgui/OpenGLWindow/MacOpenGLWindow.h +++ b/btgui/OpenGLWindow/MacOpenGLWindow.h @@ -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); diff --git a/btgui/OpenGLWindow/Win32InternalWindowData.h b/btgui/OpenGLWindow/Win32InternalWindowData.h index 374b1b92e..9f4b2f376 100644 --- a/btgui/OpenGLWindow/Win32InternalWindowData.h +++ b/btgui/OpenGLWindow/Win32InternalWindowData.h @@ -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; diff --git a/btgui/OpenGLWindow/Win32OpenGLWindow.cpp b/btgui/OpenGLWindow/Win32OpenGLWindow.cpp index 1aa9d16ef..2b70a29b4 100644 --- a/btgui/OpenGLWindow/Win32OpenGLWindow.cpp +++ b/btgui/OpenGLWindow/Win32OpenGLWindow.cpp @@ -77,7 +77,7 @@ void Win32OpenGLWindow::disableOpenGL() -void Win32OpenGLWindow::createWindow(const btgWindowConstructionInfo& ci) +void Win32OpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci) { Win32Window::createWindow(ci); diff --git a/btgui/OpenGLWindow/Win32OpenGLWindow.h b/btgui/OpenGLWindow/Win32OpenGLWindow.h index 613ced9bd..68b710da4 100644 --- a/btgui/OpenGLWindow/Win32OpenGLWindow.h +++ b/btgui/OpenGLWindow/Win32OpenGLWindow.h @@ -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(); diff --git a/btgui/OpenGLWindow/Win32Window.cpp b/btgui/OpenGLWindow/Win32Window.cpp index 017a70a67..c3c9ca223 100644 --- a/btgui/OpenGLWindow/Win32Window.cpp +++ b/btgui/OpenGLWindow/Win32Window.cpp @@ -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; } diff --git a/btgui/OpenGLWindow/Win32Window.h b/btgui/OpenGLWindow/Win32Window.h index 06ddf57b2..d5566b618 100644 --- a/btgui/OpenGLWindow/Win32Window.h +++ b/btgui/OpenGLWindow/Win32Window.h @@ -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); }; diff --git a/btgui/OpenGLWindow/X11OpenGLWindow.cpp b/btgui/OpenGLWindow/X11OpenGLWindow.cpp index 89c8313e2..dac32cfd2 100644 --- a/btgui/OpenGLWindow/X11OpenGLWindow.cpp +++ b/btgui/OpenGLWindow/X11OpenGLWindow.cpp @@ -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; diff --git a/btgui/OpenGLWindow/X11OpenGLWindow.h b/btgui/OpenGLWindow/X11OpenGLWindow.h index 5c0eaa9a4..5e6caac77 100644 --- a/btgui/OpenGLWindow/X11OpenGLWindow.h +++ b/btgui/OpenGLWindow/X11OpenGLWindow.h @@ -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); diff --git a/btgui/OpenGLWindow/b3gWindowInterface.h b/btgui/OpenGLWindow/b3gWindowInterface.h new file mode 100644 index 000000000..3402c8168 --- /dev/null +++ b/btgui/OpenGLWindow/b3gWindowInterface.h @@ -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 \ No newline at end of file diff --git a/btgui/OpenGLWindow/btgWindowInterface.h b/btgui/OpenGLWindow/btgWindowInterface.h deleted file mode 100644 index 3042faa19..000000000 --- a/btgui/OpenGLWindow/btgWindowInterface.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/btgui/OpenGLWindow/main.cpp b/btgui/OpenGLWindow/main.cpp index 4730b46b5..cff1bcd32 100644 --- a/btgui/OpenGLWindow/main.cpp +++ b/btgui/OpenGLWindow/main.cpp @@ -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(); diff --git a/btgui/OpenGLWindow/renderscene.cpp b/btgui/OpenGLWindow/renderscene.cpp index d8a1be081..820399556 100644 --- a/btgui/OpenGLWindow/renderscene.cpp +++ b/btgui/OpenGLWindow/renderscene.cpp @@ -46,7 +46,7 @@ struct GraphicsShape struct InstanceGroup { -// Bullet::btCollisionShapeData* m_shape; +// Bullet::b3CollisionShapeData* m_shape; int m_collisionShapeIndex; // b3AlignedObjectArray m_rigidBodies; diff --git a/demo/donttouch/Bullet2GpuDemo.cpp b/demo/donttouch/Bullet2GpuDemo.cpp index c2c054af8..2851d2c53 100644 --- a/demo/donttouch/Bullet2GpuDemo.cpp +++ b/demo/donttouch/Bullet2GpuDemo.cpp @@ -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); } diff --git a/demo/donttouch/Bullet2GpuDemo.h b/demo/donttouch/Bullet2GpuDemo.h index 7e9158cf2..bef549c97 100644 --- a/demo/donttouch/Bullet2GpuDemo.h +++ b/demo/donttouch/Bullet2GpuDemo.h @@ -7,7 +7,7 @@ class Bullet2GpuDemo : public GpuRigidBodyDemo { protected: - class btGpuDynamicsWorld* m_gpuDynamicsWorld; + class b3GpuDynamicsWorld* m_gpuDynamicsWorld; public: diff --git a/demo/donttouch/GpuDemo.cpp b/demo/donttouch/GpuDemo.cpp index 067d0cd72..08a2805db 100644 --- a/demo/donttouch/GpuDemo.cpp +++ b/demo/donttouch/GpuDemo.cpp @@ -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;jaddRigidBody(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 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;jaddRigidBody(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 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;jaddRigidBody(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; + b3AlignedObjectArray 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; } diff --git a/demo/donttouch/OpenGL3CoreRenderer.cpp b/demo/donttouch/OpenGL3CoreRenderer.cpp index b36038609..cd2274fcc 100644 --- a/demo/donttouch/OpenGL3CoreRenderer.cpp +++ b/demo/donttouch/OpenGL3CoreRenderer.cpp @@ -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* vertices = new b3AlignedObjectArray; @@ -71,7 +71,7 @@ GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilP b3AlignedObjectArray* indicesPtr = new b3AlignedObjectArray; for (int f=0;fm_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* vertexArray = new b3AlignedObjectArray; @@ -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;igetNumChildShapes();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* vertices = new b3AlignedObjectArray; @@ -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;igetWorldTransform().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 diff --git a/demo/donttouch/OpenGL3CoreRenderer.h b/demo/donttouch/OpenGL3CoreRenderer.h index bad474591..60a79e0c4 100644 --- a/demo/donttouch/OpenGL3CoreRenderer.h +++ b/demo/donttouch/OpenGL3CoreRenderer.h @@ -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() { diff --git a/demo/donttouch/b3CpuDynamicsWorld.cpp b/demo/donttouch/b3CpuDynamicsWorld.cpp new file mode 100644 index 000000000..5b9ea666a --- /dev/null +++ b/demo/donttouch/b3CpuDynamicsWorld.cpp @@ -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() +{ + +} diff --git a/demo/donttouch/b3CpuDynamicsWorld.h b/demo/donttouch/b3CpuDynamicsWorld.h new file mode 100644 index 000000000..8325da879 --- /dev/null +++ b/demo/donttouch/b3CpuDynamicsWorld.h @@ -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 diff --git a/demo/donttouch/btGpuDynamicsWorld.cpp b/demo/donttouch/b3GpuDynamicsWorld.cpp similarity index 77% rename from demo/donttouch/btGpuDynamicsWorld.cpp rename to demo/donttouch/b3GpuDynamicsWorld.cpp index 4042c9fe2..01428d7ab 100644 --- a/demo/donttouch/btGpuDynamicsWorld.cpp +++ b/demo/donttouch/b3GpuDynamicsWorld.cpp @@ -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;im_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 vertices; b3AlignedObjectArray 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 childShapes; + b3CompoundShape* compound = (b3CompoundShape*) colShape; + b3AlignedObjectArray childShapes; for (int i=0;igetNumChildShapes();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); } diff --git a/demo/donttouch/b3GpuDynamicsWorld.h b/demo/donttouch/b3GpuDynamicsWorld.h new file mode 100644 index 000000000..b4832b7a4 --- /dev/null +++ b/demo/donttouch/b3GpuDynamicsWorld.h @@ -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 m_uniqueShapes; + b3AlignedObjectArray 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& getCollisionObjectArray(); + + const b3AlignedObjectArray& 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 diff --git a/demo/donttouch/btCpuDynamicsWorld.cpp b/demo/donttouch/btCpuDynamicsWorld.cpp deleted file mode 100644 index 4af87c5d3..000000000 --- a/demo/donttouch/btCpuDynamicsWorld.cpp +++ /dev/null @@ -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() -{ - -} diff --git a/demo/donttouch/btCpuDynamicsWorld.h b/demo/donttouch/btCpuDynamicsWorld.h deleted file mode 100644 index 150ae65c1..000000000 --- a/demo/donttouch/btCpuDynamicsWorld.h +++ /dev/null @@ -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 diff --git a/demo/donttouch/btGpuDynamicsWorld.h b/demo/donttouch/btGpuDynamicsWorld.h deleted file mode 100644 index 2bb93ecc2..000000000 --- a/demo/donttouch/btGpuDynamicsWorld.h +++ /dev/null @@ -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 m_uniqueShapes; - b3AlignedObjectArray 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& getCollisionObjectArray(); - - const b3AlignedObjectArray& 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 diff --git a/demo/gpu_initialize/main.cpp b/demo/gpu_initialize/main.cpp index 12f64a2d4..d1de96c2f 100644 --- a/demo/gpu_initialize/main.cpp +++ b/demo/gpu_initialize/main.cpp @@ -12,7 +12,7 @@ #include "OpenGLWindow/GLInstancingRenderer.h" //#include "OpenGL3CoreRenderer.h" #include "Bullet3Common/b3Quickprof.h" -//#include "btGpuDynamicsWorld.h" +//#include "b3GpuDynamicsWorld.h" #include #include #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;iAddNode( 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(); } diff --git a/demo/gpudemo/GpuDemo.cpp b/demo/gpudemo/GpuDemo.cpp index 334109ec6..ee8ca45c2 100644 --- a/demo/gpudemo/GpuDemo.cpp +++ b/demo/gpudemo/GpuDemo.cpp @@ -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) diff --git a/demo/gpudemo/GpuDemo.h b/demo/gpudemo/GpuDemo.h index 2bfc81fd7..9e845a602 100644 --- a/demo/gpudemo/GpuDemo.h +++ b/demo/gpudemo/GpuDemo.h @@ -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() diff --git a/demo/gpudemo/ParticleDemo.cpp b/demo/gpudemo/ParticleDemo.cpp index a9e72db77..3d712a87f 100644 --- a/demo/gpudemo/ParticleDemo.cpp +++ b/demo/gpudemo/ParticleDemo.cpp @@ -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 m_velocitiesCPU; - btOpenCLArray* m_velocitiesGPU; + b3OpenCLArray* m_velocitiesGPU; - b3AlignedObjectArray m_simParamCPU; - btOpenCLArray* m_simParamGPU; + b3AlignedObjectArray m_simParamCPU; + b3OpenCLArray* 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(m_clData->m_clContext,m_clData->m_clQueue,numParticles); + m_data->m_velocitiesGPU = new b3OpenCLArray(m_clData->m_clContext,m_clData->m_clQueue,numParticles); m_data->m_velocitiesCPU.resize(numParticles); for (int i=0;im_velocitiesGPU->copyFromHost(m_data->m_velocitiesCPU); - m_data->m_simParamGPU = new btOpenCLArray(m_clData->m_clContext,m_clData->m_clQueue,1,false); + m_data->m_simParamGPU = new b3OpenCLArray(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; diff --git a/demo/gpudemo/broadphase/PairBench.cpp b/demo/gpudemo/broadphase/PairBench.cpp index 02dc1e4e9..adde27d19 100644 --- a/demo/gpudemo/broadphase/PairBench.cpp +++ b/demo/gpudemo/broadphase/PairBench.cpp @@ -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* m_instancePosOrnColor; - btOpenCLArray* m_bodyTimes; + b3OpenCLArray* m_instancePosOrnColor; + b3OpenCLArray* 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(m_clData->m_clContext,m_clData->m_clQueue); + m_data->m_instancePosOrnColor = new b3OpenCLArray(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(m_clData->m_clContext,m_clData->m_clQueue); + m_data->m_bodyTimes = new b3OpenCLArray(m_clData->m_clContext,m_clData->m_clQueue); m_data->m_bodyTimes ->resize(numObjects); b3AlignedObjectArray 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); diff --git a/demo/gpudemo/broadphase/PairBench.h b/demo/gpudemo/broadphase/PairBench.h index 5be869ae7..d4380a19e 100644 --- a/demo/gpudemo/broadphase/PairBench.h +++ b/demo/gpudemo/broadphase/PairBench.h @@ -7,7 +7,7 @@ class PairBench : public GpuDemo { class GLInstancingRenderer* m_instancingRenderer; - class btgWindowInterface* m_window; + class b3gWindowInterface* m_window; struct PairBenchInternalData* m_data; diff --git a/demo/gpudemo/gwenUserInterface.cpp b/demo/gpudemo/gwenUserInterface.cpp index 590965470..e8e7ae2f9 100644 --- a/demo/gpudemo/gwenUserInterface.cpp +++ b/demo/gpudemo/gwenUserInterface.cpp @@ -39,8 +39,8 @@ struct GwenInternalData Gwen::Controls::Label* m_leftStatusBar; b3AlignedObjectArray 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; } diff --git a/demo/gpudemo/gwenUserInterface.h b/demo/gpudemo/gwenUserInterface.h index edb8c9836..9a48ad5cf 100644 --- a/demo/gpudemo/gwenUserInterface.h +++ b/demo/gpudemo/gwenUserInterface.h @@ -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); diff --git a/demo/gpudemo/main_opengl3core.cpp b/demo/gpudemo/main_opengl3core.cpp index 3727e4118..b4ffe7b68 100644 --- a/demo/gpudemo/main_opengl3core.cpp +++ b/demo/gpudemo/main_opengl3core.cpp @@ -17,7 +17,7 @@ #include "OpenGLWindow/GLInstancingRenderer.h" //#include "OpenGL3CoreRenderer.h" #include "Bullet3Common/b3Quickprof.h" -//#include "btGpuDynamicsWorld.h" +//#include "b3GpuDynamicsWorld.h" #include #include #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 arr = demo->getDynamicsWorld()->getCollisionObjectArray(); - btCollisionObject** colObjArray = &arr[0]; + B3_PROFILE("renderPhysicsWorld"); + b3AlignedObjectArray 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"); } diff --git a/demo/gpudemo/premake4.lua b/demo/gpudemo/premake4.lua index 0953aaa79..00ac422b4 100644 --- a/demo/gpudemo/premake4.lua +++ b/demo/gpudemo/premake4.lua @@ -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", diff --git a/demo/gpudemo/rigidbody/Bullet2FileDemo.cpp b/demo/gpudemo/rigidbody/Bullet2FileDemo.cpp index d9fc9a868..ec64bf269 100644 --- a/demo/gpudemo/rigidbody/Bullet2FileDemo.cpp +++ b/demo/gpudemo/rigidbody/Bullet2FileDemo.cpp @@ -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); diff --git a/demo/gpudemo/rigidbody/Bullet2FileDemo.h b/demo/gpudemo/rigidbody/Bullet2FileDemo.h index 382ec6ea5..0efe6c95f 100644 --- a/demo/gpudemo/rigidbody/Bullet2FileDemo.h +++ b/demo/gpudemo/rigidbody/Bullet2FileDemo.h @@ -7,7 +7,7 @@ class Bullet2FileDemo : public GpuRigidBodyDemo { - class btBulletDataExtractor* m_loader; + class b3BulletDataExtractor* m_loader; public: diff --git a/demo/gpudemo/rigidbody/BulletDataExtractor.cpp b/demo/gpudemo/rigidbody/BulletDataExtractor.cpp index 4b2b0d808..3f45e9c42 100644 --- a/demo/gpudemo/rigidbody/BulletDataExtractor.cpp +++ b/demo/gpudemo/rigidbody/BulletDataExtractor.cpp @@ -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 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;im_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;im_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;jm_shape == shapeData) @@ -237,10 +237,10 @@ void btBulletDataExtractor::convertAllObjects(bParse::btBulletFile* bulletFile2) for (int j=0;jm_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 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;im_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;im_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 childShapes; + b3AlignedObjectArray childShapes; for (int i=0;im_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* vertices = new b3AlignedObjectArray; { @@ -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* indicesPtr = new b3AlignedObjectArray; for (int f=0;fm_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) { diff --git a/demo/gpudemo/rigidbody/BulletDataExtractor.h b/demo/gpudemo/rigidbody/BulletDataExtractor.h index e3187af1f..8452f333c 100644 --- a/demo/gpudemo/rigidbody/BulletDataExtractor.h +++ b/demo/gpudemo/rigidbody/BulletDataExtractor.h @@ -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 m_instanceGroups; b3AlignedObjectArray 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); diff --git a/demo/gpudemo/rigidbody/ConcaveScene.cpp b/demo/gpudemo/rigidbody/ConcaveScene.cpp index 913ed260b..3c13aae8a 100644 --- a/demo/gpudemo/rigidbody/ConcaveScene.cpp +++ b/demo/gpudemo/rigidbody/ConcaveScene.cpp @@ -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 vertices; int stride2 = sizeof(GLInstanceVertex); - btAssert(stride2 == strideInBytes); + b3Assert(stride2 == strideInBytes); { - b3AlignedObjectArray childShapes; + b3AlignedObjectArray 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 childShapes; + b3AlignedObjectArray childShapes; int numChildShapes = 3; for (int i=0;iregisterShape(&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); diff --git a/demo/gpudemo/rigidbody/GpuCompoundScene.cpp b/demo/gpudemo/rigidbody/GpuCompoundScene.cpp index 2d6cf75e0..7bf815650 100644 --- a/demo/gpudemo/rigidbody/GpuCompoundScene.cpp +++ b/demo/gpudemo/rigidbody/GpuCompoundScene.cpp @@ -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 vertexArray; @@ -50,12 +50,12 @@ void GpuCompoundScene::setupScene(const ConstructionInfo& ci) }; - b3AlignedObjectArray childShapes; + b3AlignedObjectArray childShapes; int numChildShapes = 3; for (int i=0;iregisterShape(&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); diff --git a/demo/gpudemo/rigidbody/GpuConvexScene.cpp b/demo/gpudemo/rigidbody/GpuConvexScene.cpp index 16fd83d2b..f298d583a 100644 --- a/demo/gpudemo/rigidbody/GpuConvexScene.cpp +++ b/demo/gpudemo/rigidbody/GpuConvexScene.cpp @@ -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); diff --git a/demo/gpudemo/rigidbody/GpuRigidBodyDemo.cpp b/demo/gpudemo/rigidbody/GpuRigidBodyDemo.cpp index 609961034..2a6ea647b 100644 --- a/demo/gpudemo/rigidbody/GpuRigidBodyDemo.cpp +++ b/demo/gpudemo/rigidbody/GpuRigidBodyDemo.cpp @@ -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(m_clData->m_clContext,m_clData->m_clQueue); + m_data->m_instancePosOrnColor = new b3OpenCLArray(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); diff --git a/demo/gpudemo/rigidbody/GpuRigidBodyDemo.h b/demo/gpudemo/rigidbody/GpuRigidBodyDemo.h index 91d08425b..c42dfc779 100644 --- a/demo/gpudemo/rigidbody/GpuRigidBodyDemo.h +++ b/demo/gpudemo/rigidbody/GpuRigidBodyDemo.h @@ -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; diff --git a/demo/gpudemo/rigidbody/GpuRigidBodyDemoInternalData.h b/demo/gpudemo/rigidbody/GpuRigidBodyDemoInternalData.h index 609faffd1..69c0333ec 100644 --- a/demo/gpudemo/rigidbody/GpuRigidBodyDemoInternalData.h +++ b/demo/gpudemo/rigidbody/GpuRigidBodyDemoInternalData.h @@ -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* m_instancePosOrnColor; + b3OpenCLArray* m_instancePosOrnColor; class b3GpuRigidBodyPipeline* m_rigidBodyPipeline; diff --git a/demo/gpudemo/rigidbody/GpuSphereScene.cpp b/demo/gpudemo/rigidbody/GpuSphereScene.cpp index decc39308..ea0b88ebb 100644 --- a/demo/gpudemo/rigidbody/GpuSphereScene.cpp +++ b/demo/gpudemo/rigidbody/GpuSphereScene.cpp @@ -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); diff --git a/opencl/basic_initialize/b3OpenCLInclude.h b/opencl/basic_initialize/b3OpenCLInclude.h index 5f0e78da6..456d43390 100644 --- a/opencl/basic_initialize/b3OpenCLInclude.h +++ b/opencl/basic_initialize/b3OpenCLInclude.h @@ -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 diff --git a/opencl/basic_initialize/b3OpenCLUtils.cpp b/opencl/basic_initialize/b3OpenCLUtils.cpp index 3a7bb3f42..17fcb89a8 100644 --- a/opencl/basic_initialize/b3OpenCLUtils.cpp +++ b/opencl/basic_initialize/b3OpenCLUtils.cpp @@ -31,14 +31,14 @@ bool gDebugSkipLoadingBinary = false; #include #include -#define BT_MAX_CL_DEVICES 16 //who needs 16 devices? +#define B3_MAX_CL_DEVICES 16 //who needs 16 devices? #ifdef _WIN32 #include #endif #include -#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_ 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); } diff --git a/opencl/basic_initialize/b3OpenCLUtils.h b/opencl/basic_initialize/b3OpenCLUtils.h index 42ccd0014..d7af1ab01 100644 --- a/opencl/basic_initialize/b3OpenCLUtils.h +++ b/opencl/basic_initialize/b3OpenCLUtils.h @@ -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 diff --git a/opencl/basic_initialize/main.cpp b/opencl/basic_initialize/main.cpp index 19d4445f4..b708ad1cc 100644 --- a/opencl/basic_initialize/main.cpp +++ b/opencl/basic_initialize/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) for (int i=0;i=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 hostPairs; + b3AlignedObjectArray 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 pairCount(m_context, m_queue); + b3OpenCLArray 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 pairCount(m_context, m_queue); + b3OpenCLArray 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 hostOoverlappingPairs; - btOpenCLArray tmpGpuPairs(m_context,m_queue); + b3AlignedObjectArray hostOoverlappingPairs; + b3OpenCLArray 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"); } diff --git a/opencl/gpu_broadphase/host/b3GpuSapBroadphase.h b/opencl/gpu_broadphase/host/b3GpuSapBroadphase.h index eba284932..3bef7149d 100644 --- a/opencl/gpu_broadphase/host/b3GpuSapBroadphase.h +++ b/opencl/gpu_broadphase/host/b3GpuSapBroadphase.h @@ -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 m_sortedAxisCPU[3][2]; + b3AlignedObjectArray m_sortedAxisCPU[3][2]; int m_currentBuffer; public: - btOpenCLArray m_allAabbsGPU; + b3OpenCLArray m_allAabbsGPU; b3AlignedObjectArray m_allAabbsCPU; - btOpenCLArray m_smallAabbsGPU; + b3OpenCLArray m_smallAabbsGPU; b3AlignedObjectArray m_smallAabbsCPU; - btOpenCLArray m_largeAabbsGPU; + b3OpenCLArray m_largeAabbsGPU; b3AlignedObjectArray m_largeAabbsCPU; - btOpenCLArray m_overlappingPairs; + b3OpenCLArray m_overlappingPairs; //temporary gpu work memory - btOpenCLArray m_gpuSmallSortData; - btOpenCLArray m_gpuSmallSortedAabbs; + b3OpenCLArray m_gpuSmallSortData; + b3OpenCLArray 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 \ No newline at end of file +#endif //B3_GPU_SAP_BROADPHASE_H \ No newline at end of file diff --git a/opencl/gpu_broadphase/host/b3SapAabb.h b/opencl/gpu_broadphase/host/b3SapAabb.h index 423e10ba9..81661db6f 100644 --- a/opencl/gpu_broadphase/host/b3SapAabb.h +++ b/opencl/gpu_broadphase/host/b3SapAabb.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 diff --git a/opencl/gpu_broadphase/kernels/sapFastKernels.h b/opencl/gpu_broadphase/kernels/sapFastKernels.h index b9986a74c..758ae91cc 100644 --- a/opencl/gpu_broadphase/kernels/sapFastKernels.h +++ b/opencl/gpu_broadphase/kernels/sapFastKernels.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 = (im_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)\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" diff --git a/opencl/gpu_broadphase/test/main.cpp b/opencl/gpu_broadphase/test/main.cpp index b448c3535..81b4e2b11 100644 --- a/opencl/gpu_broadphase/test/main.cpp +++ b/opencl/gpu_broadphase/test/main.cpp @@ -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); diff --git a/opencl/gpu_narrowphase/host/b3Collidable.h b/opencl/gpu_narrowphase/host/b3Collidable.h index a483abb92..5217a6c1e 100644 --- a/opencl/gpu_narrowphase/host/b3Collidable.h +++ b/opencl/gpu_narrowphase/host/b3Collidable.h @@ -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 diff --git a/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp b/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp index dc35640cc..82e93dcb2 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp +++ b/opencl/gpu_narrowphase/host/b3ConvexHullContact.cpp @@ -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 //memcpy #include "b3ConvexPolyhedronCL.h" -typedef b3AlignedObjectArray btVertexArray; +typedef b3AlignedObjectArray b3VertexArray; #include "Bullet3Common/b3Quickprof.h" #include //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 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 (l2minDist) { minDist = dist; @@ -833,32 +833,32 @@ void computeContactSphereConvex(int pairIndex, } -void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray* pairs, int nPairs, - const btOpenCLArray* bodyBuf, - btOpenCLArray* contactOut, int& nContacts, +void GpuSatCollision::computeConvexConvexContactsGPUSAT( const b3OpenCLArray* pairs, int nPairs, + const b3OpenCLArray* bodyBuf, + b3OpenCLArray* contactOut, int& nContacts, int maxContactCapacity, - const btOpenCLArray& convexData, - const btOpenCLArray& gpuVertices, - const btOpenCLArray& gpuUniqueEdges, - const btOpenCLArray& gpuFaces, - const btOpenCLArray& gpuIndices, - const btOpenCLArray& gpuCollidables, - const btOpenCLArray& gpuChildShapes, + const b3OpenCLArray& convexData, + const b3OpenCLArray& gpuVertices, + const b3OpenCLArray& gpuUniqueEdges, + const b3OpenCLArray& gpuFaces, + const b3OpenCLArray& gpuIndices, + const b3OpenCLArray& gpuCollidables, + const b3OpenCLArray& gpuChildShapes, - const btOpenCLArray& clAabbsWS, - btOpenCLArray& worldVertsB1GPU, - btOpenCLArray& clippingFacesOutGPU, - btOpenCLArray& worldNormalsAGPU, - btOpenCLArray& worldVertsA1GPU, - btOpenCLArray& worldVertsB2GPU, + const b3OpenCLArray& clAabbsWS, + b3OpenCLArray& worldVertsB1GPU, + b3OpenCLArray& clippingFacesOutGPU, + b3OpenCLArray& worldNormalsAGPU, + b3OpenCLArray& worldVertsA1GPU, + b3OpenCLArray& worldVertsB2GPU, b3AlignedObjectArray& bvhData, - btOpenCLArray* treeNodesGPU, - btOpenCLArray* subTreesGPU, - btOpenCLArray* bvhInfo, + b3OpenCLArray* treeNodesGPU, + b3OpenCLArray* subTreesGPU, + b3OpenCLArray* bvhInfo, int numObjects, int maxTriConvexPairCapacity, - btOpenCLArray& triangleConvexPairsOut, + b3OpenCLArray& triangleConvexPairsOut, int& numTriConvexPairsOut ) { @@ -868,9 +868,9 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray hostAabbs; + b3AlignedObjectArray hostAabbs; clAabbsWS.copyToHost(hostAabbs); - b3AlignedObjectArray hostPairs; + b3AlignedObjectArray hostPairs; pairs->copyToHost(hostPairs); b3AlignedObjectArray hostBodyBuf; @@ -886,18 +886,18 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArray hostUniqueEdges; gpuUniqueEdges.copyToHost(hostUniqueEdges); - b3AlignedObjectArray hostFaces; + b3AlignedObjectArray hostFaces; gpuFaces.copyToHost(hostFaces); b3AlignedObjectArray hostIndices; gpuIndices.copyToHost(hostIndices); b3AlignedObjectArray hostCollidables; gpuCollidables.copyToHost(hostCollidables); - b3AlignedObjectArray cpuChildShapes; + b3AlignedObjectArray cpuChildShapes; gpuChildShapes.copyToHost(cpuChildShapes); - b3AlignedObjectArray hostTriangleConvexPairs; + b3AlignedObjectArray hostTriangleConvexPairs; b3AlignedObjectArray hostContacts; if (nContacts) @@ -984,22 +984,22 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArraygetBufferCL(), 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 sepNormals(m_context,m_queue); + b3OpenCLArray sepNormals(m_context,m_queue); sepNormals.resize(nPairs); - btOpenCLArray hasSeparatingNormals(m_context,m_queue); + b3OpenCLArray hasSeparatingNormals(m_context,m_queue); hasSeparatingNormals.resize(nPairs); int concaveCapacity=maxTriConvexPairCapacity; - btOpenCLArray concaveSepNormals(m_context,m_queue); + b3OpenCLArray concaveSepNormals(m_context,m_queue); concaveSepNormals.resize(concaveCapacity); - btOpenCLArray numConcavePairsOut(m_context,m_queue); + b3OpenCLArray numConcavePairsOut(m_context,m_queue); numConcavePairsOut.push_back(0); int compoundPairCapacity=65536*10; - btOpenCLArray gpuCompoundPairs(m_context,m_queue); + b3OpenCLArray gpuCompoundPairs(m_context,m_queue); gpuCompoundPairs.resize(compoundPairCapacity); - btOpenCLArray gpuCompoundSepNormals(m_context,m_queue); + b3OpenCLArray gpuCompoundSepNormals(m_context,m_queue); gpuCompoundSepNormals.resize(compoundPairCapacity); - btOpenCLArray gpuHasCompoundSepNormals(m_context,m_queue); + b3OpenCLArray gpuHasCompoundSepNormals(m_context,m_queue); gpuHasCompoundSepNormals.resize(compoundPairCapacity); - btOpenCLArray numCompoundPairsOut(m_context,m_queue); + b3OpenCLArray numCompoundPairsOut(m_context,m_queue); numCompoundPairsOut.push_back(0); int numCompoundPairs = 0; @@ -1053,23 +1053,23 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArraygetBufferCL(), 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 btOpenCLArraysize() && 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 btOpenCLArraygetBufferCL(),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 cpuCompoundSepNormals; // concaveSepNormals.copyToHost(cpuCompoundSepNormals); - // b3AlignedObjectArray cpuConcavePairs; + // b3AlignedObjectArray cpuConcavePairs; // triangleConvexPairsOut.copyToHost(cpuConcavePairs); @@ -1156,25 +1156,25 @@ void GpuSatCollision::computeConvexConvexContactsGPUSAT( const btOpenCLArraygetBufferCL(), 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 btOpenCLArraygetBufferCL(),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 btOpenCLArraygetBufferCL(),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 btOpenCLArraygetBufferCL(),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 btOpenCLArraygetBufferCL(),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 btOpenCLArraygetBufferCL(), 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 btOpenCLArraygetBufferCL(), 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 btOpenCLArrayreserve(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 btOpenCLArraygetBufferCL(), 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 btOpenCLArraygetBufferCL(),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); diff --git a/opencl/gpu_narrowphase/host/b3ConvexHullContact.h b/opencl/gpu_narrowphase/host/b3ConvexHullContact.h index bfdf955e6..dbdd5f883 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexHullContact.h +++ b/opencl/gpu_narrowphase/host/b3ConvexHullContact.h @@ -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 m_totalContactsOut; + b3OpenCLArray m_totalContactsOut; GpuSatCollision(cl_context ctx,cl_device_id device, cl_command_queue q ); virtual ~GpuSatCollision(); - void computeConvexConvexContactsGPUSAT( const btOpenCLArray* pairs, int nPairs, - const btOpenCLArray* bodyBuf, - btOpenCLArray* contactOut, int& nContacts, + void computeConvexConvexContactsGPUSAT( const b3OpenCLArray* pairs, int nPairs, + const b3OpenCLArray* bodyBuf, + b3OpenCLArray* contactOut, int& nContacts, int maxContactCapacity, - const btOpenCLArray& hostConvexData, - const btOpenCLArray& vertices, - const btOpenCLArray& uniqueEdges, - const btOpenCLArray& faces, - const btOpenCLArray& indices, - const btOpenCLArray& gpuCollidables, - const btOpenCLArray& gpuChildShapes, + const b3OpenCLArray& hostConvexData, + const b3OpenCLArray& vertices, + const b3OpenCLArray& uniqueEdges, + const b3OpenCLArray& faces, + const b3OpenCLArray& indices, + const b3OpenCLArray& gpuCollidables, + const b3OpenCLArray& gpuChildShapes, - const btOpenCLArray& clAabbs, - btOpenCLArray& worldVertsB1GPU, - btOpenCLArray& clippingFacesOutGPU, - btOpenCLArray& worldNormalsAGPU, - btOpenCLArray& worldVertsA1GPU, - btOpenCLArray& worldVertsB2GPU, + const b3OpenCLArray& clAabbs, + b3OpenCLArray& worldVertsB1GPU, + b3OpenCLArray& clippingFacesOutGPU, + b3OpenCLArray& worldNormalsAGPU, + b3OpenCLArray& worldVertsA1GPU, + b3OpenCLArray& worldVertsB2GPU, b3AlignedObjectArray& bvhData, - btOpenCLArray* treeNodesGPU, - btOpenCLArray* subTreesGPU, - btOpenCLArray* bvhInfo, + b3OpenCLArray* treeNodesGPU, + b3OpenCLArray* subTreesGPU, + b3OpenCLArray* bvhInfo, int numObjects, int maxTriConvexPairCapacity, - btOpenCLArray& triangleConvexPairs, + b3OpenCLArray& triangleConvexPairs, int& numTriConvexPairsOut ); diff --git a/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h b/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h index ec63bca26..1327d719f 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h +++ b/opencl/gpu_narrowphase/host/b3ConvexPolyhedronCL.h @@ -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; } diff --git a/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp b/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp index 16ca87725..609776ec1 100644 --- a/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp +++ b/opencl/gpu_narrowphase/host/b3ConvexUtility.cpp @@ -42,7 +42,7 @@ bool b3ConvexUtility::initializePolyhedralFeatures(const b3Vector3* orgVertices, b3ConvexHullComputer* convexUtil = &conv; - b3AlignedObjectArray tmpFaces; + b3AlignedObjectArray 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;fm_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 edges; + b3HashMap edges; b3Scalar TotalArea = 0.0f; @@ -351,8 +351,8 @@ void b3ConvexUtility::initialize() for(int j=0;jm_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;jm_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_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 m_vertices; - b3AlignedObjectArray m_faces; + b3AlignedObjectArray m_faces; b3AlignedObjectArray m_uniqueEdges; diff --git a/opencl/gpu_narrowphase/host/b3OptimizedBvh.cpp b/opencl/gpu_narrowphase/host/b3OptimizedBvh.cpp index cc2fa8b1e..bcfee0785 100644 --- a/opencl/gpu_narrowphase/host/b3OptimizedBvh.cpp +++ b/opencl/gpu_narrowphase/host/b3OptimizedBvh.cpp @@ -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<=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_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;im_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()]; diff --git a/opencl/gpu_narrowphase/host/b3OptimizedBvh.h b/opencl/gpu_narrowphase/host/b3OptimizedBvh.h index eac52f7bc..6d0fed77a 100644 --- a/opencl/gpu_narrowphase/host/b3OptimizedBvh.h +++ b/opencl/gpu_narrowphase/host/b3OptimizedBvh.h @@ -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 diff --git a/opencl/gpu_narrowphase/host/b3QuantizedBvh.cpp b/opencl/gpu_narrowphase/host/b3QuantizedBvh.cpp index 03a3f6191..7ea10b419 100644 --- a/opencl/gpu_narrowphase/host/b3QuantizedBvh.cpp +++ b/opencl/gpu_narrowphase/host/b3QuantizedBvh.cpp @@ -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(sizeof(btQuantizedBvhNode)); + int leftSubTreeSizeInBytes = leftSubTreeSize * static_cast(sizeof(b3QuantizedBvhNode)); - btQuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex]; + b3QuantizedBvhNode& rightChildNode = m_quantizedContiguousNodes[rightChildNodexIndex]; int rightSubTreeSize = rightChildNode.isLeafNode() ? 1 : rightChildNode.getEscapeIndex(); - int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast(sizeof(btQuantizedBvhNode)); + int rightSubTreeSizeInBytes = rightSubTreeSize * static_cast(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;im_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(btSwapEndian(m_curNodeIndex)); + targetBvh->m_curNodeIndex = static_cast(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(btSwapEndian(m_subtreeHeaderCount)); + targetBvh->m_traversalMode = (b3TraversalMode)b3SwapEndian(m_traversalMode); + targetBvh->m_subtreeHeaderCount = static_cast(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(btSwapEndian(m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex)); + targetBvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast(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(btSwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex)); - targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast(btSwapEndian(m_contiguousNodes[nodeIndex].m_subPart)); - targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast(btSwapEndian(m_contiguousNodes[nodeIndex].m_triangleIndex)); + targetBvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast(b3SwapEndian(m_contiguousNodes[nodeIndex].m_escapeIndex)); + targetBvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast(b3SwapEndian(m_contiguousNodes[nodeIndex].m_subPart)); + targetBvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast(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(btSwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex)); - targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast(btSwapEndian(m_SubtreeHeaders[i].m_subtreeSize)); + targetBvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast(b3SwapEndian(m_SubtreeHeaders[i].m_rootNodeIndex)); + targetBvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast(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(btSwapEndian(bvh->m_curNodeIndex)); + bvh->m_curNodeIndex = static_cast(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(btSwapEndian(bvh->m_subtreeHeaderCount)); + bvh->m_traversalMode = (b3TraversalMode)b3SwapEndian(bvh->m_traversalMode); + bvh->m_subtreeHeaderCount = static_cast(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(btSwapEndian(bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex)); + bvh->m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = static_cast(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(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex)); - bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart)); - bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast(btSwapEndian(bvh->m_contiguousNodes[nodeIndex].m_triangleIndex)); + bvh->m_contiguousNodes[nodeIndex].m_escapeIndex = static_cast(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_escapeIndex)); + bvh->m_contiguousNodes[nodeIndex].m_subPart = static_cast(b3SwapEndian(bvh->m_contiguousNodes[nodeIndex].m_subPart)); + bvh->m_contiguousNodes[nodeIndex].m_triangleIndex = static_cast(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(btSwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex)); - bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast(btSwapEndian(bvh->m_SubtreeHeaders[i].m_subtreeSize)); + bvh->m_SubtreeHeaders[i].m_rootNodeIndex = static_cast(b3SwapEndian(bvh->m_SubtreeHeaders[i].m_rootNodeIndex)); + bvh->m_SubtreeHeaders[i].m_subtreeSize = static_cast(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;im_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;im_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;im_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;im_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; } diff --git a/opencl/gpu_narrowphase/host/b3QuantizedBvh.h b/opencl/gpu_narrowphase/host/b3QuantizedBvh.h index 2f9a0dfc6..49d778ef1 100644 --- a/opencl/gpu_narrowphase/host/b3QuantizedBvh.h +++ b/opencl/gpu_narrowphase/host/b3QuantizedBvh.h @@ -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 NodeArray; -typedef b3AlignedObjectArray QuantizedNodeArray; -typedef b3AlignedObjectArray BvhSubtreeInfoArray; +typedef b3AlignedObjectArray NodeArray; +typedef b3AlignedObjectArray QuantizedNodeArray; +typedef b3AlignedObjectArray 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 diff --git a/opencl/gpu_narrowphase/host/b3StridingMeshInterface.cpp b/opencl/gpu_narrowphase/host/b3StridingMeshInterface.cpp index 5f0e64b99..4d97f7f62 100644 --- a/opencl/gpu_narrowphase/host/b3StridingMeshInterface.cpp +++ b/opencl/gpu_narrowphase/host/b3StridingMeshInterface.cpp @@ -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; diff --git a/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h b/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h index edc0fccd1..4ec11d12c 100644 --- a/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h +++ b/opencl/gpu_narrowphase/host/b3StridingMeshInterface.h @@ -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 diff --git a/opencl/gpu_narrowphase/host/b3TriangleCallback.cpp b/opencl/gpu_narrowphase/host/b3TriangleCallback.cpp index 3a4e619e0..e74c97383 100644 --- a/opencl/gpu_narrowphase/host/b3TriangleCallback.cpp +++ b/opencl/gpu_narrowphase/host/b3TriangleCallback.cpp @@ -21,7 +21,7 @@ b3TriangleCallback::~b3TriangleCallback() } -btInternalTriangleIndexCallback::~btInternalTriangleIndexCallback() +b3InternalTriangleIndexCallback::~b3InternalTriangleIndexCallback() { } diff --git a/opencl/gpu_narrowphase/host/b3TriangleCallback.h b/opencl/gpu_narrowphase/host/b3TriangleCallback.h index c76712eb0..3059fa4f2 100644 --- a/opencl/gpu_narrowphase/host/b3TriangleCallback.h +++ b/opencl/gpu_narrowphase/host/b3TriangleCallback.h @@ -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 diff --git a/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.cpp b/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.cpp index 3ef677071..a0f59babb 100644 --- a/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.cpp +++ b/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.cpp @@ -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; diff --git a/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h b/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h index 2b42cfa8c..c8f1ec97b 100644 --- a/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h +++ b/opencl/gpu_narrowphase/host/b3TriangleIndexVertexArray.h @@ -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 IndexedMeshArray; +typedef b3AlignedObjectArray 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 diff --git a/opencl/gpu_narrowphase/kernels/bvhTraversal.h b/opencl/gpu_narrowphase/kernels/bvhTraversal.h index 6640917cb..7d6ba62b7 100644 --- a/opencl/gpu_narrowphase/kernels/bvhTraversal.h +++ b/opencl/gpu_narrowphase/kernels/bvhTraversal.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;im_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;e0m_faceOffset+closestFaceB];\n" +" const b3GpuFace polyB = facesB[hullB->m_faceOffset+closestFaceB];\n" " const int numVertices = polyB.m_numIndices;\n" " for(int e0=0;e0m_faceOffset+closestFaceB];\n" +" const b3GpuFace polyB = faces[hullB->m_faceOffset+closestFaceB];\n" " const int numVertices = polyB.m_numIndices;\n" " for(int e0=0;e00) { - btOpenCLDeviceInfo info; + b3OpenCLDeviceInfo info; g_device= b3OpenCLUtils::getDevice(g_context,0); g_queue = clCreateCommandQueue(g_context, g_device, 0, &ciErrNum); oclCHECKERROR(ciErrNum, CL_SUCCESS); diff --git a/opencl/gpu_rigidbody/host/b3Config.h b/opencl/gpu_rigidbody/host/b3Config.h index 94f5fafce..00befa3c5 100644 --- a/opencl/gpu_rigidbody/host/b3Config.h +++ b/opencl/gpu_rigidbody/host/b3Config.h @@ -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 diff --git a/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp b/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp index d87c38d30..c1ddefce4 100644 --- a/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp +++ b/opencl/gpu_rigidbody/host/b3GpuBatchingPgsSolver.cpp @@ -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 #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* m_contactCGPU; - btOpenCLArray* m_numConstraints; - btOpenCLArray* m_offsets; + b3OpenCLArray* m_contactCGPU; + b3OpenCLArray* m_numConstraints; + b3OpenCLArray* 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* m_sortDataBuffer; - btOpenCLArray* m_contactBuffer; + b3OpenCLArray* m_sortDataBuffer; + b3OpenCLArray* m_contactBuffer; - btOpenCLArray* m_bodyBufferGPU; - btOpenCLArray* m_inertiaBufferGPU; - btOpenCLArray* m_pBufContactOutGPU; + b3OpenCLArray* m_bodyBufferGPU; + b3OpenCLArray* m_inertiaBufferGPU; + b3OpenCLArray* m_pBufContactOutGPU; b3AlignedObjectArray m_idxBuffer; - b3AlignedObjectArray m_sortData; + b3AlignedObjectArray m_sortData; b3AlignedObjectArray 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(ctx,q); - m_data->m_inertiaBufferGPU = new btOpenCLArray(ctx,q); - m_data->m_pBufContactOutGPU = new btOpenCLArray(ctx,q); + m_data->m_bodyBufferGPU = new b3OpenCLArray(ctx,q); + m_data->m_inertiaBufferGPU = new b3OpenCLArray(ctx,q); + m_data->m_pBufContactOutGPU = new b3OpenCLArray(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(ctx,m_data->m_queue,sortSize); - m_data->m_contactBuffer = new btOpenCLArray(ctx,m_data->m_queue); + m_data->m_sortDataBuffer = new b3OpenCLArray(ctx,m_data->m_queue,sortSize); + m_data->m_contactBuffer = new b3OpenCLArray(ctx,m_data->m_queue); - m_data->m_numConstraints = new btOpenCLArray(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(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(ctx,q,pairCapacity); + m_data->m_contactCGPU = new b3OpenCLArray(ctx,q,pairCapacity); - m_data->m_offsets = new btOpenCLArray( 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( 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* bodyBuf, const btOpenCLArray* shapeBuf, - btOpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations) +void b3GpuBatchingPgsSolver::solveContactConstraint( const b3OpenCLArray* bodyBuf, const b3OpenCLArray* shapeBuf, + b3OpenCLArray* 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 gpuDebugInfo(data->m_device,numWorkItems); + adl::b3OpenCLArray gpuDebugInfo(data->m_device,numWorkItems); #endif { - BT_PROFILE("m_batchSolveKernel iterations"); + B3_PROFILE("m_batchSolveKernel iterations"); for(int iter=0; iterm_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 btOpenCLArraygetBufferCL() ), - 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* bodyBuf = m_data->m_bodyBufferGPU; + b3OpenCLArray* bodyBuf = m_data->m_bodyBufferGPU; void* additionalData = 0;//m_data->m_frictionCGPU; - const btOpenCLArray* shapeBuf = m_data->m_inertiaBufferGPU; - btOpenCLArray* contactConstraintOut = m_data->m_contactCGPU; + const b3OpenCLArray* shapeBuf = m_data->m_inertiaBufferGPU; + b3OpenCLArray* 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(m_data->m_context,m_data->m_queue, nContacts ); + m_data->m_solverGPU->m_contactBuffer2 = new b3OpenCLArray(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* bodyNative = bodyBuf; + const b3OpenCLArray* bodyNative = bodyBuf; { - //btOpenCLArray* bodyNative = btOpenCLArrayUtils::map( data->m_device, bodyBuf ); - //btOpenCLArray* contactNative = btOpenCLArrayUtils::map( data->m_device, contactsIn ); + //b3OpenCLArray* bodyNative = b3OpenCLArrayUtils::map( data->m_device, bodyBuf ); + //b3OpenCLArray* contactNative = b3OpenCLArrayUtils::map( 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* countsNative = m_data->m_solverGPU->m_numConstraints; - btOpenCLArray* offsetsNative = m_data->m_solverGPU->m_offsets; + b3OpenCLArray* countsNative = m_data->m_solverGPU->m_numConstraints; + b3OpenCLArray* 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::execute( data->m_sort, *data->m_sortDataBuffer, sortSize ); //adl::RadixSort32::execute( data->m_sort32, *data->m_sortDataBuffer, sortSize ); - btOpenCLArray& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer); + b3OpenCLArray& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer); this->m_data->m_solverGPU->m_sort32->execute(keyValuesInOut); - /*b3AlignedObjectArray hostValues; + /*b3AlignedObjectArray 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::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 cpuContacts; - btOpenCLArray* contactsIn = m_data->m_solverGPU->m_contactBuffer2; + b3OpenCLArray* contactsIn = m_data->m_solverGPU->m_contactBuffer2; contactsIn->copyToHost(cpuContacts); - btOpenCLArray* countsNative = m_data->m_solverGPU->m_numConstraints; - btOpenCLArray* offsetsNative = m_data->m_solverGPU->m_offsets; + b3OpenCLArray* countsNative = m_data->m_solverGPU->m_numConstraints; + b3OpenCLArray* offsetsNative = m_data->m_solverGPU->m_offsets; b3AlignedObjectArray nNativeHost; b3AlignedObjectArray 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; iglobalMaxBatch ) { @@ -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&)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* contacts, int nContacts, btOpenCLArray* n, btOpenCLArray* offsets, int staticIdx ) +void b3GpuBatchingPgsSolver::batchContacts( b3OpenCLArray* contacts, int nContacts, b3OpenCLArray* n, b3OpenCLArray* 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 idxBuffer; -b3AlignedObjectArray sortData; +b3AlignedObjectArray sortData; b3AlignedObjectArray 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 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; im_sortData.quickSort(sortfnc); } { - BT_PROFILE("reorder"); + B3_PROFILE("reorder"); // reorder memcpy( &m_data->m_old[0], cs, sizeof(b3Contact4)*numConstraints); for(int i=0; im_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 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* contacts, int nContacts, btOpenCLArray* n, btOpenCLArray* offsets, int staticIdx ); + void batchContacts( b3OpenCLArray* contacts, int nContacts, b3OpenCLArray* n, b3OpenCLArray* 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* bodyBuf, const btOpenCLArray* shapeBuf, - btOpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations); + void solveContactConstraint( const b3OpenCLArray* bodyBuf, const b3OpenCLArray* shapeBuf, + b3OpenCLArray* 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 diff --git a/opencl/gpu_rigidbody/host/b3GpuConstraint4.h b/opencl/gpu_rigidbody/host/b3GpuConstraint4.h index 33c02e352..1783cf38f 100644 --- a/opencl/gpu_rigidbody/host/b3GpuConstraint4.h +++ b/opencl/gpu_rigidbody/host/b3GpuConstraint4.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 diff --git a/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.cpp b/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.cpp index 2c0fcef66..b6d9904a5 100644 --- a/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.cpp +++ b/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.cpp @@ -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* m_convexData; @@ -21,59 +21,59 @@ struct btGpuNarrowPhaseInternalData b3AlignedObjectArray m_convexVertices; b3AlignedObjectArray m_convexIndices; - btOpenCLArray* m_convexPolyhedraGPU; - btOpenCLArray* m_uniqueEdgesGPU; - btOpenCLArray* m_convexVerticesGPU; - btOpenCLArray* m_convexIndicesGPU; + b3OpenCLArray* m_convexPolyhedraGPU; + b3OpenCLArray* m_uniqueEdgesGPU; + b3OpenCLArray* m_convexVerticesGPU; + b3OpenCLArray* m_convexIndicesGPU; - btOpenCLArray* m_worldVertsB1GPU; - btOpenCLArray* m_clippingFacesOutGPU; - btOpenCLArray* m_worldNormalsAGPU; - btOpenCLArray* m_worldVertsA1GPU; - btOpenCLArray* m_worldVertsB2GPU; + b3OpenCLArray* m_worldVertsB1GPU; + b3OpenCLArray* m_clippingFacesOutGPU; + b3OpenCLArray* m_worldNormalsAGPU; + b3OpenCLArray* m_worldVertsA1GPU; + b3OpenCLArray* m_worldVertsB2GPU; - b3AlignedObjectArray m_cpuChildShapes; - btOpenCLArray* m_gpuChildShapes; + b3AlignedObjectArray m_cpuChildShapes; + b3OpenCLArray* m_gpuChildShapes; - b3AlignedObjectArray m_convexFaces; - btOpenCLArray* m_convexFacesGPU; + b3AlignedObjectArray m_convexFaces; + b3OpenCLArray* m_convexFacesGPU; GpuSatCollision* m_gpuSatCollision; - b3AlignedObjectArray* m_pBufPairsCPU; + b3AlignedObjectArray* m_pBufPairsCPU; - btOpenCLArray* m_convexPairsOutGPU; - btOpenCLArray* m_planePairs; + b3OpenCLArray* m_convexPairsOutGPU; + b3OpenCLArray* m_planePairs; - btOpenCLArray* m_pBufContactOutGPU; + b3OpenCLArray* m_pBufContactOutGPU; b3AlignedObjectArray* m_pBufContactOutCPU; b3AlignedObjectArray* m_bodyBufferCPU; - btOpenCLArray* m_bodyBufferGPU; + b3OpenCLArray* m_bodyBufferGPU; - b3AlignedObjectArray* m_inertiaBufferCPU; - btOpenCLArray* m_inertiaBufferGPU; + b3AlignedObjectArray* m_inertiaBufferCPU; + b3OpenCLArray* m_inertiaBufferGPU; int m_numAcceleratedShapes; int m_numAcceleratedRigidBodies; b3AlignedObjectArray m_collidablesCPU; - btOpenCLArray* m_collidablesGPU; + b3OpenCLArray* m_collidablesGPU; - btOpenCLArray* m_localShapeAABBGPU; + b3OpenCLArray* m_localShapeAABBGPU; b3AlignedObjectArray* m_localShapeAABBCPU; b3AlignedObjectArray m_bvhData; - b3AlignedObjectArray m_treeNodesCPU; - b3AlignedObjectArray m_subTreesCPU; + b3AlignedObjectArray m_treeNodesCPU; + b3AlignedObjectArray m_subTreesCPU; b3AlignedObjectArray m_bvhInfoCPU; - btOpenCLArray* m_bvhInfoGPU; + b3OpenCLArray* m_bvhInfoGPU; - btOpenCLArray* m_treeNodesGPU; - btOpenCLArray* m_subTreesGPU; + b3OpenCLArray* m_treeNodesGPU; + b3OpenCLArray* 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; + m_data->m_pBufPairsCPU = new b3AlignedObjectArray; m_data->m_pBufPairsCPU->resize(config.m_maxBroadphasePairs); - m_data->m_convexPairsOutGPU = new btOpenCLArray(ctx,queue,config.m_maxBroadphasePairs,false); - m_data->m_planePairs = new btOpenCLArray(ctx,queue,config.m_maxBroadphasePairs,false); + m_data->m_convexPairsOutGPU = new b3OpenCLArray(ctx,queue,config.m_maxBroadphasePairs,false); + m_data->m_planePairs = new b3OpenCLArray(ctx,queue,config.m_maxBroadphasePairs,false); m_data->m_pBufContactOutCPU = new b3AlignedObjectArray(); m_data->m_pBufContactOutCPU->resize(config.m_maxBroadphasePairs); m_data->m_bodyBufferCPU = new b3AlignedObjectArray(); m_data->m_bodyBufferCPU->resize(config.m_maxConvexBodies); - m_data->m_inertiaBufferCPU = new b3AlignedObjectArray(); + m_data->m_inertiaBufferCPU = new b3AlignedObjectArray(); m_data->m_inertiaBufferCPU->resize(config.m_maxConvexBodies); - m_data->m_pBufContactOutGPU = new btOpenCLArray(ctx,queue, config.m_maxContactCapacity,true); + m_data->m_pBufContactOutGPU = new b3OpenCLArray(ctx,queue, config.m_maxContactCapacity,true); - m_data->m_inertiaBufferGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexBodies,false); - m_data->m_collidablesGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexShapes); + m_data->m_inertiaBufferGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexBodies,false); + m_data->m_collidablesGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexShapes); m_data->m_localShapeAABBCPU = new b3AlignedObjectArray; - m_data->m_localShapeAABBGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexShapes); + m_data->m_localShapeAABBGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexShapes); //m_data->m_solverDataGPU = adl::Solver::allocate(ctx,queue, config.m_maxBroadphasePairs,false); - m_data->m_bodyBufferGPU = new btOpenCLArray(ctx,queue, config.m_maxConvexBodies,false); + m_data->m_bodyBufferGPU = new b3OpenCLArray(ctx,queue, config.m_maxConvexBodies,false); - m_data->m_convexFacesGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false); - m_data->m_gpuChildShapes = new btOpenCLArray(ctx,queue,config.m_maxCompoundChildShapes,false); + m_data->m_convexFacesGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false); + m_data->m_gpuChildShapes = new b3OpenCLArray(ctx,queue,config.m_maxCompoundChildShapes,false); - m_data->m_convexPolyhedraGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexShapes,false); - m_data->m_uniqueEdgesGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexUniqueEdges,true); - m_data->m_convexVerticesGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexVertices,true); - m_data->m_convexIndicesGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexIndices,true); + m_data->m_convexPolyhedraGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexShapes,false); + m_data->m_uniqueEdgesGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexUniqueEdges,true); + m_data->m_convexVerticesGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexVertices,true); + m_data->m_convexIndicesGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexIndices,true); - m_data->m_worldVertsB1GPU = new btOpenCLArray(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace); - m_data->m_clippingFacesOutGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexBodies); - m_data->m_worldNormalsAGPU = new btOpenCLArray(ctx,queue,config.m_maxConvexBodies); - m_data->m_worldVertsA1GPU = new btOpenCLArray(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace); - m_data->m_worldVertsB2GPU = new btOpenCLArray(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace); + m_data->m_worldVertsB1GPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace); + m_data->m_clippingFacesOutGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexBodies); + m_data->m_worldNormalsAGPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexBodies); + m_data->m_worldVertsA1GPU = new b3OpenCLArray(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace); + m_data->m_worldVertsB2GPU = new b3OpenCLArray(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(this->m_context,this->m_queue); - m_data->m_treeNodesGPU = new btOpenCLArray(this->m_context,this->m_queue); - m_data->m_bvhInfoGPU = new btOpenCLArray(this->m_context,this->m_queue); + m_data->m_subTreesGPU = new b3OpenCLArray(this->m_context,this->m_queue); + m_data->m_treeNodesGPU = new b3OpenCLArray(this->m_context,this->m_queue); + m_data->m_bvhInfoGPU = new b3OpenCLArray(this->m_context,this->m_queue); - //m_data->m_contactCGPU = new btOpenCLArray(ctx,queue,config.m_maxBroadphasePairs,false); - //m_data->m_frictionCGPU = new btOpenCLArray::allocateFrictionConstraint( m_data->m_deviceCL, config.m_maxBroadphasePairs); + //m_data->m_contactCGPU = new b3OpenCLArray(ctx,queue,config.m_maxBroadphasePairs,false); + //m_data->m_frictionCGPU = new b3OpenCLArray::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* childShapes) +int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray* childShapes) { int collidableIndex = allocateCollidable(); @@ -435,7 +435,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArraym_cpuChildShapes.size(); { - btAssert(col.m_shapeIndex+childShapes->size()m_config.m_maxCompoundChildShapes); + b3Assert(col.m_shapeIndex+childShapes->size()m_config.m_maxCompoundChildShapes); for (int i=0;isize();i++) { m_data->m_cpuChildShapes.push_back(childShapes->at(i)); @@ -474,7 +474,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArrayat(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* 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* 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* treeNodesGPU = new btOpenCLArray(this->m_context,this->m_queue,numNodes); + //b3OpenCLArray* treeNodesGPU = new b3OpenCLArray(this->m_context,this->m_queue,numNodes); //treeNodesGPU->copyFromHost(bvh->getQuantizedNodeArray()); int numSubTrees = bvh->getSubtreeInfoArray().size(); @@ -582,7 +582,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray* vert m_data->m_treeNodesCPU.push_back(bvh->getQuantizedNodeArray()[i]); } - //btOpenCLArray* subTreesGPU = new btOpenCLArray(this->m_context,this->m_queue,numSubTrees); + //b3OpenCLArray* subTreesGPU = new b3OpenCLArray(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 triangleConvexPairs(m_context,m_queue, maxTriConvexPairCapacity); + b3OpenCLArray triangleConvexPairs(m_context,m_queue, maxTriConvexPairCapacity); int numTriConvexPairsOut=0; - btOpenCLArray broadphasePairsGPU(m_context,m_queue); + b3OpenCLArray broadphasePairsGPU(m_context,m_queue); broadphasePairsGPU.setFromOpenCLBuffer(broadphasePairs,numBroadphasePairs); - btOpenCLArray clAabbArray(this->m_context,this->m_queue); + b3OpenCLArray 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) { diff --git a/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.h b/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.h index 52488b88e..78c6da7e9 100644 --- a/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.h +++ b/opencl/gpu_rigidbody/host/b3GpuNarrowPhase.h @@ -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* childShapes); + int registerCompoundShape(b3AlignedObjectArray* childShapes); int registerFace(const b3Vector3& faceNormal, float faceConstant); int registerConcaveMesh(b3AlignedObjectArray* vertices, b3AlignedObjectArray* 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 diff --git a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp index 27ac3bf1c..74d9a5db3 100644 --- a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp +++ b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.cpp @@ -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(ctx,q,config.m_maxConvexBodies); - m_data->m_overlappingPairsGPU = new btOpenCLArray(ctx,q,config.m_maxBroadphasePairs); + m_data->m_allAabbsGPU = new b3OpenCLArray(ctx,q,config.m_maxConvexBodies); + m_data->m_overlappingPairsGPU = new b3OpenCLArray(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;im_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 gpuBodies(m_data->m_context,m_data->m_queue,0,true); + b3OpenCLArray gpuBodies(m_data->m_context,m_data->m_queue,0,true); gpuBodies.setFromOpenCLBuffer(m_data->m_narrowphase->getBodiesGpu(),m_data->m_narrowphase->getNumBodiesGpu()); - btOpenCLArray gpuInertias(m_data->m_context,m_data->m_queue,0,true); + b3OpenCLArray gpuInertias(m_data->m_context,m_data->m_queue,0,true); gpuInertias.setFromOpenCLBuffer(m_data->m_narrowphase->getBodyInertiasGpu(),m_data->m_narrowphase->getNumBodiesGpu()); - btOpenCLArray gpuContacts(m_data->m_context,m_data->m_queue,0,true); + b3OpenCLArray 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 hostBodies; gpuBodies.copyToHost(hostBodies); - b3AlignedObjectArray hostInertias; + b3AlignedObjectArray hostInertias; gpuInertias.copyToHost(hostInertias); b3AlignedObjectArray hostContacts; gpuContacts.copyToHost(hostContacts); @@ -230,36 +230,36 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime) if (forceHost) { b3AlignedObjectArray hostBodies; - b3AlignedObjectArray hostInertias; + b3AlignedObjectArray hostInertias; b3AlignedObjectArray 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 hostBodies; gpuBodies.copyToHost(hostBodies); - b3AlignedObjectArray hostInertias; + b3AlignedObjectArray hostInertias; gpuInertias.copyToHost(hostInertias); b3AlignedObjectArray hostContacts; gpuContacts.copyToHost(hostContacts); @@ -279,9 +279,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime) /*m_data->m_solver3->solveContactConstraintHost( - (btOpenCLArray*)&gpuBodies, - (btOpenCLArray*)&gpuInertias, - (btOpenCLArray*) &gpuContacts, + (b3OpenCLArray*)&gpuBodies, + (b3OpenCLArray*)&gpuInertias, + (b3OpenCLArray*) &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); diff --git a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.h b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.h index c27b34f9f..c552105a2 100644 --- a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.h +++ b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipeline.h @@ -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* vertices, b3AlignedObjectArray* indices, const float* scaling); - //int registerCompoundShape(b3AlignedObjectArray* childShapes); + //int registerCompoundShape(b3AlignedObjectArray* 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 \ No newline at end of file +#endif //B3_GPU_RIGIDBODY_PIPELINE_H \ No newline at end of file diff --git a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipelineInternalData.h b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipelineInternalData.h index fac30328f..3104c06cf 100644 --- a/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipelineInternalData.h +++ b/opencl/gpu_rigidbody/host/b3GpuRigidBodyPipelineInternalData.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* m_allAabbsGPU; + b3OpenCLArray* m_allAabbsGPU; b3AlignedObjectArray m_allAabbsCPU; - btOpenCLArray* m_overlappingPairsGPU; + b3OpenCLArray* m_overlappingPairsGPU; b3AlignedObjectArray m_joints; class b3GpuNarrowPhase* m_narrowphase; }; -#endif //BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H +#endif //B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H diff --git a/opencl/gpu_rigidbody/host/b3Solver.cpp b/opencl/gpu_rigidbody/host/b3Solver.cpp index 1238dcc19..8180a9b75 100644 --- a/opencl/gpu_rigidbody/host/b3Solver.cpp +++ b/opencl/gpu_rigidbody/host/b3Solver.cpp @@ -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* m_numConstraints; - btOpenCLArray* m_offsets; + b3OpenCLArray* m_numConstraints; + b3OpenCLArray* 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(ctx,queue,sortSize); - m_contactBuffer2 = new btOpenCLArray(ctx,queue); + m_sortDataBuffer = new b3OpenCLArray(ctx,queue,sortSize); + m_contactBuffer2 = new b3OpenCLArray(ctx,queue); - m_numConstraints = new btOpenCLArray(ctx,queue,N_SPLIT*N_SPLIT ); + m_numConstraints = new b3OpenCLArray(ctx,queue,N_SPLIT*N_SPLIT ); m_numConstraints->resize(N_SPLIT*N_SPLIT); - m_offsets = new btOpenCLArray( ctx,queue, N_SPLIT*N_SPLIT ); + m_offsets = new b3OpenCLArray( 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* bodyBuf, - const btOpenCLArray* shapeBuf, - btOpenCLArray* contactsIn, btOpenCLArray* contactCOut, void* additionalData, +/*void b3Solver::reorderConvertToConstraints( const b3OpenCLArray* bodyBuf, + const b3OpenCLArray* shapeBuf, + b3OpenCLArray* contactsIn, b3OpenCLArray* 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(m_context,m_queue,nContacts ); + B3_PROFILE("new m_contactBuffer;"); + m_contactBuffer = new b3OpenCLArray(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& bodies, b3AlignedObjectArray& shapes, b3AlignedObjectArray& constraints, + SolveTask(b3AlignedObjectArray& bodies, b3AlignedObjectArray& shapes, b3AlignedObjectArray& 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& m_bodies; - b3AlignedObjectArray& m_shapes; + b3AlignedObjectArray& m_shapes; b3AlignedObjectArray& m_constraints; int m_start; int m_nConstraints; @@ -521,13 +521,13 @@ struct SolveTask// : public ThreadPool::Task }; -void b3Solver::solveContactConstraintHost( btOpenCLArray* bodyBuf, btOpenCLArray* shapeBuf, - btOpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches) +void b3Solver::solveContactConstraintHost( b3OpenCLArray* bodyBuf, b3OpenCLArray* shapeBuf, + b3OpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches) { b3AlignedObjectArray bodyNative; bodyBuf->copyToHost(bodyNative); - b3AlignedObjectArray shapeNative; + b3AlignedObjectArray shapeNative; shapeBuf->copyToHost(shapeNative); b3AlignedObjectArray constraintNative; constraint->copyToHost(constraintNative); @@ -553,12 +553,12 @@ void b3Solver::solveContactConstraintHost( btOpenCLArray* bodyBu } -void b3Solver::solveContactConstraint( const btOpenCLArray* bodyBuf, const btOpenCLArray* shapeBuf, - btOpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches) +void b3Solver::solveContactConstraint( const b3OpenCLArray* bodyBuf, const b3OpenCLArray* shapeBuf, + b3OpenCLArray* 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* body int numWorkItems = 64*nn/N_BATCHES; #ifdef DEBUG_ME SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems]; - adl::btOpenCLArray gpuDebugInfo(data->m_device,numWorkItems); + adl::b3OpenCLArray gpuDebugInfo(data->m_device,numWorkItems); #endif { - BT_PROFILE("m_batchSolveKernel iterations"); + B3_PROFILE("m_batchSolveKernel iterations"); for(int iter=0; iter* 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* body bool applyFriction=true; if (applyFriction) { - BT_PROFILE("m_batchSolveKernel iterations2"); + B3_PROFILE("m_batchSolveKernel iterations2"); for(int iter=0; iter* 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* body } -void b3Solver::convertToConstraints( const btOpenCLArray* bodyBuf, - const btOpenCLArray* shapeBuf, - btOpenCLArray* contactsIn, btOpenCLArray* contactCOut, void* additionalData, +void b3Solver::convertToConstraints( const b3OpenCLArray* bodyBuf, + const b3OpenCLArray* shapeBuf, + b3OpenCLArray* contactsIn, b3OpenCLArray* contactCOut, void* additionalData, int nContacts, const ConstraintCfg& cfg ) { - btOpenCLArray* constraintNative =0; + b3OpenCLArray* constraintNative =0; struct CB { @@ -728,7 +728,7 @@ void b3Solver::convertToConstraints( const btOpenCLArray* 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* 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* bodyBuf } /* -void b3Solver::sortContacts( const btOpenCLArray* bodyBuf, - btOpenCLArray* contactsIn, void* additionalData, +void b3Solver::sortContacts( const b3OpenCLArray* bodyBuf, + b3OpenCLArray* contactsIn, void* additionalData, int nContacts, const b3Solver::ConstraintCfg& cfg ) { @@ -770,8 +770,8 @@ void b3Solver::sortContacts( const btOpenCLArray* bodyBuf, int sortSize = NEXTMULTIPLEOF( nContacts, sortAlignment ); - btOpenCLArray* countsNative = m_numConstraints;//BufferUtils::map( data->m_device, &countsHost ); - btOpenCLArray* offsetsNative = m_offsets;//BufferUtils::map( data->m_device, &offsetsHost ); + b3OpenCLArray* countsNative = m_numConstraints;//BufferUtils::map( data->m_device, &countsHost ); + b3OpenCLArray* offsetsNative = m_offsets;//BufferUtils::map( data->m_device, &offsetsHost ); { // 2. set cell idx struct CB @@ -782,7 +782,7 @@ void b3Solver::sortContacts( const btOpenCLArray* 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* 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* 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* out = BufferUtils::map( data->m_device, contactsIn ); // copying contacts to this buffer +// b3Assert( contactsIn->getType() == TYPE_HOST ); +// b3OpenCLArray* out = BufferUtils::map( 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* bodyBuf, */ -void b3Solver::batchContacts( btOpenCLArray* contacts, int nContacts, btOpenCLArray* nNative, btOpenCLArray* offsetsNative, int staticIdx ) +void b3Solver::batchContacts( b3OpenCLArray* contacts, int nContacts, b3OpenCLArray* nNative, b3OpenCLArray* 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* contacts, int nContact #ifdef BATCH_DEBUG SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems]; - adl::btOpenCLArray gpuDebugInfo(data->m_device,numWorkItems); + adl::b3OpenCLArray gpuDebugInfo(data->m_device,numWorkItems); memset(debugInfo,0,sizeof(SolverDebugInfo)*numWorkItems); gpuDebugInfo.write(debugInfo,numWorkItems); #endif @@ -857,13 +857,13 @@ void b3Solver::batchContacts( btOpenCLArray* 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* 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* 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? diff --git a/opencl/gpu_rigidbody/host/b3Solver.h b/opencl/gpu_rigidbody/host/b3Solver.h index cdf5dc495..738bfa629 100644 --- a/opencl/gpu_rigidbody/host/b3Solver.h +++ b/opencl/gpu_rigidbody/host/b3Solver.h @@ -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* m_numConstraints; - btOpenCLArray* m_offsets; + b3OpenCLArray* m_numConstraints; + b3OpenCLArray* 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* m_sortDataBuffer; - btOpenCLArray* m_contactBuffer2; + b3OpenCLArray* m_sortDataBuffer; + b3OpenCLArray* m_contactBuffer2; enum { @@ -102,19 +102,19 @@ class b3Solver : public b3SolverBase virtual ~b3Solver(); - void solveContactConstraint( const btOpenCLArray* bodyBuf, const btOpenCLArray* inertiaBuf, - btOpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches); + void solveContactConstraint( const b3OpenCLArray* bodyBuf, const b3OpenCLArray* inertiaBuf, + b3OpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches); - void solveContactConstraintHost( btOpenCLArray* bodyBuf, btOpenCLArray* shapeBuf, - btOpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches); + void solveContactConstraintHost( b3OpenCLArray* bodyBuf, b3OpenCLArray* shapeBuf, + b3OpenCLArray* constraint, void* additionalData, int n ,int maxNumBatches); - void convertToConstraints( const btOpenCLArray* bodyBuf, - const btOpenCLArray* shapeBuf, - btOpenCLArray* contactsIn, btOpenCLArray* contactCOut, void* additionalData, + void convertToConstraints( const b3OpenCLArray* bodyBuf, + const b3OpenCLArray* shapeBuf, + b3OpenCLArray* contactsIn, b3OpenCLArray* contactCOut, void* additionalData, int nContacts, const ConstraintCfg& cfg ); - void batchContacts( btOpenCLArray* contacts, int nContacts, btOpenCLArray* n, btOpenCLArray* offsets, int staticIdx ); + void batchContacts( b3OpenCLArray* contacts, int nContacts, b3OpenCLArray* n, b3OpenCLArray* offsets, int staticIdx ); }; diff --git a/opencl/gpu_rigidbody/kernels/batchingKernelsNew.h b/opencl/gpu_rigidbody/kernels/batchingKernelsNew.h index b54f83671..6471f9aee 100644 --- a/opencl/gpu_rigidbody/kernels/batchingKernelsNew.h +++ b/opencl/gpu_rigidbody/kernels/batchingKernelsNew.h @@ -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" diff --git a/opencl/gpu_rigidbody/kernels/integrateKernel.h b/opencl/gpu_rigidbody/kernels/integrateKernel.h index 296234c81..4ed0e9a8f 100644 --- a/opencl/gpu_rigidbody/kernels/integrateKernel.h +++ b/opencl/gpu_rigidbody/kernels/integrateKernel.h @@ -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" diff --git a/opencl/gpu_rigidbody/kernels/solveContact.h b/opencl/gpu_rigidbody/kernels/solveContact.h index b758f43d8..ccb4daf32 100644 --- a/opencl/gpu_rigidbody/kernels/solveContact.h +++ b/opencl/gpu_rigidbody/kernels/solveContact.h @@ -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" diff --git a/opencl/gpu_rigidbody/kernels/solveFriction.h b/opencl/gpu_rigidbody/kernels/solveFriction.h index 9d6de6ccc..b890bb85c 100644 --- a/opencl/gpu_rigidbody/kernels/solveFriction.h +++ b/opencl/gpu_rigidbody/kernels/solveFriction.h @@ -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" diff --git a/opencl/gpu_rigidbody/kernels/solverSetup.h b/opencl/gpu_rigidbody/kernels/solverSetup.h index 83371897b..ad6ba0e58 100644 --- a/opencl/gpu_rigidbody/kernels/solverSetup.h +++ b/opencl/gpu_rigidbody/kernels/solverSetup.h @@ -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" diff --git a/opencl/gpu_rigidbody/kernels/solverUtils.h b/opencl/gpu_rigidbody/kernels/solverUtils.h index 91726f36e..7b85f6c56 100644 --- a/opencl/gpu_rigidbody/kernels/solverUtils.h +++ b/opencl/gpu_rigidbody/kernels/solverUtils.h @@ -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" diff --git a/opencl/gpu_rigidbody/kernels/updateAabbsKernel.h b/opencl/gpu_rigidbody/kernels/updateAabbsKernel.h index 43db8bb56..8b7f7f42b 100644 --- a/opencl/gpu_rigidbody/kernels/updateAabbsKernel.h +++ b/opencl/gpu_rigidbody/kernels/updateAabbsKernel.h @@ -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" diff --git a/opencl/lds_bank_conflict/main.cpp b/opencl/lds_bank_conflict/main.cpp index 83e6e0ad0..b6e70f688 100644 --- a/opencl/lds_bank_conflict/main.cpp +++ b/opencl/lds_bank_conflict/main.cpp @@ -17,10 +17,10 @@ #include "b3OpenCLUtils.h" -#include "../parallel_primitives/host/btOpenCLArray.h" -#include "../parallel_primitives/host/btLauncherCL.h" +#include "../parallel_primitives/host/b3OpenCLArray.h" +#include "../parallel_primitives/host/b3LauncherCL.h" #include "Bullet3Common/b3Quickprof.h" -#include "../parallel_primitives/host/btFillCL.h" +#include "../parallel_primitives/host/b3FillCL.h" #include "Bullet3Common/b3CommandLineArgs.h" #include @@ -93,7 +93,7 @@ int main(int argc, char **argv) const int mem_size = nx*ny*sizeof(float); const int num_elements = nx*ny; - btClock clock; + b3Clock clock; double startEvent=0.f; double stopEvent=0.f; @@ -172,7 +172,7 @@ char flags[1024]={0}; transposeCoalescedKernel = b3OpenCLUtils::compileCLKernelFromString(ctx,device,cSourceCL,"transposeCoalescedKernel",&ciErrNum,0,flags); transposeNoBankConflictsKernel = b3OpenCLUtils::compileCLKernelFromString(ctx,device,cSourceCL,"transposeNoBankConflictsKernel",&ciErrNum,0,flags); - btFillCL clMemSet(ctx,device,queue); + b3FillCL clMemSet(ctx,device,queue); printf("\n============================================\n"); @@ -184,9 +184,9 @@ char flags[1024]={0}; float *h_tdata = (float*)malloc(mem_size); float *gold = (float*)malloc(mem_size); - btOpenCLArray d_idataCL(ctx,queue);d_idataCL.resize(num_elements); - btOpenCLArray d_cdataCL(ctx,queue);d_cdataCL.resize(num_elements); - btOpenCLArray d_tdataCL(ctx,queue);d_tdataCL.resize(num_elements); + b3OpenCLArray d_idataCL(ctx,queue);d_idataCL.resize(num_elements); + b3OpenCLArray d_cdataCL(ctx,queue);d_cdataCL.resize(num_elements); + b3OpenCLArray d_tdataCL(ctx,queue);d_tdataCL.resize(num_elements); // check parameters and calculate execution configuration @@ -235,7 +235,7 @@ char flags[1024]={0}; { // warm up - btLauncherCL launcher( queue, copyKernel); + b3LauncherCL launcher( queue, copyKernel); launcher.setBuffer( d_cdataCL.getBufferCL()); launcher.setBuffer( d_idataCL.getBufferCL()); launcher.launch2D(numThreadsX,numThreadsY,localSizeX,localSizeY ); @@ -260,7 +260,7 @@ char flags[1024]={0}; clMemSet.execute(d_cdataCL,0.f,num_elements); { - btLauncherCL launcher( queue, copySharedMemKernel); + b3LauncherCL launcher( queue, copySharedMemKernel); launcher.setBuffer( d_cdataCL.getBufferCL()); launcher.setBuffer( d_idataCL.getBufferCL()); launcher.launch2D(numThreadsX,numThreadsY,localSizeX,localSizeY ); @@ -284,7 +284,7 @@ char flags[1024]={0}; clMemSet.execute(d_tdataCL,0.f,num_elements); { // warmup - btLauncherCL launcher( queue, transposeNaiveKernel); + b3LauncherCL launcher( queue, transposeNaiveKernel); launcher.setBuffer( d_tdataCL.getBufferCL()); launcher.setBuffer( d_idataCL.getBufferCL()); launcher.launch2D(numThreadsX,numThreadsY,localSizeX,localSizeY ); @@ -306,7 +306,7 @@ char flags[1024]={0}; printf("%25s", "coalesced transpose"); clMemSet.execute(d_tdataCL,0.f,num_elements); { - btLauncherCL launcher( queue, transposeCoalescedKernel); + b3LauncherCL launcher( queue, transposeCoalescedKernel); launcher.setBuffer( d_tdataCL.getBufferCL()); launcher.setBuffer( d_idataCL.getBufferCL()); launcher.launch2D(numThreadsX,numThreadsY,localSizeX,localSizeY ); @@ -329,7 +329,7 @@ char flags[1024]={0}; printf("%25s", "conflict-free transpose"); clMemSet.execute(d_tdataCL,0.f,num_elements); { - btLauncherCL launcher( queue, transposeNoBankConflictsKernel); + b3LauncherCL launcher( queue, transposeNoBankConflictsKernel); launcher.setBuffer( d_tdataCL.getBufferCL()); launcher.setBuffer( d_idataCL.getBufferCL()); launcher.launch2D(numThreadsX,numThreadsY,localSizeX,localSizeY ); diff --git a/opencl/parallel_primitives/benchmark/premake4.lua b/opencl/parallel_primitives/benchmark/premake4.lua index da57316f8..73499e487 100644 --- a/opencl/parallel_primitives/benchmark/premake4.lua +++ b/opencl/parallel_primitives/benchmark/premake4.lua @@ -21,9 +21,9 @@ function createProject(vendor) "test_large_problem_sorting.cpp", "../../basic_initialize/b3OpenCLUtils.cpp", "../../basic_initialize/b3OpenCLUtils.h", - "../host/btFillCL.cpp", - "../host/btPrefixScanCL.cpp", - "../host/btRadixSort32CL.cpp", + "../host/b3FillCL.cpp", + "../host/b3PrefixScanCL.cpp", + "../host/b3RadixSort32CL.cpp", "../../../src/Bullet3Common/b3AlignedAllocator.cpp", "../../../src/Bullet3Common/b3AlignedAllocator.h", "../../../src/Bullet3Common/b3AlignedObjectArray.h", diff --git a/opencl/parallel_primitives/benchmark/test_large_problem_sorting.cpp b/opencl/parallel_primitives/benchmark/test_large_problem_sorting.cpp index 6f9e089c0..01bf03e8a 100644 --- a/opencl/parallel_primitives/benchmark/test_large_problem_sorting.cpp +++ b/opencl/parallel_primitives/benchmark/test_large_problem_sorting.cpp @@ -64,7 +64,7 @@ * */ -#include "../host/btRadixSort32CL.h" +#include "../host/b3RadixSort32CL.h" #include "../../basic_initialize/b3OpenCLUtils.h" #include "Bullet3Common/b3Quickprof.h" @@ -119,9 +119,9 @@ void TimedSort( hostData[i] = h_keys[i]; } - btRadixSort32CL sorter(g_cxMainContext,g_device,g_cqCommandQueue); + b3RadixSort32CL sorter(g_cxMainContext,g_device,g_cqCommandQueue); - btOpenCLArray gpuData(g_cxMainContext,g_cqCommandQueue); + b3OpenCLArray gpuData(g_cxMainContext,g_cqCommandQueue); gpuData.copyFromHost(hostData); //sorter.executeHost(gpuData); sorter.execute(gpuData); @@ -139,7 +139,7 @@ void TimedSort( // Perform the timed number of sorting iterations double elapsed = 0; float duration = 0; - btClock watch; + b3Clock watch; //warm-start gpuData.copyFromHost(hostData); @@ -218,7 +218,7 @@ void TimedSort( printf("Key-values, %d iterations, %d elements\n", iterations, num_elements); int max_elements = num_elements; - b3AlignedObjectArray hostData; + b3AlignedObjectArray hostData; hostData.resize(num_elements); for (int i=0;i gpuData(g_cxMainContext,g_cqCommandQueue); + b3OpenCLArray gpuData(g_cxMainContext,g_cqCommandQueue); gpuData.copyFromHost(hostData); //sorter.executeHost(gpuData); sorter.execute(gpuData); - b3AlignedObjectArray hostDataSorted; + b3AlignedObjectArray hostDataSorted; gpuData.copyToHost(hostDataSorted); #if 0 for (int i=0;i( device, 1, BufferBase::BUFFER_CONST ); + //m_constBuffer = new b3OpenCLArray( device, 1, BufferBase::BUFFER_CONST ); - m_lower = (maxSize == 0)? 0: new btOpenCLArray(ctx,queue,maxSize ); - m_upper = (maxSize == 0)? 0: new btOpenCLArray(ctx,queue, maxSize ); + m_lower = (maxSize == 0)? 0: new b3OpenCLArray(ctx,queue,maxSize ); + m_upper = (maxSize == 0)? 0: new b3OpenCLArray(ctx,queue, maxSize ); - m_filler = new btFillCL(ctx,device,queue); + m_filler = new b3FillCL(ctx,device,queue); } -btBoundSearchCL::~btBoundSearchCL() +b3BoundSearchCL::~b3BoundSearchCL() { delete m_lower; @@ -77,18 +77,18 @@ btBoundSearchCL::~btBoundSearchCL() } -void btBoundSearchCL::execute(btOpenCLArray& src, int nSrc, btOpenCLArray& dst, int nDst, Option option ) +void b3BoundSearchCL::execute(b3OpenCLArray& src, int nSrc, b3OpenCLArray& dst, int nDst, Option option ) { - btInt4 constBuffer; + b3Int4 constBuffer; constBuffer.x = nSrc; constBuffer.y = nDst; if( option == BOUND_LOWER ) { - btBufferInfoCL bInfo[] = { btBufferInfoCL( src.getBufferCL(), true ), btBufferInfoCL( dst.getBufferCL()) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src.getBufferCL(), true ), b3BufferInfoCL( dst.getBufferCL()) }; - btLauncherCL launcher( m_queue, m_lowerSortDataKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher( m_queue, m_lowerSortDataKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( nSrc ); launcher.setConst( nDst ); @@ -96,10 +96,10 @@ void btBoundSearchCL::execute(btOpenCLArray& src, int nSrc, btOpenCL } else if( option == BOUND_UPPER ) { - btBufferInfoCL bInfo[] = { btBufferInfoCL( src.getBufferCL(), true ), btBufferInfoCL( dst.getBufferCL() ) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src.getBufferCL(), true ), b3BufferInfoCL( dst.getBufferCL() ) }; - btLauncherCL launcher(m_queue, m_upperSortDataKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher(m_queue, m_upperSortDataKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( nSrc ); launcher.setConst( nDst ); @@ -107,10 +107,10 @@ void btBoundSearchCL::execute(btOpenCLArray& src, int nSrc, btOpenCL } else if( option == COUNT ) { - btAssert( m_lower ); - btAssert( m_upper ); - btAssert( m_lower->capacity() <= (int)nDst ); - btAssert( m_upper->capacity() <= (int)nDst ); + b3Assert( m_lower ); + b3Assert( m_upper ); + b3Assert( m_lower->capacity() <= (int)nDst ); + b3Assert( m_upper->capacity() <= (int)nDst ); int zero = 0; m_filler->execute( *m_lower, zero, nDst ); @@ -120,10 +120,10 @@ void btBoundSearchCL::execute(btOpenCLArray& src, int nSrc, btOpenCL execute( src, nSrc, *m_upper, nDst, BOUND_UPPER ); { - btBufferInfoCL bInfo[] = { btBufferInfoCL( m_upper->getBufferCL(), true ), btBufferInfoCL( m_lower->getBufferCL(), true ), btBufferInfoCL( dst.getBufferCL() ) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_upper->getBufferCL(), true ), b3BufferInfoCL( m_lower->getBufferCL(), true ), b3BufferInfoCL( dst.getBufferCL() ) }; - btLauncherCL launcher( m_queue, m_subtractKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher( m_queue, m_subtractKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( nSrc ); launcher.setConst( nDst ); @@ -132,21 +132,21 @@ void btBoundSearchCL::execute(btOpenCLArray& src, int nSrc, btOpenCL } else { - btAssert( 0 ); + b3Assert( 0 ); } } -void btBoundSearchCL::executeHost( b3AlignedObjectArray& src, int nSrc, +void b3BoundSearchCL::executeHost( b3AlignedObjectArray& src, int nSrc, b3AlignedObjectArray& dst, int nDst, Option option ) { for(int i=0; i& src, int nS { for(int i=0; i& src, int nS { for(int i=1; i& src, int nS } else { - btAssert( 0 ); + b3Assert( 0 ); } } diff --git a/opencl/parallel_primitives/host/btBoundSearchCL.h b/opencl/parallel_primitives/host/b3BoundSearchCL.h similarity index 73% rename from opencl/parallel_primitives/host/btBoundSearchCL.h rename to opencl/parallel_primitives/host/b3BoundSearchCL.h index 67e2b3e64..7e2940965 100644 --- a/opencl/parallel_primitives/host/btBoundSearchCL.h +++ b/opencl/parallel_primitives/host/b3BoundSearchCL.h @@ -13,8 +13,8 @@ subject to the following restrictions: */ //Originally written by Takahiro Harada -#ifndef BT_BOUNDSEARCH_H -#define BT_BOUNDSEARCH_H +#ifndef B3_BOUNDSEARCH_H +#define B3_BOUNDSEARCH_H #pragma once @@ -24,10 +24,10 @@ subject to the following restrictions: #include */ -#include "btOpenCLArray.h" -#include "btFillCL.h" -#include "btRadixSort32CL.h" //for btSortData (perhaps move it?) -class btBoundSearchCL +#include "b3OpenCLArray.h" +#include "b3FillCL.h" +#include "b3RadixSort32CL.h" //for b3SortData (perhaps move it?) +class b3BoundSearchCL { public: @@ -47,21 +47,21 @@ class btBoundSearchCL cl_kernel m_upperSortDataKernel; cl_kernel m_subtractKernel; - btOpenCLArray* m_constbtOpenCLArray; - btOpenCLArray* m_lower; - btOpenCLArray* m_upper; + b3OpenCLArray* m_constbtOpenCLArray; + b3OpenCLArray* m_lower; + b3OpenCLArray* m_upper; - btFillCL* m_filler; + b3FillCL* m_filler; - btBoundSearchCL(cl_context context, cl_device_id device, cl_command_queue queue, int size); + b3BoundSearchCL(cl_context context, cl_device_id device, cl_command_queue queue, int size); - virtual ~btBoundSearchCL(); + virtual ~b3BoundSearchCL(); // src has to be src[i].m_key <= src[i+1].m_key - void execute( btOpenCLArray& src, int nSrc, btOpenCLArray& dst, int nDst, Option option = BOUND_LOWER ); + void execute( b3OpenCLArray& src, int nSrc, b3OpenCLArray& dst, int nDst, Option option = BOUND_LOWER ); - void executeHost( b3AlignedObjectArray& src, int nSrc, b3AlignedObjectArray& dst, int nDst, Option option = BOUND_LOWER); + void executeHost( b3AlignedObjectArray& src, int nSrc, b3AlignedObjectArray& dst, int nDst, Option option = BOUND_LOWER); }; -#endif //BT_BOUNDSEARCH_H +#endif //B3_BOUNDSEARCH_H diff --git a/opencl/parallel_primitives/host/b3BufferInfoCL.h b/opencl/parallel_primitives/host/b3BufferInfoCL.h new file mode 100644 index 000000000..52f219ae3 --- /dev/null +++ b/opencl/parallel_primitives/host/b3BufferInfoCL.h @@ -0,0 +1,19 @@ + +#ifndef B3_BUFFER_INFO_CL_H +#define B3_BUFFER_INFO_CL_H + +#include "b3OpenCLArray.h" + + +struct b3BufferInfoCL +{ + //b3BufferInfoCL(){} + +// template + b3BufferInfoCL(cl_mem buff, bool isReadOnly = false): m_clBuffer(buff), m_isReadOnly(isReadOnly){} + + cl_mem m_clBuffer; + bool m_isReadOnly; +}; + +#endif //B3_BUFFER_INFO_CL_H diff --git a/opencl/parallel_primitives/host/btFillCL.cpp b/opencl/parallel_primitives/host/b3FillCL.cpp similarity index 61% rename from opencl/parallel_primitives/host/btFillCL.cpp rename to opencl/parallel_primitives/host/b3FillCL.cpp index 6b4f45ce3..522cecca9 100644 --- a/opencl/parallel_primitives/host/btFillCL.cpp +++ b/opencl/parallel_primitives/host/b3FillCL.cpp @@ -1,13 +1,13 @@ -#include "btFillCL.h" +#include "b3FillCL.h" #include "../../basic_initialize/b3OpenCLUtils.h" -#include "btBufferInfoCL.h" -#include "btLauncherCL.h" +#include "b3BufferInfoCL.h" +#include "b3LauncherCL.h" #define FILL_CL_PROGRAM_PATH "opencl/parallel_primitives/kernels/FillKernels.cl" #include "../kernels/FillKernelsCL.h" -btFillCL::btFillCL(cl_context ctx, cl_device_id device, cl_command_queue queue) +b3FillCL::b3FillCL(cl_context ctx, cl_device_id device, cl_command_queue queue) :m_commandQueue(queue) { const char* kernelSource = fillKernelsCL; @@ -15,25 +15,25 @@ btFillCL::btFillCL(cl_context ctx, cl_device_id device, cl_command_queue queue) const char* additionalMacros = ""; cl_program fillProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, kernelSource, &pErrNum,additionalMacros, FILL_CL_PROGRAM_PATH); - btAssert(fillProg); + b3Assert(fillProg); m_fillIntKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "FillIntKernel", &pErrNum, fillProg,additionalMacros ); - btAssert(m_fillIntKernel); + b3Assert(m_fillIntKernel); m_fillUnsignedIntKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "FillUnsignedIntKernel", &pErrNum, fillProg,additionalMacros ); - btAssert(m_fillIntKernel); + b3Assert(m_fillIntKernel); m_fillFloatKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "FillFloatKernel", &pErrNum, fillProg,additionalMacros ); - btAssert(m_fillFloatKernel); + b3Assert(m_fillFloatKernel); m_fillKernelInt2 = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "FillInt2Kernel", &pErrNum, fillProg,additionalMacros ); - btAssert(m_fillKernelInt2); + b3Assert(m_fillKernelInt2); } -btFillCL::~btFillCL() +b3FillCL::~b3FillCL() { clReleaseKernel(m_fillKernelInt2); clReleaseKernel(m_fillIntKernel); @@ -42,12 +42,12 @@ btFillCL::~btFillCL() } -void btFillCL::execute(btOpenCLArray& src, const float value, int n, int offset) +void b3FillCL::execute(b3OpenCLArray& src, const float value, int n, int offset) { - btAssert( n>0 ); + b3Assert( n>0 ); { - btLauncherCL launcher( m_commandQueue, m_fillFloatKernel ); + b3LauncherCL launcher( m_commandQueue, m_fillFloatKernel ); launcher.setBuffer( src.getBufferCL()); launcher.setConst( n ); launcher.setConst( value ); @@ -57,13 +57,13 @@ void btFillCL::execute(btOpenCLArray& src, const float value, int n, int } } -void btFillCL::execute(btOpenCLArray& src, const int value, int n, int offset) +void b3FillCL::execute(b3OpenCLArray& src, const int value, int n, int offset) { - btAssert( n>0 ); + b3Assert( n>0 ); { - btLauncherCL launcher( m_commandQueue, m_fillIntKernel ); + b3LauncherCL launcher( m_commandQueue, m_fillIntKernel ); launcher.setBuffer(src.getBufferCL()); launcher.setConst( n); launcher.setConst( value); @@ -73,15 +73,15 @@ void btFillCL::execute(btOpenCLArray& src, const int value, int n, int offs } -void btFillCL::execute(btOpenCLArray& src, const unsigned int value, int n, int offset) +void b3FillCL::execute(b3OpenCLArray& src, const unsigned int value, int n, int offset) { - btAssert( n>0 ); + b3Assert( n>0 ); { - btBufferInfoCL bInfo[] = { btBufferInfoCL( src.getBufferCL() ) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src.getBufferCL() ) }; - btLauncherCL launcher( m_commandQueue, m_fillUnsignedIntKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher( m_commandQueue, m_fillUnsignedIntKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( n ); launcher.setConst(value); launcher.setConst(offset); @@ -90,7 +90,7 @@ void btFillCL::execute(btOpenCLArray& src, const unsigned int valu } } -void btFillCL::executeHost(b3AlignedObjectArray &src, const btInt2 &value, int n, int offset) +void b3FillCL::executeHost(b3AlignedObjectArray &src, const b3Int2 &value, int n, int offset) { for (int i=0;i &src, const btInt2 &valu } } -void btFillCL::executeHost(b3AlignedObjectArray &src, const int value, int n, int offset) +void b3FillCL::executeHost(b3AlignedObjectArray &src, const int value, int n, int offset) { for (int i=0;i &src, const int value, int } } -void btFillCL::execute(btOpenCLArray &src, const btInt2 &value, int n, int offset) +void b3FillCL::execute(b3OpenCLArray &src, const b3Int2 &value, int n, int offset) { - btAssert( n>0 ); + b3Assert( n>0 ); { - btBufferInfoCL bInfo[] = { btBufferInfoCL( src.getBufferCL() ) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src.getBufferCL() ) }; - btLauncherCL launcher(m_commandQueue, m_fillKernelInt2); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher(m_commandQueue, m_fillKernelInt2); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst(n); launcher.setConst(value); launcher.setConst(offset); diff --git a/opencl/parallel_primitives/host/b3FillCL.h b/opencl/parallel_primitives/host/b3FillCL.h new file mode 100644 index 000000000..113c549b4 --- /dev/null +++ b/opencl/parallel_primitives/host/b3FillCL.h @@ -0,0 +1,63 @@ +#ifndef B3_FILL_CL_H +#define B3_FILL_CL_H + +#include "b3OpenCLArray.h" +#include "Bullet3Common/b3Scalar.h" + +#include "b3Int2.h" +#include "b3Int4.h" + + +class b3FillCL +{ + + cl_command_queue m_commandQueue; + + cl_kernel m_fillKernelInt2; + cl_kernel m_fillIntKernel; + cl_kernel m_fillUnsignedIntKernel; + cl_kernel m_fillFloatKernel; + + public: + + struct b3ConstData + { + union + { + b3Int4 m_data; + b3UnsignedInt4 m_UnsignedData; + }; + int m_offset; + int m_n; + int m_padding[2]; + }; + +protected: + +public: + + b3FillCL(cl_context ctx, cl_device_id device, cl_command_queue queue); + + virtual ~b3FillCL(); + + void execute(b3OpenCLArray& src, const unsigned int value, int n, int offset = 0); + + void execute(b3OpenCLArray& src, const int value, int n, int offset = 0); + + void execute(b3OpenCLArray& src, const float value, int n, int offset = 0); + + void execute(b3OpenCLArray& src, const b3Int2& value, int n, int offset = 0); + + void executeHost(b3AlignedObjectArray &src, const b3Int2 &value, int n, int offset); + + void executeHost(b3AlignedObjectArray &src, const int value, int n, int offset); + + // void execute(b3OpenCLArray& src, const b3Int4& value, int n, int offset = 0); + +}; + + + + + +#endif //B3_FILL_CL_H diff --git a/src/Bullet3Common/btInt2.h b/opencl/parallel_primitives/host/b3Int2.h similarity index 72% rename from src/Bullet3Common/btInt2.h rename to opencl/parallel_primitives/host/b3Int2.h index a0a2977d8..be0dbd9bd 100644 --- a/src/Bullet3Common/btInt2.h +++ b/opencl/parallel_primitives/host/b3Int2.h @@ -1,7 +1,7 @@ -#ifndef BT_INT2_H -#define BT_INT2_H +#ifndef B3_INT2_H +#define B3_INT2_H -struct btUnsignedInt2 +struct b3UnsignedInt2 { union { @@ -16,7 +16,7 @@ struct btUnsignedInt2 }; }; -struct btInt2 +struct b3Int2 { union { diff --git a/opencl/parallel_primitives/host/btInt4.h b/opencl/parallel_primitives/host/b3Int4.h similarity index 53% rename from opencl/parallel_primitives/host/btInt4.h rename to opencl/parallel_primitives/host/b3Int4.h index a66a0d10d..ed043f1ea 100644 --- a/opencl/parallel_primitives/host/btInt4.h +++ b/opencl/parallel_primitives/host/b3Int4.h @@ -1,11 +1,11 @@ -#ifndef BT_INT4_H -#define BT_INT4_H +#ifndef B3_INT4_H +#define B3_INT4_H #include "Bullet3Common/b3Scalar.h" -ATTRIBUTE_ALIGNED16(struct) btUnsignedInt4 +ATTRIBUTE_ALIGNED16(struct) b3UnsignedInt4 { - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); union { @@ -20,9 +20,9 @@ ATTRIBUTE_ALIGNED16(struct) btUnsignedInt4 }; }; -ATTRIBUTE_ALIGNED16(struct) btInt4 +ATTRIBUTE_ALIGNED16(struct) b3Int4 { - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); union { @@ -37,19 +37,19 @@ ATTRIBUTE_ALIGNED16(struct) btInt4 }; }; -SIMD_FORCE_INLINE btInt4 btMakeInt4(int x, int y, int z, int w = 0) +SIMD_FORCE_INLINE b3Int4 b3MakeInt4(int x, int y, int z, int w = 0) { - btInt4 v; + b3Int4 v; v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w; return v; } -SIMD_FORCE_INLINE btUnsignedInt4 btMakeUnsignedInt4(unsigned int x, unsigned int y, unsigned int z, unsigned int w = 0) +SIMD_FORCE_INLINE b3UnsignedInt4 b3MakeUnsignedInt4(unsigned int x, unsigned int y, unsigned int z, unsigned int w = 0) { - btUnsignedInt4 v; + b3UnsignedInt4 v; v.s[0] = x; v.s[1] = y; v.s[2] = z; v.s[3] = w; return v; } -#endif //BT_INT4_H +#endif //B3_INT4_H diff --git a/opencl/parallel_primitives/host/btLauncherCL.h b/opencl/parallel_primitives/host/b3LauncherCL.h similarity index 83% rename from opencl/parallel_primitives/host/btLauncherCL.h rename to opencl/parallel_primitives/host/b3LauncherCL.h index aebad90b3..5d1f0db86 100644 --- a/opencl/parallel_primitives/host/btLauncherCL.h +++ b/opencl/parallel_primitives/host/b3LauncherCL.h @@ -1,17 +1,17 @@ -#ifndef BT_LAUNCHER_CL_H -#define BT_LAUNCHER_CL_H +#ifndef B3_LAUNCHER_CL_H +#define B3_LAUNCHER_CL_H -#include "btBufferInfoCL.h" +#include "b3BufferInfoCL.h" #include "Bullet3Common/b3MinMax.h" -#include "btOpenCLArray.h" +#include "b3OpenCLArray.h" #include #ifdef _WIN32 #pragma warning(disable :4996) #endif -#define BT_CL_MAX_ARG_SIZE 16 -struct btKernelArgData +#define B3_CL_MAX_ARG_SIZE 16 +struct b3KernelArgData { int m_isBuffer; int m_argIndex; @@ -19,28 +19,28 @@ struct btKernelArgData union { cl_mem m_clBuffer; - unsigned char m_argData[BT_CL_MAX_ARG_SIZE]; + unsigned char m_argData[B3_CL_MAX_ARG_SIZE]; }; }; -class btLauncherCL +class b3LauncherCL { cl_command_queue m_commandQueue; cl_kernel m_kernel; int m_idx; - b3AlignedObjectArray m_kernelArguments; + b3AlignedObjectArray m_kernelArguments; int m_serializationSizeInBytes; public: - b3AlignedObjectArray* > m_arrays; + b3AlignedObjectArray* > m_arrays; - btLauncherCL(cl_command_queue queue, cl_kernel kernel) + b3LauncherCL(cl_command_queue queue, cl_kernel kernel) :m_commandQueue(queue), m_kernel(kernel), m_idx(0) @@ -48,7 +48,7 @@ class btLauncherCL m_serializationSizeInBytes = sizeof(int); } - virtual ~btLauncherCL() + virtual ~b3LauncherCL() { for (int i=0;im_isBuffer) { - btOpenCLArray* clData = new btOpenCLArray(ctx,m_commandQueue, arg->m_argSizeInBytes); + b3OpenCLArray* clData = new b3OpenCLArray(ctx,m_commandQueue, arg->m_argSizeInBytes); clData->resize(arg->m_argSizeInBytes); clData->copyFromHostPointer(&buf[index], arg->m_argSizeInBytes); @@ -148,12 +148,12 @@ class btLauncherCL m_arrays.push_back(clData); cl_int status = clSetKernelArg( m_kernel, m_idx++, sizeof(cl_mem), &arg->m_clBuffer); - btAssert( status == CL_SUCCESS ); + b3Assert( status == CL_SUCCESS ); index+=arg->m_argSizeInBytes; } else { cl_int status = clSetKernelArg( m_kernel, m_idx++, arg->m_argSizeInBytes, &arg->m_argData); - btAssert( status == CL_SUCCESS ); + b3Assert( status == CL_SUCCESS ); } m_kernelArguments.push_back(*arg); } @@ -176,7 +176,7 @@ class btLauncherCL for (int ii=0;iim_argSizeInBytes) { @@ -194,7 +194,7 @@ class btLauncherCL return -3; } } - index+=sizeof(btKernelArgData); + index+=sizeof(b3KernelArgData); if (argGold->m_isBuffer) { @@ -209,7 +209,7 @@ class btLauncherCL cl_int status = 0; status = clEnqueueReadBuffer( m_commandQueue, m_kernelArguments[ii].m_clBuffer, CL_TRUE, 0, m_kernelArguments[ii].m_argSizeInBytes, memBuf, 0,0,0 ); - btAssert( status==CL_SUCCESS ); + b3Assert( status==CL_SUCCESS ); clFinish(m_commandQueue); for (int b=0;b=m_serializationSizeInBytes); - //todo: use the btSerializer for this to allow for 32/64bit, endianness etc + //todo: use the b3Serializer for this to allow for 32/64bit, endianness etc int numArguments = m_kernelArguments.size(); int curBufferSize = 0; int* dest = (int*)&destBuffer[curBufferSize]; @@ -267,16 +267,16 @@ class btLauncherCL for (int i=0;im_kernelArguments.size();i++) { - btKernelArgData* arg = (btKernelArgData*) &destBuffer[curBufferSize]; + b3KernelArgData* arg = (b3KernelArgData*) &destBuffer[curBufferSize]; *arg = m_kernelArguments[i]; - curBufferSize+=sizeof(btKernelArgData); + curBufferSize+=sizeof(b3KernelArgData); if (arg->m_isBuffer==1) { //copy the OpenCL buffer content cl_int status = 0; status = clEnqueueReadBuffer( m_commandQueue, arg->m_clBuffer, 0, 0, arg->m_argSizeInBytes, &destBuffer[curBufferSize], 0,0,0 ); - btAssert( status==CL_SUCCESS ); + b3Assert( status==CL_SUCCESS ); clFinish(m_commandQueue); curBufferSize+=arg->m_argSizeInBytes; } @@ -317,18 +317,18 @@ class btLauncherCL inline void setConst( const T& consts ) { int sz=sizeof(T); - btAssert(sz<=BT_CL_MAX_ARG_SIZE); - btKernelArgData kernelArg; + b3Assert(sz<=B3_CL_MAX_ARG_SIZE); + b3KernelArgData kernelArg; kernelArg.m_argIndex = m_idx; kernelArg.m_isBuffer = 0; T* destArg = (T*)kernelArg.m_argData; *destArg = consts; kernelArg.m_argSizeInBytes = sizeof(T); m_kernelArguments.push_back(kernelArg); - m_serializationSizeInBytes+=sizeof(btKernelArgData); + m_serializationSizeInBytes+=sizeof(b3KernelArgData); cl_int status = clSetKernelArg( m_kernel, m_idx++, sz, &consts ); - btAssert( status == CL_SUCCESS ); + b3Assert( status == CL_SUCCESS ); } inline void launch1D( int numThreads, int localSize = 64) @@ -342,9 +342,9 @@ class btLauncherCL size_t lRange[3] = {1,1,1}; lRange[0] = localSizeX; lRange[1] = localSizeY; - gRange[0] = btMax((size_t)1, (numThreadsX/lRange[0])+(!(numThreadsX%lRange[0])?0:1)); + gRange[0] = b3Max((size_t)1, (numThreadsX/lRange[0])+(!(numThreadsX%lRange[0])?0:1)); gRange[0] *= lRange[0]; - gRange[1] = btMax((size_t)1, (numThreadsY/lRange[1])+(!(numThreadsY%lRange[1])?0:1)); + gRange[1] = b3Max((size_t)1, (numThreadsY/lRange[1])+(!(numThreadsY%lRange[1])?0:1)); gRange[1] *= lRange[1]; cl_int status = clEnqueueNDRangeKernel( m_commandQueue, @@ -353,11 +353,11 @@ class btLauncherCL { printf("Error: OpenCL status = %d\n",status); } - btAssert( status == CL_SUCCESS ); + b3Assert( status == CL_SUCCESS ); } }; -#endif //BT_LAUNCHER_CL_H +#endif //B3_LAUNCHER_CL_H diff --git a/opencl/parallel_primitives/host/btOpenCLArray.h b/opencl/parallel_primitives/host/b3OpenCLArray.h similarity index 82% rename from opencl/parallel_primitives/host/btOpenCLArray.h rename to opencl/parallel_primitives/host/b3OpenCLArray.h index 9e446b67a..05277cab8 100644 --- a/opencl/parallel_primitives/host/btOpenCLArray.h +++ b/opencl/parallel_primitives/host/b3OpenCLArray.h @@ -1,11 +1,11 @@ -#ifndef BT_OPENCL_ARRAY_H -#define BT_OPENCL_ARRAY_H +#ifndef B3_OPENCL_ARRAY_H +#define B3_OPENCL_ARRAY_H #include "Bullet3Common/b3AlignedObjectArray.h" #include "../../basic_initialize/b3OpenCLInclude.h" template -class btOpenCLArray +class b3OpenCLArray { int m_size; int m_capacity; @@ -28,7 +28,7 @@ class btOpenCLArray m_capacity=0; } - btOpenCLArray& operator=(const btOpenCLArray& src); + b3OpenCLArray& operator=(const b3OpenCLArray& src); SIMD_FORCE_INLINE int allocSize(int size) { @@ -37,7 +37,7 @@ class btOpenCLArray public: - btOpenCLArray(cl_context ctx, cl_command_queue queue, int initialCapacity=0, bool allowGrowingCapacity=true) + b3OpenCLArray(cl_context ctx, cl_command_queue queue, int initialCapacity=0, bool allowGrowingCapacity=true) :m_size(0), m_capacity(0),m_clBuffer(0), m_clContext(ctx),m_commandQueue(queue), m_ownsMemory(true),m_allowGrowingCapacity(true) @@ -61,7 +61,7 @@ public: } // we could enable this assignment, but need to make sure to avoid accidental deep copies -// btOpenCLArray& operator=(const b3AlignedObjectArray& src) +// b3OpenCLArray& operator=(const b3AlignedObjectArray& src) // { // copyFromArray(src); // return *this; @@ -74,7 +74,7 @@ public: } - virtual ~btOpenCLArray() + virtual ~b3OpenCLArray() { deallocate(); m_size=0; @@ -94,8 +94,8 @@ public: SIMD_FORCE_INLINE T forcedAt(int n) const { - btAssert(n>=0); - btAssert(n=0); + b3Assert(n=0); - btAssert(n=0); + b3Assert(n0); - btAssert(numElements<=m_size); + b3Assert(numElements>0); + b3Assert(numElements<=m_size); int srcOffsetBytes = sizeof(T)*firstElem; int dstOffsetInBytes = sizeof(T)*dstOffsetInElems; @@ -209,7 +209,7 @@ public: status = clEnqueueCopyBuffer( m_commandQueue, m_clBuffer, destination, srcOffsetBytes, dstOffsetInBytes, sizeof(T)*numElements, 0, 0, 0 ); - btAssert( status == CL_SUCCESS ); + b3Assert( status == CL_SUCCESS ); } void copyFromHost(const b3AlignedObjectArray& srcArray, bool waitForCompletion=true) @@ -225,13 +225,13 @@ public: void copyFromHostPointer(const T* src, int numElems, int destFirstElem= 0, bool waitForCompletion=true) { - btAssert(numElems+destFirstElem <= capacity()); + b3Assert(numElems+destFirstElem <= capacity()); cl_int status = 0; int sizeInBytes=sizeof(T)*numElems; status = clEnqueueWriteBuffer( m_commandQueue, m_clBuffer, 0, sizeof(T)*destFirstElem, sizeInBytes, src, 0,0,0 ); - btAssert(status == CL_SUCCESS ); + b3Assert(status == CL_SUCCESS ); if (waitForCompletion) clFinish(m_commandQueue); @@ -247,18 +247,18 @@ public: void copyToHostPointer(T* destPtr, int numElem, int srcFirstElem=0, bool waitForCompletion=true) const { - btAssert(numElem+srcFirstElem <= capacity()); + b3Assert(numElem+srcFirstElem <= capacity()); cl_int status = 0; status = clEnqueueReadBuffer( m_commandQueue, m_clBuffer, 0, sizeof(T)*srcFirstElem, sizeof(T)*numElem, destPtr, 0,0,0 ); - btAssert( status==CL_SUCCESS ); + b3Assert( status==CL_SUCCESS ); if (waitForCompletion) clFinish(m_commandQueue); } - void copyFromOpenCLArray(const btOpenCLArray& src) + void copyFromOpenCLArray(const b3OpenCLArray& src) { int newSize = src.size(); resize(newSize); @@ -271,4 +271,4 @@ public: }; -#endif //BT_OPENCL_ARRAY_H +#endif //B3_OPENCL_ARRAY_H diff --git a/opencl/parallel_primitives/host/btPrefixScanCL.cpp b/opencl/parallel_primitives/host/b3PrefixScanCL.cpp similarity index 56% rename from opencl/parallel_primitives/host/btPrefixScanCL.cpp rename to opencl/parallel_primitives/host/b3PrefixScanCL.cpp index a7ee23fcf..4a9359e54 100644 --- a/opencl/parallel_primitives/host/btPrefixScanCL.cpp +++ b/opencl/parallel_primitives/host/b3PrefixScanCL.cpp @@ -1,32 +1,32 @@ -#include "btPrefixScanCL.h" -#include "btFillCL.h" -#define BT_PREFIXSCAN_PROG_PATH "opencl/parallel_primitives/kernels/PrefixScanKernels.cl" +#include "b3PrefixScanCL.h" +#include "b3FillCL.h" +#define B3_PREFIXSCAN_PROG_PATH "opencl/parallel_primitives/kernels/PrefixScanKernels.cl" -#include "btLauncherCL.h" +#include "b3LauncherCL.h" #include "../../basic_initialize/b3OpenCLUtils.h" #include "../kernels/PrefixScanKernelsCL.h" -btPrefixScanCL::btPrefixScanCL(cl_context ctx, cl_device_id device, cl_command_queue queue, int size) +b3PrefixScanCL::b3PrefixScanCL(cl_context ctx, cl_device_id device, cl_command_queue queue, int size) :m_commandQueue(queue) { const char* scanKernelSource = prefixScanKernelsCL; cl_int pErrNum; char* additionalMacros=0; - m_workBuffer = new btOpenCLArray(ctx,queue,size); - cl_program scanProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, scanKernelSource, &pErrNum,additionalMacros, BT_PREFIXSCAN_PROG_PATH); - btAssert(scanProg); + m_workBuffer = new b3OpenCLArray(ctx,queue,size); + cl_program scanProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, scanKernelSource, &pErrNum,additionalMacros, B3_PREFIXSCAN_PROG_PATH); + b3Assert(scanProg); m_localScanKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, scanKernelSource, "LocalScanKernel", &pErrNum, scanProg,additionalMacros ); - btAssert(m_localScanKernel ); + b3Assert(m_localScanKernel ); m_blockSumKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, scanKernelSource, "TopLevelScanKernel", &pErrNum, scanProg,additionalMacros ); - btAssert(m_blockSumKernel ); + b3Assert(m_blockSumKernel ); m_propagationKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, scanKernelSource, "AddOffsetKernel", &pErrNum, scanProg,additionalMacros ); - btAssert(m_propagationKernel ); + b3Assert(m_propagationKernel ); } -btPrefixScanCL::~btPrefixScanCL() +b3PrefixScanCL::~b3PrefixScanCL() { delete m_workBuffer; clReleaseKernel(m_localScanKernel); @@ -35,7 +35,7 @@ btPrefixScanCL::~btPrefixScanCL() } template -T btNextPowerOf2(T n) +T b3NextPowerOf2(T n) { n -= 1; for(int i=0; i& src, btOpenCLArray& dst, int n, unsigned int* sum) +void b3PrefixScanCL::execute(b3OpenCLArray& src, b3OpenCLArray& dst, int n, unsigned int* sum) { -// btAssert( data->m_option == EXCLUSIVE ); +// b3Assert( data->m_option == EXCLUSIVE ); const unsigned int numBlocks = (const unsigned int)( (n+BLOCK_SIZE*2-1)/(BLOCK_SIZE*2) ); dst.resize(src.size()); m_workBuffer->resize(src.size()); - btInt4 constBuffer; + b3Int4 constBuffer; constBuffer.x = n; constBuffer.y = numBlocks; - constBuffer.z = (int)btNextPowerOf2( numBlocks ); + constBuffer.z = (int)b3NextPowerOf2( numBlocks ); - btOpenCLArray* srcNative = &src; - btOpenCLArray* dstNative = &dst; + b3OpenCLArray* srcNative = &src; + b3OpenCLArray* dstNative = &dst; { - btBufferInfoCL bInfo[] = { btBufferInfoCL( dstNative->getBufferCL() ), btBufferInfoCL( srcNative->getBufferCL() ), btBufferInfoCL( m_workBuffer->getBufferCL() ) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( dstNative->getBufferCL() ), b3BufferInfoCL( srcNative->getBufferCL() ), b3BufferInfoCL( m_workBuffer->getBufferCL() ) }; - btLauncherCL launcher( m_commandQueue, m_localScanKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher( m_commandQueue, m_localScanKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( constBuffer ); launcher.launch1D( numBlocks*BLOCK_SIZE, BLOCK_SIZE ); } { - btBufferInfoCL bInfo[] = { btBufferInfoCL( m_workBuffer->getBufferCL() ) }; + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_workBuffer->getBufferCL() ) }; - btLauncherCL launcher( m_commandQueue, m_blockSumKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3LauncherCL launcher( m_commandQueue, m_blockSumKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( constBuffer ); launcher.launch1D( BLOCK_SIZE, BLOCK_SIZE ); } @@ -81,9 +81,9 @@ void btPrefixScanCL::execute(btOpenCLArray& src, btOpenCLArray 1 ) { - btBufferInfoCL bInfo[] = { btBufferInfoCL( dstNative->getBufferCL() ), btBufferInfoCL( m_workBuffer->getBufferCL() ) }; - btLauncherCL launcher( m_commandQueue, m_propagationKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( dstNative->getBufferCL() ), b3BufferInfoCL( m_workBuffer->getBufferCL() ) }; + b3LauncherCL launcher( m_commandQueue, m_propagationKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( constBuffer ); launcher.launch1D( (numBlocks-1)*BLOCK_SIZE, BLOCK_SIZE ); } @@ -98,7 +98,7 @@ void btPrefixScanCL::execute(btOpenCLArray& src, btOpenCLArray& src, b3AlignedObjectArray& dst, int n, unsigned int* sum) +void b3PrefixScanCL::executeHost(b3AlignedObjectArray& src, b3AlignedObjectArray& dst, int n, unsigned int* sum) { unsigned int s = 0; //if( data->m_option == EXCLUSIVE ) diff --git a/opencl/parallel_primitives/host/btPrefixScanCL.h b/opencl/parallel_primitives/host/b3PrefixScanCL.h similarity index 55% rename from opencl/parallel_primitives/host/btPrefixScanCL.h rename to opencl/parallel_primitives/host/b3PrefixScanCL.h index 087df14c0..665e46e90 100644 --- a/opencl/parallel_primitives/host/btPrefixScanCL.h +++ b/opencl/parallel_primitives/host/b3PrefixScanCL.h @@ -1,12 +1,12 @@ -#ifndef BT_PREFIX_SCAN_CL_H -#define BT_PREFIX_SCAN_CL_H +#ifndef B3_PREFIX_SCAN_CL_H +#define B3_PREFIX_SCAN_CL_H -#include "btOpenCLArray.h" -#include "btBufferInfoCL.h" +#include "b3OpenCLArray.h" +#include "b3BufferInfoCL.h" #include "Bullet3Common/b3AlignedObjectArray.h" -class btPrefixScanCL +class b3PrefixScanCL { enum { @@ -21,17 +21,17 @@ class btPrefixScanCL cl_kernel m_blockSumKernel; cl_kernel m_propagationKernel; - btOpenCLArray* m_workBuffer; + b3OpenCLArray* m_workBuffer; public: - btPrefixScanCL(cl_context ctx, cl_device_id device, cl_command_queue queue,int size=0); + b3PrefixScanCL(cl_context ctx, cl_device_id device, cl_command_queue queue,int size=0); - virtual ~btPrefixScanCL(); + virtual ~b3PrefixScanCL(); - void execute(btOpenCLArray& src, btOpenCLArray& dst, int n, unsigned int* sum = 0); + void execute(b3OpenCLArray& src, b3OpenCLArray& dst, int n, unsigned int* sum = 0); void executeHost(b3AlignedObjectArray& src, b3AlignedObjectArray& dst, int n, unsigned int* sum); }; -#endif //BT_PREFIX_SCAN_CL_H +#endif //B3_PREFIX_SCAN_CL_H diff --git a/opencl/parallel_primitives/host/btRadixSort32CL.cpp b/opencl/parallel_primitives/host/b3RadixSort32CL.cpp similarity index 77% rename from opencl/parallel_primitives/host/btRadixSort32CL.cpp rename to opencl/parallel_primitives/host/b3RadixSort32CL.cpp index be4616d56..9f5345896 100644 --- a/opencl/parallel_primitives/host/btRadixSort32CL.cpp +++ b/opencl/parallel_primitives/host/b3RadixSort32CL.cpp @@ -1,27 +1,27 @@ -#include "btRadixSort32CL.h" -#include "btLauncherCL.h" +#include "b3RadixSort32CL.h" +#include "b3LauncherCL.h" #include "../../basic_initialize/b3OpenCLUtils.h" -#include "btPrefixScanCL.h" -#include "btFillCL.h" +#include "b3PrefixScanCL.h" +#include "b3FillCL.h" #define RADIXSORT32_PATH "opencl/parallel_primitives/kernels/RadixSort32Kernels.cl" #include "../kernels/RadixSort32KernelsCL.h" -btRadixSort32CL::btRadixSort32CL(cl_context ctx, cl_device_id device, cl_command_queue queue, int initialCapacity) +b3RadixSort32CL::b3RadixSort32CL(cl_context ctx, cl_device_id device, cl_command_queue queue, int initialCapacity) :m_commandQueue(queue) { - btOpenCLDeviceInfo info; + b3OpenCLDeviceInfo info; b3OpenCLUtils::getDeviceInfo(device,&info); m_deviceCPU = (info.m_deviceType & CL_DEVICE_TYPE_CPU)!=0; - m_workBuffer1 = new btOpenCLArray(ctx,queue); - m_workBuffer2 = new btOpenCLArray(ctx,queue); - m_workBuffer3 = new btOpenCLArray(ctx,queue); - m_workBuffer3a = new btOpenCLArray(ctx,queue); - m_workBuffer4 = new btOpenCLArray(ctx,queue); - m_workBuffer4a = new btOpenCLArray(ctx,queue); + m_workBuffer1 = new b3OpenCLArray(ctx,queue); + m_workBuffer2 = new b3OpenCLArray(ctx,queue); + m_workBuffer3 = new b3OpenCLArray(ctx,queue); + m_workBuffer3a = new b3OpenCLArray(ctx,queue); + m_workBuffer4 = new b3OpenCLArray(ctx,queue); + m_workBuffer4a = new b3OpenCLArray(ctx,queue); if (initialCapacity>0) @@ -33,8 +33,8 @@ btRadixSort32CL::btRadixSort32CL(cl_context ctx, cl_device_id device, cl_command m_workBuffer4a->resize(initialCapacity); } - m_scan = new btPrefixScanCL(ctx,device,queue); - m_fill = new btFillCL(ctx,device,queue); + m_scan = new b3PrefixScanCL(ctx,device,queue); + m_fill = new b3FillCL(ctx,device,queue); const char* additionalMacros = ""; const char* srcFileNameForCaching=""; @@ -43,15 +43,15 @@ btRadixSort32CL::btRadixSort32CL(cl_context ctx, cl_device_id device, cl_command const char* kernelSource = radixSort32KernelsCL; cl_program sortProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, kernelSource, &pErrNum,additionalMacros, RADIXSORT32_PATH); - btAssert(sortProg); + b3Assert(sortProg); m_streamCountSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "StreamCountSortDataKernel", &pErrNum, sortProg,additionalMacros ); - btAssert(m_streamCountSortDataKernel ); + b3Assert(m_streamCountSortDataKernel ); m_streamCountKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "StreamCountKernel", &pErrNum, sortProg,additionalMacros ); - btAssert(m_streamCountKernel); + b3Assert(m_streamCountKernel); @@ -59,23 +59,23 @@ btRadixSort32CL::btRadixSort32CL(cl_context ctx, cl_device_id device, cl_command { m_sortAndScatterSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "SortAndScatterSortDataKernelSerial", &pErrNum, sortProg,additionalMacros ); - btAssert(m_sortAndScatterSortDataKernel); + b3Assert(m_sortAndScatterSortDataKernel); m_sortAndScatterKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "SortAndScatterKernelSerial", &pErrNum, sortProg,additionalMacros ); - btAssert(m_sortAndScatterKernel); + b3Assert(m_sortAndScatterKernel); } else { m_sortAndScatterSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "SortAndScatterSortDataKernel", &pErrNum, sortProg,additionalMacros ); - btAssert(m_sortAndScatterSortDataKernel); + b3Assert(m_sortAndScatterSortDataKernel); m_sortAndScatterKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "SortAndScatterKernel", &pErrNum, sortProg,additionalMacros ); - btAssert(m_sortAndScatterKernel); + b3Assert(m_sortAndScatterKernel); } m_prefixScanKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, kernelSource, "PrefixScanKernel", &pErrNum, sortProg,additionalMacros ); - btAssert(m_prefixScanKernel); + b3Assert(m_prefixScanKernel); } -btRadixSort32CL::~btRadixSort32CL() +b3RadixSort32CL::~b3RadixSort32CL() { delete m_scan; delete m_fill; @@ -93,7 +93,7 @@ btRadixSort32CL::~btRadixSort32CL() clReleaseKernel(m_prefixScanKernel); } -void btRadixSort32CL::executeHost(b3AlignedObjectArray& inout, int sortBits /* = 32 */) +void b3RadixSort32CL::executeHost(b3AlignedObjectArray& inout, int sortBits /* = 32 */) { int n = inout.size(); const int BITS_PER_PASS = 8; @@ -103,10 +103,10 @@ void btRadixSort32CL::executeHost(b3AlignedObjectArray& inout, int s int tables[NUM_TABLES]; int counter[NUM_TABLES]; - btSortData* src = &inout[0]; - b3AlignedObjectArray workbuffer; + b3SortData* src = &inout[0]; + b3AlignedObjectArray workbuffer; workbuffer.resize(inout.size()); - btSortData* dst = &workbuffer[0]; + b3SortData* dst = &workbuffer[0]; int count=0; for(int startBit=0; startBit& inout, int s counter[tableIdx] ++; } - btSwap( src, dst ); + b3Swap( src, dst ); count++; } if (count&1) { - btAssert(0);//need to copy + b3Assert(0);//need to copy } } -void btRadixSort32CL::executeHost(btOpenCLArray& keyValuesInOut, int sortBits /* = 32 */) +void b3RadixSort32CL::executeHost(b3OpenCLArray& keyValuesInOut, int sortBits /* = 32 */) { - b3AlignedObjectArray inout; + b3AlignedObjectArray inout; keyValuesInOut.copyToHost(inout); executeHost(inout,sortBits); @@ -174,8 +174,8 @@ void btRadixSort32CL::executeHost(btOpenCLArray& keyValuesInOut, int keyValuesInOut.copyFromHost(inout); } -void btRadixSort32CL::execute(btOpenCLArray& keysIn, btOpenCLArray& keysOut, btOpenCLArray& valuesIn, - btOpenCLArray& valuesOut, int n, int sortBits) +void b3RadixSort32CL::execute(b3OpenCLArray& keysIn, b3OpenCLArray& keysOut, b3OpenCLArray& valuesIn, + b3OpenCLArray& valuesOut, int n, int sortBits) { } @@ -184,7 +184,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keysIn, btOpenCLArray //#define DEBUG_RADIXSORT2 -void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sortBits /* = 32 */) +void b3RadixSort32CL::execute(b3OpenCLArray& keyValuesInOut, int sortBits /* = 32 */) { int originalSize = keyValuesInOut.size(); @@ -194,7 +194,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor int dataAlignment = DATA_ALIGNMENT; #ifdef DEBUG_RADIXSORT2 - b3AlignedObjectArray test2; + b3AlignedObjectArray test2; keyValuesInOut.copyToHost(test2); printf("numElem = %d\n",test2.size()); for (int i=0;i& keyValuesInOut, int sor } #endif //DEBUG_RADIXSORT2 - btOpenCLArray* src = 0; + b3OpenCLArray* src = 0; if (workingSize%dataAlignment) { workingSize += dataAlignment-(workingSize%dataAlignment); m_workBuffer4->copyFromOpenCLArray(keyValuesInOut); m_workBuffer4->resize(workingSize); - btSortData fillValue; + b3SortData fillValue; fillValue.m_key = 0xffffffff; fillValue.m_value = 0xffffffff; #define USE_BTFILL #ifdef USE_BTFILL - m_fill->execute((btOpenCLArray&)*m_workBuffer4,(btInt2&)fillValue,workingSize-originalSize,originalSize); + m_fill->execute((b3OpenCLArray&)*m_workBuffer4,(b3Int2&)fillValue,workingSize-originalSize,originalSize); #else //fill the remaining bits (very slow way, todo: fill on GPU/OpenCL side) @@ -234,7 +234,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor m_workBuffer4->resize(0); } - btAssert( workingSize%DATA_ALIGNMENT == 0 ); + b3Assert( workingSize%DATA_ALIGNMENT == 0 ); int minCap = NUM_BUCKET*NUM_WGS; @@ -245,20 +245,20 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor // ADLASSERT( ELEMENTS_PER_WORK_ITEM == 4 ); - btAssert( BITS_PER_PASS == 4 ); - btAssert( WG_SIZE == 64 ); - btAssert( (sortBits&0x3) == 0 ); + b3Assert( BITS_PER_PASS == 4 ); + b3Assert( WG_SIZE == 64 ); + b3Assert( (sortBits&0x3) == 0 ); - btOpenCLArray* dst = m_workBuffer3; + b3OpenCLArray* dst = m_workBuffer3; - btOpenCLArray* srcHisto = m_workBuffer1; - btOpenCLArray* destHisto = m_workBuffer2; + b3OpenCLArray* srcHisto = m_workBuffer1; + b3OpenCLArray* destHisto = m_workBuffer2; int nWGs = NUM_WGS; - btConstData cdata; + b3ConstData cdata; { int blockSize = ELEMENTS_PER_WORK_ITEM*WG_SIZE;//set at 256 @@ -294,10 +294,10 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor if (src->size()) { - btBufferInfoCL bInfo[] = { btBufferInfoCL( src->getBufferCL(), true ), btBufferInfoCL( srcHisto->getBufferCL() ) }; - btLauncherCL launcher(m_commandQueue, m_streamCountSortDataKernel); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src->getBufferCL(), true ), b3BufferInfoCL( srcHisto->getBufferCL() ) }; + b3LauncherCL launcher(m_commandQueue, m_streamCountSortDataKernel); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( cdata ); int num = NUM_WGS*WG_SIZE; @@ -328,9 +328,9 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor if (fastScan) {// prefix scan group histogram - btBufferInfoCL bInfo[] = { btBufferInfoCL( srcHisto->getBufferCL() ) }; - btLauncherCL launcher( m_commandQueue, m_prefixScanKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( srcHisto->getBufferCL() ) }; + b3LauncherCL launcher( m_commandQueue, m_prefixScanKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( cdata ); launcher.launch1D( 128, 128 ); destHisto = srcHisto; @@ -362,9 +362,9 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor if (src->size()) {// local sort and distribute - btBufferInfoCL bInfo[] = { btBufferInfoCL( src->getBufferCL(), true ), btBufferInfoCL( destHisto->getBufferCL(), true ), btBufferInfoCL( dst->getBufferCL() )}; - btLauncherCL launcher( m_commandQueue, m_sortAndScatterSortDataKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src->getBufferCL(), true ), b3BufferInfoCL( destHisto->getBufferCL(), true ), b3BufferInfoCL( dst->getBufferCL() )}; + b3LauncherCL launcher( m_commandQueue, m_sortAndScatterSortDataKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( cdata ); launcher.launch1D( nWGs*WG_SIZE, WG_SIZE ); @@ -379,8 +379,8 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor int startBit = ib; destHisto->copyToHost(testHist); - b3AlignedObjectArray srcHost; - b3AlignedObjectArray dstHost; + b3AlignedObjectArray srcHost; + b3AlignedObjectArray dstHost; dstHost.resize(src->size()); src->copyToHost(srcHost); @@ -405,11 +405,11 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor int counter2[NUM_TABLES]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int tables[NUM_TABLES]; - b3AlignedObjectArray dstHostOK; + b3AlignedObjectArray dstHostOK; dstHostOK.resize(src->size()); destHisto->copyToHost(testHist); - b3AlignedObjectArray srcHost; + b3AlignedObjectArray srcHost; src->copyToHost(srcHost); int blockSize = 256; @@ -435,7 +435,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor } - b3AlignedObjectArray dstHost; + b3AlignedObjectArray dstHost; dstHost.resize(src->size()); @@ -449,7 +449,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor int nBlocks = (n)/blockSize - nBlocksPerWG*wgIdx; - for(int iblock=0; iblock& keyValuesInOut, int sor int destIndex = testHist[tableIdx*NUM_WGS+wgIdx] + counter[tableIdx]; - btSortData ok = dstHostOK[destIndex]; + b3SortData ok = dstHostOK[destIndex]; if (ok.m_key != srcHost[i].m_key) { @@ -512,8 +512,8 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor printf("testHist[%d]=%d\n",i,testHist[i]); } #endif //DEBUG_RADIXSORT - btSwap(src, dst ); - btSwap(srcHisto,destHisto); + b3Swap(src, dst ); + b3Swap(srcHisto,destHisto); #ifdef DEBUG_RADIXSORT2 keyValuesInOut.copyToHost(test2); @@ -537,7 +537,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor if (count&1) { - btAssert(0);//need to copy from workbuffer to keyValuesInOut + b3Assert(0);//need to copy from workbuffer to keyValuesInOut } if (m_workBuffer4->size()) @@ -565,7 +565,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keyValuesInOut, int sor -void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBits /* = 32 */) +void b3RadixSort32CL::execute(b3OpenCLArray& keysInOut, int sortBits /* = 32 */) { int originalSize = keysInOut.size(); int workingSize = originalSize; @@ -573,7 +573,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBi int dataAlignment = DATA_ALIGNMENT; - btOpenCLArray* src = 0; + b3OpenCLArray* src = 0; if (workingSize%dataAlignment) { @@ -593,7 +593,7 @@ void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBi - btAssert( workingSize%DATA_ALIGNMENT == 0 ); + b3Assert( workingSize%DATA_ALIGNMENT == 0 ); int minCap = NUM_BUCKET*NUM_WGS; @@ -605,20 +605,20 @@ void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBi m_workBuffer3a->resize(workingSize); // ADLASSERT( ELEMENTS_PER_WORK_ITEM == 4 ); - btAssert( BITS_PER_PASS == 4 ); - btAssert( WG_SIZE == 64 ); - btAssert( (sortBits&0x3) == 0 ); + b3Assert( BITS_PER_PASS == 4 ); + b3Assert( WG_SIZE == 64 ); + b3Assert( (sortBits&0x3) == 0 ); - btOpenCLArray* dst = m_workBuffer3a; + b3OpenCLArray* dst = m_workBuffer3a; - btOpenCLArray* srcHisto = m_workBuffer1; - btOpenCLArray* destHisto = m_workBuffer2; + b3OpenCLArray* srcHisto = m_workBuffer1; + b3OpenCLArray* destHisto = m_workBuffer2; int nWGs = NUM_WGS; - btConstData cdata; + b3ConstData cdata; { int blockSize = ELEMENTS_PER_WORK_ITEM*WG_SIZE;//set at 256 @@ -641,10 +641,10 @@ void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBi if (src->size()) { - btBufferInfoCL bInfo[] = { btBufferInfoCL( src->getBufferCL(), true ), btBufferInfoCL( srcHisto->getBufferCL() ) }; - btLauncherCL launcher(m_commandQueue, m_streamCountKernel); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src->getBufferCL(), true ), b3BufferInfoCL( srcHisto->getBufferCL() ) }; + b3LauncherCL launcher(m_commandQueue, m_streamCountKernel); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( cdata ); int num = NUM_WGS*WG_SIZE; @@ -663,9 +663,9 @@ void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBi if (fastScan) {// prefix scan group histogram - btBufferInfoCL bInfo[] = { btBufferInfoCL( srcHisto->getBufferCL() ) }; - btLauncherCL launcher( m_commandQueue, m_prefixScanKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( srcHisto->getBufferCL() ) }; + b3LauncherCL launcher( m_commandQueue, m_prefixScanKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( cdata ); launcher.launch1D( 128, 128 ); destHisto = srcHisto; @@ -677,23 +677,23 @@ void btRadixSort32CL::execute(btOpenCLArray& keysInOut, int sortBi if (src->size()) {// local sort and distribute - btBufferInfoCL bInfo[] = { btBufferInfoCL( src->getBufferCL(), true ), btBufferInfoCL( destHisto->getBufferCL(), true ), btBufferInfoCL( dst->getBufferCL() )}; - btLauncherCL launcher( m_commandQueue, m_sortAndScatterKernel ); - launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) ); + b3BufferInfoCL bInfo[] = { b3BufferInfoCL( src->getBufferCL(), true ), b3BufferInfoCL( destHisto->getBufferCL(), true ), b3BufferInfoCL( dst->getBufferCL() )}; + b3LauncherCL launcher( m_commandQueue, m_sortAndScatterKernel ); + launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) ); launcher.setConst( cdata ); launcher.launch1D( nWGs*WG_SIZE, WG_SIZE ); } - btSwap(src, dst ); - btSwap(srcHisto,destHisto); + b3Swap(src, dst ); + b3Swap(srcHisto,destHisto); count++; } if (count&1) { - btAssert(0);//need to copy from workbuffer to keyValuesInOut + b3Assert(0);//need to copy from workbuffer to keyValuesInOut } if (m_workBuffer4a->size()) diff --git a/opencl/parallel_primitives/host/b3RadixSort32CL.h b/opencl/parallel_primitives/host/b3RadixSort32CL.h new file mode 100644 index 000000000..61d4573bc --- /dev/null +++ b/opencl/parallel_primitives/host/b3RadixSort32CL.h @@ -0,0 +1,85 @@ + +#ifndef B3_RADIXSORT32_H +#define B3_RADIXSORT32_H + +#include "b3OpenCLArray.h" + +struct b3SortData +{ + int m_key; + int m_value; +}; +#include "b3BufferInfoCL.h" + +class b3RadixSort32CL +{ + + b3OpenCLArray* m_workBuffer1; + b3OpenCLArray* m_workBuffer2; + + b3OpenCLArray* m_workBuffer3; + b3OpenCLArray* m_workBuffer4; + + b3OpenCLArray* m_workBuffer3a; + b3OpenCLArray* m_workBuffer4a; + + cl_command_queue m_commandQueue; + + cl_kernel m_streamCountSortDataKernel; + cl_kernel m_streamCountKernel; + + cl_kernel m_prefixScanKernel; + cl_kernel m_sortAndScatterSortDataKernel; + cl_kernel m_sortAndScatterKernel; + + + bool m_deviceCPU; + + class b3PrefixScanCL* m_scan; + class b3FillCL* m_fill; + +public: + struct b3ConstData + { + int m_n; + int m_nWGs; + int m_startBit; + int m_nBlocksPerWG; + }; + enum + { + DATA_ALIGNMENT = 256, + WG_SIZE = 64, + BLOCK_SIZE = 256, + ELEMENTS_PER_WORK_ITEM = (BLOCK_SIZE/WG_SIZE), + BITS_PER_PASS = 4, + NUM_BUCKET=(1<& keysIn, b3OpenCLArray& keysOut, b3OpenCLArray& valuesIn, + b3OpenCLArray& valuesOut, int n, int sortBits = 32); + + ///keys only + void execute(b3OpenCLArray& keysInOut, int sortBits = 32 ); + + void execute(b3OpenCLArray& keyValuesInOut, int sortBits = 32 ); + void executeHost(b3OpenCLArray& keyValuesInOut, int sortBits = 32); + void executeHost(b3AlignedObjectArray& keyValuesInOut, int sortBits = 32); + +}; +#endif //B3_RADIXSORT32_H + diff --git a/opencl/parallel_primitives/host/btBufferInfoCL.h b/opencl/parallel_primitives/host/btBufferInfoCL.h deleted file mode 100644 index 48798e232..000000000 --- a/opencl/parallel_primitives/host/btBufferInfoCL.h +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef BT_BUFFER_INFO_CL_H -#define BT_BUFFER_INFO_CL_H - -#include "btOpenCLArray.h" - - -struct btBufferInfoCL -{ - //btBufferInfoCL(){} - -// template - btBufferInfoCL(cl_mem buff, bool isReadOnly = false): m_clBuffer(buff), m_isReadOnly(isReadOnly){} - - cl_mem m_clBuffer; - bool m_isReadOnly; -}; - -#endif //BT_BUFFER_INFO_CL_H diff --git a/opencl/parallel_primitives/host/btFillCL.h b/opencl/parallel_primitives/host/btFillCL.h deleted file mode 100644 index 9eb5292dd..000000000 --- a/opencl/parallel_primitives/host/btFillCL.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef BT_FILL_CL_H -#define BT_FILL_CL_H - -#include "btOpenCLArray.h" -#include "Bullet3Common/b3Scalar.h" - -#include "btInt2.h" -#include "btInt4.h" - - -class btFillCL -{ - - cl_command_queue m_commandQueue; - - cl_kernel m_fillKernelInt2; - cl_kernel m_fillIntKernel; - cl_kernel m_fillUnsignedIntKernel; - cl_kernel m_fillFloatKernel; - - public: - - struct btConstData - { - union - { - btInt4 m_data; - btUnsignedInt4 m_UnsignedData; - }; - int m_offset; - int m_n; - int m_padding[2]; - }; - -protected: - -public: - - btFillCL(cl_context ctx, cl_device_id device, cl_command_queue queue); - - virtual ~btFillCL(); - - void execute(btOpenCLArray& src, const unsigned int value, int n, int offset = 0); - - void execute(btOpenCLArray& src, const int value, int n, int offset = 0); - - void execute(btOpenCLArray& src, const float value, int n, int offset = 0); - - void execute(btOpenCLArray& src, const btInt2& value, int n, int offset = 0); - - void executeHost(b3AlignedObjectArray &src, const btInt2 &value, int n, int offset); - - void executeHost(b3AlignedObjectArray &src, const int value, int n, int offset); - - // void execute(btOpenCLArray& src, const btInt4& value, int n, int offset = 0); - -}; - - - - - -#endif //BT_FILL_CL_H diff --git a/opencl/parallel_primitives/host/btRadixSort32CL.h b/opencl/parallel_primitives/host/btRadixSort32CL.h deleted file mode 100644 index c1516aa8d..000000000 --- a/opencl/parallel_primitives/host/btRadixSort32CL.h +++ /dev/null @@ -1,85 +0,0 @@ - -#ifndef BT_RADIXSORT32_H -#define BT_RADIXSORT32_H - -#include "btOpenCLArray.h" - -struct btSortData -{ - int m_key; - int m_value; -}; -#include "btBufferInfoCL.h" - -class btRadixSort32CL -{ - - btOpenCLArray* m_workBuffer1; - btOpenCLArray* m_workBuffer2; - - btOpenCLArray* m_workBuffer3; - btOpenCLArray* m_workBuffer4; - - btOpenCLArray* m_workBuffer3a; - btOpenCLArray* m_workBuffer4a; - - cl_command_queue m_commandQueue; - - cl_kernel m_streamCountSortDataKernel; - cl_kernel m_streamCountKernel; - - cl_kernel m_prefixScanKernel; - cl_kernel m_sortAndScatterSortDataKernel; - cl_kernel m_sortAndScatterKernel; - - - bool m_deviceCPU; - - class btPrefixScanCL* m_scan; - class btFillCL* m_fill; - -public: - struct btConstData - { - int m_n; - int m_nWGs; - int m_startBit; - int m_nBlocksPerWG; - }; - enum - { - DATA_ALIGNMENT = 256, - WG_SIZE = 64, - BLOCK_SIZE = 256, - ELEMENTS_PER_WORK_ITEM = (BLOCK_SIZE/WG_SIZE), - BITS_PER_PASS = 4, - NUM_BUCKET=(1<& keysIn, btOpenCLArray& keysOut, btOpenCLArray& valuesIn, - btOpenCLArray& valuesOut, int n, int sortBits = 32); - - ///keys only - void execute(btOpenCLArray& keysInOut, int sortBits = 32 ); - - void execute(btOpenCLArray& keyValuesInOut, int sortBits = 32 ); - void executeHost(btOpenCLArray& keyValuesInOut, int sortBits = 32); - void executeHost(b3AlignedObjectArray& keyValuesInOut, int sortBits = 32); - -}; -#endif //BT_RADIXSORT32_H - diff --git a/opencl/parallel_primitives/test/main.cpp b/opencl/parallel_primitives/test/main.cpp index 8b06e32f8..9ecb637c9 100644 --- a/opencl/parallel_primitives/test/main.cpp +++ b/opencl/parallel_primitives/test/main.cpp @@ -15,10 +15,10 @@ subject to the following restrictions: #include #include "../basic_initialize/b3OpenCLUtils.h" -#include "../host/btFillCL.h" -#include "../host/btBoundSearchCL.h" -#include "../host/btRadixSort32CL.h" -#include "../host/btPrefixScanCL.h" +#include "../host/b3FillCL.h" +#include "../host/b3BoundSearchCL.h" +#include "../host/b3RadixSort32CL.h" +#include "../host/b3PrefixScanCL.h" #include "Bullet3Common/b3CommandLineArgs.h" #include "Bullet3Common/b3MinMax.h" @@ -50,7 +50,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); @@ -71,9 +71,9 @@ inline void fillIntTest() { TEST_INIT; - btFillCL* fillCL = new btFillCL(g_context,g_device,g_queue); + b3FillCL* fillCL = new b3FillCL(g_context,g_device,g_queue); int maxSize=1024*256; - btOpenCLArray intBuffer(g_context,g_queue,maxSize); + b3OpenCLArray intBuffer(g_context,g_queue,maxSize); intBuffer.resize(maxSize); #define NUM_TESTS 7 @@ -81,7 +81,7 @@ inline void fillIntTest() int dx = maxSize/NUM_TESTS; for (int iter=0;iter srcCL(g_context,g_queue,maxSize); - btOpenCLArray upperCL(g_context,g_queue,maxSize); - btOpenCLArray lowerCL(g_context,g_queue,maxSize); + b3OpenCLArray srcCL(g_context,g_queue,maxSize); + b3OpenCLArray upperCL(g_context,g_queue,maxSize); + b3OpenCLArray lowerCL(g_context,g_queue,maxSize); - b3AlignedObjectArray srcHost; + b3AlignedObjectArray srcHost; b3AlignedObjectArray upperHost; b3AlignedObjectArray lowerHost; b3AlignedObjectArray upperHostCompare; b3AlignedObjectArray lowerHostCompare; - btBoundSearchCL* search = new btBoundSearchCL(g_context,g_device,g_queue, maxSize); + b3BoundSearchCL* search = new b3BoundSearchCL(g_context,g_device,g_queue, maxSize); int dx = maxSize/NUM_TESTS; for(int iter=0; iterexecute(srcCL,size,upperCL,bucketSize,btBoundSearchCL::BOUND_UPPER); - search->execute(srcCL,size,lowerCL,bucketSize,btBoundSearchCL::BOUND_LOWER); + search->execute(srcCL,size,upperCL,bucketSize,b3BoundSearchCL::BOUND_UPPER); + search->execute(srcCL,size,lowerCL,bucketSize,b3BoundSearchCL::BOUND_LOWER); - search->executeHost(srcHost,size,upperHostCompare,bucketSize,btBoundSearchCL::BOUND_UPPER); - search->executeHost(srcHost,size,lowerHostCompare,bucketSize,btBoundSearchCL::BOUND_LOWER); + search->executeHost(srcHost,size,upperHostCompare,bucketSize,b3BoundSearchCL::BOUND_UPPER); + search->executeHost(srcHost,size,lowerHostCompare,bucketSize,b3BoundSearchCL::BOUND_LOWER); lowerCL.copyToHost(lowerHost); upperCL.copyToHost(upperHost); @@ -263,16 +263,16 @@ void prefixScanTest() b3AlignedObjectArray buf0Host; b3AlignedObjectArray buf1Host; - btOpenCLArray buf2CL(g_context,g_queue,maxSize); - btOpenCLArray buf3CL(g_context,g_queue,maxSize); + b3OpenCLArray buf2CL(g_context,g_queue,maxSize); + b3OpenCLArray buf3CL(g_context,g_queue,maxSize); - btPrefixScanCL* scan = new btPrefixScanCL(g_context,g_device,g_queue,maxSize); + b3PrefixScanCL* scan = new b3PrefixScanCL(g_context,g_device,g_queue,maxSize); int dx = maxSize/NUM_TESTS; for(int iter=0; iter buf0Host; + b3AlignedObjectArray buf0Host; buf0Host.resize(maxSize); - b3AlignedObjectArray buf1Host; + b3AlignedObjectArray buf1Host; buf1Host.resize(maxSize ); - btOpenCLArray buf2CL(g_context,g_queue,maxSize); + b3OpenCLArray buf2CL(g_context,g_queue,maxSize); - btRadixSort32CL* sort = new btRadixSort32CL(g_context,g_device,g_queue,maxSize); + b3RadixSort32CL* sort = new b3RadixSort32CL(g_context,g_device,g_queue,maxSize); int dx = maxSize/NUM_TESTS; for(int iter=0; iter @@ -58,8 +58,8 @@ int main(int argc, char* argv[]) addKernel = b3OpenCLUtils::compileCLKernelFromString(ctx,device,kernelString,"ReduceGlobal",&ciErrNum); oclCHECKERROR(ciErrNum, CL_SUCCESS); int numElements = 1024*1024; - btOpenCLArray a(ctx,queue); - btOpenCLArray b(ctx,queue); + b3OpenCLArray a(ctx,queue); + b3OpenCLArray b(ctx,queue); b3AlignedObjectArray hostA; b3AlignedObjectArray hostB; @@ -79,7 +79,7 @@ int main(int argc, char* argv[]) b.resize(numElements); { - btLauncherCL launcher( queue, addKernel); + b3LauncherCL launcher( queue, addKernel); launcher.setBuffer( a.getBufferCL()); launcher.setBuffer( b.getBufferCL()); launcher.setConst( numElements ); @@ -87,7 +87,7 @@ int main(int argc, char* argv[]) } clFinish(queue); { - btLauncherCL launcher( queue, addKernel); + b3LauncherCL launcher( queue, addKernel); launcher.setBuffer( b.getBufferCL()); launcher.setBuffer( a.getBufferCL()); launcher.setConst( 1024 ); diff --git a/opencl/vector_add/main.cpp b/opencl/vector_add/main.cpp index aa4132d98..c7b7956be 100644 --- a/opencl/vector_add/main.cpp +++ b/opencl/vector_add/main.cpp @@ -21,7 +21,7 @@ #include #include -#define GRID3DOCL_CHECKERROR(a, b) if((a)!=(b)) { printf("3D GRID OCL Error : %d\n", (a)); btAssert((a) == (b)); } +#define GRID3DOCL_CHECKERROR(a, b) if((a)!=(b)) { printf("3D GRID OCL Error : %d\n", (a)); b3Assert((a) == (b)); } size_t wgSize; #include "VectorAddKernels.h" @@ -334,7 +334,7 @@ int main(int argc, char **argv) else { size_t localWorkSize[2], globalWorkSize[2]; - //workgroupSize = btMin(workgroupSize, actualGlobalSize); + //workgroupSize = b3Min(workgroupSize, actualGlobalSize); int num_t = actualGlobalSize / workgroupSize; int num_g = num_t * workgroupSize; if(num_g < actualGlobalSize) diff --git a/opencl/vector_add_simplified/main.cpp b/opencl/vector_add_simplified/main.cpp index 0fcae0e34..21604156e 100644 --- a/opencl/vector_add_simplified/main.cpp +++ b/opencl/vector_add_simplified/main.cpp @@ -1,7 +1,7 @@ ///original author: Erwin Coumans #include "b3OpenCLUtils.h" -#include "../parallel_primitives/host/btOpenCLArray.h" -#include "../parallel_primitives/host/btLauncherCL.h" +#include "../parallel_primitives/host/b3OpenCLArray.h" +#include "../parallel_primitives/host/b3LauncherCL.h" #include @@ -42,9 +42,9 @@ int main(int argc, char* argv[]) addKernel = b3OpenCLUtils::compileCLKernelFromString(ctx,device,kernelString,"VectorAdd",&ciErrNum); oclCHECKERROR(ciErrNum, CL_SUCCESS); int numElements = 32; - btOpenCLArray a(ctx,queue); - btOpenCLArray b(ctx,queue); - btOpenCLArray c(ctx,queue); + b3OpenCLArray a(ctx,queue); + b3OpenCLArray b(ctx,queue); + b3OpenCLArray c(ctx,queue); for (int i=0;i tNodeArray; -typedef b3AlignedObjectArray tConstNodeArray; +typedef b3AlignedObjectArray tNodeArray; +typedef b3AlignedObjectArray tConstNodeArray; // -struct btDbvtNodeEnumerator : b3DynamicBvh::ICollide +struct b3DbvtNodeEnumerator : b3DynamicBvh::ICollide { tConstNodeArray nodes; - void Process(const btDbvtNode* n) { nodes.push_back(n); } + void Process(const b3DbvtNode* n) { nodes.push_back(n); } }; // -static DBVT_INLINE int indexof(const btDbvtNode* node) +static DBVT_INLINE int indexof(const b3DbvtNode* node) { return(node->parent->childs[1]==node); } // -static DBVT_INLINE btDbvtVolume merge( const btDbvtVolume& a, - const btDbvtVolume& b) +static DBVT_INLINE b3DbvtVolume merge( const b3DbvtVolume& a, + const b3DbvtVolume& b) { #if (DBVT_MERGE_IMPL==DBVT_IMPL_SSE) - ATTRIBUTE_ALIGNED16(char locals[sizeof(btDbvtAabbMm)]); - btDbvtVolume& res=*(btDbvtVolume*)locals; + ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtAabbMm)]); + b3DbvtVolume& res=*(b3DbvtVolume*)locals; #else - btDbvtVolume res; + b3DbvtVolume res; #endif Merge(a,b,res); return(res); } // volume+edge lengths -static DBVT_INLINE b3Scalar size(const btDbvtVolume& a) +static DBVT_INLINE b3Scalar size(const b3DbvtVolume& a) { const b3Vector3 edges=a.Lengths(); return( edges.x*edges.y*edges.z+ @@ -56,26 +56,26 @@ static DBVT_INLINE b3Scalar size(const btDbvtVolume& a) } // -static void getmaxdepth(const btDbvtNode* node,int depth,int& maxdepth) +static void getmaxdepth(const b3DbvtNode* node,int depth,int& maxdepth) { if(node->isinternal()) { getmaxdepth(node->childs[0],depth+1,maxdepth); getmaxdepth(node->childs[1],depth+1,maxdepth); - } else maxdepth=btMax(maxdepth,depth); + } else maxdepth=b3Max(maxdepth,depth); } // static DBVT_INLINE void deletenode( b3DynamicBvh* pdbvt, - btDbvtNode* node) + b3DbvtNode* node) { - btAlignedFree(pdbvt->m_free); + b3AlignedFree(pdbvt->m_free); pdbvt->m_free=node; } // static void recursedeletenode( b3DynamicBvh* pdbvt, - btDbvtNode* node) + b3DbvtNode* node) { if(!node->isleaf()) { @@ -87,15 +87,15 @@ static void recursedeletenode( b3DynamicBvh* pdbvt, } // -static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt, - btDbvtNode* parent, +static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, + b3DbvtNode* parent, void* data) { - btDbvtNode* node; + b3DbvtNode* node; if(pdbvt->m_free) { node=pdbvt->m_free;pdbvt->m_free=0; } else - { node=new(btAlignedAlloc(sizeof(btDbvtNode),16)) btDbvtNode(); } + { node=new(b3AlignedAlloc(sizeof(b3DbvtNode),16)) b3DbvtNode(); } node->parent = parent; node->data = data; node->childs[1] = 0; @@ -103,32 +103,32 @@ static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt, } // -static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt, - btDbvtNode* parent, - const btDbvtVolume& volume, +static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, + b3DbvtNode* parent, + const b3DbvtVolume& volume, void* data) { - btDbvtNode* node=createnode(pdbvt,parent,data); + b3DbvtNode* node=createnode(pdbvt,parent,data); node->volume=volume; return(node); } // -static DBVT_INLINE btDbvtNode* createnode( b3DynamicBvh* pdbvt, - btDbvtNode* parent, - const btDbvtVolume& volume0, - const btDbvtVolume& volume1, +static DBVT_INLINE b3DbvtNode* createnode( b3DynamicBvh* pdbvt, + b3DbvtNode* parent, + const b3DbvtVolume& volume0, + const b3DbvtVolume& volume1, void* data) { - btDbvtNode* node=createnode(pdbvt,parent,data); + b3DbvtNode* node=createnode(pdbvt,parent,data); Merge(volume0,volume1,node->volume); return(node); } // static void insertleaf( b3DynamicBvh* pdbvt, - btDbvtNode* root, - btDbvtNode* leaf) + b3DbvtNode* root, + b3DbvtNode* leaf) { if(!pdbvt->m_root) { @@ -145,8 +145,8 @@ static void insertleaf( b3DynamicBvh* pdbvt, root->childs[1]->volume)]; } while(!root->isleaf()); } - btDbvtNode* prev=root->parent; - btDbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0); + b3DbvtNode* prev=root->parent; + b3DbvtNode* node=createnode(pdbvt,prev,leaf->volume,root->volume,0); if(prev) { prev->childs[indexof(root)] = node; @@ -170,8 +170,8 @@ static void insertleaf( b3DynamicBvh* pdbvt, } // -static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt, - btDbvtNode* leaf) +static b3DbvtNode* removeleaf( b3DynamicBvh* pdbvt, + b3DbvtNode* leaf) { if(leaf==pdbvt->m_root) { @@ -180,9 +180,9 @@ static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt, } else { - btDbvtNode* parent=leaf->parent; - btDbvtNode* prev=parent->parent; - btDbvtNode* sibling=parent->childs[1-indexof(leaf)]; + b3DbvtNode* parent=leaf->parent; + b3DbvtNode* prev=parent->parent; + b3DbvtNode* sibling=parent->childs[1-indexof(leaf)]; if(prev) { prev->childs[indexof(parent)]=sibling; @@ -190,7 +190,7 @@ static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt, deletenode(pdbvt,parent); while(prev) { - const btDbvtVolume pb=prev->volume; + const b3DbvtVolume pb=prev->volume; Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume); if(NotEqual(pb,prev->volume)) { @@ -211,7 +211,7 @@ static btDbvtNode* removeleaf( b3DynamicBvh* pdbvt, // static void fetchleaves(b3DynamicBvh* pdbvt, - btDbvtNode* root, + b3DbvtNode* root, tNodeArray& leaves, int depth=-1) { @@ -238,7 +238,7 @@ static void split( const tNodeArray& leaves, right.resize(0); for(int i=0,ni=leaves.size();ivolume.Center()-org)<0) + if(b3Dot(axis,leaves[i]->volume.Center()-org)<0) left.push_back(leaves[i]); else right.push_back(leaves[i]); @@ -246,14 +246,14 @@ static void split( const tNodeArray& leaves, } // -static btDbvtVolume bounds( const tNodeArray& leaves) +static b3DbvtVolume bounds( const tNodeArray& leaves) { #if DBVT_MERGE_IMPL==DBVT_IMPL_SSE - ATTRIBUTE_ALIGNED16(char locals[sizeof(btDbvtVolume)]); - btDbvtVolume& volume=*(btDbvtVolume*)locals; + ATTRIBUTE_ALIGNED16(char locals[sizeof(b3DbvtVolume)]); + b3DbvtVolume& volume=*(b3DbvtVolume*)locals; volume=leaves[0]->volume; #else - btDbvtVolume volume=leaves[0]->volume; + b3DbvtVolume volume=leaves[0]->volume; #endif for(int i=1,ni=leaves.size();ivolume,n[1]->volume,0); + b3DbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]}; + b3DbvtNode* p = createnode(pdbvt,0,n[0]->volume,n[1]->volume,0); p->childs[0] = n[0]; p->childs[1] = n[1]; n[0]->parent = p; @@ -296,7 +296,7 @@ static void bottomup( b3DynamicBvh* pdbvt, } // -static btDbvtNode* topdown(b3DynamicBvh* pdbvt, +static b3DbvtNode* topdown(b3DynamicBvh* pdbvt, tNodeArray& leaves, int bu_treshold) { @@ -307,7 +307,7 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt, { if(leaves.size()>bu_treshold) { - const btDbvtVolume vol=bounds(leaves); + const b3DbvtVolume vol=bounds(leaves); const b3Vector3 org=vol.Center(); tNodeArray sets[2]; int bestaxis=-1; @@ -319,14 +319,14 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt, const b3Vector3 x=leaves[i]->volume.Center()-org; for(int j=0;j<3;++j) { - ++splitcount[j][btDot(x,axis[j])>0?1:0]; + ++splitcount[j][b3Dot(x,axis[j])>0?1:0]; } } for( i=0;i<3;++i) { if((splitcount[i][0]>0)&&(splitcount[i][1]>0)) { - const int midp=(int)btFabs(b3Scalar(splitcount[i][0]-splitcount[i][1])); + const int midp=(int)b3Fabs(b3Scalar(splitcount[i][0]-splitcount[i][1])); if(midpchilds[0]=topdown(pdbvt,sets[0],bu_treshold); node->childs[1]=topdown(pdbvt,sets[1],bu_treshold); node->childs[0]->parent=node; @@ -366,17 +366,17 @@ static btDbvtNode* topdown(b3DynamicBvh* pdbvt, } // -static DBVT_INLINE btDbvtNode* sort(btDbvtNode* n,btDbvtNode*& r) +static DBVT_INLINE b3DbvtNode* sort(b3DbvtNode* n,b3DbvtNode*& r) { - btDbvtNode* p=n->parent; - btAssert(n->isinternal()); + b3DbvtNode* p=n->parent; + b3Assert(n->isinternal()); if(p>n) { const int i=indexof(n); const int j=1-i; - btDbvtNode* s=p->childs[j]; - btDbvtNode* q=p->parent; - btAssert(n==p->childs[i]); + b3DbvtNode* s=p->childs[j]; + b3DbvtNode* q=p->parent; + b3Assert(n==p->childs[i]); if(q) q->childs[indexof(p)]=n; else r=n; s->parent=n; p->parent=n; @@ -387,14 +387,14 @@ static DBVT_INLINE btDbvtNode* sort(btDbvtNode* n,btDbvtNode*& r) n->childs[1]->parent=p; n->childs[i]=p; n->childs[j]=s; - btSwap(p->volume,n->volume); + b3Swap(p->volume,n->volume); return(p); } return(n); } #if 0 -static DBVT_INLINE btDbvtNode* walkup(btDbvtNode* n,int count) +static DBVT_INLINE b3DbvtNode* walkup(b3DbvtNode* n,int count) { while(n&&(count--)) n=n->parent; return(n); @@ -426,7 +426,7 @@ void b3DynamicBvh::clear() { if(m_root) recursedeletenode(this,m_root); - btAlignedFree(m_free); + b3AlignedFree(m_free); m_free=0; m_lkhd = -1; m_stkStack.clear(); @@ -466,7 +466,7 @@ void b3DynamicBvh::optimizeIncremental(int passes) if(m_root&&(passes>0)) { do { - btDbvtNode* node=m_root; + b3DbvtNode* node=m_root; unsigned bit=0; while(node->isinternal()) { @@ -480,18 +480,18 @@ void b3DynamicBvh::optimizeIncremental(int passes) } // -btDbvtNode* b3DynamicBvh::insert(const btDbvtVolume& volume,void* data) +b3DbvtNode* b3DynamicBvh::insert(const b3DbvtVolume& volume,void* data) { - btDbvtNode* leaf=createnode(this,0,volume,data); + b3DbvtNode* leaf=createnode(this,0,volume,data); insertleaf(this,m_root,leaf); ++m_leaves; return(leaf); } // -void b3DynamicBvh::update(btDbvtNode* leaf,int lookahead) +void b3DynamicBvh::update(b3DbvtNode* leaf,int lookahead) { - btDbvtNode* root=removeleaf(this,leaf); + b3DbvtNode* root=removeleaf(this,leaf); if(root) { if(lookahead>=0) @@ -506,9 +506,9 @@ void b3DynamicBvh::update(btDbvtNode* leaf,int lookahead) } // -void b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume) +void b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume) { - btDbvtNode* root=removeleaf(this,leaf); + b3DbvtNode* root=removeleaf(this,leaf); if(root) { if(m_lkhd>=0) @@ -524,7 +524,7 @@ void b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume) } // -bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin) +bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin) { if(leaf->volume.Contain(volume)) return(false); volume.Expand(b3Vector3(margin,margin,margin)); @@ -534,7 +534,7 @@ bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector } // -bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity) +bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity) { if(leaf->volume.Contain(volume)) return(false); volume.SignedExpand(velocity); @@ -543,7 +543,7 @@ bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector } // -bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,b3Scalar margin) +bool b3DynamicBvh::update(b3DbvtNode* leaf,b3DbvtVolume& volume,b3Scalar margin) { if(leaf->volume.Contain(volume)) return(false); volume.Expand(b3Vector3(margin,margin,margin)); @@ -552,7 +552,7 @@ bool b3DynamicBvh::update(btDbvtNode* leaf,btDbvtVolume& volume,b3Scalar margi } // -void b3DynamicBvh::remove(btDbvtNode* leaf) +void b3DynamicBvh::remove(b3DbvtNode* leaf) { removeleaf(this,leaf); deletenode(this,leaf); @@ -562,13 +562,13 @@ void b3DynamicBvh::remove(btDbvtNode* leaf) // void b3DynamicBvh::write(IWriter* iwriter) const { - btDbvtNodeEnumerator nodes; + b3DbvtNodeEnumerator nodes; nodes.nodes.reserve(m_leaves*2); enumNodes(m_root,nodes); iwriter->Prepare(m_root,nodes.nodes.size()); for(int i=0;iparent) p=nodes.nodes.findLinearSearch(n->parent); if(n->isinternal()) @@ -596,7 +596,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const do { const int i=stack.size()-1; const sStkCLN e=stack[i]; - btDbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data); + b3DbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data); stack.pop_back(); if(e.parent!=0) e.parent->childs[i&1]=n; @@ -616,7 +616,7 @@ void b3DynamicBvh::clone(b3DynamicBvh& dest,IClone* iclone) const } // -int b3DynamicBvh::maxdepth(const btDbvtNode* node) +int b3DynamicBvh::maxdepth(const b3DbvtNode* node) { int depth=0; if(node) getmaxdepth(node,1,depth); @@ -624,7 +624,7 @@ int b3DynamicBvh::maxdepth(const btDbvtNode* node) } // -int b3DynamicBvh::countLeaves(const btDbvtNode* node) +int b3DynamicBvh::countLeaves(const b3DbvtNode* node) { if(node->isinternal()) return(countLeaves(node->childs[0])+countLeaves(node->childs[1])); @@ -633,7 +633,7 @@ int b3DynamicBvh::countLeaves(const btDbvtNode* node) } // -void b3DynamicBvh::extractLeaves(const btDbvtNode* node,b3AlignedObjectArray& leaves) +void b3DynamicBvh::extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray& leaves) { if(node->isinternal()) { @@ -651,7 +651,7 @@ void b3DynamicBvh::extractLeaves(const btDbvtNode* node,b3AlignedObjectArray #include -#include "LinearMath/btQuickProf.h" +#include "LinearMath/b3QuickProf.h" /* q6600,2.4ghz @@ -667,10 +667,10 @@ World scale: 100.000000 Extents base: 1.000000 Extents range: 4.000000 Leaves: 8192 -sizeof(btDbvtVolume): 32 bytes -sizeof(btDbvtNode): 44 bytes -[1] btDbvtVolume intersections: 3499 ms (-1%) -[2] btDbvtVolume merges: 1934 ms (0%) +sizeof(b3DbvtVolume): 32 bytes +sizeof(b3DbvtNode): 44 bytes +[1] b3DbvtVolume intersections: 3499 ms (-1%) +[2] b3DbvtVolume merges: 1934 ms (0%) [3] b3DynamicBvh::collideTT: 5485 ms (-21%) [4] b3DynamicBvh::collideTT self: 2814 ms (-20%) [5] b3DynamicBvh::collideTT xform: 7379 ms (-1%) @@ -680,22 +680,22 @@ sizeof(btDbvtNode): 44 bytes [9] updates (teleport): 1879 ms (-3%),(1116100 u/s) [10] updates (jitter): 1244 ms (-4%),(1685813 u/s) [11] optimize (incremental): 2514 ms (0%),(1668000 o/s) -[12] btDbvtVolume notequal: 3659 ms (0%) +[12] b3DbvtVolume notequal: 3659 ms (0%) [13] culling(OCL+fullsort): 2218 ms (0%),(461 t/s) [14] culling(OCL+qsort): 3688 ms (5%),(2221 t/s) [15] culling(KDOP+qsort): 1139 ms (-1%),(7192 t/s) [16] insert/remove batch(256): 5092 ms (0%),(823704 bir/s) -[17] btDbvtVolume select: 3419 ms (0%) +[17] b3DbvtVolume select: 3419 ms (0%) */ -struct btDbvtBenchmark +struct b3DbvtBenchmark { struct NilPolicy : b3DynamicBvh::ICollide { NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true) {} - void Process(const btDbvtNode*,const btDbvtNode*) { ++m_pcount; } - void Process(const btDbvtNode*) { ++m_pcount; } - void Process(const btDbvtNode*,b3Scalar depth) + void Process(const b3DbvtNode*,const b3DbvtNode*) { ++m_pcount; } + void Process(const b3DbvtNode*) { ++m_pcount; } + void Process(const b3DbvtNode*,b3Scalar depth) { ++m_pcount; if(m_checksort) @@ -709,10 +709,10 @@ struct btDbvtBenchmark { struct Node { - const btDbvtNode* leaf; + const b3DbvtNode* leaf; b3Scalar depth; }; - void Process(const btDbvtNode* leaf,b3Scalar depth) + void Process(const b3DbvtNode* leaf,b3Scalar depth) { Node n; n.leaf = leaf; @@ -730,10 +730,10 @@ struct btDbvtBenchmark { struct Node { - const btDbvtNode* leaf; + const b3DbvtNode* leaf; b3Scalar depth; }; - void Process(const btDbvtNode* leaf) + void Process(const b3DbvtNode* leaf) { Node n; n.leaf = leaf; @@ -760,15 +760,15 @@ struct btDbvtBenchmark { return(RandVector3()*cs-b3Vector3(cs,cs,cs)/2); } - static btDbvtVolume RandVolume(b3Scalar cs,b3Scalar eb,b3Scalar es) + static b3DbvtVolume RandVolume(b3Scalar cs,b3Scalar eb,b3Scalar es) { - return(btDbvtVolume::FromCE(RandVector3(cs),b3Vector3(eb,eb,eb)+RandVector3()*es)); + return(b3DbvtVolume::FromCE(RandVector3(cs),b3Vector3(eb,eb,eb)+RandVector3()*es)); } static b3Transform RandTransform(b3Scalar cs) { b3Transform t; t.setOrigin(RandVector3(cs)); - t.setRotation(btQuaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized()); + t.setRotation(b3Quaternion(RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2,RandUnit()*SIMD_PI*2).normalized()); return(t); } static void RandTree(b3Scalar cs,b3Scalar eb,b3Scalar es,int leaves,b3DynamicBvh& dbvt) @@ -789,11 +789,11 @@ void b3DynamicBvh::benchmark() static const int cfgLeaves = 8192; static const bool cfgEnable = true; - //[1] btDbvtVolume intersections + //[1] b3DbvtVolume intersections bool cfgBenchmark1_Enable = cfgEnable; static const int cfgBenchmark1_Iterations = 8; static const int cfgBenchmark1_Reference = 3499; - //[2] btDbvtVolume merges + //[2] b3DbvtVolume merges bool cfgBenchmark2_Enable = cfgEnable; static const int cfgBenchmark2_Iterations = 4; static const int cfgBenchmark2_Reference = 1945; @@ -841,7 +841,7 @@ void b3DynamicBvh::benchmark() static const int cfgBenchmark11_Passes = 64; static const int cfgBenchmark11_Iterations = 65536; static const int cfgBenchmark11_Reference = 2510; - //[12] btDbvtVolume notequal + //[12] b3DbvtVolume notequal bool cfgBenchmark12_Enable = cfgEnable; static const int cfgBenchmark12_Iterations = 32; static const int cfgBenchmark12_Reference = 3677; @@ -867,26 +867,26 @@ void b3DynamicBvh::benchmark() static const int cfgBenchmark17_Iterations = 4; static const int cfgBenchmark17_Reference = 3390; - btClock wallclock; + b3Clock wallclock; printf("Benchmarking dbvt...\r\n"); printf("\tWorld scale: %f\r\n",cfgVolumeCenterScale); printf("\tExtents base: %f\r\n",cfgVolumeExentsBase); printf("\tExtents range: %f\r\n",cfgVolumeExentsScale); printf("\tLeaves: %u\r\n",cfgLeaves); - printf("\tsizeof(btDbvtVolume): %u bytes\r\n",sizeof(btDbvtVolume)); - printf("\tsizeof(btDbvtNode): %u bytes\r\n",sizeof(btDbvtNode)); + printf("\tsizeof(b3DbvtVolume): %u bytes\r\n",sizeof(b3DbvtVolume)); + printf("\tsizeof(b3DbvtNode): %u bytes\r\n",sizeof(b3DbvtNode)); if(cfgBenchmark1_Enable) {// Benchmark 1 srand(380843); - b3AlignedObjectArray volumes; + b3AlignedObjectArray volumes; b3AlignedObjectArray results; volumes.resize(cfgLeaves); results.resize(cfgLeaves); for(int i=0;i volumes; - b3AlignedObjectArray results; + b3AlignedObjectArray volumes; + b3AlignedObjectArray results; volumes.resize(cfgLeaves); results.resize(cfgLeaves); for(int i=0;i transforms; - btDbvtBenchmark::NilPolicy policy; + b3DbvtBenchmark::NilPolicy policy; transforms.resize(cfgBenchmark5_Iterations); for(int i=0;i transforms; - btDbvtBenchmark::NilPolicy policy; + b3DbvtBenchmark::NilPolicy policy; transforms.resize(cfgBenchmark6_Iterations); for(int i=0;i rayorg; b3AlignedObjectArray raydir; - btDbvtBenchmark::NilPolicy policy; + b3DbvtBenchmark::NilPolicy policy; rayorg.resize(cfgBenchmark7_Iterations); raydir.resize(cfgBenchmark7_Iterations); for(int i=0;i leaves; - btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); + b3AlignedObjectArray leaves; + b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); dbvt.optimizeTopDown(); dbvt.extractLeaves(dbvt.m_root,leaves); printf("[9] updates (teleport): "); @@ -1069,8 +1069,8 @@ void b3DynamicBvh::benchmark() { for(int j=0;j(leaves[rand()%cfgLeaves]), - btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale)); + dbvt.update(const_cast(leaves[rand()%cfgLeaves]), + b3DbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale)); } } const int time=(int)wallclock.getTimeMilliseconds(); @@ -1081,14 +1081,14 @@ void b3DynamicBvh::benchmark() {// Benchmark 10 srand(380843); b3DynamicBvh dbvt; - b3AlignedObjectArray leaves; + b3AlignedObjectArray leaves; b3AlignedObjectArray vectors; vectors.resize(cfgBenchmark10_Iterations); for(int i=0;i(leaves[rand()%cfgLeaves]); - btDbvtVolume v=btDbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d); + b3DbvtNode* l=const_cast(leaves[rand()%cfgLeaves]); + b3DbvtVolume v=b3DbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d); dbvt.update(l,v); } } @@ -1112,7 +1112,7 @@ void b3DynamicBvh::benchmark() {// Benchmark 11 srand(380843); b3DynamicBvh dbvt; - btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); + b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); dbvt.optimizeTopDown(); printf("[11] optimize (incremental): "); wallclock.reset(); @@ -1127,15 +1127,15 @@ void b3DynamicBvh::benchmark() if(cfgBenchmark12_Enable) {// Benchmark 12 srand(380843); - b3AlignedObjectArray volumes; + b3AlignedObjectArray volumes; b3AlignedObjectArray results; volumes.resize(cfgLeaves); results.resize(cfgLeaves); for(int i=0;i vectors; - btDbvtBenchmark::NilPolicy policy; + b3DbvtBenchmark::NilPolicy policy; vectors.resize(cfgBenchmark13_Iterations); for(int i=0;i vectors; - btDbvtBenchmark::P14 policy; + b3DbvtBenchmark::P14 policy; vectors.resize(cfgBenchmark14_Iterations); for(int i=0;i vectors; - btDbvtBenchmark::P15 policy; + b3DbvtBenchmark::P15 policy; vectors.resize(cfgBenchmark15_Iterations); for(int i=0;i batch; - btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); + b3AlignedObjectArray batch; + b3DbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt); dbvt.optimizeTopDown(); batch.reserve(cfgBenchmark16_BatchCount); printf("[16] insert/remove batch(%u): ",cfgBenchmark16_BatchCount); @@ -1244,7 +1244,7 @@ void b3DynamicBvh::benchmark() { for(int j=0;j volumes; + b3AlignedObjectArray volumes; b3AlignedObjectArray results; b3AlignedObjectArray indices; volumes.resize(cfgLeaves); @@ -1268,13 +1268,13 @@ void b3DynamicBvh::benchmark() for(int i=0;i m_stkStack; - mutable b3AlignedObjectArray m_rayTestStack; + mutable b3AlignedObjectArray m_rayTestStack; // Methods @@ -274,18 +274,18 @@ struct b3DynamicBvh void optimizeBottomUp(); void optimizeTopDown(int bu_treshold=128); void optimizeIncremental(int passes); - btDbvtNode* insert(const btDbvtVolume& box,void* data); - void update(btDbvtNode* leaf,int lookahead=-1); - void update(btDbvtNode* leaf,btDbvtVolume& volume); - bool update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin); - bool update(btDbvtNode* leaf,btDbvtVolume& volume,const b3Vector3& velocity); - bool update(btDbvtNode* leaf,btDbvtVolume& volume,b3Scalar margin); - void remove(btDbvtNode* leaf); + b3DbvtNode* insert(const b3DbvtVolume& box,void* data); + void update(b3DbvtNode* leaf,int lookahead=-1); + void update(b3DbvtNode* leaf,b3DbvtVolume& volume); + bool update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity,b3Scalar margin); + bool update(b3DbvtNode* leaf,b3DbvtVolume& volume,const b3Vector3& velocity); + bool update(b3DbvtNode* leaf,b3DbvtVolume& volume,b3Scalar margin); + void remove(b3DbvtNode* leaf); void write(IWriter* iwriter) const; void clone(b3DynamicBvh& dest,IClone* iclone=0) const; - static int maxdepth(const btDbvtNode* node); - static int countLeaves(const btDbvtNode* node); - static void extractLeaves(const btDbvtNode* node,b3AlignedObjectArray& leaves); + static int maxdepth(const b3DbvtNode* node); + static int countLeaves(const b3DbvtNode* node); + static void extractLeaves(const b3DbvtNode* node,b3AlignedObjectArray& leaves); #if DBVT_ENABLE_BENCHMARK static void benchmark(); #else @@ -293,49 +293,49 @@ struct b3DynamicBvh #endif // DBVT_IPOLICY must support ICollide policy/interface DBVT_PREFIX - static void enumNodes( const btDbvtNode* root, + static void enumNodes( const b3DbvtNode* root, DBVT_IPOLICY); DBVT_PREFIX - static void enumLeaves( const btDbvtNode* root, + static void enumLeaves( const b3DbvtNode* root, DBVT_IPOLICY); DBVT_PREFIX - void collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, + void collideTT( const b3DbvtNode* root0, + const b3DbvtNode* root1, DBVT_IPOLICY); DBVT_PREFIX - void collideTTpersistentStack( const btDbvtNode* root0, - const btDbvtNode* root1, + void collideTTpersistentStack( const b3DbvtNode* root0, + const b3DbvtNode* root1, DBVT_IPOLICY); #if 0 DBVT_PREFIX - void collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, + void collideTT( const b3DbvtNode* root0, + const b3DbvtNode* root1, const b3Transform& xform, DBVT_IPOLICY); DBVT_PREFIX - void collideTT( const btDbvtNode* root0, + void collideTT( const b3DbvtNode* root0, const b3Transform& xform0, - const btDbvtNode* root1, + const b3DbvtNode* root1, const b3Transform& xform1, DBVT_IPOLICY); #endif DBVT_PREFIX - void collideTV( const btDbvtNode* root, - const btDbvtVolume& volume, + void collideTV( const b3DbvtNode* root, + const b3DbvtVolume& volume, DBVT_IPOLICY) const; - ///rayTest is a re-entrant ray test, and can be called in parallel as long as the btAlignedAlloc is thread-safe (uses locking etc) + ///rayTest is a re-entrant ray test, and can be called in parallel as long as the b3AlignedAlloc is thread-safe (uses locking etc) ///rayTest is slower than rayTestInternal, because it builds a local stack, using memory allocations, and it recomputes signs/rayDirectionInverses each time DBVT_PREFIX - static void rayTest( const btDbvtNode* root, + static void rayTest( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, DBVT_IPOLICY); ///rayTestInternal is faster than rayTest, because it uses a persistent stack (to reduce dynamic memory allocations to a minimum) and it uses precomputed signs/rayInverseDirections ///rayTestInternal is used by b3DynamicBvhBroadphase to accelerate world ray casts DBVT_PREFIX - void rayTestInternal( const btDbvtNode* root, + void rayTestInternal( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, const b3Vector3& rayDirectionInverse, @@ -346,13 +346,13 @@ struct b3DynamicBvh DBVT_IPOLICY) const; DBVT_PREFIX - static void collideKDOP(const btDbvtNode* root, + static void collideKDOP(const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, int count, DBVT_IPOLICY); DBVT_PREFIX - static void collideOCL( const btDbvtNode* root, + static void collideOCL( const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, const b3Vector3& sortaxis, @@ -360,7 +360,7 @@ struct b3DynamicBvh DBVT_IPOLICY, bool fullsort=true); DBVT_PREFIX - static void collideTU( const btDbvtNode* root, + static void collideTU( const b3DbvtNode* root, DBVT_IPOLICY); // Helpers static DBVT_INLINE int nearest(const int* i,const b3DynamicBvh::sStkNPS* a,b3Scalar v,int l,int h) @@ -394,31 +394,31 @@ private: // // -inline btDbvtAabbMm btDbvtAabbMm::FromCE(const b3Vector3& c,const b3Vector3& e) +inline b3DbvtAabbMm b3DbvtAabbMm::FromCE(const b3Vector3& c,const b3Vector3& e) { - btDbvtAabbMm box; + b3DbvtAabbMm box; box.mi=c-e;box.mx=c+e; return(box); } // -inline btDbvtAabbMm btDbvtAabbMm::FromCR(const b3Vector3& c,b3Scalar r) +inline b3DbvtAabbMm b3DbvtAabbMm::FromCR(const b3Vector3& c,b3Scalar r) { return(FromCE(c,b3Vector3(r,r,r))); } // -inline btDbvtAabbMm btDbvtAabbMm::FromMM(const b3Vector3& mi,const b3Vector3& mx) +inline b3DbvtAabbMm b3DbvtAabbMm::FromMM(const b3Vector3& mi,const b3Vector3& mx) { - btDbvtAabbMm box; + b3DbvtAabbMm box; box.mi=mi;box.mx=mx; return(box); } // -inline btDbvtAabbMm btDbvtAabbMm::FromPoints(const b3Vector3* pts,int n) +inline b3DbvtAabbMm b3DbvtAabbMm::FromPoints(const b3Vector3* pts,int n) { - btDbvtAabbMm box; + b3DbvtAabbMm box; box.mi=box.mx=pts[0]; for(int i=1;i0) mx.setX(mx.x+e[0]); else mi.setX(mi.x+e[0]); if(e.y>0) mx.setY(mx.y+e[1]); else mi.setY(mi.y+e[1]); @@ -456,7 +456,7 @@ DBVT_INLINE void btDbvtAabbMm::SignedExpand(const b3Vector3& e) } // -DBVT_INLINE bool btDbvtAabbMm::Contain(const btDbvtAabbMm& a) const +DBVT_INLINE bool b3DbvtAabbMm::Contain(const b3DbvtAabbMm& a) const { return( (mi.x<=a.mi.x)&& (mi.y<=a.mi.y)&& @@ -467,7 +467,7 @@ DBVT_INLINE bool btDbvtAabbMm::Contain(const btDbvtAabbMm& a) const } // -DBVT_INLINE int btDbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const +DBVT_INLINE int b3DbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) const { b3Vector3 pi,px; switch(s) @@ -489,23 +489,23 @@ DBVT_INLINE int btDbvtAabbMm::Classify(const b3Vector3& n,b3Scalar o,int s) con case (1+2+4): px=b3Vector3(mx.x,mx.y,mx.z); pi=b3Vector3(mi.x,mi.y,mi.z);break; } - if((btDot(n,px)+o)<0) return(-1); - if((btDot(n,pi)+o)>=0) return(+1); + if((b3Dot(n,px)+o)<0) return(-1); + if((b3Dot(n,pi)+o)>=0) return(+1); return(0); } // -DBVT_INLINE b3Scalar btDbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const +DBVT_INLINE b3Scalar b3DbvtAabbMm::ProjectMinimum(const b3Vector3& v,unsigned signs) const { const b3Vector3* b[]={&mx,&mi}; const b3Vector3 p( b[(signs>>0)&1]->x, b[(signs>>1)&1]->y, b[(signs>>2)&1]->z); - return(btDot(p,v)); + return(b3Dot(p,v)); } // -DBVT_INLINE void btDbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const +DBVT_INLINE void b3DbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scalar& smx) const { for(int i=0;i<3;++i) { @@ -517,8 +517,8 @@ DBVT_INLINE void btDbvtAabbMm::AddSpan(const b3Vector3& d,b3Scalar& smi,b3Scala } // -DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, - const btDbvtAabbMm& b) +DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a, + const b3DbvtAabbMm& b) { #if DBVT_INT0_IMPL == DBVT_IMPL_SSE const __m128 rt(_mm_or_ps( _mm_cmplt_ps(_mm_load_ps(b.mx),_mm_load_ps(a.mi)), @@ -542,7 +542,7 @@ DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, // -DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, +DBVT_INLINE bool Intersect( const b3DbvtAabbMm& a, const b3Vector3& b) { return( (b.x>=a.mi.x)&& @@ -561,19 +561,19 @@ DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, // -DBVT_INLINE b3Scalar Proximity( const btDbvtAabbMm& a, - const btDbvtAabbMm& b) +DBVT_INLINE b3Scalar Proximity( const b3DbvtAabbMm& a, + const b3DbvtAabbMm& b) { const b3Vector3 d=(a.mi+a.mx)-(b.mi+b.mx); - return(btFabs(d.x)+btFabs(d.y)+btFabs(d.z)); + return(b3Fabs(d.x)+b3Fabs(d.y)+b3Fabs(d.z)); } // -DBVT_INLINE int Select( const btDbvtAabbMm& o, - const btDbvtAabbMm& a, - const btDbvtAabbMm& b) +DBVT_INLINE int Select( const b3DbvtAabbMm& o, + const b3DbvtAabbMm& a, + const b3DbvtAabbMm& b) { #if DBVT_SELECT_IMPL == DBVT_IMPL_SSE @@ -585,7 +585,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o, ///@todo: the intrinsic version is 11% slower #if DBVT_USE_INTRINSIC_SSE - union btSSEUnion ///NOTE: if we use more intrinsics, move btSSEUnion into the LinearMath directory + union b3SSEUnion ///NOTE: if we use more intrinsics, move b3SSEUnion into the LinearMath directory { __m128 ssereg; float floats[4]; @@ -609,7 +609,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o, bmi=_mm_add_ps(bmi,t1); bmi=_mm_add_ss(bmi,_mm_shuffle_ps(bmi,bmi,1)); - btSSEUnion tmp; + b3SSEUnion tmp; tmp.ssereg = _mm_cmple_ss(bmi,ami); return tmp.ints[0]&1; @@ -650,9 +650,9 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o, } // -DBVT_INLINE void Merge( const btDbvtAabbMm& a, - const btDbvtAabbMm& b, - btDbvtAabbMm& r) +DBVT_INLINE void Merge( const b3DbvtAabbMm& a, + const b3DbvtAabbMm& b, + b3DbvtAabbMm& r) { #if DBVT_MERGE_IMPL==DBVT_IMPL_SSE __m128 ami(_mm_load_ps(a.mi)); @@ -673,8 +673,8 @@ DBVT_INLINE void Merge( const btDbvtAabbMm& a, } // -DBVT_INLINE bool NotEqual( const btDbvtAabbMm& a, - const btDbvtAabbMm& b) +DBVT_INLINE bool NotEqual( const b3DbvtAabbMm& a, + const b3DbvtAabbMm& b) { return( (a.mi.x!=b.mi.x)|| (a.mi.y!=b.mi.y)|| @@ -690,7 +690,7 @@ DBVT_INLINE bool NotEqual( const btDbvtAabbMm& a, // DBVT_PREFIX -inline void b3DynamicBvh::enumNodes( const btDbvtNode* root, +inline void b3DynamicBvh::enumNodes( const b3DbvtNode* root, DBVT_IPOLICY) { DBVT_CHECKTYPE @@ -704,7 +704,7 @@ inline void b3DynamicBvh::enumNodes( const btDbvtNode* root, // DBVT_PREFIX -inline void b3DynamicBvh::enumLeaves( const btDbvtNode* root, +inline void b3DynamicBvh::enumLeaves( const b3DbvtNode* root, DBVT_IPOLICY) { DBVT_CHECKTYPE @@ -721,8 +721,8 @@ inline void b3DynamicBvh::enumLeaves( const btDbvtNode* root, // DBVT_PREFIX -inline void b3DynamicBvh::collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, +inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, + const b3DbvtNode* root1, DBVT_IPOLICY) { DBVT_CHECKTYPE @@ -786,8 +786,8 @@ inline void b3DynamicBvh::collideTT( const btDbvtNode* root0, DBVT_PREFIX -inline void b3DynamicBvh::collideTTpersistentStack( const btDbvtNode* root0, - const btDbvtNode* root1, +inline void b3DynamicBvh::collideTTpersistentStack( const b3DbvtNode* root0, + const b3DbvtNode* root1, DBVT_IPOLICY) { DBVT_CHECKTYPE @@ -851,8 +851,8 @@ inline void b3DynamicBvh::collideTTpersistentStack( const btDbvtNode* root0, #if 0 // DBVT_PREFIX -inline void b3DynamicBvh::collideTT( const btDbvtNode* root0, - const btDbvtNode* root1, +inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, + const b3DbvtNode* root1, const b3Transform& xform, DBVT_IPOLICY) { @@ -906,9 +906,9 @@ inline void b3DynamicBvh::collideTT( const btDbvtNode* root0, } // DBVT_PREFIX -inline void b3DynamicBvh::collideTT( const btDbvtNode* root0, +inline void b3DynamicBvh::collideTT( const b3DbvtNode* root0, const b3Transform& xform0, - const btDbvtNode* root1, + const b3DbvtNode* root1, const b3Transform& xform1, DBVT_IPOLICY) { @@ -919,20 +919,20 @@ inline void b3DynamicBvh::collideTT( const btDbvtNode* root0, // DBVT_PREFIX -inline void b3DynamicBvh::collideTV( const btDbvtNode* root, - const btDbvtVolume& vol, +inline void b3DynamicBvh::collideTV( const b3DbvtNode* root, + const b3DbvtVolume& vol, DBVT_IPOLICY) const { DBVT_CHECKTYPE if(root) { - ATTRIBUTE_ALIGNED16(btDbvtVolume) volume(vol); - b3AlignedObjectArray stack; + ATTRIBUTE_ALIGNED16(b3DbvtVolume) volume(vol); + b3AlignedObjectArray stack; stack.resize(0); stack.reserve(SIMPLE_STACKSIZE); stack.push_back(root); do { - const btDbvtNode* n=stack[stack.size()-1]; + const b3DbvtNode* n=stack[stack.size()-1]; stack.pop_back(); if(Intersect(n->volume,volume)) { @@ -951,7 +951,7 @@ inline void b3DynamicBvh::collideTV( const btDbvtNode* root, } DBVT_PREFIX -inline void b3DynamicBvh::rayTestInternal( const btDbvtNode* root, +inline void b3DynamicBvh::rayTestInternal( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, const b3Vector3& rayDirectionInverse, @@ -969,18 +969,18 @@ inline void b3DynamicBvh::rayTestInternal( const btDbvtNode* root, int depth=1; int treshold=DOUBLE_STACKSIZE-2; - b3AlignedObjectArray& stack = m_rayTestStack; + b3AlignedObjectArray& stack = m_rayTestStack; stack.resize(DOUBLE_STACKSIZE); stack[0]=root; b3Vector3 bounds[2]; do { - const btDbvtNode* node=stack[--depth]; + const b3DbvtNode* node=stack[--depth]; bounds[0] = node->volume.Mins()-aabbMax; bounds[1] = node->volume.Maxs()-aabbMin; b3Scalar tmin=1.f,lambda_min=0.f; unsigned int result1=false; - result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); + result1 = b3RayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); if(result1) { if(node->isinternal()) @@ -1004,7 +1004,7 @@ inline void b3DynamicBvh::rayTestInternal( const btDbvtNode* root, // DBVT_PREFIX -inline void b3DynamicBvh::rayTest( const btDbvtNode* root, +inline void b3DynamicBvh::rayTest( const b3DbvtNode* root, const b3Vector3& rayFrom, const b3Vector3& rayTo, DBVT_IPOLICY) @@ -1015,18 +1015,18 @@ inline void b3DynamicBvh::rayTest( const btDbvtNode* root, b3Vector3 rayDir = (rayTo-rayFrom); rayDir.normalize (); - ///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT + ///what about division by zero? --> just set rayDirection[i] to INF/B3_LARGE_FLOAT 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 signs[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0}; b3Scalar lambda_max = rayDir.dot(rayTo-rayFrom); b3Vector3 resultNormal; - b3AlignedObjectArray stack; + b3AlignedObjectArray stack; int depth=1; int treshold=DOUBLE_STACKSIZE-2; @@ -1035,18 +1035,18 @@ inline void b3DynamicBvh::rayTest( const btDbvtNode* root, stack[0]=root; b3Vector3 bounds[2]; do { - const btDbvtNode* node=stack[--depth]; + const b3DbvtNode* node=stack[--depth]; bounds[0] = node->volume.Mins(); bounds[1] = node->volume.Maxs(); b3Scalar tmin=1.f,lambda_min=0.f; - unsigned int result1 = btRayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); + unsigned int result1 = b3RayAabb2(rayFrom,rayDirectionInverse,signs,bounds,tmin,lambda_min,lambda_max); #ifdef COMPARE_BTRAY_AABB2 b3Scalar param=1.f; - bool result2 = btRayAabb(rayFrom,rayTo,node->volume.Mins(),node->volume.Maxs(),param,resultNormal); - btAssert(result1 == result2); + bool result2 = b3RayAabb(rayFrom,rayTo,node->volume.Mins(),node->volume.Maxs(),param,resultNormal); + b3Assert(result1 == result2); #endif //TEST_BTRAY_AABB2 if(result1) @@ -1073,7 +1073,7 @@ inline void b3DynamicBvh::rayTest( const btDbvtNode* root, // DBVT_PREFIX -inline void b3DynamicBvh::collideKDOP(const btDbvtNode* root, +inline void b3DynamicBvh::collideKDOP(const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, int count, @@ -1085,7 +1085,7 @@ inline void b3DynamicBvh::collideKDOP(const btDbvtNode* root, const int inside=(1< stack; int signs[sizeof(unsigned)*8]; - btAssert(count=0)?1:0)+ @@ -1128,7 +1128,7 @@ inline void b3DynamicBvh::collideKDOP(const btDbvtNode* root, // DBVT_PREFIX -inline void b3DynamicBvh::collideOCL( const btDbvtNode* root, +inline void b3DynamicBvh::collideOCL( const b3DbvtNode* root, const b3Vector3* normals, const b3Scalar* offsets, const b3Vector3& sortaxis, @@ -1147,7 +1147,7 @@ inline void b3DynamicBvh::collideOCL( const btDbvtNode* root, b3AlignedObjectArray ifree; b3AlignedObjectArray stack; int signs[sizeof(unsigned)*8]; - btAssert(count=0)?1:0)+ @@ -1183,7 +1183,7 @@ inline void b3DynamicBvh::collideOCL( const btDbvtNode* root, { if(se.node->isinternal()) { - const btDbvtNode* pns[]={ se.node->childs[0],se.node->childs[1]}; + const b3DbvtNode* pns[]={ se.node->childs[0],se.node->childs[1]}; sStkNPS nes[]={ sStkNPS(pns[0],se.mask,pns[0]->volume.ProjectMinimum(sortaxis,srtsgns)), sStkNPS(pns[1],se.mask,pns[1]->volume.ProjectMinimum(sortaxis,srtsgns))}; const int q=nes[0].value stack; + b3AlignedObjectArray stack; stack.reserve(SIMPLE_STACKSIZE); stack.push_back(root); do { - const btDbvtNode* n=stack[stack.size()-1]; + const b3DbvtNode* n=stack[stack.size()-1]; stack.pop_back(); if(policy.Descent(n)) { diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp b/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp index cb65dc191..c4f8421ea 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp +++ b/src/Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.cpp @@ -29,7 +29,7 @@ subject to the following restrictions: #if DBVT_BP_PROFILE struct ProfileScope { - __forceinline ProfileScope(btClock& clock,unsigned long& value) : + __forceinline ProfileScope(b3Clock& clock,unsigned long& value) : m_clock(&clock),m_value(&value),m_base(clock.getTimeMicroseconds()) { } @@ -37,7 +37,7 @@ struct ProfileScope { (*m_value)+=m_clock->getTimeMicroseconds()-m_base; } - btClock* m_clock; + b3Clock* m_clock; unsigned long* m_value; unsigned long m_base; }; @@ -90,26 +90,26 @@ static inline void clear(T& value) // /* Tree collider */ -struct btDbvtTreeCollider : b3DynamicBvh::ICollide +struct b3DbvtTreeCollider : b3DynamicBvh::ICollide { b3DynamicBvhBroadphase* pbp; - btDbvtProxy* proxy; - btDbvtTreeCollider(b3DynamicBvhBroadphase* p) : pbp(p) {} - void Process(const btDbvtNode* na,const btDbvtNode* nb) + b3DbvtProxy* proxy; + b3DbvtTreeCollider(b3DynamicBvhBroadphase* p) : pbp(p) {} + void Process(const b3DbvtNode* na,const b3DbvtNode* nb) { if(na!=nb) { - btDbvtProxy* pa=(btDbvtProxy*)na->data; - btDbvtProxy* pb=(btDbvtProxy*)nb->data; + b3DbvtProxy* pa=(b3DbvtProxy*)na->data; + b3DbvtProxy* pb=(b3DbvtProxy*)nb->data; #if DBVT_BP_SORTPAIRS if(pa->m_uniqueId>pb->m_uniqueId) - btSwap(pa,pb); + b3Swap(pa,pb); #endif pbp->m_paircache->addOverlappingPair(pa->getUid(),pb->getUid()); ++pbp->m_newpairs; } } - void Process(const btDbvtNode* n) + void Process(const b3DbvtNode* n) { Process(n,proxy->leaf); } @@ -135,7 +135,7 @@ b3DynamicBvhBroadphase::b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingP m_updates_call = 0; m_updates_done = 0; m_updates_ratio = 0; - m_paircache = paircache? paircache : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache(); + m_paircache = paircache? paircache : new(b3AlignedAlloc(sizeof(b3HashedOverlappingPairCache),16)) b3HashedOverlappingPairCache(); m_pid = 0; m_cid = 0; @@ -155,33 +155,33 @@ b3DynamicBvhBroadphase::~b3DynamicBvhBroadphase() if(m_releasepaircache) { m_paircache->~b3OverlappingPairCache(); - btAlignedFree(m_paircache); + b3AlignedFree(m_paircache); } } // -btBroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabbMin, +b3BroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabbMin, const b3Vector3& aabbMax, int objectId, void* userPtr, short int collisionFilterGroup, short int collisionFilterMask) { - btDbvtProxy* mem = &m_proxies[objectId]; - btDbvtProxy* proxy=new(mem) btDbvtProxy( aabbMin,aabbMax,userPtr, + b3DbvtProxy* mem = &m_proxies[objectId]; + b3DbvtProxy* proxy=new(mem) b3DbvtProxy( aabbMin,aabbMax,userPtr, collisionFilterGroup, collisionFilterMask); - btDbvtAabbMm aabb = btDbvtVolume::FromMM(aabbMin,aabbMax); + b3DbvtAabbMm aabb = b3DbvtVolume::FromMM(aabbMin,aabbMax); - //bproxy->aabb = btDbvtVolume::FromMM(aabbMin,aabbMax); + //bproxy->aabb = b3DbvtVolume::FromMM(aabbMin,aabbMax); proxy->stage = m_stageCurrent; proxy->m_uniqueId = objectId; proxy->leaf = m_sets[0].insert(aabb,proxy); listappend(proxy,m_stageRoots[m_stageCurrent]); if(!m_deferedcollide) { - btDbvtTreeCollider collider(this); + b3DbvtTreeCollider collider(this); collider.proxy=proxy; m_sets[0].collideTV(m_sets[0].m_root,aabb,collider); m_sets[1].collideTV(m_sets[1].m_root,aabb,collider); @@ -190,10 +190,10 @@ btBroadphaseProxy* b3DynamicBvhBroadphase::createProxy( const b3Vector3& aabb } // -void b3DynamicBvhBroadphase::destroyProxy( btBroadphaseProxy* absproxy, - btDispatcher* dispatcher) +void b3DynamicBvhBroadphase::destroyProxy( b3BroadphaseProxy* absproxy, + b3Dispatcher* dispatcher) { - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; + b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy; if(proxy->stage==STAGECOUNT) m_sets[1].remove(proxy->leaf); else @@ -204,28 +204,28 @@ void b3DynamicBvhBroadphase::destroyProxy( btBroadphaseProxy* absproxy, m_needcleanup=true; } -void b3DynamicBvhBroadphase::getAabb(btBroadphaseProxy* absproxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const +void b3DynamicBvhBroadphase::getAabb(b3BroadphaseProxy* absproxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const { - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; + b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy; aabbMin = proxy->m_aabbMin; aabbMax = proxy->m_aabbMax; } struct BroadphaseRayTester : b3DynamicBvh::ICollide { - btBroadphaseRayCallback& m_rayCallback; - BroadphaseRayTester(btBroadphaseRayCallback& orgCallback) + b3BroadphaseRayCallback& m_rayCallback; + BroadphaseRayTester(b3BroadphaseRayCallback& orgCallback) :m_rayCallback(orgCallback) { } - void Process(const btDbvtNode* leaf) + void Process(const b3DbvtNode* leaf) { - btDbvtProxy* proxy=(btDbvtProxy*)leaf->data; + b3DbvtProxy* proxy=(b3DbvtProxy*)leaf->data; m_rayCallback.process(proxy); } }; -void b3DynamicBvhBroadphase::rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, btBroadphaseRayCallback& rayCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) +void b3DynamicBvhBroadphase::rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, b3BroadphaseRayCallback& rayCallback,const b3Vector3& aabbMin,const b3Vector3& aabbMax) { BroadphaseRayTester callback(rayCallback); @@ -254,23 +254,23 @@ void b3DynamicBvhBroadphase::rayTest(const b3Vector3& rayFrom,const b3Vector3& r struct BroadphaseAabbTester : b3DynamicBvh::ICollide { - btBroadphaseAabbCallback& m_aabbCallback; - BroadphaseAabbTester(btBroadphaseAabbCallback& orgCallback) + b3BroadphaseAabbCallback& m_aabbCallback; + BroadphaseAabbTester(b3BroadphaseAabbCallback& orgCallback) :m_aabbCallback(orgCallback) { } - void Process(const btDbvtNode* leaf) + void Process(const b3DbvtNode* leaf) { - btDbvtProxy* proxy=(btDbvtProxy*)leaf->data; + b3DbvtProxy* proxy=(b3DbvtProxy*)leaf->data; m_aabbCallback.process(proxy); } }; -void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3& aabbMax,btBroadphaseAabbCallback& aabbCallback) +void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3BroadphaseAabbCallback& aabbCallback) { BroadphaseAabbTester callback(aabbCallback); - const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(aabbMin,aabbMax); + const ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds=b3DbvtVolume::FromMM(aabbMin,aabbMax); //process all children, that overlap with the given AABB bounds m_sets[0].collideTV(m_sets[0].m_root,bounds,callback); m_sets[1].collideTV(m_sets[1].m_root,bounds,callback); @@ -280,13 +280,13 @@ void b3DynamicBvhBroadphase::aabbTest(const b3Vector3& aabbMin,const b3Vector3& // -void b3DynamicBvhBroadphase::setAabb( btBroadphaseProxy* absproxy, +void b3DynamicBvhBroadphase::setAabb( b3BroadphaseProxy* absproxy, const b3Vector3& aabbMin, const b3Vector3& aabbMax, - btDispatcher* /*dispatcher*/) + b3Dispatcher* /*dispatcher*/) { - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; - ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax); + b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy; + ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax); #if DBVT_BP_PREVENTFALSEUPDATE if(NotEqual(aabb,proxy->leaf->volume)) #endif @@ -338,7 +338,7 @@ void b3DynamicBvhBroadphase::setAabb( btBroadphaseProxy* absproxy, m_needcleanup=true; if(!m_deferedcollide) { - btDbvtTreeCollider collider(this); + b3DbvtTreeCollider collider(this); m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy->leaf,collider); m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy->leaf,collider); } @@ -348,13 +348,13 @@ void b3DynamicBvhBroadphase::setAabb( btBroadphaseProxy* absproxy, // -void b3DynamicBvhBroadphase::setAabbForceUpdate( btBroadphaseProxy* absproxy, +void b3DynamicBvhBroadphase::setAabbForceUpdate( b3BroadphaseProxy* absproxy, const b3Vector3& aabbMin, const b3Vector3& aabbMax, - btDispatcher* /*dispatcher*/) + b3Dispatcher* /*dispatcher*/) { - btDbvtProxy* proxy=(btDbvtProxy*)absproxy; - ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax); + b3DbvtProxy* proxy=(b3DbvtProxy*)absproxy; + ATTRIBUTE_ALIGNED16(b3DbvtVolume) aabb=b3DbvtVolume::FromMM(aabbMin,aabbMax); bool docollide=false; if(proxy->stage==STAGECOUNT) {/* fixed -> dynamic set */ @@ -380,7 +380,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( btBroadphaseProxy* abspr m_needcleanup=true; if(!m_deferedcollide) { - btDbvtTreeCollider collider(this); + b3DbvtTreeCollider collider(this); m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy->leaf,collider); m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy->leaf,collider); } @@ -388,7 +388,7 @@ void b3DynamicBvhBroadphase::setAabbForceUpdate( btBroadphaseProxy* abspr } // -void b3DynamicBvhBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) +void b3DynamicBvhBroadphase::calculateOverlappingPairs(b3Dispatcher* dispatcher) { collide(dispatcher); #if DBVT_BP_PROFILE @@ -415,30 +415,30 @@ void b3DynamicBvhBroadphase::calculateOverlappingPairs(btDispatcher* dispa } -void b3DynamicBvhBroadphase::performDeferredRemoval(btDispatcher* dispatcher) +void b3DynamicBvhBroadphase::performDeferredRemoval(b3Dispatcher* dispatcher) { if (m_paircache->hasDeferredRemoval()) { - btBroadphasePairArray& overlappingPairArray = m_paircache->getOverlappingPairArray(); + b3BroadphasePairArray& overlappingPairArray = m_paircache->getOverlappingPairArray(); //perform a sort, to find duplicates and to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); + overlappingPairArray.quickSort(b3BroadphasePairSortPredicate()); int invalidPair = 0; int i; - btBroadphasePair previousPair(-1,-1); + b3BroadphasePair previousPair(-1,-1); for (i=0;ileaf->volume,pb->leaf->volume); if (hasOverlap) @@ -479,13 +479,13 @@ void b3DynamicBvhBroadphase::performDeferredRemoval(btDispatcher* dispatcher) } //perform a sort, to sort 'invalid' pairs to the end - overlappingPairArray.quickSort(btBroadphasePairSortPredicate()); + overlappingPairArray.quickSort(b3BroadphasePairSortPredicate()); overlappingPairArray.resize(overlappingPairArray.size() - invalidPair); } } // -void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher) +void b3DynamicBvhBroadphase::collide(b3Dispatcher* dispatcher) { /*printf("---------------------------------------------------------\n"); printf("m_sets[0].m_leaves=%d\n",m_sets[0].m_leaves); @@ -511,16 +511,16 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher) { const int count=1+(m_sets[1].m_leaves*m_fupdates)/100; m_sets[1].optimizeIncremental(1+(m_sets[1].m_leaves*m_fupdates)/100); - m_fixedleft=btMax(0,m_fixedleft-count); + m_fixedleft=b3Max(0,m_fixedleft-count); } /* dynamic -> fixed set */ m_stageCurrent=(m_stageCurrent+1)%STAGECOUNT; - btDbvtProxy* current=m_stageRoots[m_stageCurrent]; + b3DbvtProxy* current=m_stageRoots[m_stageCurrent]; if(current) { - btDbvtTreeCollider collider(this); + b3DbvtTreeCollider collider(this); do { - btDbvtProxy* next=current->links[1]; + b3DbvtProxy* next=current->links[1]; listremove(current,m_stageRoots[current->stage]); listappend(current,m_stageRoots[STAGECOUNT]); #if DBVT_BP_ACCURATESLEEPING @@ -530,7 +530,7 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher) b3DynamicBvh::collideTV(m_sets[1].m_root,current->aabb,collider); #endif m_sets[0].remove(current->leaf); - ATTRIBUTE_ALIGNED16(btDbvtVolume) curAabb=btDbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax); + ATTRIBUTE_ALIGNED16(b3DbvtVolume) curAabb=b3DbvtVolume::FromMM(current->m_aabbMin,current->m_aabbMax); current->leaf = m_sets[1].insert(curAabb,current); current->stage = STAGECOUNT; current = next; @@ -540,7 +540,7 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher) } /* collide dynamics */ { - btDbvtTreeCollider collider(this); + b3DbvtTreeCollider collider(this); if(m_deferedcollide) { SPC(m_profiling.m_fdcollide); @@ -556,21 +556,21 @@ void b3DynamicBvhBroadphase::collide(btDispatcher* dispatcher) if(m_needcleanup) { SPC(m_profiling.m_cleanup); - btBroadphasePairArray& pairs=m_paircache->getOverlappingPairArray(); + b3BroadphasePairArray& pairs=m_paircache->getOverlappingPairArray(); if(pairs.size()>0) { - int ni=btMin(pairs.size(),btMax(m_newpairs,(pairs.size()*m_cupdates)/100)); + int ni=b3Min(pairs.size(),b3Max(m_newpairs,(pairs.size()*m_cupdates)/100)); for(int i=0;ileaf->volume,pb->leaf->volume)) { #if DBVT_BP_SORTPAIRS if(pa->m_uniqueId>pb->m_uniqueId) - btSwap(pa,pb); + b3Swap(pa,pb); #endif m_paircache->removeOverlappingPair(pa->getUid(),pb->getUid(),dispatcher); --ni;--i; @@ -613,7 +613,7 @@ const b3OverlappingPairCache* b3DynamicBvhBroadphase::getOverlappingPairCache() void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const { - ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds; + ATTRIBUTE_ALIGNED16(b3DbvtVolume) bounds; if(!m_sets[0].empty()) if(!m_sets[1].empty()) Merge( m_sets[0].m_root->volume, @@ -622,12 +622,12 @@ void b3DynamicBvhBroadphase::getBroadphaseAabb(b3Vector3& aabbMin,b3Vector bounds=m_sets[0].m_root->volume; else if(!m_sets[1].empty()) bounds=m_sets[1].m_root->volume; else - bounds=btDbvtVolume::FromCR(b3Vector3(0,0,0),0); + bounds=b3DbvtVolume::FromCR(b3Vector3(0,0,0),0); aabbMin=bounds.Mins(); aabbMax=bounds.Maxs(); } -void b3DynamicBvhBroadphase::resetPool(btDispatcher* dispatcher) +void b3DynamicBvhBroadphase::resetPool(b3Dispatcher* dispatcher) { int totalObjects = m_sets[0].m_leaves + m_sets[1].m_leaves; @@ -665,7 +665,7 @@ void b3DynamicBvhBroadphase::printStats() // #if DBVT_BP_ENABLE_BENCHMARK -struct btBroadphaseBenchmark +struct b3BroadphaseBenchmark { struct Experiment { @@ -681,22 +681,22 @@ struct btBroadphaseBenchmark { b3Vector3 center; b3Vector3 extents; - btBroadphaseProxy* proxy; + b3BroadphaseProxy* proxy; b3Scalar time; - void update(b3Scalar speed,b3Scalar amplitude,btBroadphaseInterface* pbi) + void update(b3Scalar speed,b3Scalar amplitude,b3BroadphaseInterface* pbi) { time += speed; - center[0] = btCos(time*(b3Scalar)2.17)*amplitude+ - btSin(time)*amplitude/2; - center[1] = btCos(time*(b3Scalar)1.38)*amplitude+ - btSin(time)*amplitude; - center[2] = btSin(time*(b3Scalar)0.777)*amplitude; + center[0] = b3Cos(time*(b3Scalar)2.17)*amplitude+ + b3Sin(time)*amplitude/2; + center[1] = b3Cos(time*(b3Scalar)1.38)*amplitude+ + b3Sin(time)*amplitude; + center[2] = b3Sin(time*(b3Scalar)0.777)*amplitude; pbi->setAabb(proxy,center-extents,center+extents,0); } }; static int UnsignedRand(int range=RAND_MAX-1) { return(rand()%(range+1)); } static b3Scalar UnitRand() { return(UnsignedRand(16384)/(b3Scalar)16384); } - static void OutputTime(const char* name,btClock& c,unsigned count=0) + static void OutputTime(const char* name,b3Clock& c,unsigned count=0) { const unsigned long us=c.getTimeMicroseconds(); const unsigned long ms=(us+500)/1000; @@ -708,21 +708,21 @@ struct btBroadphaseBenchmark } }; -void b3DynamicBvhBroadphase::benchmark(btBroadphaseInterface* pbi) +void b3DynamicBvhBroadphase::benchmark(b3BroadphaseInterface* pbi) { - static const btBroadphaseBenchmark::Experiment experiments[]= + static const b3BroadphaseBenchmark::Experiment experiments[]= { {"1024o.10%",1024,10,0,8192,(b3Scalar)0.005,(b3Scalar)100}, /*{"4096o.10%",4096,10,0,8192,(b3Scalar)0.005,(b3Scalar)100}, {"8192o.10%",8192,10,0,8192,(b3Scalar)0.005,(b3Scalar)100},*/ }; static const int nexperiments=sizeof(experiments)/sizeof(experiments[0]); - b3AlignedObjectArray objects; - btClock wallclock; + b3AlignedObjectArray objects; + b3Clock wallclock; /* Begin */ for(int iexp=0;iexpcenter[0]=btBroadphaseBenchmark::UnitRand()*50; - po->center[1]=btBroadphaseBenchmark::UnitRand()*50; - po->center[2]=btBroadphaseBenchmark::UnitRand()*50; - po->extents[0]=btBroadphaseBenchmark::UnitRand()*2+2; - po->extents[1]=btBroadphaseBenchmark::UnitRand()*2+2; - po->extents[2]=btBroadphaseBenchmark::UnitRand()*2+2; - po->time=btBroadphaseBenchmark::UnitRand()*2000; + b3BroadphaseBenchmark::Object* po=new b3BroadphaseBenchmark::Object(); + po->center[0]=b3BroadphaseBenchmark::UnitRand()*50; + po->center[1]=b3BroadphaseBenchmark::UnitRand()*50; + po->center[2]=b3BroadphaseBenchmark::UnitRand()*50; + po->extents[0]=b3BroadphaseBenchmark::UnitRand()*2+2; + po->extents[1]=b3BroadphaseBenchmark::UnitRand()*2+2; + po->extents[2]=b3BroadphaseBenchmark::UnitRand()*2+2; + po->time=b3BroadphaseBenchmark::UnitRand()*2000; po->proxy=pbi->createProxy(po->center-po->extents,po->center+po->extents,0,po,1,1,0,0); objects.push_back(po); } - btBroadphaseBenchmark::OutputTime("\tInitialization",wallclock); + b3BroadphaseBenchmark::OutputTime("\tInitialization",wallclock); /* First update */ wallclock.reset(); for(int i=0;iupdate(speed,amplitude,pbi); } - btBroadphaseBenchmark::OutputTime("\tFirst update",wallclock); + b3BroadphaseBenchmark::OutputTime("\tFirst update",wallclock); /* Updates */ wallclock.reset(); for(int i=0;icalculateOverlappingPairs(0); } - btBroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations); + b3BroadphaseBenchmark::OutputTime("\tUpdate",wallclock,experiment.iterations); /* Clean up */ wallclock.reset(); for(int i=0;i btDbvtProxyArray; +typedef b3AlignedObjectArray b3DbvtProxyArray; ///The b3DynamicBvhBroadphase implements a broadphase using two dynamic AABB bounding volume hierarchies/trees (see b3DynamicBvh). ///One tree is used for static/non-moving objects, and another tree is used for dynamic objects. Objects can move from one tree to the other. -///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases btAxisSweep3 and bt32BitAxisSweep3. +///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases b3AxisSweep3 and b332BitAxisSweep3. struct b3DynamicBvhBroadphase { /* Config */ @@ -129,9 +129,9 @@ struct b3DynamicBvhBroadphase }; /* Fields */ b3DynamicBvh m_sets[2]; // Dbvt sets - btDbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list + b3DbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list - b3AlignedObjectArray m_proxies; + b3AlignedObjectArray m_proxies; b3OverlappingPairCache* m_paircache; // Pair cache b3Scalar m_prediction; // Velocity prediction int m_stageCurrent; // Current stage @@ -149,7 +149,7 @@ struct b3DynamicBvhBroadphase bool m_deferedcollide; // Defere dynamic/static collision to collide call bool m_needcleanup; // Need to run cleanup? #if DBVT_BP_PROFILE - btClock m_clock; + b3Clock m_clock; struct { unsigned long m_total; unsigned long m_ddcollide; @@ -161,18 +161,18 @@ struct b3DynamicBvhBroadphase /* Methods */ b3DynamicBvhBroadphase(int proxyCapacity, b3OverlappingPairCache* paircache=0); ~b3DynamicBvhBroadphase(); - void collide(btDispatcher* dispatcher); + void collide(b3Dispatcher* dispatcher); void optimize(); - /* btBroadphaseInterface Implementation */ - btBroadphaseProxy* createProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask); - virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - virtual void setAabb(btBroadphaseProxy* proxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,btDispatcher* dispatcher); - virtual void rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, btBroadphaseRayCallback& rayCallback, const b3Vector3& aabbMin=b3Vector3(0,0,0), const b3Vector3& aabbMax = b3Vector3(0,0,0)); - virtual void aabbTest(const b3Vector3& aabbMin, const b3Vector3& aabbMax, btBroadphaseAabbCallback& callback); + /* b3BroadphaseInterface Implementation */ + b3BroadphaseProxy* createProxy(const b3Vector3& aabbMin,const b3Vector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask); + virtual void destroyProxy(b3BroadphaseProxy* proxy,b3Dispatcher* dispatcher); + virtual void setAabb(b3BroadphaseProxy* proxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3Dispatcher* dispatcher); + virtual void rayTest(const b3Vector3& rayFrom,const b3Vector3& rayTo, b3BroadphaseRayCallback& rayCallback, const b3Vector3& aabbMin=b3Vector3(0,0,0), const b3Vector3& aabbMax = b3Vector3(0,0,0)); + virtual void aabbTest(const b3Vector3& aabbMin, const b3Vector3& aabbMax, b3BroadphaseAabbCallback& callback); - virtual void getAabb(btBroadphaseProxy* proxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const; - virtual void calculateOverlappingPairs(btDispatcher* dispatcher=0); + virtual void getAabb(b3BroadphaseProxy* proxy,b3Vector3& aabbMin, b3Vector3& aabbMax ) const; + virtual void calculateOverlappingPairs(b3Dispatcher* dispatcher=0); virtual b3OverlappingPairCache* getOverlappingPairCache(); virtual const b3OverlappingPairCache* getOverlappingPairCache() const; virtual void getBroadphaseAabb(b3Vector3& aabbMin,b3Vector3& aabbMax) const; @@ -180,9 +180,9 @@ struct b3DynamicBvhBroadphase ///reset broadphase internal structures, to ensure determinism/reproducability - virtual void resetPool(btDispatcher* dispatcher); + virtual void resetPool(b3Dispatcher* dispatcher); - void performDeferredRemoval(btDispatcher* dispatcher); + void performDeferredRemoval(b3Dispatcher* dispatcher); void setVelocityPrediction(b3Scalar prediction) { @@ -194,12 +194,12 @@ struct b3DynamicBvhBroadphase } ///this setAabbForceUpdate is similar to setAabb but always forces the aabb update. - ///it is not part of the btBroadphaseInterface but specific to b3DynamicBvhBroadphase. + ///it is not part of the b3BroadphaseInterface but specific to b3DynamicBvhBroadphase. ///it bypasses certain optimizations that prevent aabb updates (when the aabb shrinks), see ///http://code.google.com/p/bullet/issues/detail?id=223 - void setAabbForceUpdate( btBroadphaseProxy* absproxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,btDispatcher* /*dispatcher*/); + void setAabbForceUpdate( b3BroadphaseProxy* absproxy,const b3Vector3& aabbMin,const b3Vector3& aabbMax,b3Dispatcher* /*dispatcher*/); - //static void benchmark(btBroadphaseInterface*); + //static void benchmark(b3BroadphaseInterface*); }; diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h index fd82761b4..5a8fd491b 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h +++ b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPair.h @@ -1,13 +1,13 @@ #ifndef B3_OVERLAPPING_PAIR_H #define B3_OVERLAPPING_PAIR_H -#include "Bullet3Common/btInt2.h" +#include "Bullet3Common/b3Int2.h" -//typedef btInt2 btBroadphasePair; -struct btBroadphasePair : public btInt2 +//typedef b3Int2 b3BroadphasePair; +struct b3BroadphasePair : public b3Int2 { - explicit btBroadphasePair(){} - btBroadphasePair(int xx,int yy) + explicit b3BroadphasePair(){} + b3BroadphasePair(int xx,int yy) { if (xx < yy) { @@ -22,11 +22,11 @@ struct btBroadphasePair : public btInt2 } }; -class btBroadphasePairSortPredicate +class b3BroadphasePairSortPredicate { public: - bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) const + bool operator() ( const b3BroadphasePair& a, const b3BroadphasePair& b ) const { const int uidA0 = a.x; const int uidB0 = b.x; @@ -36,7 +36,7 @@ class btBroadphasePairSortPredicate } }; -SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b) +SIMD_FORCE_INLINE bool operator==(const b3BroadphasePair& a, const b3BroadphasePair& b) { return (a.x == b.x ) && (a.y == b.y ); } diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp index 5d9ef1c2a..ebf20ff03 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp +++ b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.cpp @@ -17,8 +17,8 @@ subject to the following restrictions: #include "b3OverlappingPairCache.h" -//#include "btDispatcher.h" -//#include "btCollisionAlgorithm.h" +//#include "b3Dispatcher.h" +//#include "b3CollisionAlgorithm.h" #include "Bullet3Geometry/b3AabbUtil.h" #include @@ -32,7 +32,7 @@ int gFindPairs =0; -btHashedOverlappingPairCache::btHashedOverlappingPairCache(): +b3HashedOverlappingPairCache::b3HashedOverlappingPairCache(): m_overlapFilterCallback(0), m_blockedForChanges(false) { @@ -44,18 +44,18 @@ btHashedOverlappingPairCache::btHashedOverlappingPairCache(): -btHashedOverlappingPairCache::~btHashedOverlappingPairCache() +b3HashedOverlappingPairCache::~b3HashedOverlappingPairCache() { } -void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) +void b3HashedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher) { /* if (pair.m_algorithm) { { - pair.m_algorithm->~btCollisionAlgorithm(); + pair.m_algorithm->~b3CollisionAlgorithm(); dispatcher->freeCollisionAlgorithm(pair.m_algorithm); pair.m_algorithm=0; } @@ -67,23 +67,23 @@ void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,b -void btHashedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* dispatcher) +void b3HashedOverlappingPairCache::cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher) { - class CleanPairCallback : public btOverlapCallback + class CleanPairCallback : public b3OverlapCallback { int m_cleanProxy; b3OverlappingPairCache* m_pairCache; - btDispatcher* m_dispatcher; + b3Dispatcher* m_dispatcher; public: - CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,btDispatcher* dispatcher) + CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,b3Dispatcher* dispatcher) :m_cleanProxy(cleanProxy), m_pairCache(pairCache), m_dispatcher(dispatcher) { } - virtual bool processOverlap(btBroadphasePair& pair) + virtual bool processOverlap(b3BroadphasePair& pair) { if ((pair.x == m_cleanProxy) || (pair.y == m_cleanProxy)) @@ -104,10 +104,10 @@ void btHashedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* d -void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher) +void b3HashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher) { - class RemovePairCallback : public btOverlapCallback + class RemovePairCallback : public b3OverlapCallback { int m_obsoleteProxy; @@ -116,7 +116,7 @@ void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro :m_obsoleteProxy(obsoleteProxy) { } - virtual bool processOverlap(btBroadphasePair& pair) + virtual bool processOverlap(b3BroadphasePair& pair) { return ((pair.x == m_obsoleteProxy) || (pair.y == m_obsoleteProxy)); @@ -134,16 +134,16 @@ void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro -btBroadphasePair* btHashedOverlappingPairCache::findPair(int proxy0, int proxy1) +b3BroadphasePair* b3HashedOverlappingPairCache::findPair(int proxy0, int proxy1) { gFindPairs++; if(proxy0 >proxy1) - btSwap(proxy0,proxy1); + b3Swap(proxy0,proxy1); int proxyId1 = proxy0; int proxyId2 = proxy1; /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ + b3Swap(proxyId1, proxyId2);*/ int hash = static_cast(getHash(static_cast(proxyId1), static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); @@ -153,24 +153,24 @@ btBroadphasePair* btHashedOverlappingPairCache::findPair(int proxy0, int proxy1) } int index = m_hashTable[hash]; - while (index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) + while (index != B3_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) { index = m_next[index]; } - if (index == BT_NULL_PAIR) + if (index == B3_NULL_PAIR) { return NULL; } - btAssert(index < m_overlappingPairArray.size()); + b3Assert(index < m_overlappingPairArray.size()); return &m_overlappingPairArray[index]; } //#include -void btHashedOverlappingPairCache::growTables() +void b3HashedOverlappingPairCache::growTables() { int newCapacity = m_overlappingPairArray.capacity(); @@ -188,21 +188,21 @@ void btHashedOverlappingPairCache::growTables() for (i= 0; i < newCapacity; ++i) { - m_hashTable[i] = BT_NULL_PAIR; + m_hashTable[i] = B3_NULL_PAIR; } for (i = 0; i < newCapacity; ++i) { - m_next[i] = BT_NULL_PAIR; + m_next[i] = B3_NULL_PAIR; } for(i=0;i proxyId2) - btSwap(proxyId1, proxyId2);*/ + b3Swap(proxyId1, proxyId2);*/ int hashValue = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask m_next[i] = m_hashTable[hashValue]; m_hashTable[hashValue] = i; @@ -212,20 +212,20 @@ void btHashedOverlappingPairCache::growTables() } } -btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(int proxy0, int proxy1) +b3BroadphasePair* b3HashedOverlappingPairCache::internalAddPair(int proxy0, int proxy1) { if(proxy0>proxy1) - btSwap(proxy0,proxy1); + b3Swap(proxy0,proxy1); int proxyId1 = proxy0; int proxyId2 = proxy1; /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ + b3Swap(proxyId1, proxyId2);*/ int hash = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask - btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash); + b3BroadphasePair* pair = internalFindPair(proxy0, proxy1, hash); if (pair != NULL) { return pair; @@ -256,7 +256,7 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(int proxy0, int hash = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); } - pair = new (mem) btBroadphasePair(proxy0,proxy1); + pair = new (mem) b3BroadphasePair(proxy0,proxy1); // pair->m_pProxy0 = proxy0; // pair->m_pProxy1 = proxy1; @@ -272,20 +272,20 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(int proxy0, int -void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,btDispatcher* dispatcher) +void* b3HashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1,b3Dispatcher* dispatcher) { gRemovePairs++; if(proxy0>proxy1) - btSwap(proxy0,proxy1); + b3Swap(proxy0,proxy1); int proxyId1 = proxy0; int proxyId2 = proxy1; /*if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2);*/ + b3Swap(proxyId1, proxyId2);*/ int hash = static_cast(getHash(static_cast(proxyId1),static_cast(proxyId2)) & (m_overlappingPairArray.capacity()-1)); - btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash); + b3BroadphasePair* pair = internalFindPair(proxy0, proxy1, hash); if (pair == NULL) { return 0; @@ -296,22 +296,22 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1 int pairIndex = int(pair - &m_overlappingPairArray[0]); - btAssert(pairIndex < m_overlappingPairArray.size()); + b3Assert(pairIndex < m_overlappingPairArray.size()); // Remove the pair from the hash table. int index = m_hashTable[hash]; - btAssert(index != BT_NULL_PAIR); + b3Assert(index != B3_NULL_PAIR); - int previous = BT_NULL_PAIR; + int previous = B3_NULL_PAIR; while (index != pairIndex) { previous = index; index = m_next[index]; } - if (previous != BT_NULL_PAIR) + if (previous != B3_NULL_PAIR) { - btAssert(m_next[previous] == pairIndex); + b3Assert(m_next[previous] == pairIndex); m_next[previous] = m_next[pairIndex]; } else @@ -336,23 +336,23 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1 } // Remove the last pair from the hash table. - const btBroadphasePair* last = &m_overlappingPairArray[lastPairIndex]; + const b3BroadphasePair* last = &m_overlappingPairArray[lastPairIndex]; /* missing swap here too, Nat. */ int lastHash = static_cast(getHash(static_cast(last->x), static_cast(last->y)) & (m_overlappingPairArray.capacity()-1)); index = m_hashTable[lastHash]; - btAssert(index != BT_NULL_PAIR); + b3Assert(index != B3_NULL_PAIR); - previous = BT_NULL_PAIR; + previous = B3_NULL_PAIR; while (index != lastPairIndex) { previous = index; index = m_next[index]; } - if (previous != BT_NULL_PAIR) + if (previous != B3_NULL_PAIR) { - btAssert(m_next[previous] == lastPairIndex); + b3Assert(m_next[previous] == lastPairIndex); m_next[previous] = m_next[lastPairIndex]; } else @@ -373,7 +373,7 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(int proxy0, int proxy1 } //#include -void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher) +void b3HashedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback* callback,b3Dispatcher* dispatcher) { int i; @@ -382,7 +382,7 @@ void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* for (i=0;iprocessOverlap(*pair)) { removeOverlappingPair(pair->x,pair->y,dispatcher); @@ -399,10 +399,10 @@ void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* -void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher) +void b3HashedOverlappingPairCache::sortOverlappingPairs(b3Dispatcher* dispatcher) { ///need to keep hashmap in sync with pair address, so rebuild all - btBroadphasePairArray tmpPairs; + b3BroadphasePairArray tmpPairs; int i; for (i=0;i -void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher) +void b3SortedOverlappingPairCache::processAllOverlappingPairs(b3OverlapCallback* callback,b3Dispatcher* dispatcher) { int i; @@ -524,7 +524,7 @@ void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* for (i=0;iprocessOverlap(*pair)) { cleanOverlappingPair(*pair,dispatcher); @@ -543,7 +543,7 @@ void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* -btSortedOverlappingPairCache::btSortedOverlappingPairCache(): +b3SortedOverlappingPairCache::b3SortedOverlappingPairCache(): m_blockedForChanges(false), m_hasDeferredRemoval(true), m_overlapFilterCallback(0) @@ -553,16 +553,16 @@ btSortedOverlappingPairCache::btSortedOverlappingPairCache(): m_overlappingPairArray.reserve(initialAllocatedSize); } -btSortedOverlappingPairCache::~btSortedOverlappingPairCache() +b3SortedOverlappingPairCache::~b3SortedOverlappingPairCache() { } -void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) +void b3SortedOverlappingPairCache::cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher) { /* if (pair.m_algorithm) { { - pair.m_algorithm->~btCollisionAlgorithm(); + pair.m_algorithm->~b3CollisionAlgorithm(); dispatcher->freeCollisionAlgorithm(pair.m_algorithm); pair.m_algorithm=0; gRemovePairs--; @@ -572,23 +572,23 @@ void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,b } -void btSortedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* dispatcher) +void b3SortedOverlappingPairCache::cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher) { - class CleanPairCallback : public btOverlapCallback + class CleanPairCallback : public b3OverlapCallback { int m_cleanProxy; b3OverlappingPairCache* m_pairCache; - btDispatcher* m_dispatcher; + b3Dispatcher* m_dispatcher; public: - CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,btDispatcher* dispatcher) + CleanPairCallback(int cleanProxy,b3OverlappingPairCache* pairCache,b3Dispatcher* dispatcher) :m_cleanProxy(cleanProxy), m_pairCache(pairCache), m_dispatcher(dispatcher) { } - virtual bool processOverlap(btBroadphasePair& pair) + virtual bool processOverlap(b3BroadphasePair& pair) { if ((pair.x == m_cleanProxy) || (pair.y == m_cleanProxy)) @@ -607,10 +607,10 @@ void btSortedOverlappingPairCache::cleanProxyFromPairs(int proxy,btDispatcher* d } -void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher) +void b3SortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher) { - class RemovePairCallback : public btOverlapCallback + class RemovePairCallback : public b3OverlapCallback { int m_obsoleteProxy; @@ -619,7 +619,7 @@ void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro :m_obsoleteProxy(obsoleteProxy) { } - virtual bool processOverlap(btBroadphasePair& pair) + virtual bool processOverlap(b3BroadphasePair& pair) { return ((pair.x == m_obsoleteProxy) || (pair.y == m_obsoleteProxy)); @@ -632,7 +632,7 @@ void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(int pro processAllOverlappingPairs(&removeCallback,dispatcher); } -void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher) +void b3SortedOverlappingPairCache::sortOverlappingPairs(b3Dispatcher* dispatcher) { //should already be sorted } diff --git a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h index 888446d9f..45ee48007 100644 --- a/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h +++ b/src/Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h @@ -13,31 +13,31 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_OVERLAPPING_PAIR_CACHE_H -#define BT_OVERLAPPING_PAIR_CACHE_H +#ifndef B3_OVERLAPPING_PAIR_CACHE_H +#define B3_OVERLAPPING_PAIR_CACHE_H -#include "Bullet3Common/btInt2.h" +#include "Bullet3Common/b3Int2.h" #include "Bullet3Common/b3AlignedObjectArray.h" -class btDispatcher; +class b3Dispatcher; #include "b3OverlappingPair.h" -typedef b3AlignedObjectArray btBroadphasePairArray; +typedef b3AlignedObjectArray b3BroadphasePairArray; -struct btOverlapCallback +struct b3OverlapCallback { - virtual ~btOverlapCallback() + virtual ~b3OverlapCallback() {} //return true for deletion of the pair - virtual bool processOverlap(btBroadphasePair& pair) = 0; + virtual bool processOverlap(b3BroadphasePair& pair) = 0; }; -struct btOverlapFilterCallback +struct b3OverlapFilterCallback { - virtual ~btOverlapFilterCallback() + virtual ~b3OverlapFilterCallback() {} // return true when pairs need collision virtual bool needBroadphaseCollision(int proxy0,int proxy1) const = 0; @@ -53,62 +53,62 @@ extern int gRemovePairs; extern int gAddedPairs; extern int gFindPairs; -const int BT_NULL_PAIR=0xffffffff; +const int B3_NULL_PAIR=0xffffffff; -///The b3OverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases. -///The btHashedOverlappingPairCache and btSortedOverlappingPairCache classes are two implementations. +///The b3OverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the b3BroadphaseInterface broadphases. +///The b3HashedOverlappingPairCache and b3SortedOverlappingPairCache classes are two implementations. class b3OverlappingPairCache { public: virtual ~b3OverlappingPairCache() {} // this is needed so we can get to the derived class destructor - virtual btBroadphasePair* getOverlappingPairArrayPtr() = 0; + virtual b3BroadphasePair* getOverlappingPairArrayPtr() = 0; - virtual const btBroadphasePair* getOverlappingPairArrayPtr() const = 0; + virtual const b3BroadphasePair* getOverlappingPairArrayPtr() const = 0; - virtual btBroadphasePairArray& getOverlappingPairArray() = 0; + virtual b3BroadphasePairArray& getOverlappingPairArray() = 0; - virtual void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) = 0; + virtual void cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher) = 0; virtual int getNumOverlappingPairs() const = 0; - virtual void cleanProxyFromPairs(int proxy,btDispatcher* dispatcher) = 0; + virtual void cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher) = 0; - virtual void setOverlapFilterCallback(btOverlapFilterCallback* callback) = 0; + virtual void setOverlapFilterCallback(b3OverlapFilterCallback* callback) = 0; - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher) = 0; + virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* dispatcher) = 0; - virtual btBroadphasePair* findPair(int proxy0, int proxy1) = 0; + virtual b3BroadphasePair* findPair(int proxy0, int proxy1) = 0; virtual bool hasDeferredRemoval() = 0; - //virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0; + //virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* ghostPairCallback)=0; - virtual btBroadphasePair* addOverlappingPair(int proxy0,int proxy1)=0; - virtual void* removeOverlappingPair(int proxy0,int proxy1,btDispatcher* dispatcher)=0; - virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,btDispatcher* /*dispatcher*/)=0; + virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1)=0; + virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher)=0; + virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,b3Dispatcher* /*dispatcher*/)=0; - virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0; + virtual void sortOverlappingPairs(b3Dispatcher* dispatcher) = 0; }; /// Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman, Codercorner, http://codercorner.com -class btHashedOverlappingPairCache : public b3OverlappingPairCache +class b3HashedOverlappingPairCache : public b3OverlappingPairCache { - btBroadphasePairArray m_overlappingPairArray; - btOverlapFilterCallback* m_overlapFilterCallback; + b3BroadphasePairArray m_overlappingPairArray; + b3OverlapFilterCallback* m_overlapFilterCallback; bool m_blockedForChanges; public: - btHashedOverlappingPairCache(); - virtual ~btHashedOverlappingPairCache(); + b3HashedOverlappingPairCache(); + virtual ~b3HashedOverlappingPairCache(); - virtual void removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher); + virtual void removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher); - virtual void* removeOverlappingPair(int proxy0,int proxy1,btDispatcher* dispatcher); + virtual void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher); SIMD_FORCE_INLINE bool needsBroadphaseCollision(int proxy0,int proxy1) const { @@ -123,7 +123,7 @@ public: // Add a pair and return the new pair. If the pair already exists, // no new pair is created and the old one is returned. - virtual btBroadphasePair* addOverlappingPair(int proxy0,int proxy1) + virtual b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1) { gAddedPairs++; @@ -135,46 +135,46 @@ public: - void cleanProxyFromPairs(int proxy,btDispatcher* dispatcher); + void cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher); - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher); + virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* dispatcher); - virtual btBroadphasePair* getOverlappingPairArrayPtr() + virtual b3BroadphasePair* getOverlappingPairArrayPtr() { return &m_overlappingPairArray[0]; } - const btBroadphasePair* getOverlappingPairArrayPtr() const + const b3BroadphasePair* getOverlappingPairArrayPtr() const { return &m_overlappingPairArray[0]; } - btBroadphasePairArray& getOverlappingPairArray() + b3BroadphasePairArray& getOverlappingPairArray() { return m_overlappingPairArray; } - const btBroadphasePairArray& getOverlappingPairArray() const + const b3BroadphasePairArray& getOverlappingPairArray() const { return m_overlappingPairArray; } - void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher); + void cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher); - btBroadphasePair* findPair(int proxy0, int proxy1); + b3BroadphasePair* findPair(int proxy0, int proxy1); int GetCount() const { return m_overlappingPairArray.size(); } -// btBroadphasePair* GetPairs() { return m_pairs; } +// b3BroadphasePair* GetPairs() { return m_pairs; } - btOverlapFilterCallback* getOverlapFilterCallback() + b3OverlapFilterCallback* getOverlapFilterCallback() { return m_overlapFilterCallback; } - void setOverlapFilterCallback(btOverlapFilterCallback* callback) + void setOverlapFilterCallback(b3OverlapFilterCallback* callback) { m_overlapFilterCallback = callback; } @@ -185,11 +185,11 @@ public: } private: - btBroadphasePair* internalAddPair(int proxy0,int proxy1); + b3BroadphasePair* internalAddPair(int proxy0,int proxy1); void growTables(); - SIMD_FORCE_INLINE bool equalsPair(const btBroadphasePair& pair, int proxyId1, int proxyId2) + SIMD_FORCE_INLINE bool equalsPair(const b3BroadphasePair& pair, int proxyId1, int proxyId2) { return pair.x == proxyId1 && pair.y == proxyId2; } @@ -230,28 +230,28 @@ private: - SIMD_FORCE_INLINE btBroadphasePair* internalFindPair(int proxy0, int proxy1, int hash) + SIMD_FORCE_INLINE b3BroadphasePair* internalFindPair(int proxy0, int proxy1, int hash) { int proxyId1 = proxy0; int proxyId2 = proxy1; #if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat. if (proxyId1 > proxyId2) - btSwap(proxyId1, proxyId2); + b3Swap(proxyId1, proxyId2); #endif int index = m_hashTable[hash]; - while( index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) + while( index != B3_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) { index = m_next[index]; } - if ( index == BT_NULL_PAIR ) + if ( index == B3_NULL_PAIR ) { return NULL; } - btAssert(index < m_overlappingPairArray.size()); + b3Assert(index < m_overlappingPairArray.size()); return &m_overlappingPairArray[index]; } @@ -261,33 +261,33 @@ private: return false; } -/* virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback) +/* virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* ghostPairCallback) { m_ghostPairCallback = ghostPairCallback; } */ - virtual void sortOverlappingPairs(btDispatcher* dispatcher); + virtual void sortOverlappingPairs(b3Dispatcher* dispatcher); protected: b3AlignedObjectArray m_hashTable; b3AlignedObjectArray m_next; -// btOverlappingPairCallback* m_ghostPairCallback; +// b3OverlappingPairCallback* m_ghostPairCallback; }; -///btSortedOverlappingPairCache maintains the objects with overlapping AABB -///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase -class btSortedOverlappingPairCache : public b3OverlappingPairCache +///b3SortedOverlappingPairCache maintains the objects with overlapping AABB +///Typically managed by the Broadphase, Axis3Sweep or b3SimpleBroadphase +class b3SortedOverlappingPairCache : public b3OverlappingPairCache { protected: //avoid brute-force finding all the time - btBroadphasePairArray m_overlappingPairArray; + b3BroadphasePairArray m_overlappingPairArray; //during the dispatch, check that user doesn't destroy/create proxy bool m_blockedForChanges; @@ -296,29 +296,29 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache bool m_hasDeferredRemoval; //if set, use the callback instead of the built in filter in needBroadphaseCollision - btOverlapFilterCallback* m_overlapFilterCallback; + b3OverlapFilterCallback* m_overlapFilterCallback; -// btOverlappingPairCallback* m_ghostPairCallback; +// b3OverlappingPairCallback* m_ghostPairCallback; public: - btSortedOverlappingPairCache(); - virtual ~btSortedOverlappingPairCache(); + b3SortedOverlappingPairCache(); + virtual ~b3SortedOverlappingPairCache(); - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher); + virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* dispatcher); - void* removeOverlappingPair(int proxy0,int proxy1,btDispatcher* dispatcher); + void* removeOverlappingPair(int proxy0,int proxy1,b3Dispatcher* dispatcher); - void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher); + void cleanOverlappingPair(b3BroadphasePair& pair,b3Dispatcher* dispatcher); - btBroadphasePair* addOverlappingPair(int proxy0,int proxy1); + b3BroadphasePair* addOverlappingPair(int proxy0,int proxy1); - btBroadphasePair* findPair(int proxy0,int proxy1); + b3BroadphasePair* findPair(int proxy0,int proxy1); - void cleanProxyFromPairs(int proxy,btDispatcher* dispatcher); + void cleanProxyFromPairs(int proxy,b3Dispatcher* dispatcher); - virtual void removeOverlappingPairsContainingProxy(int proxy,btDispatcher* dispatcher); + virtual void removeOverlappingPairsContainingProxy(int proxy,b3Dispatcher* dispatcher); inline bool needsBroadphaseCollision(int proxy0,int proxy1) const @@ -332,12 +332,12 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache return collides; } - btBroadphasePairArray& getOverlappingPairArray() + b3BroadphasePairArray& getOverlappingPairArray() { return m_overlappingPairArray; } - const btBroadphasePairArray& getOverlappingPairArray() const + const b3BroadphasePairArray& getOverlappingPairArray() const { return m_overlappingPairArray; } @@ -345,12 +345,12 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache - btBroadphasePair* getOverlappingPairArrayPtr() + b3BroadphasePair* getOverlappingPairArrayPtr() { return &m_overlappingPairArray[0]; } - const btBroadphasePair* getOverlappingPairArrayPtr() const + const b3BroadphasePair* getOverlappingPairArrayPtr() const { return &m_overlappingPairArray[0]; } @@ -360,12 +360,12 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache return m_overlappingPairArray.size(); } - btOverlapFilterCallback* getOverlapFilterCallback() + b3OverlapFilterCallback* getOverlapFilterCallback() { return m_overlapFilterCallback; } - void setOverlapFilterCallback(btOverlapFilterCallback* callback) + void setOverlapFilterCallback(b3OverlapFilterCallback* callback) { m_overlapFilterCallback = callback; } @@ -375,40 +375,40 @@ class btSortedOverlappingPairCache : public b3OverlappingPairCache return m_hasDeferredRemoval; } -/* virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback) +/* virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* ghostPairCallback) { m_ghostPairCallback = ghostPairCallback; } */ - virtual void sortOverlappingPairs(btDispatcher* dispatcher); + virtual void sortOverlappingPairs(b3Dispatcher* dispatcher); }; -///btNullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and unit testing. -class btNullPairCache : public b3OverlappingPairCache +///b3NullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and unit testing. +class b3NullPairCache : public b3OverlappingPairCache { - btBroadphasePairArray m_overlappingPairArray; + b3BroadphasePairArray m_overlappingPairArray; public: - virtual btBroadphasePair* getOverlappingPairArrayPtr() + virtual b3BroadphasePair* getOverlappingPairArrayPtr() { return &m_overlappingPairArray[0]; } - const btBroadphasePair* getOverlappingPairArrayPtr() const + const b3BroadphasePair* getOverlappingPairArrayPtr() const { return &m_overlappingPairArray[0]; } - btBroadphasePairArray& getOverlappingPairArray() + b3BroadphasePairArray& getOverlappingPairArray() { return m_overlappingPairArray; } - virtual void cleanOverlappingPair(btBroadphasePair& /*pair*/,btDispatcher* /*dispatcher*/) + virtual void cleanOverlappingPair(b3BroadphasePair& /*pair*/,b3Dispatcher* /*dispatcher*/) { } @@ -418,20 +418,20 @@ public: return 0; } - virtual void cleanProxyFromPairs(int /*proxy*/,btDispatcher* /*dispatcher*/) + virtual void cleanProxyFromPairs(int /*proxy*/,b3Dispatcher* /*dispatcher*/) { } - virtual void setOverlapFilterCallback(btOverlapFilterCallback* /*callback*/) + virtual void setOverlapFilterCallback(b3OverlapFilterCallback* /*callback*/) { } - virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* /*dispatcher*/) + virtual void processAllOverlappingPairs(b3OverlapCallback*,b3Dispatcher* /*dispatcher*/) { } - virtual btBroadphasePair* findPair(int /*proxy0*/, int /*proxy1*/) + virtual b3BroadphasePair* findPair(int /*proxy0*/, int /*proxy1*/) { return 0; } @@ -441,26 +441,26 @@ public: return true; } -// virtual void setInternalGhostPairCallback(btOverlappingPairCallback* /* ghostPairCallback */) +// virtual void setInternalGhostPairCallback(b3OverlappingPairCallback* /* ghostPairCallback */) // { // // } - virtual btBroadphasePair* addOverlappingPair(int /*proxy0*/,int /*proxy1*/) + virtual b3BroadphasePair* addOverlappingPair(int /*proxy0*/,int /*proxy1*/) { return 0; } - virtual void* removeOverlappingPair(int /*proxy0*/,int /*proxy1*/,btDispatcher* /*dispatcher*/) + virtual void* removeOverlappingPair(int /*proxy0*/,int /*proxy1*/,b3Dispatcher* /*dispatcher*/) { return 0; } - virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,btDispatcher* /*dispatcher*/) + virtual void removeOverlappingPairsContainingProxy(int /*proxy0*/,b3Dispatcher* /*dispatcher*/) { } - virtual void sortOverlappingPairs(btDispatcher* dispatcher) + virtual void sortOverlappingPairs(b3Dispatcher* dispatcher) { (void) dispatcher; } @@ -469,6 +469,6 @@ public: }; -#endif //BT_OVERLAPPING_PAIR_CACHE_H +#endif //B3_OVERLAPPING_PAIR_CACHE_H diff --git a/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h b/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h index 0282f831b..cdd1c5b7e 100644 --- a/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h +++ b/src/Bullet3Collision/NarrowPhaseCollision/b3Contact4.h @@ -1,12 +1,12 @@ -#ifndef BT_CONTACT4_H -#define BT_CONTACT4_H +#ifndef B3_CONTACT4_H +#define B3_CONTACT4_H #include "Bullet3Common/b3Vector3.h" ATTRIBUTE_ALIGNED16(struct) b3Contact4 { - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); b3Vector3 m_worldPos[4]; b3Vector3 m_worldNormal; @@ -27,9 +27,9 @@ ATTRIBUTE_ALIGNED16(struct) b3Contact4 int& getBatchIdx() { return m_batchIdx; } const int& getBatchIdx() const { return m_batchIdx; } float getRestituitionCoeff() const { return ((float)m_restituitionCoeffCmp/(float)0xffff); } - void setRestituitionCoeff( float c ) { btAssert( c >= 0.f && c <= 1.f ); m_restituitionCoeffCmp = (unsigned short)(c*0xffff); } + void setRestituitionCoeff( float c ) { b3Assert( c >= 0.f && c <= 1.f ); m_restituitionCoeffCmp = (unsigned short)(c*0xffff); } float getFrictionCoeff() const { return ((float)m_frictionCoeffCmp/(float)0xffff); } - void setFrictionCoeff( float c ) { btAssert( c >= 0.f && c <= 1.f ); m_frictionCoeffCmp = (unsigned short)(c*0xffff); } + void setFrictionCoeff( float c ) { b3Assert( c >= 0.f && c <= 1.f ); m_frictionCoeffCmp = (unsigned short)(c*0xffff); } float& getNPoints() { return m_worldNormal[3]; } float getNPoints() const { return m_worldNormal[3]; } @@ -39,4 +39,4 @@ ATTRIBUTE_ALIGNED16(struct) b3Contact4 bool isInvalid() const { return (getBodyA()==0 || getBodyB()==0); } }; -#endif //BT_CONTACT4_H +#endif //B3_CONTACT4_H diff --git a/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h b/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h index 135e5ece3..ecf9e726f 100644 --- a/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h +++ b/src/Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h @@ -1,12 +1,12 @@ -#ifndef BT_RIGID_BODY_CL -#define BT_RIGID_BODY_CL +#ifndef B3_RIGID_BODY_CL +#define B3_RIGID_BODY_CL #include "Bullet3Common/b3Scalar.h" #include "Bullet3Common/b3Matrix3x3.h" ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL { - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); b3Vector3 m_pos; b3Quaternion m_quat; @@ -25,11 +25,11 @@ ATTRIBUTE_ALIGNED16(struct) b3RigidBodyCL }; -struct btInertiaCL +struct b3InertiaCL { b3Matrix3x3 m_invInertiaWorld; b3Matrix3x3 m_initInvInertia; }; -#endif//BT_RIGID_BODY_CL +#endif//B3_RIGID_BODY_CL diff --git a/src/Bullet3Common/b3AlignedAllocator.cpp b/src/Bullet3Common/b3AlignedAllocator.cpp index 0bb926450..7aaf74242 100644 --- a/src/Bullet3Common/b3AlignedAllocator.cpp +++ b/src/Bullet3Common/b3AlignedAllocator.cpp @@ -19,41 +19,41 @@ int gNumAlignedAllocs = 0; int gNumAlignedFree = 0; int gTotalBytesAlignedAllocs = 0;//detect memory leaks -static void *btAllocDefault(size_t size) +static void *b3AllocDefault(size_t size) { return malloc(size); } -static void btFreeDefault(void *ptr) +static void b3FreeDefault(void *ptr) { free(ptr); } -static btAllocFunc *sAllocFunc = btAllocDefault; -static btFreeFunc *sFreeFunc = btFreeDefault; +static b3AllocFunc *sAllocFunc = b3AllocDefault; +static b3FreeFunc *sFreeFunc = b3FreeDefault; -#if defined (BT_HAS_ALIGNED_ALLOCATOR) +#if defined (B3_HAS_ALIGNED_ALLOCATOR) #include -static void *btAlignedAllocDefault(size_t size, int alignment) +static void *b3AlignedAllocDefault(size_t size, int alignment) { return _aligned_malloc(size, (size_t)alignment); } -static void btAlignedFreeDefault(void *ptr) +static void b3AlignedFreeDefault(void *ptr) { _aligned_free(ptr); } #elif defined(__CELLOS_LV2__) #include -static inline void *btAlignedAllocDefault(size_t size, int alignment) +static inline void *b3AlignedAllocDefault(size_t size, int alignment) { return memalign(alignment, size); } -static inline void btAlignedFreeDefault(void *ptr) +static inline void b3AlignedFreeDefault(void *ptr) { free(ptr); } @@ -63,13 +63,13 @@ static inline void btAlignedFreeDefault(void *ptr) -static inline void *btAlignedAllocDefault(size_t size, int alignment) +static inline void *b3AlignedAllocDefault(size_t size, int alignment) { void *ret; char *real; real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1)); if (real) { - ret = btAlignPointer(real + sizeof(void *),alignment); + ret = b3AlignPointer(real + sizeof(void *),alignment); *((void **)(ret)-1) = (void *)(real); } else { ret = (void *)(real); @@ -77,7 +77,7 @@ static inline void *btAlignedAllocDefault(size_t size, int alignment) return (ret); } -static inline void btAlignedFreeDefault(void *ptr) +static inline void b3AlignedFreeDefault(void *ptr) { void* real; @@ -89,26 +89,26 @@ static inline void btAlignedFreeDefault(void *ptr) #endif -static btAlignedAllocFunc *sAlignedAllocFunc = btAlignedAllocDefault; -static btAlignedFreeFunc *sAlignedFreeFunc = btAlignedFreeDefault; +static b3AlignedAllocFunc *sAlignedAllocFunc = b3AlignedAllocDefault; +static b3AlignedFreeFunc *sAlignedFreeFunc = b3AlignedFreeDefault; -void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc) +void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *allocFunc, b3AlignedFreeFunc *freeFunc) { - sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault; - sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault; + sAlignedAllocFunc = allocFunc ? allocFunc : b3AlignedAllocDefault; + sAlignedFreeFunc = freeFunc ? freeFunc : b3AlignedFreeDefault; } -void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc) +void b3AlignedAllocSetCustom(b3AllocFunc *allocFunc, b3FreeFunc *freeFunc) { - sAllocFunc = allocFunc ? allocFunc : btAllocDefault; - sFreeFunc = freeFunc ? freeFunc : btFreeDefault; + sAllocFunc = allocFunc ? allocFunc : b3AllocDefault; + sFreeFunc = freeFunc ? freeFunc : b3FreeDefault; } -#ifdef BT_DEBUG_MEMORY_ALLOCATIONS +#ifdef B3_DEBUG_MEMORY_ALLOCATIONS //this generic allocator provides the total allocated number of bytes #include -void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename) +void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filename) { void *ret; char *real; @@ -119,7 +119,7 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1)); if (real) { - ret = (void*) btAlignPointer(real + 2*sizeof(void *), alignment); + ret = (void*) b3AlignPointer(real + 2*sizeof(void *), alignment); *((void **)(ret)-1) = (void *)(real); *((int*)(ret)-2) = size; @@ -134,7 +134,7 @@ void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filen return (ret); } -void btAlignedFreeInternal (void* ptr,int line,char* filename) +void b3AlignedFreeInternal (void* ptr,int line,char* filename) { void* real; @@ -154,18 +154,18 @@ void btAlignedFreeInternal (void* ptr,int line,char* filename) } } -#else //BT_DEBUG_MEMORY_ALLOCATIONS +#else //B3_DEBUG_MEMORY_ALLOCATIONS -void* btAlignedAllocInternal (size_t size, int alignment) +void* b3AlignedAllocInternal (size_t size, int alignment) { gNumAlignedAllocs++; void* ptr; ptr = sAlignedAllocFunc(size, alignment); -// printf("btAlignedAllocInternal %d, %x\n",size,ptr); +// printf("b3AlignedAllocInternal %d, %x\n",size,ptr); return ptr; } -void btAlignedFreeInternal (void* ptr) +void b3AlignedFreeInternal (void* ptr) { if (!ptr) { @@ -173,9 +173,9 @@ void btAlignedFreeInternal (void* ptr) } gNumAlignedFree++; -// printf("btAlignedFreeInternal %x\n",ptr); +// printf("b3AlignedFreeInternal %x\n",ptr); sAlignedFreeFunc(ptr); } -#endif //BT_DEBUG_MEMORY_ALLOCATIONS +#endif //B3_DEBUG_MEMORY_ALLOCATIONS diff --git a/src/Bullet3Common/b3AlignedAllocator.h b/src/Bullet3Common/b3AlignedAllocator.h index 4cb6b9ebc..e38eb7d57 100644 --- a/src/Bullet3Common/b3AlignedAllocator.h +++ b/src/Bullet3Common/b3AlignedAllocator.h @@ -13,50 +13,50 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_ALIGNED_ALLOCATOR -#define BT_ALIGNED_ALLOCATOR +#ifndef B3_ALIGNED_ALLOCATOR +#define B3_ALIGNED_ALLOCATOR ///we probably replace this with our own aligned memory allocator ///so we replace _aligned_malloc and _aligned_free with our own ///that is better portable and more predictable #include "b3Scalar.h" -//#define BT_DEBUG_MEMORY_ALLOCATIONS 1 -#ifdef BT_DEBUG_MEMORY_ALLOCATIONS +//#define B3_DEBUG_MEMORY_ALLOCATIONS 1 +#ifdef B3_DEBUG_MEMORY_ALLOCATIONS -#define btAlignedAlloc(a,b) \ - btAlignedAllocInternal(a,b,__LINE__,__FILE__) +#define b3AlignedAlloc(a,b) \ + b3AlignedAllocInternal(a,b,__LINE__,__FILE__) -#define btAlignedFree(ptr) \ - btAlignedFreeInternal(ptr,__LINE__,__FILE__) +#define b3AlignedFree(ptr) \ + b3AlignedFreeInternal(ptr,__LINE__,__FILE__) -void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename); +void* b3AlignedAllocInternal (size_t size, int alignment,int line,char* filename); -void btAlignedFreeInternal (void* ptr,int line,char* filename); +void b3AlignedFreeInternal (void* ptr,int line,char* filename); #else - void* btAlignedAllocInternal (size_t size, int alignment); - void btAlignedFreeInternal (void* ptr); + void* b3AlignedAllocInternal (size_t size, int alignment); + void b3AlignedFreeInternal (void* ptr); - #define btAlignedAlloc(size,alignment) btAlignedAllocInternal(size,alignment) - #define btAlignedFree(ptr) btAlignedFreeInternal(ptr) + #define b3AlignedAlloc(size,alignment) b3AlignedAllocInternal(size,alignment) + #define b3AlignedFree(ptr) b3AlignedFreeInternal(ptr) #endif typedef int size_type; -typedef void *(btAlignedAllocFunc)(size_t size, int alignment); -typedef void (btAlignedFreeFunc)(void *memblock); -typedef void *(btAllocFunc)(size_t size); -typedef void (btFreeFunc)(void *memblock); +typedef void *(b3AlignedAllocFunc)(size_t size, int alignment); +typedef void (b3AlignedFreeFunc)(void *memblock); +typedef void *(b3AllocFunc)(size_t size); +typedef void (b3FreeFunc)(void *memblock); -///The developer can let all Bullet memory allocations go through a custom memory allocator, using btAlignedAllocSetCustom -void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc); -///If the developer has already an custom aligned allocator, then btAlignedAllocSetCustomAligned can be used. The default aligned allocator pre-allocates extra memory using the non-aligned allocator, and instruments it. -void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc); +///The developer can let all Bullet memory allocations go through a custom memory allocator, using b3AlignedAllocSetCustom +void b3AlignedAllocSetCustom(b3AllocFunc *allocFunc, b3FreeFunc *freeFunc); +///If the developer has already an custom aligned allocator, then b3AlignedAllocSetCustomAligned can be used. The default aligned allocator pre-allocates extra memory using the non-aligned allocator, and instruments it. +void b3AlignedAllocSetCustomAligned(b3AlignedAllocFunc *allocFunc, b3AlignedFreeFunc *freeFunc); ///The b3AlignedAllocator is a portable class for aligned memory allocations. -///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using btAlignedAllocSetCustom and btAlignedAllocSetCustomAligned. +///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using b3AlignedAllocSetCustom and b3AlignedAllocSetCustomAligned. template < typename T , unsigned Alignment > class b3AlignedAllocator { @@ -83,11 +83,11 @@ public: const_pointer address ( const_reference ref ) const { return &ref; } pointer allocate ( size_type n , const_pointer * hint = 0 ) { (void)hint; - return reinterpret_cast< pointer >(btAlignedAlloc( sizeof(value_type) * n , Alignment )); + return reinterpret_cast< pointer >(b3AlignedAlloc( sizeof(value_type) * n , Alignment )); } void construct ( pointer ptr , const value_type & value ) { new (ptr) value_type( value ); } void deallocate( pointer ptr ) { - btAlignedFree( reinterpret_cast< void * >( ptr ) ); + b3AlignedFree( reinterpret_cast< void * >( ptr ) ); } void destroy ( pointer ptr ) { ptr->~value_type(); } @@ -103,5 +103,5 @@ public: -#endif //BT_ALIGNED_ALLOCATOR +#endif //B3_ALIGNED_ALLOCATOR diff --git a/src/Bullet3Common/b3AlignedObjectArray.h b/src/Bullet3Common/b3AlignedObjectArray.h index eebe9df00..9abdcbf33 100644 --- a/src/Bullet3Common/b3AlignedObjectArray.h +++ b/src/Bullet3Common/b3AlignedObjectArray.h @@ -14,30 +14,30 @@ subject to the following restrictions: */ -#ifndef BT_OBJECT_ARRAY__ -#define BT_OBJECT_ARRAY__ +#ifndef B3_OBJECT_ARRAY__ +#define B3_OBJECT_ARRAY__ #include "b3Scalar.h" // has definitions like SIMD_FORCE_INLINE #include "b3AlignedAllocator.h" -///If the platform doesn't support placement new, you can disable BT_USE_PLACEMENT_NEW +///If the platform doesn't support placement new, you can disable B3_USE_PLACEMENT_NEW ///then the b3AlignedObjectArray doesn't support objects with virtual methods, and non-trivial constructors/destructors -///You can enable BT_USE_MEMCPY, then swapping elements in the array will use memcpy instead of operator= +///You can enable B3_USE_MEMCPY, then swapping elements in the array will use memcpy instead of operator= ///see discussion here: http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1231 and ///http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1240 -#define BT_USE_PLACEMENT_NEW 1 -//#define BT_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in or or otherwise... -#define BT_ALLOW_ARRAY_COPY_OPERATOR // enabling this can accidently perform deep copies of data if you are not careful +#define B3_USE_PLACEMENT_NEW 1 +//#define B3_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in or or otherwise... +#define B3_ALLOW_ARRAY_COPY_OPERATOR // enabling this can accidently perform deep copies of data if you are not careful -#ifdef BT_USE_MEMCPY +#ifdef B3_USE_MEMCPY #include #include -#endif //BT_USE_MEMCPY +#endif //B3_USE_MEMCPY -#ifdef BT_USE_PLACEMENT_NEW +#ifdef B3_USE_PLACEMENT_NEW #include //for placement new -#endif //BT_USE_PLACEMENT_NEW +#endif //B3_USE_PLACEMENT_NEW ///The b3AlignedObjectArray template class uses a subset of the stl::vector interface for its methods @@ -54,17 +54,17 @@ class b3AlignedObjectArray //PCK: added this line bool m_ownsMemory; -#ifdef BT_ALLOW_ARRAY_COPY_OPERATOR +#ifdef B3_ALLOW_ARRAY_COPY_OPERATOR public: SIMD_FORCE_INLINE b3AlignedObjectArray& operator=(const b3AlignedObjectArray &other) { copyFromArray(other); return *this; } -#else//BT_ALLOW_ARRAY_COPY_OPERATOR +#else//B3_ALLOW_ARRAY_COPY_OPERATOR private: SIMD_FORCE_INLINE b3AlignedObjectArray& operator=(const b3AlignedObjectArray &other); -#endif//BT_ALLOW_ARRAY_COPY_OPERATOR +#endif//B3_ALLOW_ARRAY_COPY_OPERATOR protected: SIMD_FORCE_INLINE int allocSize(int size) @@ -75,11 +75,11 @@ protected: { int i; for (i=start;i=0); - btAssert(n=0); + b3Assert(n=0); - btAssert(n=0); + b3Assert(n=0); - btAssert(n=0); + b3Assert(n=0); - btAssert(n=0); + b3Assert(n0); + b3Assert(m_size>0); m_size--; m_data[m_size].~T(); } @@ -233,12 +233,12 @@ protected: { reserve(newsize); } -#ifdef BT_USE_PLACEMENT_NEW +#ifdef B3_USE_PLACEMENT_NEW for (int i=curSize;i -class btHashKeyPtr +class b3HashKeyPtr { int m_uid; public: - btHashKeyPtr(int uid) :m_uid(uid) + b3HashKeyPtr(int uid) :m_uid(uid) { } @@ -166,7 +166,7 @@ public: return m_uid; } - bool equals(const btHashKeyPtr& other) const + bool equals(const b3HashKeyPtr& other) const { return getUid1() == other.getUid1(); } @@ -185,12 +185,12 @@ public: template -class btHashKey +class b3HashKey { int m_uid; public: - btHashKey(int uid) :m_uid(uid) + b3HashKey(int uid) :m_uid(uid) { } @@ -199,7 +199,7 @@ public: return m_uid; } - bool equals(const btHashKey& other) const + bool equals(const b3HashKey& other) const { return getUid1() == other.getUid1(); } @@ -243,11 +243,11 @@ protected: for (i= 0; i < newCapacity; ++i) { - m_hashTable[i] = BT_HASH_NULL; + m_hashTable[i] = B3_HASH_NULL; } for (i = 0; i < newCapacity; ++i) { - m_next[i] = BT_HASH_NULL; + m_next[i] = B3_HASH_NULL; } for(i=0;i= (unsigned int)m_hashTable.size()) { - return BT_HASH_NULL; + return B3_HASH_NULL; } int index = m_hashTable[hash]; - while ((index != BT_HASH_NULL) && key.equals(m_keyArray[index]) == false) + while ((index != B3_HASH_NULL) && key.equals(m_keyArray[index]) == false) { index = m_next[index]; } @@ -447,4 +447,4 @@ protected: }; -#endif //BT_HASH_MAP_H +#endif //B3_HASH_MAP_H diff --git a/opencl/parallel_primitives/host/btInt2.h b/src/Bullet3Common/b3Int2.h similarity index 72% rename from opencl/parallel_primitives/host/btInt2.h rename to src/Bullet3Common/b3Int2.h index a0a2977d8..be0dbd9bd 100644 --- a/opencl/parallel_primitives/host/btInt2.h +++ b/src/Bullet3Common/b3Int2.h @@ -1,7 +1,7 @@ -#ifndef BT_INT2_H -#define BT_INT2_H +#ifndef B3_INT2_H +#define B3_INT2_H -struct btUnsignedInt2 +struct b3UnsignedInt2 { union { @@ -16,7 +16,7 @@ struct btUnsignedInt2 }; }; -struct btInt2 +struct b3Int2 { union { diff --git a/src/Bullet3Common/b3Matrix3x3.h b/src/Bullet3Common/b3Matrix3x3.h index 0149aa8e4..f5b36859b 100644 --- a/src/Bullet3Common/b3Matrix3x3.h +++ b/src/Bullet3Common/b3Matrix3x3.h @@ -13,29 +13,29 @@ subject to the following restrictions: */ -#ifndef BT_MATRIX3x3_H -#define BT_MATRIX3x3_H +#ifndef B3_MATRIX3x3_H +#define B3_MATRIX3x3_H #include "b3Vector3.h" #include "b3Quaternion.h" #include -#ifdef BT_USE_SSE +#ifdef B3_USE_SSE //const __m128 ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f}; const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f}; #endif -#if defined(BT_USE_SSE) || defined(BT_USE_NEON) -const btSimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f}; -const btSimdFloat4 ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f}; -const btSimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f}; +#if defined(B3_USE_SSE) || defined(B3_USE_NEON) +const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f}; +const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f}; +const b3SimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f}; #endif -#ifdef BT_USE_DOUBLE_PRECISION -#define btMatrix3x3Data btMatrix3x3DoubleData +#ifdef B3_USE_DOUBLE_PRECISION +#define b3Matrix3x3Data b3Matrix3x3DoubleData #else -#define btMatrix3x3Data btMatrix3x3FloatData -#endif //BT_USE_DOUBLE_PRECISION +#define b3Matrix3x3Data b3Matrix3x3FloatData +#endif //B3_USE_DOUBLE_PRECISION /**@brief The b3Matrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with b3Quaternion, b3Transform and b3Vector3. @@ -70,8 +70,8 @@ public: zx, zy, zz); } -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) - SIMD_FORCE_INLINE b3Matrix3x3 (const btSimdFloat4 v0, const btSimdFloat4 v1, const btSimdFloat4 v2 ) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) + SIMD_FORCE_INLINE b3Matrix3x3 (const b3SimdFloat4 v0, const b3SimdFloat4 v1, const b3SimdFloat4 v2 ) { m_el[0].mVec128 = v0; m_el[1].mVec128 = v1; @@ -136,7 +136,7 @@ public: * @param i Row number 0 indexed */ SIMD_FORCE_INLINE const b3Vector3& getRow(int i) const { - btFullAssert(0 <= i && i < 3); + b3FullAssert(0 <= i && i < 3); return m_el[i]; } @@ -144,7 +144,7 @@ public: * @param i Row number 0 indexed */ SIMD_FORCE_INLINE b3Vector3& operator[](int i) { - btFullAssert(0 <= i && i < 3); + b3FullAssert(0 <= i && i < 3); return m_el[i]; } @@ -152,7 +152,7 @@ public: * @param i Row number 0 indexed */ SIMD_FORCE_INLINE const b3Vector3& operator[](int i) const { - btFullAssert(0 <= i && i < 3); + b3FullAssert(0 <= i && i < 3); return m_el[i]; } @@ -204,38 +204,38 @@ public: void setRotation(const b3Quaternion& q) { b3Scalar d = q.length2(); - btFullAssert(d != b3Scalar(0.0)); + b3FullAssert(d != b3Scalar(0.0)); b3Scalar s = b3Scalar(2.0) / d; - #if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) + #if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vs, Q = q.get128(); - __m128i Qi = btCastfTo128i(Q); + __m128i Qi = b3CastfTo128i(Q); __m128 Y, Z; __m128 V1, V2, V3; __m128 V11, V21, V31; - __m128 NQ = _mm_xor_ps(Q, btvMzeroMask); - __m128i NQi = btCastfTo128i(NQ); + __m128 NQ = _mm_xor_ps(Q, b3vMzeroMask); + __m128i NQi = b3CastfTo128i(NQ); - V1 = btCastiTo128f(_mm_shuffle_epi32 (Qi, BT_SHUFFLE(1,0,2,3))); // Y X Z W - V2 = _mm_shuffle_ps(NQ, Q, BT_SHUFFLE(0,0,1,3)); // -X -X Y W - V3 = btCastiTo128f(_mm_shuffle_epi32 (Qi, BT_SHUFFLE(2,1,0,3))); // Z Y X W + V1 = b3CastiTo128f(_mm_shuffle_epi32 (Qi, B3_SHUFFLE(1,0,2,3))); // Y X Z W + V2 = _mm_shuffle_ps(NQ, Q, B3_SHUFFLE(0,0,1,3)); // -X -X Y W + V3 = b3CastiTo128f(_mm_shuffle_epi32 (Qi, B3_SHUFFLE(2,1,0,3))); // Z Y X W V1 = _mm_xor_ps(V1, vMPPP); // change the sign of the first element - V11 = btCastiTo128f(_mm_shuffle_epi32 (Qi, BT_SHUFFLE(1,1,0,3))); // Y Y X W + V11 = b3CastiTo128f(_mm_shuffle_epi32 (Qi, B3_SHUFFLE(1,1,0,3))); // Y Y X W V21 = _mm_unpackhi_ps(Q, Q); // Z Z W W - V31 = _mm_shuffle_ps(Q, NQ, BT_SHUFFLE(0,2,0,3)); // X Z -X -W + V31 = _mm_shuffle_ps(Q, NQ, B3_SHUFFLE(0,2,0,3)); // X Z -X -W V2 = V2 * V1; // V1 = V1 * V11; // V3 = V3 * V31; // - V11 = _mm_shuffle_ps(NQ, Q, BT_SHUFFLE(2,3,1,3)); // -Z -W Y W + V11 = _mm_shuffle_ps(NQ, Q, B3_SHUFFLE(2,3,1,3)); // -Z -W Y W V11 = V11 * V21; // V21 = _mm_xor_ps(V21, vMPPP); // change the sign of the first element - V31 = _mm_shuffle_ps(Q, NQ, BT_SHUFFLE(3,3,1,3)); // W W -Y -W + V31 = _mm_shuffle_ps(Q, NQ, B3_SHUFFLE(3,3,1,3)); // W W -Y -W V31 = _mm_xor_ps(V31, vMPPP); // change the sign of the first element - Y = btCastiTo128f(_mm_shuffle_epi32 (NQi, BT_SHUFFLE(3,2,0,3))); // -W -Z -X -W - Z = btCastiTo128f(_mm_shuffle_epi32 (Qi, BT_SHUFFLE(1,0,1,3))); // Y X Y W + Y = b3CastiTo128f(_mm_shuffle_epi32 (NQi, B3_SHUFFLE(3,2,0,3))); // -W -Z -X -W + Z = b3CastiTo128f(_mm_shuffle_epi32 (Qi, B3_SHUFFLE(1,0,1,3))); // Y X Y W vs = _mm_load_ss(&s); V21 = V21 * Y; @@ -245,7 +245,7 @@ public: V2 = V2 + V21; V3 = V3 + V31; - vs = bt_splat3_ps(vs, 0); + vs = b3_splat3_ps(vs, 0); // s ready V1 = V1 * vs; V2 = V2 * vs; @@ -292,12 +292,12 @@ public: **/ void setEulerZYX(b3Scalar eulerX,b3Scalar eulerY,b3Scalar eulerZ) { ///@todo proposed to reverse this since it's labeled zyx but takes arguments xyz and it will match all other parts of the code - b3Scalar ci ( btCos(eulerX)); - b3Scalar cj ( btCos(eulerY)); - b3Scalar ch ( btCos(eulerZ)); - b3Scalar si ( btSin(eulerX)); - b3Scalar sj ( btSin(eulerY)); - b3Scalar sh ( btSin(eulerZ)); + b3Scalar ci ( b3Cos(eulerX)); + b3Scalar cj ( b3Cos(eulerY)); + b3Scalar ch ( b3Cos(eulerZ)); + b3Scalar si ( b3Sin(eulerX)); + b3Scalar sj ( b3Sin(eulerY)); + b3Scalar sh ( b3Sin(eulerZ)); b3Scalar cc = ci * ch; b3Scalar cs = ci * sh; b3Scalar sc = si * ch; @@ -311,7 +311,7 @@ public: /**@brief Set the matrix to the identity */ void setIdentity() { -#if (defined(BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) || defined(BT_USE_NEON) +#if (defined(B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) || defined(B3_USE_NEON) m_el[0] = v1000; m_el[1] = v0100; m_el[2] = v0010; @@ -324,7 +324,7 @@ public: static const b3Matrix3x3& getIdentity() { -#if (defined(BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) || defined(BT_USE_NEON) +#if (defined(B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) || defined(B3_USE_NEON) static const b3Matrix3x3 identityMatrix(v1000, v0100, v0010); #else @@ -341,26 +341,26 @@ public: * @param m The array to be filled */ void getOpenGLSubMatrix(b3Scalar *m) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 v0 = m_el[0].mVec128; __m128 v1 = m_el[1].mVec128; __m128 v2 = m_el[2].mVec128; // x2 y2 z2 w2 __m128 *vm = (__m128 *)m; __m128 vT; - v2 = _mm_and_ps(v2, btvFFF0fMask); // x2 y2 z2 0 + v2 = _mm_and_ps(v2, b3vFFF0fMask); // x2 y2 z2 0 vT = _mm_unpackhi_ps(v0, v1); // z0 z1 * * v0 = _mm_unpacklo_ps(v0, v1); // x0 x1 y0 y1 - v1 = _mm_shuffle_ps(v0, v2, BT_SHUFFLE(2, 3, 1, 3) ); // y0 y1 y2 0 - v0 = _mm_shuffle_ps(v0, v2, BT_SHUFFLE(0, 1, 0, 3) ); // x0 x1 x2 0 - v2 = btCastdTo128f(_mm_move_sd(btCastfTo128d(v2), btCastfTo128d(vT))); // z0 z1 z2 0 + v1 = _mm_shuffle_ps(v0, v2, B3_SHUFFLE(2, 3, 1, 3) ); // y0 y1 y2 0 + v0 = _mm_shuffle_ps(v0, v2, B3_SHUFFLE(0, 1, 0, 3) ); // x0 x1 x2 0 + v2 = b3CastdTo128f(_mm_move_sd(b3CastfTo128d(v2), b3CastfTo128d(vT))); // z0 z1 z2 0 vm[0] = v0; vm[1] = v1; vm[2] = v2; -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) // note: zeros the w channel. We can preserve it at the cost of two more vtrn instructions. static const uint32x2_t zMask = (const uint32x2_t) {-1, 0 }; float32x4_t *vm = (float32x4_t *)m; @@ -394,12 +394,12 @@ public: * @param q The quaternion which will be set */ void getRotation(b3Quaternion& q) const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) b3Scalar trace = m_el[0].getX() + m_el[1].getY() + m_el[2].getZ(); b3Scalar s, x; union { - btSimdFloat4 vec; + b3SimdFloat4 vec; b3Scalar f[4]; } temp; @@ -440,7 +440,7 @@ public: //temp.f[i] = s * b3Scalar(0.5); } - s = btSqrt(x); + s = b3Sqrt(x); q.set128(temp.vec); s = b3Scalar(0.5) / s; @@ -452,7 +452,7 @@ public: if (trace > b3Scalar(0.0)) { - b3Scalar s = btSqrt(trace + b3Scalar(1.0)); + b3Scalar s = b3Sqrt(trace + b3Scalar(1.0)); temp[3]=(s * b3Scalar(0.5)); s = b3Scalar(0.5) / s; @@ -468,7 +468,7 @@ public: int j = (i + 1) % 3; int k = (i + 2) % 3; - b3Scalar s = btSqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + b3Scalar(1.0)); + b3Scalar s = b3Sqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + b3Scalar(1.0)); temp[i] = s * b3Scalar(0.5); s = b3Scalar(0.5) / s; @@ -488,12 +488,12 @@ public: { // first use the normal calculus - yaw = b3Scalar(btAtan2(m_el[1].getX(), m_el[0].getX())); - pitch = b3Scalar(btAsin(-m_el[2].getX())); - roll = b3Scalar(btAtan2(m_el[2].getY(), m_el[2].getZ())); + yaw = b3Scalar(b3Atan2(m_el[1].getX(), m_el[0].getX())); + pitch = b3Scalar(b3Asin(-m_el[2].getX())); + roll = b3Scalar(b3Atan2(m_el[2].getY(), m_el[2].getZ())); // on pitch = +/-HalfPI - if (btFabs(pitch)==SIMD_HALF_PI) + if (b3Fabs(pitch)==SIMD_HALF_PI) { if (yaw>0) yaw-=SIMD_PI; @@ -527,13 +527,13 @@ public: //get the pointer to the raw data // Check that pitch is not at a singularity - if (btFabs(m_el[2].getX()) >= 1) + if (b3Fabs(m_el[2].getX()) >= 1) { euler_out.yaw = 0; euler_out2.yaw = 0; // From difference of angles formula - b3Scalar delta = btAtan2(m_el[0].getX(),m_el[0].getZ()); + b3Scalar delta = b3Atan2(m_el[0].getX(),m_el[0].getZ()); if (m_el[2].getX() > 0) //gimbal locked up { euler_out.pitch = SIMD_PI / b3Scalar(2.0); @@ -551,18 +551,18 @@ public: } else { - euler_out.pitch = - btAsin(m_el[2].getX()); + euler_out.pitch = - b3Asin(m_el[2].getX()); euler_out2.pitch = SIMD_PI - euler_out.pitch; - euler_out.roll = btAtan2(m_el[2].getY()/btCos(euler_out.pitch), - m_el[2].getZ()/btCos(euler_out.pitch)); - euler_out2.roll = btAtan2(m_el[2].getY()/btCos(euler_out2.pitch), - m_el[2].getZ()/btCos(euler_out2.pitch)); + euler_out.roll = b3Atan2(m_el[2].getY()/b3Cos(euler_out.pitch), + m_el[2].getZ()/b3Cos(euler_out.pitch)); + euler_out2.roll = b3Atan2(m_el[2].getY()/b3Cos(euler_out2.pitch), + m_el[2].getZ()/b3Cos(euler_out2.pitch)); - euler_out.yaw = btAtan2(m_el[1].getX()/btCos(euler_out.pitch), - m_el[0].getX()/btCos(euler_out.pitch)); - euler_out2.yaw = btAtan2(m_el[1].getX()/btCos(euler_out2.pitch), - m_el[0].getX()/btCos(euler_out2.pitch)); + euler_out.yaw = b3Atan2(m_el[1].getX()/b3Cos(euler_out.pitch), + m_el[0].getX()/b3Cos(euler_out.pitch)); + euler_out2.yaw = b3Atan2(m_el[1].getX()/b3Cos(euler_out2.pitch), + m_el[0].getX()/b3Cos(euler_out2.pitch)); } if (solution_number == 1) @@ -584,7 +584,7 @@ public: b3Matrix3x3 scaled(const b3Vector3& s) const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) return b3Matrix3x3(m_el[0] * s, m_el[1] * s, m_el[2] * s); #else return b3Matrix3x3( @@ -640,15 +640,15 @@ public: int p = 0; int q = 1; int r = 2; - b3Scalar max = btFabs(m_el[0][1]); - b3Scalar v = btFabs(m_el[0][2]); + b3Scalar max = b3Fabs(m_el[0][1]); + b3Scalar v = b3Fabs(m_el[0][2]); if (v > max) { q = 2; r = 1; max = v; } - v = btFabs(m_el[1][2]); + v = b3Fabs(m_el[1][2]); if (v > max) { p = 1; @@ -657,7 +657,7 @@ public: max = v; } - b3Scalar t = threshold * (btFabs(m_el[0][0]) + btFabs(m_el[1][1]) + btFabs(m_el[2][2])); + b3Scalar t = threshold * (b3Fabs(m_el[0][0]) + b3Fabs(m_el[1][1]) + b3Fabs(m_el[2][2])); if (max <= t) { if (max <= SIMD_EPSILON * t) @@ -675,9 +675,9 @@ public: b3Scalar sin; if (theta2 * theta2 < b3Scalar(10 / SIMD_EPSILON)) { - t = (theta >= 0) ? 1 / (theta + btSqrt(1 + theta2)) - : 1 / (theta - btSqrt(1 + theta2)); - cos = 1 / btSqrt(1 + t * t); + t = (theta >= 0) ? 1 / (theta + b3Sqrt(1 + theta2)) + : 1 / (theta - b3Sqrt(1 + theta2)); + cos = 1 / b3Sqrt(1 + t * t); sin = cos * t; } else @@ -724,15 +724,15 @@ public: return m_el[r1][c1] * m_el[r2][c2] - m_el[r1][c2] * m_el[r2][c1]; } - void serialize(struct btMatrix3x3Data& dataOut) const; + void serialize(struct b3Matrix3x3Data& dataOut) const; - void serializeFloat(struct btMatrix3x3FloatData& dataOut) const; + void serializeFloat(struct b3Matrix3x3FloatData& dataOut) const; - void deSerialize(const struct btMatrix3x3Data& dataIn); + void deSerialize(const struct b3Matrix3x3Data& dataIn); - void deSerializeFloat(const struct btMatrix3x3FloatData& dataIn); + void deSerializeFloat(const struct b3Matrix3x3FloatData& dataIn); - void deSerializeDouble(const struct btMatrix3x3DoubleData& dataIn); + void deSerializeDouble(const struct b3Matrix3x3DoubleData& dataIn); }; @@ -740,7 +740,7 @@ public: SIMD_FORCE_INLINE b3Matrix3x3& b3Matrix3x3::operator*=(const b3Matrix3x3& m) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 rv00, rv01, rv02; __m128 rv10, rv11, rv12; __m128 rv20, rv21, rv22; @@ -750,32 +750,32 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m) rv12 = m_el[1].mVec128; rv22 = m_el[2].mVec128; - mv0 = _mm_and_ps(m[0].mVec128, btvFFF0fMask); - mv1 = _mm_and_ps(m[1].mVec128, btvFFF0fMask); - mv2 = _mm_and_ps(m[2].mVec128, btvFFF0fMask); + mv0 = _mm_and_ps(m[0].mVec128, b3vFFF0fMask); + mv1 = _mm_and_ps(m[1].mVec128, b3vFFF0fMask); + mv2 = _mm_and_ps(m[2].mVec128, b3vFFF0fMask); // rv0 - rv00 = bt_splat_ps(rv02, 0); - rv01 = bt_splat_ps(rv02, 1); - rv02 = bt_splat_ps(rv02, 2); + rv00 = b3_splat_ps(rv02, 0); + rv01 = b3_splat_ps(rv02, 1); + rv02 = b3_splat_ps(rv02, 2); rv00 = _mm_mul_ps(rv00, mv0); rv01 = _mm_mul_ps(rv01, mv1); rv02 = _mm_mul_ps(rv02, mv2); // rv1 - rv10 = bt_splat_ps(rv12, 0); - rv11 = bt_splat_ps(rv12, 1); - rv12 = bt_splat_ps(rv12, 2); + rv10 = b3_splat_ps(rv12, 0); + rv11 = b3_splat_ps(rv12, 1); + rv12 = b3_splat_ps(rv12, 2); rv10 = _mm_mul_ps(rv10, mv0); rv11 = _mm_mul_ps(rv11, mv1); rv12 = _mm_mul_ps(rv12, mv2); // rv2 - rv20 = bt_splat_ps(rv22, 0); - rv21 = bt_splat_ps(rv22, 1); - rv22 = bt_splat_ps(rv22, 2); + rv20 = b3_splat_ps(rv22, 0); + rv21 = b3_splat_ps(rv22, 1); + rv22 = b3_splat_ps(rv22, 2); rv20 = _mm_mul_ps(rv20, mv0); rv21 = _mm_mul_ps(rv21, mv1); @@ -789,7 +789,7 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m) m_el[1].mVec128 = _mm_add_ps(rv10, rv12); m_el[2].mVec128 = _mm_add_ps(rv20, rv22); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t rv0, rv1, rv2; float32x4_t v0, v1, v2; @@ -799,9 +799,9 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m) v1 = m_el[1].mVec128; v2 = m_el[2].mVec128; - mv0 = (float32x4_t) vandq_s32((int32x4_t)m[0].mVec128, btvFFF0Mask); - mv1 = (float32x4_t) vandq_s32((int32x4_t)m[1].mVec128, btvFFF0Mask); - mv2 = (float32x4_t) vandq_s32((int32x4_t)m[2].mVec128, btvFFF0Mask); + mv0 = (float32x4_t) vandq_s32((int32x4_t)m[0].mVec128, b3vFFF0Mask); + mv1 = (float32x4_t) vandq_s32((int32x4_t)m[1].mVec128, b3vFFF0Mask); + mv2 = (float32x4_t) vandq_s32((int32x4_t)m[2].mVec128, b3vFFF0Mask); rv0 = vmulq_lane_f32(mv0, vget_low_f32(v0), 0); rv1 = vmulq_lane_f32(mv0, vget_low_f32(v1), 0); @@ -830,7 +830,7 @@ b3Matrix3x3::operator*=(const b3Matrix3x3& m) SIMD_FORCE_INLINE b3Matrix3x3& b3Matrix3x3::operator+=(const b3Matrix3x3& m) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) m_el[0].mVec128 = m_el[0].mVec128 + m.m_el[0].mVec128; m_el[1].mVec128 = m_el[1].mVec128 + m.m_el[1].mVec128; m_el[2].mVec128 = m_el[2].mVec128 + m.m_el[2].mVec128; @@ -852,13 +852,13 @@ b3Matrix3x3::operator+=(const b3Matrix3x3& m) SIMD_FORCE_INLINE b3Matrix3x3 operator*(const b3Matrix3x3& m, const b3Scalar & k) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) - __m128 vk = bt_splat_ps(_mm_load_ss((float *)&k), 0x80); +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) + __m128 vk = b3_splat_ps(_mm_load_ss((float *)&k), 0x80); return b3Matrix3x3( _mm_mul_ps(m[0].mVec128, vk), _mm_mul_ps(m[1].mVec128, vk), _mm_mul_ps(m[2].mVec128, vk)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) return b3Matrix3x3( vmulq_n_f32(m[0].mVec128, k), vmulq_n_f32(m[1].mVec128, k), @@ -874,7 +874,7 @@ operator*(const b3Matrix3x3& m, const b3Scalar & k) SIMD_FORCE_INLINE b3Matrix3x3 operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) return b3Matrix3x3( m1[0].mVec128 + m2[0].mVec128, m1[1].mVec128 + m2[1].mVec128, @@ -898,7 +898,7 @@ operator+(const b3Matrix3x3& m1, const b3Matrix3x3& m2) SIMD_FORCE_INLINE b3Matrix3x3 operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) return b3Matrix3x3( m1[0].mVec128 - m2[0].mVec128, m1[1].mVec128 - m2[1].mVec128, @@ -923,7 +923,7 @@ operator-(const b3Matrix3x3& m1, const b3Matrix3x3& m2) SIMD_FORCE_INLINE b3Matrix3x3& b3Matrix3x3::operator-=(const b3Matrix3x3& m) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) m_el[0].mVec128 = m_el[0].mVec128 - m.m_el[0].mVec128; m_el[1].mVec128 = m_el[1].mVec128 - m.m_el[1].mVec128; m_el[2].mVec128 = m_el[2].mVec128 - m.m_el[2].mVec128; @@ -946,52 +946,52 @@ b3Matrix3x3::operator-=(const b3Matrix3x3& m) SIMD_FORCE_INLINE b3Scalar b3Matrix3x3::determinant() const { - return btTriple((*this)[0], (*this)[1], (*this)[2]); + return b3Triple((*this)[0], (*this)[1], (*this)[2]); } SIMD_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::absolute() const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) return b3Matrix3x3( - _mm_and_ps(m_el[0].mVec128, btvAbsfMask), - _mm_and_ps(m_el[1].mVec128, btvAbsfMask), - _mm_and_ps(m_el[2].mVec128, btvAbsfMask)); -#elif defined(BT_USE_NEON) + _mm_and_ps(m_el[0].mVec128, b3vAbsfMask), + _mm_and_ps(m_el[1].mVec128, b3vAbsfMask), + _mm_and_ps(m_el[2].mVec128, b3vAbsfMask)); +#elif defined(B3_USE_NEON) return b3Matrix3x3( - (float32x4_t)vandq_s32((int32x4_t)m_el[0].mVec128, btv3AbsMask), - (float32x4_t)vandq_s32((int32x4_t)m_el[1].mVec128, btv3AbsMask), - (float32x4_t)vandq_s32((int32x4_t)m_el[2].mVec128, btv3AbsMask)); + (float32x4_t)vandq_s32((int32x4_t)m_el[0].mVec128, b3v3AbsMask), + (float32x4_t)vandq_s32((int32x4_t)m_el[1].mVec128, b3v3AbsMask), + (float32x4_t)vandq_s32((int32x4_t)m_el[2].mVec128, b3v3AbsMask)); #else return b3Matrix3x3( - btFabs(m_el[0].getX()), btFabs(m_el[0].getY()), btFabs(m_el[0].getZ()), - btFabs(m_el[1].getX()), btFabs(m_el[1].getY()), btFabs(m_el[1].getZ()), - btFabs(m_el[2].getX()), btFabs(m_el[2].getY()), btFabs(m_el[2].getZ())); + b3Fabs(m_el[0].getX()), b3Fabs(m_el[0].getY()), b3Fabs(m_el[0].getZ()), + b3Fabs(m_el[1].getX()), b3Fabs(m_el[1].getY()), b3Fabs(m_el[1].getZ()), + b3Fabs(m_el[2].getX()), b3Fabs(m_el[2].getY()), b3Fabs(m_el[2].getZ())); #endif } SIMD_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::transpose() const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) __m128 v0 = m_el[0].mVec128; __m128 v1 = m_el[1].mVec128; __m128 v2 = m_el[2].mVec128; // x2 y2 z2 w2 __m128 vT; - v2 = _mm_and_ps(v2, btvFFF0fMask); // x2 y2 z2 0 + v2 = _mm_and_ps(v2, b3vFFF0fMask); // x2 y2 z2 0 vT = _mm_unpackhi_ps(v0, v1); // z0 z1 * * v0 = _mm_unpacklo_ps(v0, v1); // x0 x1 y0 y1 - v1 = _mm_shuffle_ps(v0, v2, BT_SHUFFLE(2, 3, 1, 3) ); // y0 y1 y2 0 - v0 = _mm_shuffle_ps(v0, v2, BT_SHUFFLE(0, 1, 0, 3) ); // x0 x1 x2 0 - v2 = btCastdTo128f(_mm_move_sd(btCastfTo128d(v2), btCastfTo128d(vT))); // z0 z1 z2 0 + v1 = _mm_shuffle_ps(v0, v2, B3_SHUFFLE(2, 3, 1, 3) ); // y0 y1 y2 0 + v0 = _mm_shuffle_ps(v0, v2, B3_SHUFFLE(0, 1, 0, 3) ); // x0 x1 x2 0 + v2 = b3CastdTo128f(_mm_move_sd(b3CastfTo128d(v2), b3CastfTo128d(vT))); // z0 z1 z2 0 return b3Matrix3x3( v0, v1, v2 ); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) // note: zeros the w channel. We can preserve it at the cost of two more vtrn instructions. static const uint32x2_t zMask = (const uint32x2_t) {-1, 0 }; float32x4x2_t top = vtrnq_f32( m_el[0].mVec128, m_el[1].mVec128 ); // {x0 x1 z0 z1}, {y0 y1 w0 w1} @@ -1021,7 +1021,7 @@ b3Matrix3x3::inverse() const { b3Vector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)); b3Scalar det = (*this)[0].dot(co); - btFullAssert(det != b3Scalar(0.0)); + b3FullAssert(det != b3Scalar(0.0)); b3Scalar s = b3Scalar(1.0) / det; return b3Matrix3x3(co.getX() * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s, co.getY() * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s, @@ -1031,13 +1031,13 @@ b3Matrix3x3::inverse() const SIMD_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) // zeros w // static const __m128i xyzMask = (const __m128i){ -1ULL, 0xffffffffULL }; __m128 row = m_el[0].mVec128; - __m128 m0 = _mm_and_ps( m.getRow(0).mVec128, btvFFF0fMask ); - __m128 m1 = _mm_and_ps( m.getRow(1).mVec128, btvFFF0fMask); - __m128 m2 = _mm_and_ps( m.getRow(2).mVec128, btvFFF0fMask ); + __m128 m0 = _mm_and_ps( m.getRow(0).mVec128, b3vFFF0fMask ); + __m128 m1 = _mm_and_ps( m.getRow(1).mVec128, b3vFFF0fMask); + __m128 m2 = _mm_and_ps( m.getRow(2).mVec128, b3vFFF0fMask ); __m128 r0 = _mm_mul_ps(m0, _mm_shuffle_ps(row, row, 0)); __m128 r1 = _mm_mul_ps(m0, _mm_shuffle_ps(row, row, 0x55)); __m128 r2 = _mm_mul_ps(m0, _mm_shuffle_ps(row, row, 0xaa)); @@ -1051,7 +1051,7 @@ b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const r2 = _mm_add_ps( r2, _mm_mul_ps(m2, _mm_shuffle_ps(row, row, 0xaa))); return b3Matrix3x3( r0, r1, r2 ); -#elif defined BT_USE_NEON +#elif defined B3_USE_NEON // zeros w static const uint32x4_t xyzMask = (const uint32x4_t){ -1, -1, -1, 0 }; float32x4_t m0 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(0).mVec128, xyzMask ); @@ -1087,7 +1087,7 @@ b3Matrix3x3::transposeTimes(const b3Matrix3x3& m) const SIMD_FORCE_INLINE b3Matrix3x3 b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) __m128 a0 = m_el[0].mVec128; __m128 a1 = m_el[1].mVec128; __m128 a2 = m_el[2].mVec128; @@ -1108,7 +1108,7 @@ b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const r2 = _mm_add_ps(r2, _mm_mul_ps(mz, _mm_shuffle_ps(a2, a2, 0xaa))); return b3Matrix3x3( r0, r1, r2); -#elif defined BT_USE_NEON +#elif defined B3_USE_NEON float32x4_t a0 = m_el[0].mVec128; float32x4_t a1 = m_el[1].mVec128; float32x4_t a2 = m_el[2].mVec128; @@ -1140,7 +1140,7 @@ b3Matrix3x3::timesTranspose(const b3Matrix3x3& m) const SIMD_FORCE_INLINE b3Vector3 operator*(const b3Matrix3x3& m, const b3Vector3& v) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE))|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE))|| defined (B3_USE_NEON) return v.dot3(m[0], m[1], m[2]); #else return b3Vector3(m[0].dot(v), m[1].dot(v), m[2].dot(v)); @@ -1151,30 +1151,30 @@ operator*(const b3Matrix3x3& m, const b3Vector3& v) SIMD_FORCE_INLINE b3Vector3 operator*(const b3Vector3& v, const b3Matrix3x3& m) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) const __m128 vv = v.mVec128; - __m128 c0 = bt_splat_ps( vv, 0); - __m128 c1 = bt_splat_ps( vv, 1); - __m128 c2 = bt_splat_ps( vv, 2); + __m128 c0 = b3_splat_ps( vv, 0); + __m128 c1 = b3_splat_ps( vv, 1); + __m128 c2 = b3_splat_ps( vv, 2); - c0 = _mm_mul_ps(c0, _mm_and_ps(m[0].mVec128, btvFFF0fMask) ); - c1 = _mm_mul_ps(c1, _mm_and_ps(m[1].mVec128, btvFFF0fMask) ); + c0 = _mm_mul_ps(c0, _mm_and_ps(m[0].mVec128, b3vFFF0fMask) ); + c1 = _mm_mul_ps(c1, _mm_and_ps(m[1].mVec128, b3vFFF0fMask) ); c0 = _mm_add_ps(c0, c1); - c2 = _mm_mul_ps(c2, _mm_and_ps(m[2].mVec128, btvFFF0fMask) ); + c2 = _mm_mul_ps(c2, _mm_and_ps(m[2].mVec128, b3vFFF0fMask) ); return b3Vector3(_mm_add_ps(c0, c2)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) const float32x4_t vv = v.mVec128; const float32x2_t vlo = vget_low_f32(vv); const float32x2_t vhi = vget_high_f32(vv); float32x4_t c0, c1, c2; - c0 = (float32x4_t) vandq_s32((int32x4_t)m[0].mVec128, btvFFF0Mask); - c1 = (float32x4_t) vandq_s32((int32x4_t)m[1].mVec128, btvFFF0Mask); - c2 = (float32x4_t) vandq_s32((int32x4_t)m[2].mVec128, btvFFF0Mask); + c0 = (float32x4_t) vandq_s32((int32x4_t)m[0].mVec128, b3vFFF0Mask); + c1 = (float32x4_t) vandq_s32((int32x4_t)m[1].mVec128, b3vFFF0Mask); + c2 = (float32x4_t) vandq_s32((int32x4_t)m[2].mVec128, b3vFFF0Mask); c0 = vmulq_lane_f32(c0, vlo, 0); c1 = vmulq_lane_f32(c1, vlo, 1); @@ -1191,41 +1191,41 @@ operator*(const b3Vector3& v, const b3Matrix3x3& m) SIMD_FORCE_INLINE b3Matrix3x3 operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) __m128 m10 = m1[0].mVec128; __m128 m11 = m1[1].mVec128; __m128 m12 = m1[2].mVec128; - __m128 m2v = _mm_and_ps(m2[0].mVec128, btvFFF0fMask); + __m128 m2v = _mm_and_ps(m2[0].mVec128, b3vFFF0fMask); - __m128 c0 = bt_splat_ps( m10, 0); - __m128 c1 = bt_splat_ps( m11, 0); - __m128 c2 = bt_splat_ps( m12, 0); + __m128 c0 = b3_splat_ps( m10, 0); + __m128 c1 = b3_splat_ps( m11, 0); + __m128 c2 = b3_splat_ps( m12, 0); c0 = _mm_mul_ps(c0, m2v); c1 = _mm_mul_ps(c1, m2v); c2 = _mm_mul_ps(c2, m2v); - m2v = _mm_and_ps(m2[1].mVec128, btvFFF0fMask); + m2v = _mm_and_ps(m2[1].mVec128, b3vFFF0fMask); - __m128 c0_1 = bt_splat_ps( m10, 1); - __m128 c1_1 = bt_splat_ps( m11, 1); - __m128 c2_1 = bt_splat_ps( m12, 1); + __m128 c0_1 = b3_splat_ps( m10, 1); + __m128 c1_1 = b3_splat_ps( m11, 1); + __m128 c2_1 = b3_splat_ps( m12, 1); c0_1 = _mm_mul_ps(c0_1, m2v); c1_1 = _mm_mul_ps(c1_1, m2v); c2_1 = _mm_mul_ps(c2_1, m2v); - m2v = _mm_and_ps(m2[2].mVec128, btvFFF0fMask); + m2v = _mm_and_ps(m2[2].mVec128, b3vFFF0fMask); c0 = _mm_add_ps(c0, c0_1); c1 = _mm_add_ps(c1, c1_1); c2 = _mm_add_ps(c2, c2_1); - m10 = bt_splat_ps( m10, 2); - m11 = bt_splat_ps( m11, 2); - m12 = bt_splat_ps( m12, 2); + m10 = b3_splat_ps( m10, 2); + m11 = b3_splat_ps( m11, 2); + m12 = b3_splat_ps( m12, 2); m10 = _mm_mul_ps(m10, m2v); m11 = _mm_mul_ps(m11, m2v); @@ -1237,7 +1237,7 @@ operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2) return b3Matrix3x3(c0, c1, c2); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t rv0, rv1, rv2; float32x4_t v0, v1, v2; @@ -1247,9 +1247,9 @@ operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2) v1 = m1[1].mVec128; v2 = m1[2].mVec128; - mv0 = (float32x4_t) vandq_s32((int32x4_t)m2[0].mVec128, btvFFF0Mask); - mv1 = (float32x4_t) vandq_s32((int32x4_t)m2[1].mVec128, btvFFF0Mask); - mv2 = (float32x4_t) vandq_s32((int32x4_t)m2[2].mVec128, btvFFF0Mask); + mv0 = (float32x4_t) vandq_s32((int32x4_t)m2[0].mVec128, b3vFFF0Mask); + mv1 = (float32x4_t) vandq_s32((int32x4_t)m2[1].mVec128, b3vFFF0Mask); + mv2 = (float32x4_t) vandq_s32((int32x4_t)m2[2].mVec128, b3vFFF0Mask); rv0 = vmulq_lane_f32(mv0, vget_low_f32(v0), 0); rv1 = vmulq_lane_f32(mv0, vget_low_f32(v1), 0); @@ -1274,7 +1274,7 @@ operator*(const b3Matrix3x3& m1, const b3Matrix3x3& m2) } /* -SIMD_FORCE_INLINE b3Matrix3x3 btMultTransposeLeft(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { +SIMD_FORCE_INLINE b3Matrix3x3 b3MultTransposeLeft(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { return b3Matrix3x3( m1[0][0] * m2[0][0] + m1[1][0] * m2[1][0] + m1[2][0] * m2[2][0], m1[0][0] * m2[0][1] + m1[1][0] * m2[1][1] + m1[2][0] * m2[2][1], @@ -1292,7 +1292,7 @@ m1[0][2] * m2[0][2] + m1[1][2] * m2[1][2] + m1[2][2] * m2[2][2]); * It will test all elements are equal. */ SIMD_FORCE_INLINE bool operator==(const b3Matrix3x3& m1, const b3Matrix3x3& m2) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) __m128 c0, c1, c2; @@ -1313,50 +1313,50 @@ SIMD_FORCE_INLINE bool operator==(const b3Matrix3x3& m1, const b3Matrix3x3& m2) } ///for serialization -struct btMatrix3x3FloatData +struct b3Matrix3x3FloatData { - btVector3FloatData m_el[3]; + b3Vector3FloatData m_el[3]; }; ///for serialization -struct btMatrix3x3DoubleData +struct b3Matrix3x3DoubleData { - btVector3DoubleData m_el[3]; + b3Vector3DoubleData m_el[3]; }; -SIMD_FORCE_INLINE void b3Matrix3x3::serialize(struct btMatrix3x3Data& dataOut) const +SIMD_FORCE_INLINE void b3Matrix3x3::serialize(struct b3Matrix3x3Data& dataOut) const { for (int i=0;i<3;i++) m_el[i].serialize(dataOut.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::serializeFloat(struct btMatrix3x3FloatData& dataOut) const +SIMD_FORCE_INLINE void b3Matrix3x3::serializeFloat(struct b3Matrix3x3FloatData& dataOut) const { for (int i=0;i<3;i++) m_el[i].serializeFloat(dataOut.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::deSerialize(const struct btMatrix3x3Data& dataIn) +SIMD_FORCE_INLINE void b3Matrix3x3::deSerialize(const struct b3Matrix3x3Data& dataIn) { for (int i=0;i<3;i++) m_el[i].deSerialize(dataIn.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeFloat(const struct btMatrix3x3FloatData& dataIn) +SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeFloat(const struct b3Matrix3x3FloatData& dataIn) { for (int i=0;i<3;i++) m_el[i].deSerializeFloat(dataIn.m_el[i]); } -SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeDouble(const struct btMatrix3x3DoubleData& dataIn) +SIMD_FORCE_INLINE void b3Matrix3x3::deSerializeDouble(const struct b3Matrix3x3DoubleData& dataIn) { for (int i=0;i<3;i++) m_el[i].deSerializeDouble(dataIn.m_el[i]); } -#endif //BT_MATRIX3x3_H +#endif //B3_MATRIX3x3_H diff --git a/src/Bullet3Common/b3MinMax.h b/src/Bullet3Common/b3MinMax.h index 0f4f5c4c2..0bb4b5026 100644 --- a/src/Bullet3Common/b3MinMax.h +++ b/src/Bullet3Common/b3MinMax.h @@ -14,31 +14,31 @@ subject to the following restrictions: -#ifndef BT_GEN_MINMAX_H -#define BT_GEN_MINMAX_H +#ifndef B3_GEN_MINMAX_H +#define B3_GEN_MINMAX_H #include "b3Scalar.h" template -SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) +SIMD_FORCE_INLINE const T& b3Min(const T& a, const T& b) { return a < b ? a : b ; } template -SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) +SIMD_FORCE_INLINE const T& b3Max(const T& a, const T& b) { return a > b ? a : b; } template -SIMD_FORCE_INLINE const T& btClamped(const T& a, const T& lb, const T& ub) +SIMD_FORCE_INLINE const T& b3Clamped(const T& a, const T& lb, const T& ub) { return a < lb ? lb : (ub < a ? ub : a); } template -SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) +SIMD_FORCE_INLINE void b3SetMin(T& a, const T& b) { if (b < a) { @@ -47,7 +47,7 @@ SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) } template -SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) +SIMD_FORCE_INLINE void b3SetMax(T& a, const T& b) { if (a < b) { @@ -56,7 +56,7 @@ SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) } template -SIMD_FORCE_INLINE void btClamp(T& a, const T& lb, const T& ub) +SIMD_FORCE_INLINE void b3Clamp(T& a, const T& lb, const T& ub) { if (a < lb) { @@ -68,4 +68,4 @@ SIMD_FORCE_INLINE void btClamp(T& a, const T& lb, const T& ub) } } -#endif //BT_GEN_MINMAX_H +#endif //B3_GEN_MINMAX_H diff --git a/src/Bullet3Common/b3PoolAllocator.h b/src/Bullet3Common/b3PoolAllocator.h index f572153b4..671660c2d 100644 --- a/src/Bullet3Common/b3PoolAllocator.h +++ b/src/Bullet3Common/b3PoolAllocator.h @@ -34,7 +34,7 @@ public: :m_elemSize(elemSize), m_maxElements(maxElements) { - m_pool = (unsigned char*) btAlignedAlloc( static_cast(m_elemSize*m_maxElements),16); + m_pool = (unsigned char*) b3AlignedAlloc( static_cast(m_elemSize*m_maxElements),16); unsigned char* p = m_pool; m_firstFree = p; @@ -49,7 +49,7 @@ public: ~b3PoolAllocator() { - btAlignedFree( m_pool); + b3AlignedFree( m_pool); } int getFreeCount() const @@ -71,8 +71,8 @@ public: { // release mode fix (void)size; - btAssert(!size || size<=m_elemSize); - btAssert(m_freeCount>0); + b3Assert(!size || size<=m_elemSize); + b3Assert(m_freeCount>0); void* result = m_firstFree; m_firstFree = *(void**)m_firstFree; --m_freeCount; @@ -93,7 +93,7 @@ public: void freeMemory(void* ptr) { if (ptr) { - btAssert((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize); + b3Assert((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize); *(void**)ptr = m_firstFree; m_firstFree = ptr; diff --git a/src/Bullet3Common/b3QuadWord.h b/src/Bullet3Common/b3QuadWord.h index 740d67205..4500688fa 100644 --- a/src/Bullet3Common/b3QuadWord.h +++ b/src/Bullet3Common/b3QuadWord.h @@ -13,8 +13,8 @@ subject to the following restrictions: */ -#ifndef BT_SIMD_QUADWORD_H -#define BT_SIMD_QUADWORD_H +#ifndef B3_SIMD_QUADWORD_H +#define B3_SIMD_QUADWORD_H #include "b3Scalar.h" #include "b3MinMax.h" @@ -51,33 +51,33 @@ public: #else //__CELLOS_LV2__ __SPU__ -#if defined(BT_USE_SSE) || defined(BT_USE_NEON) +#if defined(B3_USE_SSE) || defined(B3_USE_NEON) union { - btSimdFloat4 mVec128; + b3SimdFloat4 mVec128; b3Scalar m_floats[4]; struct {b3Scalar x,y,z,w;}; }; public: - SIMD_FORCE_INLINE btSimdFloat4 get128() const + SIMD_FORCE_INLINE b3SimdFloat4 get128() const { return mVec128; } - SIMD_FORCE_INLINE void set128(btSimdFloat4 v128) + SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128) { mVec128 = v128; } #else b3Scalar m_floats[4]; -#endif // BT_USE_SSE +#endif // B3_USE_SSE #endif //__CELLOS_LV2__ __SPU__ public: -#if defined(BT_USE_SSE) || defined(BT_USE_NEON) +#if defined(B3_USE_SSE) || defined(B3_USE_NEON) // Set Vector - SIMD_FORCE_INLINE b3QuadWord(const btSimdFloat4 vec) + SIMD_FORCE_INLINE b3QuadWord(const b3SimdFloat4 vec) { mVec128 = vec; } @@ -124,7 +124,7 @@ public: SIMD_FORCE_INLINE bool operator==(const b3QuadWord& other) const { -#ifdef BT_USE_SSE +#ifdef B3_USE_SSE return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128))); #else return ((m_floats[3]==other.m_floats[3]) && @@ -204,15 +204,15 @@ public: */ SIMD_FORCE_INLINE void setMax(const b3QuadWord& other) { - #ifdef BT_USE_SSE + #ifdef B3_USE_SSE mVec128 = _mm_max_ps(mVec128, other.mVec128); - #elif defined(BT_USE_NEON) + #elif defined(B3_USE_NEON) mVec128 = vmaxq_f32(mVec128, other.mVec128); #else - btSetMax(m_floats[0], other.m_floats[0]); - btSetMax(m_floats[1], other.m_floats[1]); - btSetMax(m_floats[2], other.m_floats[2]); - btSetMax(m_floats[3], other.m_floats[3]); + b3SetMax(m_floats[0], other.m_floats[0]); + b3SetMax(m_floats[1], other.m_floats[1]); + b3SetMax(m_floats[2], other.m_floats[2]); + b3SetMax(m_floats[3], other.m_floats[3]); #endif } /**@brief Set each element to the min of the current values and the values of another b3QuadWord @@ -220,15 +220,15 @@ public: */ SIMD_FORCE_INLINE void setMin(const b3QuadWord& other) { - #ifdef BT_USE_SSE + #ifdef B3_USE_SSE mVec128 = _mm_min_ps(mVec128, other.mVec128); - #elif defined(BT_USE_NEON) + #elif defined(B3_USE_NEON) mVec128 = vminq_f32(mVec128, other.mVec128); #else - btSetMin(m_floats[0], other.m_floats[0]); - btSetMin(m_floats[1], other.m_floats[1]); - btSetMin(m_floats[2], other.m_floats[2]); - btSetMin(m_floats[3], other.m_floats[3]); + b3SetMin(m_floats[0], other.m_floats[0]); + b3SetMin(m_floats[1], other.m_floats[1]); + b3SetMin(m_floats[2], other.m_floats[2]); + b3SetMin(m_floats[3], other.m_floats[3]); #endif } @@ -236,4 +236,4 @@ public: }; -#endif //BT_SIMD_QUADWORD_H +#endif //B3_SIMD_QUADWORD_H diff --git a/src/Bullet3Common/b3Quaternion.h b/src/Bullet3Common/b3Quaternion.h index 083f52c7c..a844c0dbf 100644 --- a/src/Bullet3Common/b3Quaternion.h +++ b/src/Bullet3Common/b3Quaternion.h @@ -14,8 +14,8 @@ subject to the following restrictions: -#ifndef BT_SIMD__QUATERNION_H_ -#define BT_SIMD__QUATERNION_H_ +#ifndef B3_SIMD__QUATERNION_H_ +#define B3_SIMD__QUATERNION_H_ #include "b3Vector3.h" @@ -25,16 +25,16 @@ subject to the following restrictions: -#ifdef BT_USE_SSE +#ifdef B3_USE_SSE const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f}; #endif -#if defined(BT_USE_SSE) || defined(BT_USE_NEON) +#if defined(B3_USE_SSE) || defined(B3_USE_NEON) -const btSimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f}; -const btSimdFloat4 ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f}; +const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f}; +const b3SimdFloat4 ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f}; #endif @@ -44,9 +44,9 @@ public: /**@brief No initialization constructor */ b3Quaternion() {} -#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE))|| defined(BT_USE_NEON) +#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE))|| defined(B3_USE_NEON) // Set Vector - SIMD_FORCE_INLINE b3Quaternion(const btSimdFloat4 vec) + SIMD_FORCE_INLINE b3Quaternion(const b3SimdFloat4 vec) { mVec128 = vec; } @@ -74,7 +74,7 @@ public: b3Quaternion(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z, const b3Scalar& _w) : b3QuadWord(_x, _y, _z, _w) { - btAssert(!((_x==1.f) && (_y==0.f) && (_z==0.f) && (_w==0.f))); + b3Assert(!((_x==1.f) && (_y==0.f) && (_z==0.f) && (_w==0.f))); } /**@brief Axis angle Constructor * @param axis The axis which the rotation is around @@ -84,12 +84,12 @@ public: setRotation(_axis, _angle); } /**@brief Constructor from Euler angles - * @param yaw Angle around Y unless BT_EULER_DEFAULT_ZYX defined then Z - * @param pitch Angle around X unless BT_EULER_DEFAULT_ZYX defined then Y - * @param roll Angle around Z unless BT_EULER_DEFAULT_ZYX defined then X */ + * @param yaw Angle around Y unless B3_EULER_DEFAULT_ZYX defined then Z + * @param pitch Angle around X unless B3_EULER_DEFAULT_ZYX defined then Y + * @param roll Angle around Z unless B3_EULER_DEFAULT_ZYX defined then X */ b3Quaternion(const b3Scalar& yaw, const b3Scalar& pitch, const b3Scalar& roll) { -#ifndef BT_EULER_DEFAULT_ZYX +#ifndef B3_EULER_DEFAULT_ZYX setEuler(yaw, pitch, roll); #else setEulerZYX(yaw, pitch, roll); @@ -101,10 +101,10 @@ public: void setRotation(const b3Vector3& axis, const b3Scalar& _angle) { b3Scalar d = axis.length(); - btAssert(d != b3Scalar(0.0)); - b3Scalar s = btSin(_angle * b3Scalar(0.5)) / d; + b3Assert(d != b3Scalar(0.0)); + b3Scalar s = b3Sin(_angle * b3Scalar(0.5)) / d; setValue(axis.getX() * s, axis.getY() * s, axis.getZ() * s, - btCos(_angle * b3Scalar(0.5))); + b3Cos(_angle * b3Scalar(0.5))); } /**@brief Set the quaternion using Euler angles * @param yaw Angle around Y @@ -115,12 +115,12 @@ public: b3Scalar halfYaw = b3Scalar(yaw) * b3Scalar(0.5); b3Scalar halfPitch = b3Scalar(pitch) * b3Scalar(0.5); b3Scalar halfRoll = b3Scalar(roll) * b3Scalar(0.5); - b3Scalar cosYaw = btCos(halfYaw); - b3Scalar sinYaw = btSin(halfYaw); - b3Scalar cosPitch = btCos(halfPitch); - b3Scalar sinPitch = btSin(halfPitch); - b3Scalar cosRoll = btCos(halfRoll); - b3Scalar sinRoll = btSin(halfRoll); + b3Scalar cosYaw = b3Cos(halfYaw); + b3Scalar sinYaw = b3Sin(halfYaw); + b3Scalar cosPitch = b3Cos(halfPitch); + b3Scalar sinPitch = b3Sin(halfPitch); + b3Scalar cosRoll = b3Cos(halfRoll); + b3Scalar sinRoll = b3Sin(halfRoll); setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, @@ -135,12 +135,12 @@ public: b3Scalar halfYaw = b3Scalar(yaw) * b3Scalar(0.5); b3Scalar halfPitch = b3Scalar(pitch) * b3Scalar(0.5); b3Scalar halfRoll = b3Scalar(roll) * b3Scalar(0.5); - b3Scalar cosYaw = btCos(halfYaw); - b3Scalar sinYaw = btSin(halfYaw); - b3Scalar cosPitch = btCos(halfPitch); - b3Scalar sinPitch = btSin(halfPitch); - b3Scalar cosRoll = btCos(halfRoll); - b3Scalar sinRoll = btSin(halfRoll); + b3Scalar cosYaw = b3Cos(halfYaw); + b3Scalar sinYaw = b3Sin(halfYaw); + b3Scalar cosPitch = b3Cos(halfPitch); + b3Scalar sinPitch = b3Sin(halfPitch); + b3Scalar cosRoll = b3Cos(halfRoll); + b3Scalar sinRoll = b3Sin(halfRoll); setValue(sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw, //x cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw, //y cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw, //z @@ -150,9 +150,9 @@ public: * @param q The quaternion to add to this one */ SIMD_FORCE_INLINE b3Quaternion& operator+=(const b3Quaternion& q) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_add_ps(mVec128, q.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vaddq_f32(mVec128, q.mVec128); #else m_floats[0] += q.getX(); @@ -167,9 +167,9 @@ public: * @param q The quaternion to subtract from this one */ b3Quaternion& operator-=(const b3Quaternion& q) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_sub_ps(mVec128, q.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vsubq_f32(mVec128, q.mVec128); #else m_floats[0] -= q.getX(); @@ -184,11 +184,11 @@ public: * @param s The scalar to scale by */ b3Quaternion& operator*=(const b3Scalar& s) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vs = _mm_load_ss(&s); // (S 0 0 0) - vs = bt_pshufd_ps(vs, 0); // (S S S S) + vs = b3_pshufd_ps(vs, 0); // (S S S S) mVec128 = _mm_mul_ps(mVec128, vs); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vmulq_n_f32(mVec128, s); #else m_floats[0] *= s; @@ -204,25 +204,25 @@ public: * Equivilant to this = this * q */ b3Quaternion& operator*=(const b3Quaternion& q) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vQ2 = q.get128(); - __m128 A1 = bt_pshufd_ps(mVec128, BT_SHUFFLE(0,1,2,0)); - __m128 B1 = bt_pshufd_ps(vQ2, BT_SHUFFLE(3,3,3,0)); + __m128 A1 = b3_pshufd_ps(mVec128, B3_SHUFFLE(0,1,2,0)); + __m128 B1 = b3_pshufd_ps(vQ2, B3_SHUFFLE(3,3,3,0)); A1 = A1 * B1; - __m128 A2 = bt_pshufd_ps(mVec128, BT_SHUFFLE(1,2,0,1)); - __m128 B2 = bt_pshufd_ps(vQ2, BT_SHUFFLE(2,0,1,1)); + __m128 A2 = b3_pshufd_ps(mVec128, B3_SHUFFLE(1,2,0,1)); + __m128 B2 = b3_pshufd_ps(vQ2, B3_SHUFFLE(2,0,1,1)); A2 = A2 * B2; - B1 = bt_pshufd_ps(mVec128, BT_SHUFFLE(2,0,1,2)); - B2 = bt_pshufd_ps(vQ2, BT_SHUFFLE(1,2,0,2)); + B1 = b3_pshufd_ps(mVec128, B3_SHUFFLE(2,0,1,2)); + B2 = b3_pshufd_ps(vQ2, B3_SHUFFLE(1,2,0,2)); B1 = B1 * B2; // A3 *= B3 - mVec128 = bt_splat_ps(mVec128, 3); // A0 + mVec128 = b3_splat_ps(mVec128, 3); // A0 mVec128 = mVec128 * vQ2; // A0 * B0 A1 = A1 + A2; // AB12 @@ -230,7 +230,7 @@ public: A1 = _mm_xor_ps(A1, vPPPM); // change sign of the last element mVec128 = mVec128+ A1; // AB03 + AB12 -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vQ1 = mVec128; float32x4_t vQ2 = q.get128(); @@ -270,7 +270,7 @@ public: A0 = vsubq_f32(A0, A3); // AB03 = AB0 - AB3 // change the sign of the last element - A1 = (btSimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); + A1 = (b3SimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); A0 = vaddq_f32(A0, A1); // AB03 + AB12 mVec128 = A0; @@ -287,7 +287,7 @@ public: * @param q The other quaternion */ b3Scalar dot(const b3Quaternion& q) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vd; vd = _mm_mul_ps(mVec128, q.mVec128); @@ -298,7 +298,7 @@ public: vd = _mm_add_ss(vd, t); return _mm_cvtss_f32(vd); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vd = vmulq_f32(mVec128, q.mVec128); float32x2_t x = vpadd_f32(vget_low_f32(vd), vget_high_f32(vd)); x = vpadd_f32(x, x); @@ -320,14 +320,14 @@ public: /**@brief Return the length of the quaternion */ b3Scalar length() const { - return btSqrt(length2()); + return b3Sqrt(length2()); } /**@brief Normalize the quaternion * Such that x^2 + y^2 + z^2 +w^2 = 1 */ b3Quaternion& normalize() { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vd; vd = _mm_mul_ps(mVec128, mVec128); @@ -339,7 +339,7 @@ public: vd = _mm_sqrt_ss(vd); vd = _mm_div_ss(vOnes, vd); - vd = bt_pshufd_ps(vd, 0); // splat + vd = b3_pshufd_ps(vd, 0); // splat mVec128 = _mm_mul_ps(mVec128, vd); return *this; @@ -353,12 +353,12 @@ public: SIMD_FORCE_INLINE b3Quaternion operator*(const b3Scalar& s) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vs = _mm_load_ss(&s); // (S 0 0 0) - vs = bt_pshufd_ps(vs, 0x00); // (S S S S) + vs = b3_pshufd_ps(vs, 0x00); // (S S S S) return b3Quaternion(_mm_mul_ps(mVec128, vs)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) return b3Quaternion(vmulq_n_f32(mVec128, s)); #else return b3Quaternion(getX() * s, getY() * s, getZ() * s, m_floats[3] * s); @@ -369,7 +369,7 @@ public: * @param s The inverse scale factor */ b3Quaternion operator/(const b3Scalar& s) const { - btAssert(s != b3Scalar(0.0)); + b3Assert(s != b3Scalar(0.0)); return *this * (b3Scalar(1.0) / s); } @@ -377,7 +377,7 @@ public: * @param s The scale factor */ b3Quaternion& operator/=(const b3Scalar& s) { - btAssert(s != b3Scalar(0.0)); + b3Assert(s != b3Scalar(0.0)); return *this *= b3Scalar(1.0) / s; } @@ -390,14 +390,14 @@ public: * @param q The other quaternion */ b3Scalar angle(const b3Quaternion& q) const { - b3Scalar s = btSqrt(length2() * q.length2()); - btAssert(s != b3Scalar(0.0)); - return btAcos(dot(q) / s); + b3Scalar s = b3Sqrt(length2() * q.length2()); + b3Assert(s != b3Scalar(0.0)); + return b3Acos(dot(q) / s); } /**@brief Return the angle of rotation represented by this quaternion */ b3Scalar getAngle() const { - b3Scalar s = b3Scalar(2.) * btAcos(m_floats[3]); + b3Scalar s = b3Scalar(2.) * b3Acos(m_floats[3]); return s; } @@ -408,17 +408,17 @@ public: if (s_squared < b3Scalar(10.) * SIMD_EPSILON) //Check for divide by zero return b3Vector3(1.0, 0.0, 0.0); // Arbitrary - b3Scalar s = 1.f/btSqrt(s_squared); + b3Scalar s = 1.f/b3Sqrt(s_squared); return b3Vector3(m_floats[0] * s, m_floats[1] * s, m_floats[2] * s); } /**@brief Return the inverse of this quaternion */ b3Quaternion inverse() const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Quaternion(_mm_xor_ps(mVec128, vQInv)); -#elif defined(BT_USE_NEON) - return b3Quaternion((btSimdFloat4)veorq_s32((int32x4_t)mVec128, (int32x4_t)vQInv)); +#elif defined(B3_USE_NEON) + return b3Quaternion((b3SimdFloat4)veorq_s32((int32x4_t)mVec128, (int32x4_t)vQInv)); #else return b3Quaternion(-m_floats[0], -m_floats[1], -m_floats[2], m_floats[3]); #endif @@ -429,9 +429,9 @@ public: SIMD_FORCE_INLINE b3Quaternion operator+(const b3Quaternion& q2) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Quaternion(_mm_add_ps(mVec128, q2.mVec128)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) return b3Quaternion(vaddq_f32(mVec128, q2.mVec128)); #else const b3Quaternion& q1 = *this; @@ -444,9 +444,9 @@ public: SIMD_FORCE_INLINE b3Quaternion operator-(const b3Quaternion& q2) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Quaternion(_mm_sub_ps(mVec128, q2.mVec128)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) return b3Quaternion(vsubq_f32(mVec128, q2.mVec128)); #else const b3Quaternion& q1 = *this; @@ -458,10 +458,10 @@ public: * This simply negates each element */ SIMD_FORCE_INLINE b3Quaternion operator-() const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) - return b3Quaternion(_mm_xor_ps(mVec128, btvMzeroMask)); -#elif defined(BT_USE_NEON) - return b3Quaternion((btSimdFloat4)veorq_s32((int32x4_t)mVec128, (int32x4_t)btvMzeroMask) ); +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) + return b3Quaternion(_mm_xor_ps(mVec128, b3vMzeroMask)); +#elif defined(B3_USE_NEON) + return b3Quaternion((b3SimdFloat4)veorq_s32((int32x4_t)mVec128, (int32x4_t)b3vMzeroMask) ); #else const b3Quaternion& q2 = *this; return b3Quaternion( - q2.getX(), - q2.getY(), - q2.getZ(), - q2.m_floats[3]); @@ -496,19 +496,19 @@ public: * Slerp interpolates assuming constant velocity. */ b3Quaternion slerp(const b3Quaternion& q, const b3Scalar& t) const { - b3Scalar magnitude = btSqrt(length2() * q.length2()); - btAssert(magnitude > b3Scalar(0)); + b3Scalar magnitude = b3Sqrt(length2() * q.length2()); + b3Assert(magnitude > b3Scalar(0)); b3Scalar product = dot(q) / magnitude; - if (btFabs(product) < b3Scalar(1)) + if (b3Fabs(product) < b3Scalar(1)) { // Take care of long angle case see http://en.wikipedia.org/wiki/Slerp const b3Scalar sign = (product < 0) ? b3Scalar(-1) : b3Scalar(1); - const b3Scalar theta = btAcos(sign * product); - const b3Scalar s1 = btSin(sign * t * theta); - const b3Scalar d = b3Scalar(1.0) / btSin(theta); - const b3Scalar s0 = btSin((b3Scalar(1.0) - t) * theta); + const b3Scalar theta = b3Acos(sign * product); + const b3Scalar s1 = b3Sin(sign * t * theta); + const b3Scalar d = b3Scalar(1.0) / b3Sin(theta); + const b3Scalar s0 = b3Sin((b3Scalar(1.0) - t) * theta); return b3Quaternion( (m_floats[0] * s0 + q.getX() * s1) * d, @@ -541,27 +541,27 @@ public: SIMD_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q1, const b3Quaternion& q2) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vQ1 = q1.get128(); __m128 vQ2 = q2.get128(); __m128 A0, A1, B1, A2, B2; - A1 = bt_pshufd_ps(vQ1, BT_SHUFFLE(0,1,2,0)); // X Y z x // vtrn - B1 = bt_pshufd_ps(vQ2, BT_SHUFFLE(3,3,3,0)); // W W W X // vdup vext + A1 = b3_pshufd_ps(vQ1, B3_SHUFFLE(0,1,2,0)); // X Y z x // vtrn + B1 = b3_pshufd_ps(vQ2, B3_SHUFFLE(3,3,3,0)); // W W W X // vdup vext A1 = A1 * B1; - A2 = bt_pshufd_ps(vQ1, BT_SHUFFLE(1,2,0,1)); // Y Z X Y // vext - B2 = bt_pshufd_ps(vQ2, BT_SHUFFLE(2,0,1,1)); // z x Y Y // vtrn vdup + A2 = b3_pshufd_ps(vQ1, B3_SHUFFLE(1,2,0,1)); // Y Z X Y // vext + B2 = b3_pshufd_ps(vQ2, B3_SHUFFLE(2,0,1,1)); // z x Y Y // vtrn vdup A2 = A2 * B2; - B1 = bt_pshufd_ps(vQ1, BT_SHUFFLE(2,0,1,2)); // z x Y Z // vtrn vext - B2 = bt_pshufd_ps(vQ2, BT_SHUFFLE(1,2,0,2)); // Y Z x z // vext vtrn + B1 = b3_pshufd_ps(vQ1, B3_SHUFFLE(2,0,1,2)); // z x Y Z // vtrn vext + B2 = b3_pshufd_ps(vQ2, B3_SHUFFLE(1,2,0,2)); // Y Z x z // vext vtrn B1 = B1 * B2; // A3 *= B3 - A0 = bt_splat_ps(vQ1, 3); // A0 + A0 = b3_splat_ps(vQ1, 3); // A0 A0 = A0 * vQ2; // A0 * B0 A1 = A1 + A2; // AB12 @@ -572,7 +572,7 @@ operator*(const b3Quaternion& q1, const b3Quaternion& q2) return b3Quaternion(A0); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vQ1 = q1.get128(); float32x4_t vQ2 = q2.get128(); @@ -612,7 +612,7 @@ operator*(const b3Quaternion& q1, const b3Quaternion& q2) A0 = vsubq_f32(A0, A3); // AB03 = AB0 - AB3 // change the sign of the last element - A1 = (btSimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); + A1 = (b3SimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); A0 = vaddq_f32(A0, A1); // AB03 + AB12 return b3Quaternion(A0); @@ -629,23 +629,23 @@ operator*(const b3Quaternion& q1, const b3Quaternion& q2) SIMD_FORCE_INLINE b3Quaternion operator*(const b3Quaternion& q, const b3Vector3& w) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vQ1 = q.get128(); __m128 vQ2 = w.get128(); __m128 A1, B1, A2, B2, A3, B3; - A1 = bt_pshufd_ps(vQ1, BT_SHUFFLE(3,3,3,0)); - B1 = bt_pshufd_ps(vQ2, BT_SHUFFLE(0,1,2,0)); + A1 = b3_pshufd_ps(vQ1, B3_SHUFFLE(3,3,3,0)); + B1 = b3_pshufd_ps(vQ2, B3_SHUFFLE(0,1,2,0)); A1 = A1 * B1; - A2 = bt_pshufd_ps(vQ1, BT_SHUFFLE(1,2,0,1)); - B2 = bt_pshufd_ps(vQ2, BT_SHUFFLE(2,0,1,1)); + A2 = b3_pshufd_ps(vQ1, B3_SHUFFLE(1,2,0,1)); + B2 = b3_pshufd_ps(vQ2, B3_SHUFFLE(2,0,1,1)); A2 = A2 * B2; - A3 = bt_pshufd_ps(vQ1, BT_SHUFFLE(2,0,1,2)); - B3 = bt_pshufd_ps(vQ2, BT_SHUFFLE(1,2,0,2)); + A3 = b3_pshufd_ps(vQ1, B3_SHUFFLE(2,0,1,2)); + B3 = b3_pshufd_ps(vQ2, B3_SHUFFLE(1,2,0,2)); A3 = A3 * B3; // A3 *= B3 @@ -655,7 +655,7 @@ operator*(const b3Quaternion& q, const b3Vector3& w) return b3Quaternion(A1); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vQ1 = q.get128(); float32x4_t vQ2 = w.get128(); @@ -694,7 +694,7 @@ operator*(const b3Quaternion& q, const b3Vector3& w) A1 = vaddq_f32(A1, A2); // AB12 = AB1 + AB2 // change the sign of the last element - A1 = (btSimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); + A1 = (b3SimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); A1 = vsubq_f32(A1, A3); // AB123 = AB12 - AB3 @@ -712,23 +712,23 @@ operator*(const b3Quaternion& q, const b3Vector3& w) SIMD_FORCE_INLINE b3Quaternion operator*(const b3Vector3& w, const b3Quaternion& q) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vQ1 = w.get128(); __m128 vQ2 = q.get128(); __m128 A1, B1, A2, B2, A3, B3; - A1 = bt_pshufd_ps(vQ1, BT_SHUFFLE(0,1,2,0)); // X Y z x - B1 = bt_pshufd_ps(vQ2, BT_SHUFFLE(3,3,3,0)); // W W W X + A1 = b3_pshufd_ps(vQ1, B3_SHUFFLE(0,1,2,0)); // X Y z x + B1 = b3_pshufd_ps(vQ2, B3_SHUFFLE(3,3,3,0)); // W W W X A1 = A1 * B1; - A2 = bt_pshufd_ps(vQ1, BT_SHUFFLE(1,2,0,1)); - B2 = bt_pshufd_ps(vQ2, BT_SHUFFLE(2,0,1,1)); + A2 = b3_pshufd_ps(vQ1, B3_SHUFFLE(1,2,0,1)); + B2 = b3_pshufd_ps(vQ2, B3_SHUFFLE(2,0,1,1)); A2 = A2 *B2; - A3 = bt_pshufd_ps(vQ1, BT_SHUFFLE(2,0,1,2)); - B3 = bt_pshufd_ps(vQ2, BT_SHUFFLE(1,2,0,2)); + A3 = b3_pshufd_ps(vQ1, B3_SHUFFLE(2,0,1,2)); + B3 = b3_pshufd_ps(vQ2, B3_SHUFFLE(1,2,0,2)); A3 = A3 * B3; // A3 *= B3 @@ -738,7 +738,7 @@ operator*(const b3Vector3& w, const b3Quaternion& q) return b3Quaternion(A1); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vQ1 = w.get128(); float32x4_t vQ2 = q.get128(); @@ -777,7 +777,7 @@ operator*(const b3Vector3& w, const b3Quaternion& q) A1 = vaddq_f32(A1, A2); // AB12 = AB1 + AB2 // change the sign of the last element - A1 = (btSimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); + A1 = (b3SimdFloat4)veorq_s32((int32x4_t)A1, (int32x4_t)vPPPM); A1 = vsubq_f32(A1, A3); // AB123 = AB12 - AB3 @@ -809,7 +809,7 @@ length(const b3Quaternion& q) /**@brief Return the angle between two quaternions*/ SIMD_FORCE_INLINE b3Scalar -btAngle(const b3Quaternion& q1, const b3Quaternion& q2) +b3Angle(const b3Quaternion& q1, const b3Quaternion& q2) { return q1.angle(q2); } @@ -837,10 +837,10 @@ quatRotate(const b3Quaternion& rotation, const b3Vector3& v) { b3Quaternion q = rotation * v; q *= rotation.inverse(); -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) - return b3Vector3(_mm_and_ps(q.get128(), btvFFF0fMask)); -#elif defined(BT_USE_NEON) - return b3Vector3((float32x4_t)vandq_s32((int32x4_t)q.get128(), btvFFF0Mask)); +#if defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) + return b3Vector3(_mm_and_ps(q.get128(), b3vFFF0fMask)); +#elif defined(B3_USE_NEON) + return b3Vector3((float32x4_t)vandq_s32((int32x4_t)q.get128(), b3vFFF0Mask)); #else return b3Vector3(q.getX(),q.getY(),q.getZ()); #endif @@ -855,11 +855,11 @@ shortestArcQuat(const b3Vector3& v0, const b3Vector3& v1) // Game Programming Ge if (d < -1.0 + SIMD_EPSILON) { b3Vector3 n,unused; - btPlaneSpace1(v0,n,unused); + b3PlaneSpace1(v0,n,unused); return b3Quaternion(n.getX(),n.getY(),n.getZ(),0.0f); // just pick any vector that is orthogonal to v0 } - b3Scalar s = btSqrt((1.0f + d) * 2.0f); + b3Scalar s = b3Sqrt((1.0f + d) * 2.0f); b3Scalar rs = 1.0f / s; return b3Quaternion(c.getX()*rs,c.getY()*rs,c.getZ()*rs,s * 0.5f); @@ -873,7 +873,7 @@ shortestArcQuatNormalize2(b3Vector3& v0,b3Vector3& v1) return shortestArcQuat(v0,v1); } -#endif //BT_SIMD__QUATERNION_H_ +#endif //B3_SIMD__QUATERNION_H_ diff --git a/src/Bullet3Common/b3Quickprof.cpp b/src/Bullet3Common/b3Quickprof.cpp index 7bc2fed98..54d0fcc04 100644 --- a/src/Bullet3Common/b3Quickprof.cpp +++ b/src/Bullet3Common/b3Quickprof.cpp @@ -15,10 +15,10 @@ #include "b3Quickprof.h" -#ifndef BT_NO_PROFILE +#ifndef B3_NO_PROFILE -static btClock gProfileClock; +static b3Clock gProfileClock; #ifdef __CELLOS_LV2__ @@ -33,7 +33,7 @@ static btClock gProfileClock; #if defined(WIN32) || defined(_WIN32) -#define BT_USE_WINDOWS_TIMERS +#define B3_USE_WINDOWS_TIMERS #define WIN32_LEAN_AND_MEAN #define NOWINRES #define NOMCX @@ -54,10 +54,10 @@ static btClock gProfileClock; #define mymin(a,b) (a > b ? a : b) -struct btClockData +struct b3ClockData { -#ifdef BT_USE_WINDOWS_TIMERS +#ifdef B3_USE_WINDOWS_TIMERS LARGE_INTEGER mClockFrequency; DWORD mStartTick; LONGLONG mPrevElapsedTime; @@ -72,28 +72,28 @@ struct btClockData }; -///The btClock is a portable basic clock that measures accurate time in seconds, use for profiling. -btClock::btClock() +///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling. +b3Clock::b3Clock() { - m_data = new btClockData; -#ifdef BT_USE_WINDOWS_TIMERS + m_data = new b3ClockData; +#ifdef B3_USE_WINDOWS_TIMERS QueryPerformanceFrequency(&m_data->mClockFrequency); #endif reset(); } -btClock::~btClock() +b3Clock::~b3Clock() { delete m_data; } -btClock::btClock(const btClock& other) +b3Clock::b3Clock(const b3Clock& other) { - m_data = new btClockData; + m_data = new b3ClockData; *m_data = *other.m_data; } -btClock& btClock::operator=(const btClock& other) +b3Clock& b3Clock::operator=(const b3Clock& other) { *m_data = *other.m_data; return *this; @@ -101,9 +101,9 @@ btClock& btClock::operator=(const btClock& other) /// Resets the initial reference time. -void btClock::reset() +void b3Clock::reset() { -#ifdef BT_USE_WINDOWS_TIMERS +#ifdef B3_USE_WINDOWS_TIMERS QueryPerformanceCounter(&m_data->mStartTime); m_data->mStartTick = GetTickCount(); m_data->mPrevElapsedTime = 0; @@ -122,10 +122,10 @@ void btClock::reset() } /// Returns the time in ms since the last call to reset or since -/// the btClock was created. -unsigned long int btClock::getTimeMilliseconds() +/// the b3Clock was created. +unsigned long int b3Clock::getTimeMilliseconds() { -#ifdef BT_USE_WINDOWS_TIMERS +#ifdef B3_USE_WINDOWS_TIMERS LARGE_INTEGER currentTime; QueryPerformanceCounter(¤tTime); LONGLONG elapsedTime = currentTime.QuadPart - @@ -179,9 +179,9 @@ unsigned long int btClock::getTimeMilliseconds() /// Returns the time in us since the last call to reset or since /// the Clock was created. -unsigned long int btClock::getTimeMicroseconds() +unsigned long int b3Clock::getTimeMicroseconds() { -#ifdef BT_USE_WINDOWS_TIMERS +#ifdef B3_USE_WINDOWS_TIMERS LARGE_INTEGER currentTime; QueryPerformanceCounter(¤tTime); LONGLONG elapsedTime = currentTime.QuadPart - @@ -563,4 +563,4 @@ void CProfileManager::dumpAll() -#endif //BT_NO_PROFILE +#endif //B3_NO_PROFILE diff --git a/src/Bullet3Common/b3Quickprof.h b/src/Bullet3Common/b3Quickprof.h index 7dfdf5d98..0b8b33088 100644 --- a/src/Bullet3Common/b3Quickprof.h +++ b/src/Bullet3Common/b3Quickprof.h @@ -12,12 +12,12 @@ -#ifndef BT_QUICK_PROF_H -#define BT_QUICK_PROF_H +#ifndef B3_QUICK_PROF_H +#define B3_QUICK_PROF_H //To disable built-in profiling, please comment out next line -//#define BT_NO_PROFILE 1 -#ifndef BT_NO_PROFILE +//#define B3_NO_PROFILE 1 +#ifndef B3_NO_PROFILE #include //@todo remove this, backwards compatibility #include "b3Scalar.h" #include "b3AlignedAllocator.h" @@ -31,29 +31,29 @@ #ifdef USE_BT_CLOCK -///The btClock is a portable basic clock that measures accurate time in seconds, use for profiling. -class btClock +///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling. +class b3Clock { public: - btClock(); + b3Clock(); - btClock(const btClock& other); - btClock& operator=(const btClock& other); + b3Clock(const b3Clock& other); + b3Clock& operator=(const b3Clock& other); - ~btClock(); + ~b3Clock(); /// Resets the initial reference time. void reset(); /// Returns the time in ms since the last call to reset or since - /// the btClock was created. + /// the b3Clock was created. unsigned long int getTimeMilliseconds(); /// Returns the time in us since the last call to reset or since /// the Clock was created. unsigned long int getTimeMicroseconds(); private: - struct btClockData* m_data; + struct b3ClockData* m_data; }; #endif //USE_BT_CLOCK @@ -173,7 +173,7 @@ private: ///ProfileSampleClass is a simple way to profile a function's scope -///Use the BT_PROFILE macro at the start of scope to time +///Use the B3_PROFILE macro at the start of scope to time class CProfileSample { public: CProfileSample( const char * name ) @@ -188,16 +188,16 @@ public: }; -#define BT_PROFILE( name ) CProfileSample __profile( name ) +#define B3_PROFILE( name ) CProfileSample __profile( name ) #else -#define BT_PROFILE( name ) +#define B3_PROFILE( name ) -#endif //#ifndef BT_NO_PROFILE +#endif //#ifndef B3_NO_PROFILE -#endif //BT_QUICK_PROF_H +#endif //B3_QUICK_PROF_H diff --git a/src/Bullet3Common/b3Random.h b/src/Bullet3Common/b3Random.h index 4cbfc6bfe..9a99ba172 100644 --- a/src/Bullet3Common/b3Random.h +++ b/src/Bullet3Common/b3Random.h @@ -14,8 +14,8 @@ subject to the following restrictions: -#ifndef BT_GEN_RANDOM_H -#define BT_GEN_RANDOM_H +#ifndef B3_GEN_RANDOM_H +#define B3_GEN_RANDOM_H #ifdef MT19937 @@ -38,5 +38,5 @@ SIMD_FORCE_INLINE unsigned int GEN_rand() { return rand(); } #endif -#endif //BT_GEN_RANDOM_H +#endif //B3_GEN_RANDOM_H diff --git a/src/Bullet3Common/b3Scalar.h b/src/Bullet3Common/b3Scalar.h index 25c3a83a6..6b6418af6 100644 --- a/src/Bullet3Common/b3Scalar.h +++ b/src/Bullet3Common/b3Scalar.h @@ -14,10 +14,10 @@ subject to the following restrictions: -#ifndef BT_SCALAR_H -#define BT_SCALAR_H +#ifndef B3_SCALAR_H +#define B3_SCALAR_H -#ifdef BT_MANAGED_CODE +#ifdef B3_MANAGED_CODE //Aligned data types not supported in managed code #pragma unmanaged #endif @@ -28,15 +28,15 @@ subject to the following restrictions: #include /* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/ -#define BT_BULLET_VERSION 281 +#define B3_BULLET_VERSION 281 -inline int btGetVersion() +inline int b3GetVersion() { - return BT_BULLET_VERSION; + return B3_BULLET_VERSION; } #if defined(DEBUG) || defined (_DEBUG) -#define BT_DEBUG +#define B3_DEBUG #endif @@ -49,7 +49,7 @@ inline int btGetVersion() #define ATTRIBUTE_ALIGNED64(a) a #define ATTRIBUTE_ALIGNED128(a) a #else - //#define BT_HAS_ALIGNED_ALLOCATOR + //#define B3_HAS_ALIGNED_ALLOCATOR #pragma warning(disable : 4324) // disable padding warning // #pragma warning(disable:4530) // Disable the exception disable but used in MSCV Stl warning. // #pragma warning(disable:4996) //Turn off warnings about deprecated C routines @@ -60,24 +60,24 @@ inline int btGetVersion() #define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a #ifdef _XBOX - #define BT_USE_VMX128 + #define B3_USE_VMX128 #include - #define BT_HAVE_NATIVE_FSEL - #define btFsel(a,b,c) __fsel((a),(b),(c)) + #define B3_HAVE_NATIVE_FSEL + #define b3Fsel(a,b,c) __fsel((a),(b),(c)) #else -#if (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION)) - #define BT_USE_SSE - #ifdef BT_USE_SSE - //BT_USE_SSE_IN_API is disabled under Windows by default, because +#if (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (B3_USE_DOUBLE_PRECISION)) + #define B3_USE_SSE + #ifdef B3_USE_SSE + //B3_USE_SSE_IN_API is disabled under Windows by default, because //it makes it harder to integrate Bullet into your application under Windows //(structured embedding Bullet structs/classes need to be 16-byte aligned) //with relatively little performance gain //If you are not embedded Bullet data in your classes, or make sure that you align those classes on 16-byte boundaries //you can manually enable this line or set it in the build system for a bit of performance gain (a few percent, dependent on usage) - //#define BT_USE_SSE_IN_API - #endif //BT_USE_SSE + //#define B3_USE_SSE_IN_API + #endif //B3_USE_SSE #include #endif @@ -85,22 +85,22 @@ inline int btGetVersion() #endif //__MINGW32__ -#ifdef BT_DEBUG +#ifdef B3_DEBUG #ifdef _MSC_VER #include - #define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }} + #define b3Assert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }} #else//_MSC_VER #include - #define btAssert assert + #define b3Assert assert #endif//_MSC_VER #else - #define btAssert(x) + #define b3Assert(x) #endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) + //b3FullAssert is optional, slows down a lot + #define b3FullAssert(x) - #define btLikely(_c) _c - #define btUnlikely(_c) _c + #define b3Likely(_c) _c + #define b3Unlikely(_c) _c #else @@ -112,23 +112,23 @@ inline int btGetVersion() #ifndef assert #include #endif -#ifdef BT_DEBUG +#ifdef B3_DEBUG #ifdef __SPU__ #include #define printf spu_printf - #define btAssert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}} + #define b3Assert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}} #else - #define btAssert assert + #define b3Assert assert #endif #else - #define btAssert(x) + #define b3Assert(x) #endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) + //b3FullAssert is optional, slows down a lot + #define b3FullAssert(x) - #define btLikely(_c) _c - #define btUnlikely(_c) _c + #define b3Likely(_c) _c + #define b3Unlikely(_c) _c #else @@ -141,29 +141,29 @@ inline int btGetVersion() #ifndef assert #include #endif -#ifdef BT_DEBUG - #define btAssert assert +#ifdef B3_DEBUG + #define b3Assert assert #else - #define btAssert(x) + #define b3Assert(x) #endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) + //b3FullAssert is optional, slows down a lot + #define b3FullAssert(x) - #define btLikely(_c) __builtin_expect((_c), 1) - #define btUnlikely(_c) __builtin_expect((_c), 0) + #define b3Likely(_c) __builtin_expect((_c), 1) + #define b3Unlikely(_c) __builtin_expect((_c), 0) #else //non-windows systems -#if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION))) +#if (defined (__APPLE__) && (!defined (B3_USE_DOUBLE_PRECISION))) #if defined (__i386__) || defined (__x86_64__) - #define BT_USE_SSE - //BT_USE_SSE_IN_API is enabled on Mac OSX by default, because memory is automatically aligned on 16-byte boundaries + #define B3_USE_SSE + //B3_USE_SSE_IN_API is enabled on Mac OSX by default, because memory is automatically aligned on 16-byte boundaries //if apps run into issues, we will disable the next line - #define BT_USE_SSE_IN_API - #ifdef BT_USE_SSE + #define B3_USE_SSE_IN_API + #ifdef B3_USE_SSE // include appropriate SSE level #if defined (__SSE4_1__) #include @@ -174,14 +174,14 @@ inline int btGetVersion() #else #include #endif - #endif //BT_USE_SSE + #endif //B3_USE_SSE #elif defined( __armv7__ ) #ifdef __clang__ - #define BT_USE_NEON 1 + #define B3_USE_NEON 1 - #if defined BT_USE_NEON && defined (__clang__) + #if defined B3_USE_NEON && defined (__clang__) #include - #endif//BT_USE_NEON + #endif//B3_USE_NEON #endif //__clang__ #endif//__arm__ @@ -197,7 +197,7 @@ inline int btGetVersion() #if defined(DEBUG) || defined (_DEBUG) #if defined (__i386__) || defined (__x86_64__) #include - #define btAssert(x)\ + #define b3Assert(x)\ {\ if(!(x))\ {\ @@ -206,16 +206,16 @@ inline int btGetVersion() }\ } #else//defined (__i386__) || defined (__x86_64__) - #define btAssert assert + #define b3Assert assert #endif//defined (__i386__) || defined (__x86_64__) #else//defined(DEBUG) || defined (_DEBUG) - #define btAssert(x) + #define b3Assert(x) #endif//defined(DEBUG) || defined (_DEBUG) - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - #define btLikely(_c) _c - #define btUnlikely(_c) _c + //b3FullAssert is optional, slows down a lot + #define b3FullAssert(x) + #define b3Likely(_c) _c + #define b3Unlikely(_c) _c #else @@ -232,15 +232,15 @@ inline int btGetVersion() #endif #if defined(DEBUG) || defined (_DEBUG) - #define btAssert assert + #define b3Assert assert #else - #define btAssert(x) + #define b3Assert(x) #endif - //btFullAssert is optional, slows down a lot - #define btFullAssert(x) - #define btLikely(_c) _c - #define btUnlikely(_c) _c + //b3FullAssert is optional, slows down a lot + #define b3FullAssert(x) + #define b3Likely(_c) _c + #define b3Unlikely(_c) _c #endif //__APPLE__ #endif // LIBSPE2 @@ -250,31 +250,31 @@ inline int btGetVersion() ///The b3Scalar type abstracts floating point numbers, to easily switch between double and single floating point precision. -#if defined(BT_USE_DOUBLE_PRECISION) +#if defined(B3_USE_DOUBLE_PRECISION) typedef double b3Scalar; //this number could be bigger in double precision -#define BT_LARGE_FLOAT 1e30 +#define B3_LARGE_FLOAT 1e30 #else typedef float b3Scalar; -//keep BT_LARGE_FLOAT*BT_LARGE_FLOAT < FLT_MAX -#define BT_LARGE_FLOAT 1e18f +//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX +#define B3_LARGE_FLOAT 1e18f #endif -#ifdef BT_USE_SSE -typedef __m128 btSimdFloat4; -#endif//BT_USE_SSE +#ifdef B3_USE_SSE +typedef __m128 b3SimdFloat4; +#endif//B3_USE_SSE -#if defined BT_USE_SSE_IN_API && defined (BT_USE_SSE) +#if defined B3_USE_SSE_IN_API && defined (B3_USE_SSE) #ifdef _WIN32 -#ifndef BT_NAN -static int btNanMask = 0x7F800001; -#define BT_NAN (*(float*)&btNanMask) +#ifndef B3_NAN +static int b3NanMask = 0x7F800001; +#define B3_NAN (*(float*)&b3NanMask) #endif -#ifndef BT_INFINITY -static int btInfinityMask = 0x7F800000; -#define BT_INFINITY (*(float*)&btInfinityMask) +#ifndef B3_INFINITY +static int b3InfinityMask = 0x7F800000; +#define B3_INFINITY (*(float*)&b3InfinityMask) #endif inline __m128 operator + (const __m128 A, const __m128 B) @@ -292,70 +292,70 @@ inline __m128 operator * (const __m128 A, const __m128 B) return _mm_mul_ps(A, B); } -#define btCastfTo128i(a) (_mm_castps_si128(a)) -#define btCastfTo128d(a) (_mm_castps_pd(a)) -#define btCastiTo128f(a) (_mm_castsi128_ps(a)) -#define btCastdTo128f(a) (_mm_castpd_ps(a)) -#define btCastdTo128i(a) (_mm_castpd_si128(a)) -#define btAssign128(r0,r1,r2,r3) _mm_setr_ps(r0,r1,r2,r3) +#define b3CastfTo128i(a) (_mm_castps_si128(a)) +#define b3CastfTo128d(a) (_mm_castps_pd(a)) +#define b3CastiTo128f(a) (_mm_castsi128_ps(a)) +#define b3CastdTo128f(a) (_mm_castpd_ps(a)) +#define b3CastdTo128i(a) (_mm_castpd_si128(a)) +#define b3Assign128(r0,r1,r2,r3) _mm_setr_ps(r0,r1,r2,r3) #else//_WIN32 -#define btCastfTo128i(a) ((__m128i)(a)) -#define btCastfTo128d(a) ((__m128d)(a)) -#define btCastiTo128f(a) ((__m128) (a)) -#define btCastdTo128f(a) ((__m128) (a)) -#define btCastdTo128i(a) ((__m128i)(a)) -#define btAssign128(r0,r1,r2,r3) (__m128){r0,r1,r2,r3} -#define BT_INFINITY INFINITY -#define BT_NAN NAN +#define b3CastfTo128i(a) ((__m128i)(a)) +#define b3CastfTo128d(a) ((__m128d)(a)) +#define b3CastiTo128f(a) ((__m128) (a)) +#define b3CastdTo128f(a) ((__m128) (a)) +#define b3CastdTo128i(a) ((__m128i)(a)) +#define b3Assign128(r0,r1,r2,r3) (__m128){r0,r1,r2,r3} +#define B3_INFINITY INFINITY +#define B3_NAN NAN #endif//_WIN32 -#endif //BT_USE_SSE_IN_API +#endif //B3_USE_SSE_IN_API -#ifdef BT_USE_NEON +#ifdef B3_USE_NEON #include -typedef float32x4_t btSimdFloat4; -#define BT_INFINITY INFINITY -#define BT_NAN NAN -#define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3} +typedef float32x4_t b3SimdFloat4; +#define B3_INFINITY INFINITY +#define B3_NAN NAN +#define b3Assign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3} #endif -#define BT_DECLARE_ALIGNED_ALLOCATOR() \ - SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \ +#define B3_DECLARE_ALIGNED_ALLOCATOR() \ + SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \ + SIMD_FORCE_INLINE void operator delete(void* ptr) { b3AlignedFree(ptr); } \ SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ SIMD_FORCE_INLINE void operator delete(void*, void*) { } \ - SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \ - SIMD_FORCE_INLINE void operator delete[](void* ptr) { btAlignedFree(ptr); } \ + SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return b3AlignedAlloc(sizeInBytes,16); } \ + SIMD_FORCE_INLINE void operator delete[](void* ptr) { b3AlignedFree(ptr); } \ SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \ SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \ -#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS) +#if defined(B3_USE_DOUBLE_PRECISION) || defined(B3_FORCE_DOUBLE_FUNCTIONS) -SIMD_FORCE_INLINE b3Scalar btSqrt(b3Scalar x) { return sqrt(x); } -SIMD_FORCE_INLINE b3Scalar btFabs(b3Scalar x) { return fabs(x); } -SIMD_FORCE_INLINE b3Scalar btCos(b3Scalar x) { return cos(x); } -SIMD_FORCE_INLINE b3Scalar btSin(b3Scalar x) { return sin(x); } -SIMD_FORCE_INLINE b3Scalar btTan(b3Scalar x) { return tan(x); } -SIMD_FORCE_INLINE b3Scalar btAcos(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return acos(x); } -SIMD_FORCE_INLINE b3Scalar btAsin(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return asin(x); } -SIMD_FORCE_INLINE b3Scalar btAtan(b3Scalar x) { return atan(x); } -SIMD_FORCE_INLINE b3Scalar btAtan2(b3Scalar x, b3Scalar y) { return atan2(x, y); } -SIMD_FORCE_INLINE b3Scalar btExp(b3Scalar x) { return exp(x); } -SIMD_FORCE_INLINE b3Scalar btLog(b3Scalar x) { return log(x); } -SIMD_FORCE_INLINE b3Scalar btPow(b3Scalar x,b3Scalar y) { return pow(x,y); } -SIMD_FORCE_INLINE b3Scalar btFmod(b3Scalar x,b3Scalar y) { return fmod(x,y); } +SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar x) { return sqrt(x); } +SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabs(x); } +SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cos(x); } +SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sin(x); } +SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tan(x); } +SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return acos(x); } +SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return asin(x); } +SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atan(x); } +SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2(x, y); } +SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return exp(x); } +SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return log(x); } +SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return pow(x,y); } +SIMD_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmod(x,y); } #else -SIMD_FORCE_INLINE b3Scalar btSqrt(b3Scalar y) +SIMD_FORCE_INLINE b3Scalar b3Sqrt(b3Scalar y) { #ifdef USE_APPROXIMATION double x, z, tempf; @@ -375,30 +375,30 @@ SIMD_FORCE_INLINE b3Scalar btSqrt(b3Scalar y) return sqrtf(y); #endif } -SIMD_FORCE_INLINE b3Scalar btFabs(b3Scalar x) { return fabsf(x); } -SIMD_FORCE_INLINE b3Scalar btCos(b3Scalar x) { return cosf(x); } -SIMD_FORCE_INLINE b3Scalar btSin(b3Scalar x) { return sinf(x); } -SIMD_FORCE_INLINE b3Scalar btTan(b3Scalar x) { return tanf(x); } -SIMD_FORCE_INLINE b3Scalar btAcos(b3Scalar x) { +SIMD_FORCE_INLINE b3Scalar b3Fabs(b3Scalar x) { return fabsf(x); } +SIMD_FORCE_INLINE b3Scalar b3Cos(b3Scalar x) { return cosf(x); } +SIMD_FORCE_INLINE b3Scalar b3Sin(b3Scalar x) { return sinf(x); } +SIMD_FORCE_INLINE b3Scalar b3Tan(b3Scalar x) { return tanf(x); } +SIMD_FORCE_INLINE b3Scalar b3Acos(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return acosf(x); } -SIMD_FORCE_INLINE b3Scalar btAsin(b3Scalar x) { +SIMD_FORCE_INLINE b3Scalar b3Asin(b3Scalar x) { if (xb3Scalar(1)) x=b3Scalar(1); return asinf(x); } -SIMD_FORCE_INLINE b3Scalar btAtan(b3Scalar x) { return atanf(x); } -SIMD_FORCE_INLINE b3Scalar btAtan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); } -SIMD_FORCE_INLINE b3Scalar btExp(b3Scalar x) { return expf(x); } -SIMD_FORCE_INLINE b3Scalar btLog(b3Scalar x) { return logf(x); } -SIMD_FORCE_INLINE b3Scalar btPow(b3Scalar x,b3Scalar y) { return powf(x,y); } -SIMD_FORCE_INLINE b3Scalar btFmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); } +SIMD_FORCE_INLINE b3Scalar b3Atan(b3Scalar x) { return atanf(x); } +SIMD_FORCE_INLINE b3Scalar b3Atan2(b3Scalar x, b3Scalar y) { return atan2f(x, y); } +SIMD_FORCE_INLINE b3Scalar b3Exp(b3Scalar x) { return expf(x); } +SIMD_FORCE_INLINE b3Scalar b3Log(b3Scalar x) { return logf(x); } +SIMD_FORCE_INLINE b3Scalar b3Pow(b3Scalar x,b3Scalar y) { return powf(x,y); } +SIMD_FORCE_INLINE b3Scalar b3Fmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); } #endif @@ -409,10 +409,10 @@ SIMD_FORCE_INLINE b3Scalar btFmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); } #define SIMD_DEGS_PER_RAD (b3Scalar(360.0) / SIMD_2_PI) #define SIMDSQRT12 b3Scalar(0.7071067811865475244008443621048490) -#define btRecipSqrt(x) ((b3Scalar)(b3Scalar(1.0)/btSqrt(b3Scalar(x)))) /* reciprocal square root */ +#define b3RecipSqrt(x) ((b3Scalar)(b3Scalar(1.0)/b3Sqrt(b3Scalar(x)))) /* reciprocal square root */ -#ifdef BT_USE_DOUBLE_PRECISION +#ifdef B3_USE_DOUBLE_PRECISION #define SIMD_EPSILON DBL_EPSILON #define SIMD_INFINITY DBL_MAX #else @@ -420,11 +420,11 @@ SIMD_FORCE_INLINE b3Scalar btFmod(b3Scalar x,b3Scalar y) { return fmodf(x,y); } #define SIMD_INFINITY FLT_MAX #endif -SIMD_FORCE_INLINE b3Scalar btAtan2Fast(b3Scalar y, b3Scalar x) +SIMD_FORCE_INLINE b3Scalar b3Atan2Fast(b3Scalar y, b3Scalar x) { b3Scalar coeff_1 = SIMD_PI / 4.0f; b3Scalar coeff_2 = 3.0f * coeff_1; - b3Scalar abs_y = btFabs(y); + b3Scalar abs_y = b3Fabs(y); b3Scalar angle; if (x >= 0.0f) { b3Scalar r = (x - abs_y) / (x + abs_y); @@ -436,35 +436,35 @@ SIMD_FORCE_INLINE b3Scalar btAtan2Fast(b3Scalar y, b3Scalar x) return (y < 0.0f) ? -angle : angle; } -SIMD_FORCE_INLINE bool btFuzzyZero(b3Scalar x) { return btFabs(x) < SIMD_EPSILON; } +SIMD_FORCE_INLINE bool b3FuzzyZero(b3Scalar x) { return b3Fabs(x) < SIMD_EPSILON; } -SIMD_FORCE_INLINE bool btEqual(b3Scalar a, b3Scalar eps) { +SIMD_FORCE_INLINE bool b3Equal(b3Scalar a, b3Scalar eps) { return (((a) <= eps) && !((a) < -eps)); } -SIMD_FORCE_INLINE bool btGreaterEqual (b3Scalar a, b3Scalar eps) { +SIMD_FORCE_INLINE bool b3GreaterEqual (b3Scalar a, b3Scalar eps) { return (!((a) <= eps)); } -SIMD_FORCE_INLINE int btIsNegative(b3Scalar x) { +SIMD_FORCE_INLINE int b3IsNegative(b3Scalar x) { return x < b3Scalar(0.0) ? 1 : 0; } -SIMD_FORCE_INLINE b3Scalar btRadians(b3Scalar x) { return x * SIMD_RADS_PER_DEG; } -SIMD_FORCE_INLINE b3Scalar btDegrees(b3Scalar x) { return x * SIMD_DEGS_PER_RAD; } +SIMD_FORCE_INLINE b3Scalar b3Radians(b3Scalar x) { return x * SIMD_RADS_PER_DEG; } +SIMD_FORCE_INLINE b3Scalar b3Degrees(b3Scalar x) { return x * SIMD_DEGS_PER_RAD; } -#define BT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name +#define B3_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name -#ifndef btFsel -SIMD_FORCE_INLINE b3Scalar btFsel(b3Scalar a, b3Scalar b, b3Scalar c) +#ifndef b3Fsel +SIMD_FORCE_INLINE b3Scalar b3Fsel(b3Scalar a, b3Scalar b, b3Scalar c) { return a >= 0 ? b : c; } #endif -#define btFsels(a,b,c) (b3Scalar)btFsel(a,b,c) +#define b3Fsels(a,b,c) (b3Scalar)b3Fsel(a,b,c) -SIMD_FORCE_INLINE bool btMachineIsLittleEndian() +SIMD_FORCE_INLINE bool b3MachineIsLittleEndian() { long int i = 1; const char *p = (const char *) &i; @@ -476,9 +476,9 @@ SIMD_FORCE_INLINE bool btMachineIsLittleEndian() -///btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 +///b3Select avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 ///Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html -SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) +SIMD_FORCE_INLINE unsigned b3Select(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero) { // Set testNz to 0xFFFFFFFF if condition is nonzero, 0x00000000 if condition is zero // Rely on positive value or'ed with its negative having sign bit on @@ -488,22 +488,22 @@ SIMD_FORCE_INLINE unsigned btSelect(unsigned condition, unsigned valueIfConditio unsigned testEqz = ~testNz; return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); } -SIMD_FORCE_INLINE int btSelect(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero) +SIMD_FORCE_INLINE int b3Select(unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero) { unsigned testNz = (unsigned)(((int)condition | -(int)condition) >> 31); unsigned testEqz = ~testNz; return static_cast((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz)); } -SIMD_FORCE_INLINE float btSelect(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero) +SIMD_FORCE_INLINE float b3Select(unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero) { -#ifdef BT_HAVE_NATIVE_FSEL - return (float)btFsel((b3Scalar)condition - b3Scalar(1.0f), valueIfConditionNonZero, valueIfConditionZero); +#ifdef B3_HAVE_NATIVE_FSEL + return (float)b3Fsel((b3Scalar)condition - b3Scalar(1.0f), valueIfConditionNonZero, valueIfConditionZero); #else return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero; #endif } -template SIMD_FORCE_INLINE void btSwap(T& a, T& b) +template SIMD_FORCE_INLINE void b3Swap(T& a, T& b) { T tmp = a; a = b; @@ -512,33 +512,33 @@ template SIMD_FORCE_INLINE void btSwap(T& a, T& b) //PCK: endian swapping functions -SIMD_FORCE_INLINE unsigned btSwapEndian(unsigned val) +SIMD_FORCE_INLINE unsigned b3SwapEndian(unsigned val) { return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24)); } -SIMD_FORCE_INLINE unsigned short btSwapEndian(unsigned short val) +SIMD_FORCE_INLINE unsigned short b3SwapEndian(unsigned short val) { return static_cast(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8)); } -SIMD_FORCE_INLINE unsigned btSwapEndian(int val) +SIMD_FORCE_INLINE unsigned b3SwapEndian(int val) { - return btSwapEndian((unsigned)val); + return b3SwapEndian((unsigned)val); } -SIMD_FORCE_INLINE unsigned short btSwapEndian(short val) +SIMD_FORCE_INLINE unsigned short b3SwapEndian(short val) { - return btSwapEndian((unsigned short) val); + return b3SwapEndian((unsigned short) val); } -///btSwapFloat uses using char pointers to swap the endianness -////btSwapFloat/btSwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values +///b3SwapFloat uses using char pointers to swap the endianness +////b3SwapFloat/b3SwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values ///Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. ///When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. ///In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. ///so instead of returning a float/double, we return integer/long long integer -SIMD_FORCE_INLINE unsigned int btSwapEndianFloat(float d) +SIMD_FORCE_INLINE unsigned int b3SwapEndianFloat(float d) { unsigned int a = 0; unsigned char *dst = (unsigned char *)&a; @@ -552,7 +552,7 @@ SIMD_FORCE_INLINE unsigned int btSwapEndianFloat(float d) } // unswap using char pointers -SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a) +SIMD_FORCE_INLINE float b3UnswapEndianFloat(unsigned int a) { float d = 0.0f; unsigned char *src = (unsigned char *)&a; @@ -568,7 +568,7 @@ SIMD_FORCE_INLINE float btUnswapEndianFloat(unsigned int a) // swap using char pointers -SIMD_FORCE_INLINE void btSwapEndianDouble(double d, unsigned char* dst) +SIMD_FORCE_INLINE void b3SwapEndianDouble(double d, unsigned char* dst) { unsigned char *src = (unsigned char *)&d; @@ -584,7 +584,7 @@ SIMD_FORCE_INLINE void btSwapEndianDouble(double d, unsigned char* dst) } // unswap using char pointers -SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src) +SIMD_FORCE_INLINE double b3UnswapEndianDouble(const unsigned char *src) { double d = 0.0; unsigned char *dst = (unsigned char *)&d; @@ -602,9 +602,9 @@ SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src) } // returns normalized value in range [-SIMD_PI, SIMD_PI] -SIMD_FORCE_INLINE b3Scalar btNormalizeAngle(b3Scalar angleInRadians) +SIMD_FORCE_INLINE b3Scalar b3NormalizeAngle(b3Scalar angleInRadians) { - angleInRadians = btFmod(angleInRadians, SIMD_2_PI); + angleInRadians = b3Fmod(angleInRadians, SIMD_2_PI); if(angleInRadians < -SIMD_PI) { return angleInRadians + SIMD_2_PI; @@ -620,9 +620,9 @@ SIMD_FORCE_INLINE b3Scalar btNormalizeAngle(b3Scalar angleInRadians) } ///rudimentary class to provide type info -struct btTypedObject +struct b3TypedObject { - btTypedObject(int objectType) + b3TypedObject(int objectType) :m_objectType(objectType) { } @@ -636,10 +636,10 @@ struct btTypedObject ///align a pointer to the provided alignment, upwards -template T* btAlignPointer(T* unalignedPtr, size_t alignment) +template T* b3AlignPointer(T* unalignedPtr, size_t alignment) { - struct btConvertPointerSizeT + struct b3ConvertPointerSizeT { union { @@ -647,7 +647,7 @@ template T* btAlignPointer(T* unalignedPtr, size_t alignment) size_t integer; }; }; - btConvertPointerSizeT converter; + b3ConvertPointerSizeT converter; const size_t bit_mask = ~(alignment - 1); @@ -657,4 +657,4 @@ template T* btAlignPointer(T* unalignedPtr, size_t alignment) return converter.ptr; } -#endif //BT_SCALAR_H +#endif //B3_SCALAR_H diff --git a/src/Bullet3Common/b3StackAlloc.h b/src/Bullet3Common/b3StackAlloc.h index 00f75593f..6443cf48f 100644 --- a/src/Bullet3Common/b3StackAlloc.h +++ b/src/Bullet3Common/b3StackAlloc.h @@ -17,16 +17,16 @@ StackAlloc extracted from GJK-EPA collision solver by Nathanael Presson Nov.2006 */ -#ifndef BT_STACK_ALLOC -#define BT_STACK_ALLOC +#ifndef B3_STACK_ALLOC +#define B3_STACK_ALLOC -#include "b3Scalar.h" //for btAssert +#include "b3Scalar.h" //for b3Assert #include "b3AlignedAllocator.h" -///The btBlock class is an internal structure for the b3StackAlloc memory allocator. -struct btBlock +///The b3Block class is an internal structure for the b3StackAlloc memory allocator. +struct b3Block { - btBlock* previous; + b3Block* previous; unsigned char* address; }; @@ -41,18 +41,18 @@ public: inline void create(unsigned int size) { destroy(); - data = (unsigned char*) btAlignedAlloc(size,16); + data = (unsigned char*) b3AlignedAlloc(size,16); totalsize = size; } inline void destroy() { - btAssert(usedsize==0); + b3Assert(usedsize==0); //Raise(L"StackAlloc is still in use"); if(usedsize==0) { if(!ischild && data) - btAlignedFree(data); + b3AlignedFree(data); data = 0; usedsize = 0; @@ -73,27 +73,27 @@ public: usedsize=nus; return(data+(usedsize-size)); } - btAssert(0); + b3Assert(0); //&& (L"Not enough memory")); return(0); } - SIMD_FORCE_INLINE btBlock* beginBlock() + SIMD_FORCE_INLINE b3Block* beginBlock() { - btBlock* pb = (btBlock*)allocate(sizeof(btBlock)); + b3Block* pb = (b3Block*)allocate(sizeof(b3Block)); pb->previous = current; pb->address = data+usedsize; current = pb; return(pb); } - SIMD_FORCE_INLINE void endBlock(btBlock* block) + SIMD_FORCE_INLINE void endBlock(b3Block* block) { - btAssert(block==current); + b3Assert(block==current); //Raise(L"Unmatched blocks"); if(block==current) { current = block->previous; - usedsize = (unsigned int)((block->address-data)-sizeof(btBlock)); + usedsize = (unsigned int)((block->address-data)-sizeof(b3Block)); } } @@ -109,8 +109,8 @@ private: unsigned char* data; unsigned int totalsize; unsigned int usedsize; - btBlock* current; + b3Block* current; bool ischild; }; -#endif //BT_STACK_ALLOC +#endif //B3_STACK_ALLOC diff --git a/src/Bullet3Common/b3Transform.h b/src/Bullet3Common/b3Transform.h index 90284fa62..7a1921313 100644 --- a/src/Bullet3Common/b3Transform.h +++ b/src/Bullet3Common/b3Transform.h @@ -14,16 +14,16 @@ subject to the following restrictions: -#ifndef BT_TRANSFORM_H -#define BT_TRANSFORM_H +#ifndef B3_TRANSFORM_H +#define B3_TRANSFORM_H #include "b3Matrix3x3.h" -#ifdef BT_USE_DOUBLE_PRECISION -#define btTransformData btTransformDoubleData +#ifdef B3_USE_DOUBLE_PRECISION +#define b3TransformData b3TransformDoubleData #else -#define btTransformData btTransformFloatData +#define b3TransformData b3TransformFloatData #endif @@ -85,7 +85,7 @@ public: /* void multInverseLeft(const b3Transform& t1, const b3Transform& t2) { b3Vector3 v = t2.m_origin - t1.m_origin; - m_basis = btMultTransposeLeft(t1.m_basis, t2.m_basis); + m_basis = b3MultTransposeLeft(t1.m_basis, t2.m_basis); m_origin = v * t1.m_basis; } */ @@ -206,15 +206,15 @@ public: return identityTransform; } - void serialize(struct btTransformData& dataOut) const; + void serialize(struct b3TransformData& dataOut) const; - void serializeFloat(struct btTransformFloatData& dataOut) const; + void serializeFloat(struct b3TransformFloatData& dataOut) const; - void deSerialize(const struct btTransformData& dataIn); + void deSerialize(const struct b3TransformData& dataIn); - void deSerializeDouble(const struct btTransformDoubleData& dataIn); + void deSerializeDouble(const struct b3TransformDoubleData& dataIn); - void deSerializeFloat(const struct btTransformFloatData& dataIn); + void deSerializeFloat(const struct b3TransformFloatData& dataIn); }; @@ -250,53 +250,53 @@ SIMD_FORCE_INLINE bool operator==(const b3Transform& t1, const b3Transform& t2) ///for serialization -struct btTransformFloatData +struct b3TransformFloatData { - btMatrix3x3FloatData m_basis; - btVector3FloatData m_origin; + b3Matrix3x3FloatData m_basis; + b3Vector3FloatData m_origin; }; -struct btTransformDoubleData +struct b3TransformDoubleData { - btMatrix3x3DoubleData m_basis; - btVector3DoubleData m_origin; + b3Matrix3x3DoubleData m_basis; + b3Vector3DoubleData m_origin; }; -SIMD_FORCE_INLINE void b3Transform::serialize(btTransformData& dataOut) const +SIMD_FORCE_INLINE void b3Transform::serialize(b3TransformData& dataOut) const { m_basis.serialize(dataOut.m_basis); m_origin.serialize(dataOut.m_origin); } -SIMD_FORCE_INLINE void b3Transform::serializeFloat(btTransformFloatData& dataOut) const +SIMD_FORCE_INLINE void b3Transform::serializeFloat(b3TransformFloatData& dataOut) const { m_basis.serializeFloat(dataOut.m_basis); m_origin.serializeFloat(dataOut.m_origin); } -SIMD_FORCE_INLINE void b3Transform::deSerialize(const btTransformData& dataIn) +SIMD_FORCE_INLINE void b3Transform::deSerialize(const b3TransformData& dataIn) { m_basis.deSerialize(dataIn.m_basis); m_origin.deSerialize(dataIn.m_origin); } -SIMD_FORCE_INLINE void b3Transform::deSerializeFloat(const btTransformFloatData& dataIn) +SIMD_FORCE_INLINE void b3Transform::deSerializeFloat(const b3TransformFloatData& dataIn) { m_basis.deSerializeFloat(dataIn.m_basis); m_origin.deSerializeFloat(dataIn.m_origin); } -SIMD_FORCE_INLINE void b3Transform::deSerializeDouble(const btTransformDoubleData& dataIn) +SIMD_FORCE_INLINE void b3Transform::deSerializeDouble(const b3TransformDoubleData& dataIn) { m_basis.deSerializeDouble(dataIn.m_basis); m_origin.deSerializeDouble(dataIn.m_origin); } -#endif //BT_TRANSFORM_H +#endif //B3_TRANSFORM_H diff --git a/src/Bullet3Common/b3TransformUtil.h b/src/Bullet3Common/b3TransformUtil.h index 99df37791..157138b63 100644 --- a/src/Bullet3Common/b3TransformUtil.h +++ b/src/Bullet3Common/b3TransformUtil.h @@ -13,8 +13,8 @@ subject to the following restrictions: */ -#ifndef BT_TRANSFORM_UTIL_H -#define BT_TRANSFORM_UTIL_H +#ifndef B3_TRANSFORM_UTIL_H +#define B3_TRANSFORM_UTIL_H #include "b3Transform.h" #define ANGULAR_MOTION_THRESHOLD b3Scalar(0.5)*SIMD_HALF_PI @@ -22,7 +22,7 @@ subject to the following restrictions: -SIMD_FORCE_INLINE b3Vector3 btAabbSupport(const b3Vector3& halfExtents,const b3Vector3& supportDir) +SIMD_FORCE_INLINE b3Vector3 b3AabbSupport(const b3Vector3& halfExtents,const b3Vector3& supportDir) { return b3Vector3(supportDir.getX() < b3Scalar(0.0) ? -halfExtents.getX() : halfExtents.getX(), supportDir.getY() < b3Scalar(0.0) ? -halfExtents.getY() : halfExtents.getY(), @@ -68,9 +68,9 @@ public: else { // sync(fAngle) = sin(c*fAngle)/t - axis = angvel*( btSin(b3Scalar(0.5)*fAngle*timeStep)/fAngle ); + axis = angvel*( b3Sin(b3Scalar(0.5)*fAngle*timeStep)/fAngle ); } - b3Quaternion dorn (axis.getX(),axis.getY(),axis.getZ(),btCos( fAngle*timeStep*b3Scalar(0.5) )); + b3Quaternion dorn (axis.getX(),axis.getY(),axis.getZ(),b3Cos( fAngle*timeStep*b3Scalar(0.5) )); b3Quaternion orn0 = curTrans.getRotation(); b3Quaternion predictedOrn = dorn * orn0; @@ -106,7 +106,7 @@ public: if (len < SIMD_EPSILON*SIMD_EPSILON) axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.)); else - axis /= btSqrt(len); + axis /= b3Sqrt(len); } static void calculateVelocity(const b3Transform& transform0,const b3Transform& transform1,b3Scalar timeStep,b3Vector3& linVel,b3Vector3& angVel) @@ -135,15 +135,15 @@ public: if (len < SIMD_EPSILON*SIMD_EPSILON) axis = b3Vector3(b3Scalar(1.),b3Scalar(0.),b3Scalar(0.)); else - axis /= btSqrt(len); + axis /= b3Sqrt(len); } }; -///The btConvexSeparatingDistanceUtil can help speed up convex collision detection +///The b3ConvexSeparatingDistanceUtil can help speed up convex collision detection ///by conservatively updating a cached separating distance/vector instead of re-calculating the closest distance -class btConvexSeparatingDistanceUtil +class b3ConvexSeparatingDistanceUtil { b3Quaternion m_ornA; b3Quaternion m_ornB; @@ -158,7 +158,7 @@ class btConvexSeparatingDistanceUtil public: - btConvexSeparatingDistanceUtil(b3Scalar boundingRadiusA,b3Scalar boundingRadiusB) + b3ConvexSeparatingDistanceUtil(b3Scalar boundingRadiusA,b3Scalar boundingRadiusB) :m_boundingRadiusA(boundingRadiusA), m_boundingRadiusB(boundingRadiusB), m_separatingDistance(0.f) @@ -224,5 +224,5 @@ public: }; -#endif //BT_TRANSFORM_UTIL_H +#endif //B3_TRANSFORM_UTIL_H diff --git a/src/Bullet3Common/b3Vector3.cpp b/src/Bullet3Common/b3Vector3.cpp index 46df728cf..e8d4f4ddd 100644 --- a/src/Bullet3Common/b3Vector3.cpp +++ b/src/Bullet3Common/b3Vector3.cpp @@ -16,12 +16,12 @@ */ #if defined (_WIN32) || defined (__i386__) -#define BT_USE_SSE_IN_API +#define B3_USE_SSE_IN_API #endif #include "b3Vector3.h" -#if defined (BT_USE_SSE) || defined (BT_USE_NEON) +#if defined (B3_USE_SSE) || defined (B3_USE_NEON) #ifdef __APPLE__ #include @@ -32,7 +32,7 @@ typedef float float4 __attribute__ ((vector_size(16))); //typedef uint32_t uint4 __attribute__ ((vector_size(16))); -#if defined BT_USE_SSE || defined _WIN32 +#if defined B3_USE_SSE || defined _WIN32 #define LOG2_ARRAY_SIZE 6 #define STACK_ARRAY_COUNT (1UL << LOG2_ARRAY_SIZE) @@ -44,9 +44,9 @@ long _maxdot_large( const float *vv, const float *vec, unsigned long count, floa { const float4 *vertices = (const float4*) vv; static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; - float4 dotMax = btAssign128( -BT_INFINITY, -BT_INFINITY, -BT_INFINITY, -BT_INFINITY ); + float4 dotMax = b3Assign128( -B3_INFINITY, -B3_INFINITY, -B3_INFINITY, -B3_INFINITY ); float4 vvec = _mm_loadu_ps( vec ); - float4 vHi = btCastiTo128f(_mm_shuffle_epi32( btCastfTo128i( vvec), 0xaa )); /// zzzz + float4 vHi = b3CastiTo128f(_mm_shuffle_epi32( b3CastfTo128i( vvec), 0xaa )); /// zzzz float4 vLo = _mm_movelh_ps( vvec, vvec ); /// xyxy long maxIndex = -1L; @@ -180,7 +180,7 @@ long _maxdot_large( const float *vv, const float *vec, unsigned long count, floa index = 0; - if( btUnlikely( count > 16) ) + if( b3Unlikely( count > 16) ) { for( ; index + 4 <= count / 4; index+=4 ) { // do four dot products at a time. Carefully avoid touching the w element. @@ -429,9 +429,9 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa { const float4 *vertices = (const float4*) vv; static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; - float4 dotmin = btAssign128( BT_INFINITY, BT_INFINITY, BT_INFINITY, BT_INFINITY ); + float4 dotmin = b3Assign128( B3_INFINITY, B3_INFINITY, B3_INFINITY, B3_INFINITY ); float4 vvec = _mm_loadu_ps( vec ); - float4 vHi = btCastiTo128f(_mm_shuffle_epi32( btCastfTo128i( vvec), 0xaa )); /// zzzz + float4 vHi = b3CastiTo128f(_mm_shuffle_epi32( b3CastfTo128i( vvec), 0xaa )); /// zzzz float4 vLo = _mm_movelh_ps( vvec, vvec ); /// xyxy long minIndex = -1L; @@ -565,7 +565,7 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa index = 0; - if(btUnlikely( count > 16) ) + if(b3Unlikely( count > 16) ) { for( ; index + 4 <= count / 4; index+=4 ) { // do four dot products at a time. Carefully avoid touching the w element. @@ -812,7 +812,7 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa } -#elif defined BT_USE_NEON +#elif defined B3_USE_NEON #define ARM_NEON_GCC_COMPATIBILITY 1 #include @@ -860,8 +860,8 @@ long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, f float32x4_t vvec = vld1q_f32_aligned_postincrement( vec ); float32x2_t vLo = vget_low_f32(vvec); float32x2_t vHi = vdup_lane_f32(vget_high_f32(vvec), 0); - float32x2_t dotMaxLo = (float32x2_t) { -BT_INFINITY, -BT_INFINITY }; - float32x2_t dotMaxHi = (float32x2_t) { -BT_INFINITY, -BT_INFINITY }; + float32x2_t dotMaxLo = (float32x2_t) { -B3_INFINITY, -B3_INFINITY }; + float32x2_t dotMaxHi = (float32x2_t) { -B3_INFINITY, -B3_INFINITY }; uint32x2_t indexLo = (uint32x2_t) {0, 1}; uint32x2_t indexHi = (uint32x2_t) {2, 3}; uint32x2_t iLo = (uint32x2_t) {-1, -1}; @@ -1052,7 +1052,7 @@ long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, f const uint32x4_t four = (uint32x4_t){ 4, 4, 4, 4 }; uint32x4_t local_index = (uint32x4_t) {0, 1, 2, 3}; uint32x4_t index = (uint32x4_t) { -1, -1, -1, -1 }; - float32x4_t maxDot = (float32x4_t) { -BT_INFINITY, -BT_INFINITY, -BT_INFINITY, -BT_INFINITY }; + float32x4_t maxDot = (float32x4_t) { -B3_INFINITY, -B3_INFINITY, -B3_INFINITY, -B3_INFINITY }; unsigned long i = 0; for( ; i + 8 <= count; i += 8 ) @@ -1245,8 +1245,8 @@ long _mindot_large_v0( const float *vv, const float *vec, unsigned long count, f float32x4_t vvec = vld1q_f32_aligned_postincrement( vec ); float32x2_t vLo = vget_low_f32(vvec); float32x2_t vHi = vdup_lane_f32(vget_high_f32(vvec), 0); - float32x2_t dotMinLo = (float32x2_t) { BT_INFINITY, BT_INFINITY }; - float32x2_t dotMinHi = (float32x2_t) { BT_INFINITY, BT_INFINITY }; + float32x2_t dotMinLo = (float32x2_t) { B3_INFINITY, B3_INFINITY }; + float32x2_t dotMinHi = (float32x2_t) { B3_INFINITY, B3_INFINITY }; uint32x2_t indexLo = (uint32x2_t) {0, 1}; uint32x2_t indexHi = (uint32x2_t) {2, 3}; uint32x2_t iLo = (uint32x2_t) {-1, -1}; @@ -1435,7 +1435,7 @@ long _mindot_large_v1( const float *vv, const float *vec, unsigned long count, f const uint32x4_t four = (uint32x4_t){ 4, 4, 4, 4 }; uint32x4_t local_index = (uint32x4_t) {0, 1, 2, 3}; uint32x4_t index = (uint32x4_t) { -1, -1, -1, -1 }; - float32x4_t minDot = (float32x4_t) { BT_INFINITY, BT_INFINITY, BT_INFINITY, BT_INFINITY }; + float32x4_t minDot = (float32x4_t) { B3_INFINITY, B3_INFINITY, B3_INFINITY, B3_INFINITY }; unsigned long i = 0; for( ; i + 8 <= count; i += 8 ) diff --git a/src/Bullet3Common/b3Vector3.h b/src/Bullet3Common/b3Vector3.h index e6fa49c90..3188efbf4 100644 --- a/src/Bullet3Common/b3Vector3.h +++ b/src/Bullet3Common/b3Vector3.h @@ -14,23 +14,23 @@ subject to the following restrictions: -#ifndef BT_VECTOR3_H -#define BT_VECTOR3_H +#ifndef B3_VECTOR3_H +#define B3_VECTOR3_H //#include #include "b3Scalar.h" #include "b3MinMax.h" #include "b3AlignedAllocator.h" -#ifdef BT_USE_DOUBLE_PRECISION -#define btVector3Data btVector3DoubleData -#define btVector3DataName "btVector3DoubleData" +#ifdef B3_USE_DOUBLE_PRECISION +#define b3Vector3Data b3Vector3DoubleData +#define b3Vector3DataName "b3Vector3DoubleData" #else -#define btVector3Data btVector3FloatData -#define btVector3DataName "btVector3FloatData" -#endif //BT_USE_DOUBLE_PRECISION +#define b3Vector3Data b3Vector3FloatData +#define b3Vector3DataName "b3Vector3FloatData" +#endif //B3_USE_DOUBLE_PRECISION -#if defined BT_USE_SSE +#if defined B3_USE_SSE //typedef uint32_t __m128i __attribute__ ((vector_size(16))); @@ -39,35 +39,35 @@ subject to the following restrictions: #endif -#define BT_SHUFFLE(x,y,z,w) ((w)<<6 | (z)<<4 | (y)<<2 | (x)) -//#define bt_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) ) -#define bt_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) ) -#define bt_splat3_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i, 3) ) -#define bt_splat_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i,_i) ) +#define B3_SHUFFLE(x,y,z,w) ((w)<<6 | (z)<<4 | (y)<<2 | (x)) +//#define b3_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) ) +#define b3_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) ) +#define b3_splat3_ps( _a, _i ) b3_pshufd_ps((_a), B3_SHUFFLE(_i,_i,_i, 3) ) +#define b3_splat_ps( _a, _i ) b3_pshufd_ps((_a), B3_SHUFFLE(_i,_i,_i,_i) ) -#define btv3AbsiMask (_mm_set_epi32(0x00000000, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF)) -#define btvAbsMask (_mm_set_epi32( 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF)) -#define btvFFF0Mask (_mm_set_epi32(0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF)) -#define btv3AbsfMask btCastiTo128f(btv3AbsiMask) -#define btvFFF0fMask btCastiTo128f(btvFFF0Mask) -#define btvxyzMaskf btvFFF0fMask -#define btvAbsfMask btCastiTo128f(btvAbsMask) +#define b3v3AbsiMask (_mm_set_epi32(0x00000000, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF)) +#define b3vAbsMask (_mm_set_epi32( 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF)) +#define b3vFFF0Mask (_mm_set_epi32(0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF)) +#define b3v3AbsfMask b3CastiTo128f(b3v3AbsiMask) +#define b3vFFF0fMask b3CastiTo128f(b3vFFF0Mask) +#define b3vxyzMaskf b3vFFF0fMask +#define b3vAbsfMask b3CastiTo128f(b3vAbsMask) -const __m128 ATTRIBUTE_ALIGNED16(btvMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f}; +const __m128 ATTRIBUTE_ALIGNED16(b3vMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f}; const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f}; const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f}; const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f}; #endif -#ifdef BT_USE_NEON +#ifdef B3_USE_NEON -const float32x4_t ATTRIBUTE_ALIGNED16(btvMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f}; -const int32x4_t ATTRIBUTE_ALIGNED16(btvFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0}; -const int32x4_t ATTRIBUTE_ALIGNED16(btvAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; -const int32x4_t ATTRIBUTE_ALIGNED16(btv3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0}; +const float32x4_t ATTRIBUTE_ALIGNED16(b3vMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f}; +const int32x4_t ATTRIBUTE_ALIGNED16(b3vFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0}; +const int32x4_t ATTRIBUTE_ALIGNED16(b3vAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; +const int32x4_t ATTRIBUTE_ALIGNED16(b3v3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0}; #endif @@ -79,7 +79,7 @@ ATTRIBUTE_ALIGNED16(class) b3Vector3 { public: - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); #if defined (__SPU__) && defined (__CELLOS_LV2__) b3Scalar m_floats[4]; @@ -90,18 +90,18 @@ public: } public: #else //__CELLOS_LV2__ __SPU__ - #if defined (BT_USE_SSE) || defined(BT_USE_NEON) // _WIN32 || ARM + #if defined (B3_USE_SSE) || defined(B3_USE_NEON) // _WIN32 || ARM union { - btSimdFloat4 mVec128; + b3SimdFloat4 mVec128; b3Scalar m_floats[4]; struct {b3Scalar x,y,z,w;}; }; - SIMD_FORCE_INLINE btSimdFloat4 get128() const + SIMD_FORCE_INLINE b3SimdFloat4 get128() const { return mVec128; } - SIMD_FORCE_INLINE void set128(btSimdFloat4 v128) + SIMD_FORCE_INLINE void set128(b3SimdFloat4 v128) { mVec128 = v128; } @@ -133,9 +133,9 @@ public: m_floats[3] = b3Scalar(0.f); } -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) )|| defined (BT_USE_NEON) +#if (defined (B3_USE_SSE_IN_API) && defined (B3_USE_SSE) )|| defined (B3_USE_NEON) // Set Vector - SIMD_FORCE_INLINE b3Vector3( btSimdFloat4 v) + SIMD_FORCE_INLINE b3Vector3( b3SimdFloat4 v) { mVec128 = v; } @@ -154,15 +154,15 @@ public: return *this; } -#endif // #if defined (BT_USE_SSE_IN_API) || defined (BT_USE_NEON) +#endif // #if defined (B3_USE_SSE_IN_API) || defined (B3_USE_NEON) /**@brief Add a vector to this one * @param The vector to add to this one */ SIMD_FORCE_INLINE b3Vector3& operator+=(const b3Vector3& v) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_add_ps(mVec128, v.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vaddq_f32(mVec128, v.mVec128); #else m_floats[0] += v.m_floats[0]; @@ -177,9 +177,9 @@ public: * @param The vector to subtract */ SIMD_FORCE_INLINE b3Vector3& operator-=(const b3Vector3& v) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_sub_ps(mVec128, v.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vsubq_f32(mVec128, v.mVec128); #else m_floats[0] -= v.m_floats[0]; @@ -193,11 +193,11 @@ public: * @param s Scale factor */ SIMD_FORCE_INLINE b3Vector3& operator*=(const b3Scalar& s) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vs = _mm_load_ss(&s); // (S 0 0 0) - vs = bt_pshufd_ps(vs, 0x80); // (S S S 0.0) + vs = b3_pshufd_ps(vs, 0x80); // (S S S 0.0) mVec128 = _mm_mul_ps(mVec128, vs); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vmulq_n_f32(mVec128, s); #else m_floats[0] *= s; @@ -211,13 +211,13 @@ public: * @param s Scale factor to divide by */ SIMD_FORCE_INLINE b3Vector3& operator/=(const b3Scalar& s) { - btFullAssert(s != b3Scalar(0.0)); + b3FullAssert(s != b3Scalar(0.0)); -#if 0 //defined(BT_USE_SSE_IN_API) +#if 0 //defined(B3_USE_SSE_IN_API) // this code is not faster ! __m128 vs = _mm_load_ss(&s); vs = _mm_div_ss(v1110, vs); - vs = bt_pshufd_ps(vs, 0x00); // (S S S S) + vs = b3_pshufd_ps(vs, 0x00); // (S S S S) mVec128 = _mm_mul_ps(mVec128, vs); @@ -231,14 +231,14 @@ public: * @param v The other vector in the dot product */ SIMD_FORCE_INLINE b3Scalar dot(const b3Vector3& v) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vd = _mm_mul_ps(mVec128, v.mVec128); __m128 z = _mm_movehl_ps(vd, vd); __m128 y = _mm_shuffle_ps(vd, vd, 0x55); vd = _mm_add_ss(vd, y); vd = _mm_add_ss(vd, z); return _mm_cvtss_f32(vd); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vd = vmulq_f32(mVec128, v.mVec128); float32x2_t x = vpadd_f32(vget_low_f32(vd), vget_low_f32(vd)); x = vadd_f32(x, vget_high_f32(vd)); @@ -259,7 +259,7 @@ public: /**@brief Return the length of the vector */ SIMD_FORCE_INLINE b3Scalar length() const { - return btSqrt(length2()); + return b3Sqrt(length2()); } /**@brief Return the distance squared between the ends of this and another vector @@ -287,7 +287,7 @@ public: * x^2 + y^2 + z^2 = 1 */ SIMD_FORCE_INLINE b3Vector3& normalize() { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) // dot product first __m128 vd = _mm_mul_ps(mVec128, mVec128); __m128 z = _mm_movehl_ps(vd, vd); @@ -298,7 +298,7 @@ public: #if 0 vd = _mm_sqrt_ss(vd); vd = _mm_div_ss(v1110, vd); - vd = bt_splat_ps(vd, 0x80); + vd = b3_splat_ps(vd, 0x80); mVec128 = _mm_mul_ps(mVec128, vd); #else @@ -315,7 +315,7 @@ public: y = _mm_mul_ss(y, z); // y0 * (1.5 - vd * 0.5 * y0 * y0) - y = bt_splat_ps(y, 0x80); + y = b3_splat_ps(y, 0x80); mVec128 = _mm_mul_ps(mVec128, y); #endif @@ -339,23 +339,23 @@ public: * @param v The other vector */ SIMD_FORCE_INLINE b3Scalar angle(const b3Vector3& v) const { - b3Scalar s = btSqrt(length2() * v.length2()); - btFullAssert(s != b3Scalar(0.0)); - return btAcos(dot(v) / s); + b3Scalar s = b3Sqrt(length2() * v.length2()); + b3FullAssert(s != b3Scalar(0.0)); + return b3Acos(dot(v) / s); } /**@brief Return a vector will the absolute values of each element */ SIMD_FORCE_INLINE b3Vector3 absolute() const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) - return b3Vector3(_mm_and_ps(mVec128, btv3AbsfMask)); -#elif defined(BT_USE_NEON) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) + return b3Vector3(_mm_and_ps(mVec128, b3v3AbsfMask)); +#elif defined(B3_USE_NEON) return b3Vector3(vabsq_f32(mVec128)); #else return b3Vector3( - btFabs(m_floats[0]), - btFabs(m_floats[1]), - btFabs(m_floats[2])); + b3Fabs(m_floats[0]), + b3Fabs(m_floats[1]), + b3Fabs(m_floats[2])); #endif } @@ -363,19 +363,19 @@ public: * @param v The other vector */ SIMD_FORCE_INLINE b3Vector3 cross(const b3Vector3& v) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 T, V; - T = bt_pshufd_ps(mVec128, BT_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) - V = bt_pshufd_ps(v.mVec128, BT_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) + T = b3_pshufd_ps(mVec128, B3_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) + V = b3_pshufd_ps(v.mVec128, B3_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) V = _mm_mul_ps(V, mVec128); T = _mm_mul_ps(T, v.mVec128); V = _mm_sub_ps(V, T); - V = bt_pshufd_ps(V, BT_SHUFFLE(1, 2, 0, 3)); + V = b3_pshufd_ps(V, B3_SHUFFLE(1, 2, 0, 3)); return b3Vector3(V); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t T, V; // form (Y, Z, X, _) of mVec128 and v.mVec128 float32x2_t Tlow = vget_low_f32(mVec128); @@ -389,7 +389,7 @@ public: Vlow = vget_low_f32(V); // form (Y, Z, X, _); V = vcombine_f32(vext_f32(Vlow, vget_high_f32(V), 1), Vlow); - V = (float32x4_t)vandq_s32((int32x4_t)V, btvFFF0Mask); + V = (float32x4_t)vandq_s32((int32x4_t)V, b3vFFF0Mask); return b3Vector3(V); #else @@ -402,16 +402,16 @@ public: SIMD_FORCE_INLINE b3Scalar triple(const b3Vector3& v1, const b3Vector3& v2) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) // cross: - __m128 T = _mm_shuffle_ps(v1.mVec128, v1.mVec128, BT_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) - __m128 V = _mm_shuffle_ps(v2.mVec128, v2.mVec128, BT_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) + __m128 T = _mm_shuffle_ps(v1.mVec128, v1.mVec128, B3_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) + __m128 V = _mm_shuffle_ps(v2.mVec128, v2.mVec128, B3_SHUFFLE(1, 2, 0, 3)); // (Y Z X 0) V = _mm_mul_ps(V, v1.mVec128); T = _mm_mul_ps(T, v2.mVec128); V = _mm_sub_ps(V, T); - V = _mm_shuffle_ps(V, V, BT_SHUFFLE(1, 2, 0, 3)); + V = _mm_shuffle_ps(V, V, B3_SHUFFLE(1, 2, 0, 3)); // dot: V = _mm_mul_ps(V, mVec128); @@ -421,7 +421,7 @@ public: V = _mm_add_ss(V, z); return _mm_cvtss_f32(V); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) // cross: float32x4_t T, V; // form (Y, Z, X, _) of mVec128 and v.mVec128 @@ -477,17 +477,17 @@ public: SIMD_FORCE_INLINE void setInterpolate3(const b3Vector3& v0, const b3Vector3& v1, b3Scalar rt) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vrt = _mm_load_ss(&rt); // (rt 0 0 0) b3Scalar s = b3Scalar(1.0) - rt; __m128 vs = _mm_load_ss(&s); // (S 0 0 0) - vs = bt_pshufd_ps(vs, 0x80); // (S S S 0.0) + vs = b3_pshufd_ps(vs, 0x80); // (S S S 0.0) __m128 r0 = _mm_mul_ps(v0.mVec128, vs); - vrt = bt_pshufd_ps(vrt, 0x80); // (rt rt rt 0.0) + vrt = b3_pshufd_ps(vrt, 0x80); // (rt rt rt 0.0) __m128 r1 = _mm_mul_ps(v1.mVec128, vrt); __m128 tmp3 = _mm_add_ps(r0,r1); mVec128 = tmp3; -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vsubq_f32(v1.mVec128, v0.mVec128); mVec128 = vmulq_n_f32(mVec128, rt); mVec128 = vaddq_f32(mVec128, v0.mVec128); @@ -506,15 +506,15 @@ public: * @param t The ration of this to v (t = 0 => return this, t=1 => return other) */ SIMD_FORCE_INLINE b3Vector3 lerp(const b3Vector3& v, const b3Scalar& t) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vt = _mm_load_ss(&t); // (t 0 0 0) - vt = bt_pshufd_ps(vt, 0x80); // (rt rt rt 0.0) + vt = b3_pshufd_ps(vt, 0x80); // (rt rt rt 0.0) __m128 vl = _mm_sub_ps(v.mVec128, mVec128); vl = _mm_mul_ps(vl, vt); vl = _mm_add_ps(vl, mVec128); return b3Vector3(vl); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t vl = vsubq_f32(v.mVec128, mVec128); vl = vmulq_n_f32(vl, t); vl = vaddq_f32(vl, mVec128); @@ -532,9 +532,9 @@ public: * @param v The other vector */ SIMD_FORCE_INLINE b3Vector3& operator*=(const b3Vector3& v) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_mul_ps(mVec128, v.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vmulq_f32(mVec128, v.mVec128); #else m_floats[0] *= v.m_floats[0]; @@ -570,7 +570,7 @@ public: SIMD_FORCE_INLINE bool operator==(const b3Vector3& other) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return (0xf == _mm_movemask_ps((__m128)_mm_cmpeq_ps(mVec128, other.mVec128))); #else return ((m_floats[3]==other.m_floats[3]) && @@ -590,15 +590,15 @@ public: */ SIMD_FORCE_INLINE void setMax(const b3Vector3& other) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_max_ps(mVec128, other.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vmaxq_f32(mVec128, other.mVec128); #else - btSetMax(m_floats[0], other.m_floats[0]); - btSetMax(m_floats[1], other.m_floats[1]); - btSetMax(m_floats[2], other.m_floats[2]); - btSetMax(m_floats[3], other.m_floats[3]); + b3SetMax(m_floats[0], other.m_floats[0]); + b3SetMax(m_floats[1], other.m_floats[1]); + b3SetMax(m_floats[2], other.m_floats[2]); + b3SetMax(m_floats[3], other.m_floats[3]); #endif } @@ -607,15 +607,15 @@ public: */ SIMD_FORCE_INLINE void setMin(const b3Vector3& other) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = _mm_min_ps(mVec128, other.mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) mVec128 = vminq_f32(mVec128, other.mVec128); #else - btSetMin(m_floats[0], other.m_floats[0]); - btSetMin(m_floats[1], other.m_floats[1]); - btSetMin(m_floats[2], other.m_floats[2]); - btSetMin(m_floats[3], other.m_floats[3]); + b3SetMin(m_floats[0], other.m_floats[0]); + b3SetMin(m_floats[1], other.m_floats[1]); + b3SetMin(m_floats[2], other.m_floats[2]); + b3SetMin(m_floats[3], other.m_floats[3]); #endif } @@ -629,10 +629,10 @@ public: void getSkewSymmetricMatrix(b3Vector3* v0,b3Vector3* v1,b3Vector3* v2) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) - __m128 V = _mm_and_ps(mVec128, btvFFF0fMask); - __m128 V0 = _mm_xor_ps(btvMzeroMask, V); + __m128 V = _mm_and_ps(mVec128, b3vFFF0fMask); + __m128 V0 = _mm_xor_ps(b3vMzeroMask, V); __m128 V2 = _mm_movelh_ps(V0, V); __m128 V1 = _mm_shuffle_ps(V, V0, 0xCE); @@ -652,9 +652,9 @@ public: void setZero() { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) mVec128 = (__m128)_mm_xor_ps(mVec128, mVec128); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) int32x4_t vi = vdupq_n_s32(0); mVec128 = vreinterpretq_f32_s32(vi); #else @@ -672,17 +672,17 @@ public: return length2() < SIMD_EPSILON; } - SIMD_FORCE_INLINE void serialize(struct btVector3Data& dataOut) const; + SIMD_FORCE_INLINE void serialize(struct b3Vector3Data& dataOut) const; - SIMD_FORCE_INLINE void deSerialize(const struct btVector3Data& dataIn); + SIMD_FORCE_INLINE void deSerialize(const struct b3Vector3Data& dataIn); - SIMD_FORCE_INLINE void serializeFloat(struct btVector3FloatData& dataOut) const; + SIMD_FORCE_INLINE void serializeFloat(struct b3Vector3FloatData& dataOut) const; - SIMD_FORCE_INLINE void deSerializeFloat(const struct btVector3FloatData& dataIn); + SIMD_FORCE_INLINE void deSerializeFloat(const struct b3Vector3FloatData& dataIn); - SIMD_FORCE_INLINE void serializeDouble(struct btVector3DoubleData& dataOut) const; + SIMD_FORCE_INLINE void serializeDouble(struct b3Vector3DoubleData& dataOut) const; - SIMD_FORCE_INLINE void deSerializeDouble(const struct btVector3DoubleData& dataIn); + SIMD_FORCE_INLINE void deSerializeDouble(const struct b3Vector3DoubleData& dataIn); /**@brief returns index of maximum dot product between this and vectors in array[] * @param array The other vectors @@ -699,7 +699,7 @@ public: /* create a vector as b3Vector3( this->dot( b3Vector3 v0 ), this->dot( b3Vector3 v1), this->dot( b3Vector3 v2 )) */ SIMD_FORCE_INLINE b3Vector3 dot3( const b3Vector3 &v0, const b3Vector3 &v1, const b3Vector3 &v2 ) const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 a0 = _mm_mul_ps( v0.mVec128, this->mVec128 ); __m128 a1 = _mm_mul_ps( v1.mVec128, this->mVec128 ); @@ -709,11 +709,11 @@ public: __m128 b2 = _mm_unpacklo_ps( a2, _mm_setzero_ps() ); __m128 r = _mm_movelh_ps( b0, b2 ); r = _mm_add_ps( r, _mm_movehl_ps( b2, b0 )); - a2 = _mm_and_ps( a2, btvxyzMaskf); - r = _mm_add_ps( r, btCastdTo128f (_mm_move_sd( btCastfTo128d(a2), btCastfTo128d(b1) ))); + a2 = _mm_and_ps( a2, b3vxyzMaskf); + r = _mm_add_ps( r, b3CastdTo128f (_mm_move_sd( b3CastfTo128d(a2), b3CastfTo128d(b1) ))); return b3Vector3(r); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) static const uint32x4_t xyzMask = (const uint32x4_t){ -1, -1, -1, 0 }; float32x4_t a0 = vmulq_f32( v0.mVec128, this->mVec128); float32x4_t a1 = vmulq_f32( v1.mVec128, this->mVec128); @@ -733,9 +733,9 @@ public: SIMD_FORCE_INLINE b3Vector3 operator+(const b3Vector3& v1, const b3Vector3& v2) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Vector3(_mm_add_ps(v1.mVec128, v2.mVec128)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) return b3Vector3(vaddq_f32(v1.mVec128, v2.mVec128)); #else return b3Vector3( @@ -749,9 +749,9 @@ operator+(const b3Vector3& v1, const b3Vector3& v2) SIMD_FORCE_INLINE b3Vector3 operator*(const b3Vector3& v1, const b3Vector3& v2) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) return b3Vector3(_mm_mul_ps(v1.mVec128, v2.mVec128)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) return b3Vector3(vmulq_f32(v1.mVec128, v2.mVec128)); #else return b3Vector3( @@ -765,14 +765,14 @@ operator*(const b3Vector3& v1, const b3Vector3& v2) SIMD_FORCE_INLINE b3Vector3 operator-(const b3Vector3& v1, const b3Vector3& v2) { -#if (defined(BT_USE_SSE_IN_API) && defined(BT_USE_SSE)) +#if (defined(B3_USE_SSE_IN_API) && defined(B3_USE_SSE)) // without _mm_and_ps this code causes slowdown in Concave moving __m128 r = _mm_sub_ps(v1.mVec128, v2.mVec128); - return b3Vector3(_mm_and_ps(r, btvFFF0fMask)); -#elif defined(BT_USE_NEON) + return b3Vector3(_mm_and_ps(r, b3vFFF0fMask)); +#elif defined(B3_USE_NEON) float32x4_t r = vsubq_f32(v1.mVec128, v2.mVec128); - return b3Vector3((float32x4_t)vandq_s32((int32x4_t)r, btvFFF0Mask)); + return b3Vector3((float32x4_t)vandq_s32((int32x4_t)r, b3vFFF0Mask)); #else return b3Vector3( v1.m_floats[0] - v2.m_floats[0], @@ -785,11 +785,11 @@ operator-(const b3Vector3& v1, const b3Vector3& v2) SIMD_FORCE_INLINE b3Vector3 operator-(const b3Vector3& v) { -#if (defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) - __m128 r = _mm_xor_ps(v.mVec128, btvMzeroMask); - return b3Vector3(_mm_and_ps(r, btvFFF0fMask)); -#elif defined(BT_USE_NEON) - return b3Vector3((btSimdFloat4)veorq_s32((int32x4_t)v.mVec128, (int32x4_t)btvMzeroMask)); +#if (defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE)) + __m128 r = _mm_xor_ps(v.mVec128, b3vMzeroMask); + return b3Vector3(_mm_and_ps(r, b3vFFF0fMask)); +#elif defined(B3_USE_NEON) + return b3Vector3((b3SimdFloat4)veorq_s32((int32x4_t)v.mVec128, (int32x4_t)b3vMzeroMask)); #else return b3Vector3(-v.m_floats[0], -v.m_floats[1], -v.m_floats[2]); #endif @@ -799,13 +799,13 @@ operator-(const b3Vector3& v) SIMD_FORCE_INLINE b3Vector3 operator*(const b3Vector3& v, const b3Scalar& s) { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 vs = _mm_load_ss(&s); // (S 0 0 0) - vs = bt_pshufd_ps(vs, 0x80); // (S S S 0.0) + vs = b3_pshufd_ps(vs, 0x80); // (S S S 0.0) return b3Vector3(_mm_mul_ps(v.mVec128, vs)); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t r = vmulq_n_f32(v.mVec128, s); - return b3Vector3((float32x4_t)vandq_s32((int32x4_t)r, btvFFF0Mask)); + return b3Vector3((float32x4_t)vandq_s32((int32x4_t)r, b3vFFF0Mask)); #else return b3Vector3(v.m_floats[0] * s, v.m_floats[1] * s, v.m_floats[2] * s); #endif @@ -822,12 +822,12 @@ operator*(const b3Scalar& s, const b3Vector3& v) SIMD_FORCE_INLINE b3Vector3 operator/(const b3Vector3& v, const b3Scalar& s) { - btFullAssert(s != b3Scalar(0.0)); -#if 0 //defined(BT_USE_SSE_IN_API) + b3FullAssert(s != b3Scalar(0.0)); +#if 0 //defined(B3_USE_SSE_IN_API) // this code is not faster ! __m128 vs = _mm_load_ss(&s); vs = _mm_div_ss(v1110, vs); - vs = bt_pshufd_ps(vs, 0x00); // (S S S S) + vs = b3_pshufd_ps(vs, 0x00); // (S S S S) return b3Vector3(_mm_mul_ps(v.mVec128, vs)); #else @@ -839,11 +839,11 @@ operator/(const b3Vector3& v, const b3Scalar& s) SIMD_FORCE_INLINE b3Vector3 operator/(const b3Vector3& v1, const b3Vector3& v2) { -#if (defined(BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) +#if (defined(B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) __m128 vec = _mm_div_ps(v1.mVec128, v2.mVec128); - vec = _mm_and_ps(vec, btvFFF0fMask); + vec = _mm_and_ps(vec, b3vFFF0fMask); return b3Vector3(vec); -#elif defined(BT_USE_NEON) +#elif defined(B3_USE_NEON) float32x4_t x, y, v, m; x = v1.mVec128; @@ -867,7 +867,7 @@ operator/(const b3Vector3& v1, const b3Vector3& v2) /**@brief Return the dot product between two vectors */ SIMD_FORCE_INLINE b3Scalar -btDot(const b3Vector3& v1, const b3Vector3& v2) +b3Dot(const b3Vector3& v1, const b3Vector3& v2) { return v1.dot(v2); } @@ -875,7 +875,7 @@ btDot(const b3Vector3& v1, const b3Vector3& v2) /**@brief Return the distance squared between two vectors */ SIMD_FORCE_INLINE b3Scalar -btDistance2(const b3Vector3& v1, const b3Vector3& v2) +b3Distance2(const b3Vector3& v1, const b3Vector3& v2) { return v1.distance2(v2); } @@ -883,27 +883,27 @@ btDistance2(const b3Vector3& v1, const b3Vector3& v2) /**@brief Return the distance between two vectors */ SIMD_FORCE_INLINE b3Scalar -btDistance(const b3Vector3& v1, const b3Vector3& v2) +b3Distance(const b3Vector3& v1, const b3Vector3& v2) { return v1.distance(v2); } /**@brief Return the angle between two vectors */ SIMD_FORCE_INLINE b3Scalar -btAngle(const b3Vector3& v1, const b3Vector3& v2) +b3Angle(const b3Vector3& v1, const b3Vector3& v2) { return v1.angle(v2); } /**@brief Return the cross product of two vectors */ SIMD_FORCE_INLINE b3Vector3 -btCross(const b3Vector3& v1, const b3Vector3& v2) +b3Cross(const b3Vector3& v1, const b3Vector3& v2) { return v1.cross(v2); } SIMD_FORCE_INLINE b3Scalar -btTriple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3) +b3Triple(const b3Vector3& v1, const b3Vector3& v2, const b3Vector3& v3) { return v1.triple(v2, v3); } @@ -932,7 +932,7 @@ SIMD_FORCE_INLINE b3Scalar b3Vector3::distance(const b3Vector3& v) const SIMD_FORCE_INLINE b3Vector3 b3Vector3::normalized() const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) b3Vector3 norm = *this; return norm.normalize(); @@ -945,23 +945,23 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3S { // wAxis must be a unit lenght vector -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) __m128 O = _mm_mul_ps(wAxis.mVec128, mVec128); - b3Scalar ssin = btSin( _angle ); + b3Scalar ssin = b3Sin( _angle ); __m128 C = wAxis.cross( mVec128 ).mVec128; - O = _mm_and_ps(O, btvFFF0fMask); - b3Scalar scos = btCos( _angle ); + O = _mm_and_ps(O, b3vFFF0fMask); + b3Scalar scos = b3Cos( _angle ); __m128 vsin = _mm_load_ss(&ssin); // (S 0 0 0) __m128 vcos = _mm_load_ss(&scos); // (S 0 0 0) - __m128 Y = bt_pshufd_ps(O, 0xC9); // (Y Z X 0) - __m128 Z = bt_pshufd_ps(O, 0xD2); // (Z X Y 0) + __m128 Y = b3_pshufd_ps(O, 0xC9); // (Y Z X 0) + __m128 Z = b3_pshufd_ps(O, 0xD2); // (Z X Y 0) O = _mm_add_ps(O, Y); - vsin = bt_pshufd_ps(vsin, 0x80); // (S S S 0) + vsin = b3_pshufd_ps(vsin, 0x80); // (S S S 0) O = _mm_add_ps(O, Z); - vcos = bt_pshufd_ps(vcos, 0x80); // (S S S 0) + vcos = b3_pshufd_ps(vcos, 0x80); // (S S S 0) vsin = vsin * C; O = O * wAxis.mVec128; @@ -979,24 +979,24 @@ SIMD_FORCE_INLINE b3Vector3 b3Vector3::rotate( const b3Vector3& wAxis, const b3S _y = wAxis.cross( *this ); - return ( o + _x * btCos( _angle ) + _y * btSin( _angle ) ); + return ( o + _x * b3Cos( _angle ) + _y * b3Sin( _angle ) ); #endif } SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const { -#if defined (BT_USE_SSE) || defined (BT_USE_NEON) - #if defined _WIN32 || defined (BT_USE_SSE) +#if defined (B3_USE_SSE) || defined (B3_USE_NEON) + #if defined _WIN32 || defined (B3_USE_SSE) const long scalar_cutoff = 10; long _maxdot_large( const float *array, const float *vec, unsigned long array_count, float *dotOut ); - #elif defined BT_USE_NEON + #elif defined B3_USE_NEON const long scalar_cutoff = 4; extern long (*_maxdot_large)( const float *array, const float *vec, unsigned long array_count, float *dotOut ); #endif if( array_count < scalar_cutoff ) #else -#endif//BT_USE_SSE || BT_USE_NEON +#endif//B3_USE_SSE || B3_USE_NEON { b3Scalar maxDot = -SIMD_INFINITY; int i = 0; @@ -1015,18 +1015,18 @@ SIMD_FORCE_INLINE long b3Vector3::maxDot( const b3Vector3 *array, long arra dotOut = maxDot; return ptIndex; } -#if defined (BT_USE_SSE) || defined (BT_USE_NEON) +#if defined (B3_USE_SSE) || defined (B3_USE_NEON) return _maxdot_large( (float*) array, (float*) &m_floats[0], array_count, &dotOut ); #endif } SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long array_count, b3Scalar &dotOut ) const { -#if defined (BT_USE_SSE) || defined (BT_USE_NEON) - #if defined BT_USE_SSE +#if defined (B3_USE_SSE) || defined (B3_USE_NEON) + #if defined B3_USE_SSE const long scalar_cutoff = 10; long _mindot_large( const float *array, const float *vec, unsigned long array_count, float *dotOut ); - #elif defined BT_USE_NEON + #elif defined B3_USE_NEON const long scalar_cutoff = 4; extern long (*_mindot_large)( const float *array, const float *vec, unsigned long array_count, float *dotOut ); #else @@ -1034,7 +1034,7 @@ SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long arra #endif if( array_count < scalar_cutoff ) -#endif//BT_USE_SSE || BT_USE_NEON +#endif//B3_USE_SSE || B3_USE_NEON { b3Scalar minDot = SIMD_INFINITY; int i = 0; @@ -1055,56 +1055,56 @@ SIMD_FORCE_INLINE long b3Vector3::minDot( const b3Vector3 *array, long arra return ptIndex; } -#if defined (BT_USE_SSE) || defined (BT_USE_NEON) +#if defined (B3_USE_SSE) || defined (B3_USE_NEON) return _mindot_large( (float*) array, (float*) &m_floats[0], array_count, &dotOut ); #endif } -class btVector4 : public b3Vector3 +class b3Vector4 : public b3Vector3 { public: - SIMD_FORCE_INLINE btVector4() {} + SIMD_FORCE_INLINE b3Vector4() {} - SIMD_FORCE_INLINE btVector4(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) + SIMD_FORCE_INLINE b3Vector4(const b3Scalar& _x, const b3Scalar& _y, const b3Scalar& _z,const b3Scalar& _w) : b3Vector3(_x,_y,_z) { m_floats[3] = _w; } -#if (defined (BT_USE_SSE_IN_API)&& defined (BT_USE_SSE)) || defined (BT_USE_NEON) - SIMD_FORCE_INLINE btVector4(const btSimdFloat4 vec) +#if (defined (B3_USE_SSE_IN_API)&& defined (B3_USE_SSE)) || defined (B3_USE_NEON) + SIMD_FORCE_INLINE b3Vector4(const b3SimdFloat4 vec) { mVec128 = vec; } - SIMD_FORCE_INLINE btVector4(const b3Vector3& rhs) + SIMD_FORCE_INLINE b3Vector4(const b3Vector3& rhs) { mVec128 = rhs.mVec128; } - SIMD_FORCE_INLINE btVector4& - operator=(const btVector4& v) + SIMD_FORCE_INLINE b3Vector4& + operator=(const b3Vector4& v) { mVec128 = v.mVec128; return *this; } -#endif // #if defined (BT_USE_SSE_IN_API) || defined (BT_USE_NEON) +#endif // #if defined (B3_USE_SSE_IN_API) || defined (B3_USE_NEON) - SIMD_FORCE_INLINE btVector4 absolute4() const + SIMD_FORCE_INLINE b3Vector4 absolute4() const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) - return btVector4(_mm_and_ps(mVec128, btvAbsfMask)); -#elif defined(BT_USE_NEON) - return btVector4(vabsq_f32(mVec128)); +#if defined(B3_USE_SSE_IN_API) && defined (B3_USE_SSE) + return b3Vector4(_mm_and_ps(mVec128, b3vAbsfMask)); +#elif defined(B3_USE_NEON) + return b3Vector4(vabsq_f32(mVec128)); #else - return btVector4( - btFabs(m_floats[0]), - btFabs(m_floats[1]), - btFabs(m_floats[2]), - btFabs(m_floats[3])); + return b3Vector4( + b3Fabs(m_floats[0]), + b3Fabs(m_floats[1]), + b3Fabs(m_floats[2]), + b3Fabs(m_floats[3])); #endif } @@ -1115,7 +1115,7 @@ public: SIMD_FORCE_INLINE int maxAxis4() const { int maxIndex = -1; - b3Scalar maxVal = b3Scalar(-BT_LARGE_FLOAT); + b3Scalar maxVal = b3Scalar(-B3_LARGE_FLOAT); if (m_floats[0] > maxVal) { maxIndex = 0; @@ -1144,7 +1144,7 @@ public: SIMD_FORCE_INLINE int minAxis4() const { int minIndex = -1; - b3Scalar minVal = b3Scalar(BT_LARGE_FLOAT); + b3Scalar minVal = b3Scalar(B3_LARGE_FLOAT); if (m_floats[0] < minVal) { minIndex = 0; @@ -1210,10 +1210,10 @@ public: }; -///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void btSwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& destVal) +///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization +SIMD_FORCE_INLINE void b3SwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& destVal) { - #ifdef BT_USE_DOUBLE_PRECISION + #ifdef B3_USE_DOUBLE_PRECISION unsigned char* dest = (unsigned char*) &destVal; unsigned char* src = (unsigned char*) &sourceVal; dest[0] = src[7]; @@ -1231,37 +1231,37 @@ SIMD_FORCE_INLINE void btSwapScalarEndian(const b3Scalar& sourceVal, b3Scalar& d dest[1] = src[2]; dest[2] = src[1]; dest[3] = src[0]; -#endif //BT_USE_DOUBLE_PRECISION +#endif //B3_USE_DOUBLE_PRECISION } -///btSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void btSwapVector3Endian(const b3Vector3& sourceVec, b3Vector3& destVec) +///b3SwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization +SIMD_FORCE_INLINE void b3SwapVector3Endian(const b3Vector3& sourceVec, b3Vector3& destVec) { for (int i=0;i<4;i++) { - btSwapScalarEndian(sourceVec[i],destVec[i]); + b3SwapScalarEndian(sourceVec[i],destVec[i]); } } -///btUnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization -SIMD_FORCE_INLINE void btUnSwapVector3Endian(b3Vector3& vector) +///b3UnSwapVector3Endian swaps vector endianness, useful for network and cross-platform serialization +SIMD_FORCE_INLINE void b3UnSwapVector3Endian(b3Vector3& vector) { b3Vector3 swappedVec; for (int i=0;i<4;i++) { - btSwapScalarEndian(vector[i],swappedVec[i]); + b3SwapScalarEndian(vector[i],swappedVec[i]); } vector = swappedVec; } template -SIMD_FORCE_INLINE void btPlaneSpace1 (const T& n, T& p, T& q) +SIMD_FORCE_INLINE void b3PlaneSpace1 (const T& n, T& p, T& q) { - if (btFabs(n[2]) > SIMDSQRT12) { + if (b3Fabs(n[2]) > SIMDSQRT12) { // choose p in y-z plane b3Scalar a = n[1]*n[1] + n[2]*n[2]; - b3Scalar k = btRecipSqrt (a); + b3Scalar k = b3RecipSqrt (a); p[0] = 0; p[1] = -n[2]*k; p[2] = n[1]*k; @@ -1273,7 +1273,7 @@ SIMD_FORCE_INLINE void btPlaneSpace1 (const T& n, T& p, T& q) else { // choose p in x-y plane b3Scalar a = n[0]*n[0] + n[1]*n[1]; - b3Scalar k = btRecipSqrt (a); + b3Scalar k = b3RecipSqrt (a); p[0] = -n[1]*k; p[1] = n[0]*k; p[2] = 0; @@ -1285,56 +1285,56 @@ SIMD_FORCE_INLINE void btPlaneSpace1 (const T& n, T& p, T& q) } -struct btVector3FloatData +struct b3Vector3FloatData { float m_floats[4]; }; -struct btVector3DoubleData +struct b3Vector3DoubleData { double m_floats[4]; }; -SIMD_FORCE_INLINE void b3Vector3::serializeFloat(struct btVector3FloatData& dataOut) const +SIMD_FORCE_INLINE void b3Vector3::serializeFloat(struct b3Vector3FloatData& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = float(m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::deSerializeFloat(const struct btVector3FloatData& dataIn) +SIMD_FORCE_INLINE void b3Vector3::deSerializeFloat(const struct b3Vector3FloatData& dataIn) { for (int i=0;i<4;i++) m_floats[i] = b3Scalar(dataIn.m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::serializeDouble(struct btVector3DoubleData& dataOut) const +SIMD_FORCE_INLINE void b3Vector3::serializeDouble(struct b3Vector3DoubleData& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = double(m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::deSerializeDouble(const struct btVector3DoubleData& dataIn) +SIMD_FORCE_INLINE void b3Vector3::deSerializeDouble(const struct b3Vector3DoubleData& dataIn) { for (int i=0;i<4;i++) m_floats[i] = b3Scalar(dataIn.m_floats[i]); } -SIMD_FORCE_INLINE void b3Vector3::serialize(struct btVector3Data& dataOut) const +SIMD_FORCE_INLINE void b3Vector3::serialize(struct b3Vector3Data& dataOut) const { ///could also do a memcpy, check if it is worth it for (int i=0;i<4;i++) dataOut.m_floats[i] = m_floats[i]; } -SIMD_FORCE_INLINE void b3Vector3::deSerialize(const struct btVector3Data& dataIn) +SIMD_FORCE_INLINE void b3Vector3::deSerialize(const struct b3Vector3Data& dataIn) { for (int i=0;i<4;i++) m_floats[i] = dataIn.m_floats[i]; } -#endif //BT_VECTOR3_H +#endif //B3_VECTOR3_H diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h b/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h index eb3a8b121..4369f86ff 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h @@ -13,12 +13,12 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_CONTACT_SOLVER_INFO -#define BT_CONTACT_SOLVER_INFO +#ifndef B3_CONTACT_SOLVER_INFO +#define B3_CONTACT_SOLVER_INFO #include "Bullet3Common/b3Scalar.h" -enum btSolverMode +enum b3SolverMode { SOLVER_RANDMIZE_ORDER = 1, SOLVER_FRICTION_SEPARATE = 2, @@ -32,7 +32,7 @@ enum btSolverMode SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024 }; -struct btContactSolverInfoData +struct b3ContactSolverInfoData { @@ -62,7 +62,7 @@ struct btContactSolverInfoData }; -struct b3ContactSolverInfo : public btContactSolverInfoData +struct b3ContactSolverInfo : public b3ContactSolverInfoData { @@ -89,13 +89,13 @@ struct b3ContactSolverInfo : public btContactSolverInfoData m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD;// | SOLVER_RANDMIZE_ORDER; m_restingContactRestitutionThreshold = 2;//unused as of 2.81 m_minimumSolverBatchSize = 128; //try to combine islands until the amount of constraints reaches this limit - m_maxGyroscopicForce = 100.f; ///only used to clamp forces for bodies that have their BT_ENABLE_GYROPSCOPIC_FORCE flag set (using btRigidBody::setFlag) + m_maxGyroscopicForce = 100.f; ///only used to clamp forces for bodies that have their B3_ENABLE_GYROPSCOPIC_FORCE flag set (using b3RigidBody::setFlag) m_singleAxisRollingFrictionThreshold = 1e30f;///if the velocity is above this threshold, it will use a single constraint row (axis), otherwise 3 rows. } }; ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 -struct btContactSolverInfoDoubleData +struct b3ContactSolverInfoDoubleData { double m_tau; double m_damping;//global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'. @@ -123,7 +123,7 @@ struct btContactSolverInfoDoubleData }; ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 -struct btContactSolverInfoFloatData +struct b3ContactSolverInfoFloatData { float m_tau; float m_damping;//global non-contact constraint damping, can be locally overridden by constraints during 'getInfo2'. @@ -156,4 +156,4 @@ struct btContactSolverInfoFloatData -#endif //BT_CONTACT_SOLVER_INFO +#endif //B3_CONTACT_SOLVER_INFO diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp index cbc5e60d5..3346522e4 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp +++ b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.cpp @@ -13,8 +13,8 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -//enable BT_SOLVER_DEBUG if you experience solver crashes -//#define BT_SOLVER_DEBUG +//enable B3_SOLVER_DEBUG if you experience solver crashes +//#define B3_SOLVER_DEBUG //#define COMPUTE_IMPULSE_DENOM 1 //It is not necessary (redundant) to refresh contact manifolds, this refresh has been moved to the collision algorithms. @@ -46,7 +46,7 @@ b3Transform getWorldTransform(b3RigidBodyCL* rb) return newTrans; } -const b3Matrix3x3& getInvInertiaTensorWorld(btInertiaCL* inertia) +const b3Matrix3x3& getInvInertiaTensorWorld(b3InertiaCL* inertia) { return inertia->m_invInertiaWorld; } @@ -70,7 +70,7 @@ b3Vector3 getVelocityInLocalPoint(b3RigidBodyCL* rb, const b3Vector3& rel_pos) } -struct btContactPoint +struct b3ContactPoint { b3Vector3 m_positionWorldOnA; b3Vector3 m_positionWorldOnB; @@ -107,7 +107,7 @@ struct btContactPoint } }; -void getContactPoint(b3Contact4* contact, int contactIndex, btContactPoint& pointOut) +void getContactPoint(b3Contact4* contact, int contactIndex, b3ContactPoint& pointOut) { pointOut.m_appliedImpulse = 0.f; pointOut.m_appliedImpulseLateral1 = 0.f; @@ -125,7 +125,7 @@ void getContactPoint(b3Contact4* contact, int contactIndex, btContactPoint& poin normalOnB.normalize(); b3Vector3 l1,l2; - btPlaneSpace1(normalOnB,l1,l2); + b3PlaneSpace1(normalOnB,l1,l2); pointOut.m_normalWorldOnB = normalOnB; //printf("normalOnB = %f,%f,%f\n",normalOnB.getX(),normalOnB.getY(),normalOnB.getZ()); @@ -154,7 +154,7 @@ b3PgsJacobiSolver::~b3PgsJacobiSolver() { } -void b3PgsJacobiSolver::solveContacts(int numBodies, b3RigidBodyCL* bodies, btInertiaCL* inertias, int numContacts, b3Contact4* contacts, int numConstraints, b3TypedConstraint** constraints) +void b3PgsJacobiSolver::solveContacts(int numBodies, b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numContacts, b3Contact4* contacts, int numConstraints, b3TypedConstraint** constraints) { b3ContactSolverInfo infoGlobal; infoGlobal.m_splitImpulse = false; @@ -179,7 +179,7 @@ void b3PgsJacobiSolver::solveContacts(int numBodies, b3RigidBodyCL* bodies, btIn /// b3PgsJacobiSolver Sequentially applies impulses b3Scalar b3PgsJacobiSolver::solveGroup(b3RigidBodyCL* bodies, - btInertiaCL* inertias, + b3InertiaCL* inertias, int numBodies, b3Contact4* manifoldPtr, int numManifolds, @@ -188,7 +188,7 @@ b3Scalar b3PgsJacobiSolver::solveGroup(b3RigidBodyCL* bodies, const b3ContactSolverInfo& infoGlobal) { - BT_PROFILE("solveGroup"); + B3_PROFILE("solveGroup"); //you need to provide at least some bodies solveGroupCacheFriendlySetup( bodies, inertias,numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal); @@ -210,11 +210,11 @@ b3Scalar b3PgsJacobiSolver::solveGroup(b3RigidBodyCL* bodies, #ifdef USE_SIMD #include -#define btVecSplat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) -static inline __m128 btSimdDot3( __m128 vec0, __m128 vec1 ) +#define b3VecSplat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) +static inline __m128 b3SimdDot3( __m128 vec0, __m128 vec1 ) { __m128 result = _mm_mul_ps( vec0, vec1); - return _mm_add_ps( btVecSplat( result, 0 ), _mm_add_ps( btVecSplat( result, 1 ), btVecSplat( result, 2 ) ) ); + return _mm_add_ps( b3VecSplat( result, 0 ), _mm_add_ps( b3VecSplat( result, 1 ), b3VecSplat( result, 2 ) ) ); } #endif//USE_SIMD @@ -226,12 +226,12 @@ void b3PgsJacobiSolver::resolveSingleConstraintRowGenericSIMD(b3SolverBody& body __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm))); - __m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal.mVec128,body1.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetDeltaAngularVelocity().mVec128)); - __m128 deltaVel2Dotn = _mm_sub_ps(btSimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetDeltaAngularVelocity().mVec128),btSimdDot3((c.m_contactNormal).mVec128,body2.internalGetDeltaLinearVelocity().mVec128)); + __m128 deltaVel1Dotn = _mm_add_ps(b3SimdDot3(c.m_contactNormal.mVec128,body1.internalGetDeltaLinearVelocity().mVec128), b3SimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetDeltaAngularVelocity().mVec128)); + __m128 deltaVel2Dotn = _mm_sub_ps(b3SimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetDeltaAngularVelocity().mVec128),b3SimdDot3((c.m_contactNormal).mVec128,body2.internalGetDeltaLinearVelocity().mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); - btSimdScalar resultLowerLess,resultUpperLess; + b3SimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); + b3SimdScalar resultLowerLess,resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); @@ -290,12 +290,12 @@ void b3PgsJacobiSolver::resolveSingleConstraintRowGenericSIMD(b3SolverBody& body __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm))); - __m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal.mVec128,body1.internalGetDeltaLinearVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetDeltaAngularVelocity().mVec128)); - __m128 deltaVel2Dotn = _mm_sub_ps(btSimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetDeltaAngularVelocity().mVec128),btSimdDot3((c.m_contactNormal).mVec128,body2.internalGetDeltaLinearVelocity().mVec128)); + __m128 deltaVel1Dotn = _mm_add_ps(b3SimdDot3(c.m_contactNormal.mVec128,body1.internalGetDeltaLinearVelocity().mVec128), b3SimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetDeltaAngularVelocity().mVec128)); + __m128 deltaVel2Dotn = _mm_sub_ps(b3SimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetDeltaAngularVelocity().mVec128),b3SimdDot3((c.m_contactNormal).mVec128,body2.internalGetDeltaLinearVelocity().mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); - btSimdScalar resultLowerLess,resultUpperLess; + b3SimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); + b3SimdScalar resultLowerLess,resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); @@ -378,12 +378,12 @@ void b3PgsJacobiSolver::resolveSplitPenetrationImpulseCacheFriendly( __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhsPenetration), _mm_mul_ps(_mm_set1_ps(c.m_appliedPushImpulse),_mm_set1_ps(c.m_cfm))); - __m128 deltaVel1Dotn = _mm_add_ps(btSimdDot3(c.m_contactNormal.mVec128,body1.internalGetPushVelocity().mVec128), btSimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetTurnVelocity().mVec128)); - __m128 deltaVel2Dotn = _mm_sub_ps(btSimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetTurnVelocity().mVec128),btSimdDot3((c.m_contactNormal).mVec128,body2.internalGetPushVelocity().mVec128)); + __m128 deltaVel1Dotn = _mm_add_ps(b3SimdDot3(c.m_contactNormal.mVec128,body1.internalGetPushVelocity().mVec128), b3SimdDot3(c.m_relpos1CrossNormal.mVec128,body1.internalGetTurnVelocity().mVec128)); + __m128 deltaVel2Dotn = _mm_sub_ps(b3SimdDot3(c.m_relpos2CrossNormal.mVec128,body2.internalGetTurnVelocity().mVec128),b3SimdDot3((c.m_contactNormal).mVec128,body2.internalGetPushVelocity().mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); - btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); - btSimdScalar resultLowerLess,resultUpperLess; + b3SimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); + b3SimdScalar resultLowerLess,resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); @@ -403,7 +403,7 @@ void b3PgsJacobiSolver::resolveSplitPenetrationImpulseCacheFriendly( -unsigned long b3PgsJacobiSolver::btRand2() +unsigned long b3PgsJacobiSolver::b3Rand2() { m_btSeed2 = (1664525L*m_btSeed2 + 1013904223L) & 0xffffffff; return m_btSeed2; @@ -412,11 +412,11 @@ unsigned long b3PgsJacobiSolver::btRand2() //See ODE: adam's all-int straightforward(?) dRandInt (0..n-1) -int b3PgsJacobiSolver::btRandInt2 (int n) +int b3PgsJacobiSolver::b3RandInt2 (int n) { // seems good; xor-fold and modulus const unsigned long un = static_cast(n); - unsigned long r = btRand2(); + unsigned long r = b3Rand2(); // note: probably more aggressive than it needs to be -- might be // able to get away without one or two of the innermost branches. @@ -488,7 +488,7 @@ b3Scalar b3PgsJacobiSolver::restitutionCurve(b3Scalar rel_vel, b3Scalar restitut -void b3PgsJacobiSolver::setupFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) +void b3PgsJacobiSolver::setupFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) { @@ -566,8 +566,8 @@ void b3PgsJacobiSolver::setupFrictionConstraint(b3RigidBodyCL* bodies,btInertiaC // b3Scalar positionalError = 0.f; - btSimdScalar velocityError = desiredVelocity - rel_vel; - btSimdScalar velocityImpulse = velocityError * btSimdScalar(scaledDenom);//solverConstraint.m_jacDiagABInv); + b3SimdScalar velocityError = desiredVelocity - rel_vel; + b3SimdScalar velocityImpulse = velocityError * b3SimdScalar(scaledDenom);//solverConstraint.m_jacDiagABInv); solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_cfm = cfmSlip; solverConstraint.m_lowerLimit = 0; @@ -576,7 +576,7 @@ void b3PgsJacobiSolver::setupFrictionConstraint(b3RigidBodyCL* bodies,btInertiaC } } -b3SolverConstraint& b3PgsJacobiSolver::addFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) +b3SolverConstraint& b3PgsJacobiSolver::addFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) { b3SolverConstraint& solverConstraint = m_tmpSolverContactFrictionConstraintPool.expandNonInitializing(); solverConstraint.m_frictionIndex = frictionIndex; @@ -586,8 +586,8 @@ b3SolverConstraint& b3PgsJacobiSolver::addFrictionConstraint(b3RigidBodyCL* bodi } -void b3PgsJacobiSolver::setupRollingFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis1,int solverBodyIdA,int solverBodyIdB, - btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2, +void b3PgsJacobiSolver::setupRollingFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis1,int solverBodyIdA,int solverBodyIdB, + b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2, b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) @@ -645,8 +645,8 @@ void b3PgsJacobiSolver::setupRollingFrictionConstraint(b3RigidBodyCL* bodies,btI // b3Scalar positionalError = 0.f; - btSimdScalar velocityError = desiredVelocity - rel_vel; - btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv); + b3SimdScalar velocityError = desiredVelocity - rel_vel; + b3SimdScalar velocityImpulse = velocityError * b3SimdScalar(solverConstraint.m_jacDiagABInv); solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_cfm = cfmSlip; solverConstraint.m_lowerLimit = 0; @@ -662,7 +662,7 @@ void b3PgsJacobiSolver::setupRollingFrictionConstraint(b3RigidBodyCL* bodies,btI -b3SolverConstraint& b3PgsJacobiSolver::addRollingFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias,const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) +b3SolverConstraint& b3PgsJacobiSolver::addRollingFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias,const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity, b3Scalar cfmSlip) { b3SolverConstraint& solverConstraint = m_tmpSolverContactRollingFrictionConstraintPool.expandNonInitializing(); solverConstraint.m_frictionIndex = frictionIndex; @@ -672,9 +672,9 @@ b3SolverConstraint& b3PgsJacobiSolver::addRollingFrictionConstraint(b3RigidBodyC } -int b3PgsJacobiSolver::getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies,btInertiaCL* inertias) +int b3PgsJacobiSolver::getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies,b3InertiaCL* inertias) { - //btAssert(bodyIndex< m_tmpSolverBodyPool.size()); + //b3Assert(bodyIndex< m_tmpSolverBodyPool.size()); b3RigidBodyCL& body = bodies[bodyIndex]; int curIndex = -1; @@ -693,7 +693,7 @@ int b3PgsJacobiSolver::getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies, } } else { - btAssert(m_bodyCount[bodyIndex]>0); + b3Assert(m_bodyCount[bodyIndex]>0); m_bodyCountCheck[bodyIndex]++; curIndex = m_tmpSolverBodyPool.size(); b3SolverBody& solverBody = m_tmpSolverBodyPool.expand(); @@ -701,16 +701,16 @@ int b3PgsJacobiSolver::getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies, solverBody.m_originalBodyIndex = bodyIndex; } - btAssert(curIndex>=0); + b3Assert(curIndex>=0); return curIndex; } #include -void b3PgsJacobiSolver::setupContactConstraint(b3RigidBodyCL* bodies, btInertiaCL* inertias,b3SolverConstraint& solverConstraint, +void b3PgsJacobiSolver::setupContactConstraint(b3RigidBodyCL* bodies, b3InertiaCL* inertias,b3SolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, - btContactPoint& cp, const b3ContactSolverInfo& infoGlobal, + b3ContactPoint& cp, const b3ContactSolverInfo& infoGlobal, b3Vector3& vel, b3Scalar& rel_vel, b3Scalar& relaxation, b3Vector3& rel_pos1, b3Vector3& rel_pos2) { @@ -872,9 +872,9 @@ void b3PgsJacobiSolver::setupContactConstraint(b3RigidBodyCL* bodies, btInertiaC -void b3PgsJacobiSolver::setFrictionConstraintImpulse( b3RigidBodyCL* bodies, btInertiaCL* inertias,b3SolverConstraint& solverConstraint, +void b3PgsJacobiSolver::setFrictionConstraintImpulse( b3RigidBodyCL* bodies, b3InertiaCL* inertias,b3SolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, - btContactPoint& cp, const b3ContactSolverInfo& infoGlobal) + b3ContactPoint& cp, const b3ContactSolverInfo& infoGlobal) { b3SolverBody* bodyA = &m_tmpSolverBodyPool[solverBodyIdA]; @@ -916,7 +916,7 @@ void b3PgsJacobiSolver::setFrictionConstraintImpulse( b3RigidBodyCL* bodies, btI -void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, btInertiaCL* inertias,b3Contact4* manifold,const b3ContactSolverInfo& infoGlobal) +void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, b3InertiaCL* inertias,b3Contact4* manifold,const b3ContactSolverInfo& infoGlobal) { b3RigidBodyCL* colObj0=0,*colObj1=0; @@ -924,8 +924,8 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, btInertiaCL* inert int solverBodyIdA = getOrInitSolverBody(manifold->getBodyA(),bodies,inertias); int solverBodyIdB = getOrInitSolverBody(manifold->getBodyB(),bodies,inertias); -// btRigidBody* bodyA = btRigidBody::upcast(colObj0); -// btRigidBody* bodyB = btRigidBody::upcast(colObj1); +// b3RigidBody* bodyA = b3RigidBody::upcast(colObj0); +// b3RigidBody* bodyB = b3RigidBody::upcast(colObj1); b3SolverBody* solverBodyA = &m_tmpSolverBodyPool[solverBodyIdA]; b3SolverBody* solverBodyB = &m_tmpSolverBodyPool[solverBodyIdB]; @@ -941,7 +941,7 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, btInertiaCL* inert for (int j=0;j0.001) addRollingFrictionConstraint(bodies,inertias,axis0,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); if (axis1.length()>0.001) @@ -1019,7 +1019,7 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, btInertiaCL* inert b3Scalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) { - cp.m_lateralFrictionDir1 *= 1.f/btSqrt(lat_rel_vel); + cp.m_lateralFrictionDir1 *= 1.f/b3Sqrt(lat_rel_vel); if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); @@ -1032,7 +1032,7 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, btInertiaCL* inert } else { - btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); + b3PlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { @@ -1064,9 +1064,9 @@ void b3PgsJacobiSolver::convertContact(b3RigidBodyCL* bodies, btInertiaCL* inert } } -b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, btInertiaCL* inertias, int numBodies, b3Contact4* manifoldPtr, int numManifolds,b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal) +b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numBodies, b3Contact4* manifoldPtr, int numManifolds,b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal) { - BT_PROFILE("solveGroupCacheFriendlySetup"); + B3_PROFILE("solveGroupCacheFriendlySetup"); m_maxOverrideNumSolverIterations = 0; @@ -1099,7 +1099,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, } else { //didn't implement joints with Jacobi version yet - btAssert(0); + b3Assert(0); } } @@ -1143,7 +1143,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, } } - //btRigidBody* rb0=0,*rb1=0; + //b3RigidBody* rb0=0,*rb1=0; //if (1) { { @@ -1155,8 +1155,8 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, //calculate the total number of contraint rows for (i=0;igetJointFeedback(); + b3TypedConstraint::b3ConstraintInfo1& info1 = m_tmpConstraintSizesPool[i]; + b3JointFeedback* fb = constraints[i]->getJointFeedback(); if (fb) { fb->m_appliedForceBodyA.setZero(); @@ -1182,23 +1182,23 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, #ifndef DISABLE_JOINTS - ///setup the btSolverConstraints + ///setup the b3SolverConstraints int currentRow = 0; for (i=0;igetRigidBodyA()]; - //btRigidBody& rbA = constraint->getRigidBodyA(); - // btRigidBody& rbB = constraint->getRigidBodyB(); + //b3RigidBody& rbA = constraint->getRigidBodyA(); + // b3RigidBody& rbB = constraint->getRigidBodyB(); b3RigidBodyCL& rbB = bodies[ constraint->getRigidBodyB()]; int solverBodyIdA = getOrInitSolverBody(constraint->getRigidBodyA(),bodies,inertias); @@ -1238,7 +1238,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, bodyBPtr->internalGetTurnVelocity().setValue(0.f,0.f,0.f); - b3TypedConstraint::btConstraintInfo2 info2; + b3TypedConstraint::b3ConstraintInfo2 info2; info2.fps = 1.f/infoGlobal.m_timeStep; info2.erp = infoGlobal.m_erp; info2.m_J1linearAxis = currentConstraintRow->m_contactNormal; @@ -1247,7 +1247,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal; info2.rowskip = sizeof(b3SolverConstraint)/sizeof(b3Scalar);//check this ///the size of b3SolverConstraint needs be a multiple of b3Scalar - btAssert(info2.rowskip*sizeof(b3Scalar)== sizeof(b3SolverConstraint)); + b3Assert(info2.rowskip*sizeof(b3Scalar)== sizeof(b3SolverConstraint)); info2.m_constraintError = ¤tConstraintRow->m_rhs; currentConstraintRow->m_cfm = infoGlobal.m_globalCfm; info2.m_damping = infoGlobal.m_damping; @@ -1277,7 +1277,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, b3Matrix3x3& invInertiaWorldA= inertias[constraint->getRigidBodyA()].m_invInertiaWorld; { - //btVector3 angularFactorA(1,1,1); + //b3Vector3 angularFactorA(1,1,1); const b3Vector3& ftorqueAxis1 = solverConstraint.m_relpos1CrossNormal; solverConstraint.m_angularComponentA = invInertiaWorldA*ftorqueAxis1;//*angularFactorA; } @@ -1299,8 +1299,8 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal); sum += iMJlB.dot(solverConstraint.m_contactNormal); sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal); - b3Scalar fsum = btFabs(sum); - btAssert(fsum > SIMD_EPSILON); + b3Scalar fsum = b3Fabs(sum); + b3Assert(fsum > SIMD_EPSILON); solverConstraint.m_jacDiagABInv = fsum>SIMD_EPSILON?b3Scalar(1.)/sum : 0.f; } @@ -1392,7 +1392,7 @@ b3Scalar b3PgsJacobiSolver::solveSingleIteration(int iteration,b3TypedConstraint for (int j=0; jm_appliedImpulse = solveManifold.m_appliedImpulse; // float f = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; // printf("pt->m_appliedImpulseLateral1 = %f\n", f); @@ -1731,7 +1731,7 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlyFinish(b3RigidBodyCL* bodies, { const b3SolverConstraint& solverConstr = m_tmpSolverNonContactConstraintPool[j]; b3TypedConstraint* constr = (b3TypedConstraint*)solverConstr.m_originalContactPoint; - btJointFeedback* fb = constr->getJointFeedback(); + b3JointFeedback* fb = constr->getJointFeedback(); if (fb) { b3SolverBody* bodyA = &m_tmpSolverBodyPool[solverConstr.m_solverBodyIdA]; @@ -1745,18 +1745,18 @@ b3Scalar b3PgsJacobiSolver::solveGroupCacheFriendlyFinish(b3RigidBodyCL* bodies, } constr->internalSetAppliedImpulse(solverConstr.m_appliedImpulse); - if (btFabs(solverConstr.m_appliedImpulse)>=constr->getBreakingImpulseThreshold()) + if (b3Fabs(solverConstr.m_appliedImpulse)>=constr->getBreakingImpulseThreshold()) { constr->setEnabled(false); } } { - BT_PROFILE("write back velocities and transforms"); + B3_PROFILE("write back velocities and transforms"); for ( i=0;igetInvMass()) diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h index 02f072bf5..f8b6f5f97 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h @@ -1,12 +1,12 @@ -#ifndef BT_PGS_JACOBI_SOLVER -#define BT_PGS_JACOBI_SOLVER +#ifndef B3_PGS_JACOBI_SOLVER +#define B3_PGS_JACOBI_SOLVER struct b3Contact4; -struct btContactPoint; +struct b3ContactPoint; -class btDispatcher; +class b3Dispatcher; #include "b3TypedConstraint.h" #include "b3ContactSolverInfo.h" @@ -14,22 +14,22 @@ class btDispatcher; #include "b3SolverConstraint.h" struct b3RigidBodyCL; -struct btInertiaCL; +struct b3InertiaCL; class b3PgsJacobiSolver { protected: b3AlignedObjectArray m_tmpSolverBodyPool; - btConstraintArray m_tmpSolverContactConstraintPool; - btConstraintArray m_tmpSolverNonContactConstraintPool; - btConstraintArray m_tmpSolverContactFrictionConstraintPool; - btConstraintArray m_tmpSolverContactRollingFrictionConstraintPool; + b3ConstraintArray m_tmpSolverContactConstraintPool; + b3ConstraintArray m_tmpSolverNonContactConstraintPool; + b3ConstraintArray m_tmpSolverContactFrictionConstraintPool; + b3ConstraintArray m_tmpSolverContactRollingFrictionConstraintPool; b3AlignedObjectArray m_orderTmpConstraintPool; b3AlignedObjectArray m_orderNonContactConstraintPool; b3AlignedObjectArray m_orderFrictionConstraintPool; - b3AlignedObjectArray m_tmpConstraintSizesPool; + b3AlignedObjectArray m_tmpConstraintSizesPool; b3AlignedObjectArray m_bodyCount; b3AlignedObjectArray m_bodyCountCheck; @@ -45,27 +45,27 @@ protected: { return 0.02f; } - void setupFrictionConstraint( b3RigidBodyCL* bodies,btInertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB, - btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2, + void setupFrictionConstraint( b3RigidBodyCL* bodies,b3InertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB, + b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2, b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity=0., b3Scalar cfmSlip=0.); - void setupRollingFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB, - btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2, + void setupRollingFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias, b3SolverConstraint& solverConstraint, const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB, + b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2, b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity=0., b3Scalar cfmSlip=0.); - b3SolverConstraint& addFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias,const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity=0., b3Scalar cfmSlip=0.); - b3SolverConstraint& addRollingFrictionConstraint(b3RigidBodyCL* bodies,btInertiaCL* inertias,const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity=0, b3Scalar cfmSlip=0.f); + b3SolverConstraint& addFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias,const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity=0., b3Scalar cfmSlip=0.); + b3SolverConstraint& addRollingFrictionConstraint(b3RigidBodyCL* bodies,b3InertiaCL* inertias,const b3Vector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,b3ContactPoint& cp,const b3Vector3& rel_pos1,const b3Vector3& rel_pos2,b3RigidBodyCL* colObj0,b3RigidBodyCL* colObj1, b3Scalar relaxation, b3Scalar desiredVelocity=0, b3Scalar cfmSlip=0.f); - void setupContactConstraint(b3RigidBodyCL* bodies, btInertiaCL* inertias, - b3SolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btContactPoint& cp, + void setupContactConstraint(b3RigidBodyCL* bodies, b3InertiaCL* inertias, + b3SolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, b3ContactPoint& cp, const b3ContactSolverInfo& infoGlobal, b3Vector3& vel, b3Scalar& rel_vel, b3Scalar& relaxation, b3Vector3& rel_pos1, b3Vector3& rel_pos2); - void setFrictionConstraintImpulse( b3RigidBodyCL* bodies, btInertiaCL* inertias,b3SolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB, - btContactPoint& cp, const b3ContactSolverInfo& infoGlobal); + void setFrictionConstraintImpulse( b3RigidBodyCL* bodies, b3InertiaCL* inertias,b3SolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB, + b3ContactPoint& cp, const b3ContactSolverInfo& infoGlobal); ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction unsigned long m_btSeed2; @@ -73,7 +73,7 @@ protected: b3Scalar restitutionCurve(b3Scalar rel_vel, b3Scalar restitution); - void convertContact(b3RigidBodyCL* bodies, btInertiaCL* inertias,b3Contact4* manifold,const b3ContactSolverInfo& infoGlobal); + void convertContact(b3RigidBodyCL* bodies, b3InertiaCL* inertias,b3Contact4* manifold,const b3ContactSolverInfo& infoGlobal); void resolveSplitPenetrationSIMD( @@ -85,7 +85,7 @@ protected: const b3SolverConstraint& contactConstraint); //internal method - int getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies,btInertiaCL* inertias); + int getOrInitSolverBody(int bodyIndex, b3RigidBodyCL* bodies,b3InertiaCL* inertias); void initSolverBody(int bodyIndex, b3SolverBody* solverBody, b3RigidBodyCL* collisionObject); void resolveSingleConstraintRowGeneric(b3SolverBody& bodyA,b3SolverBody& bodyB,const b3SolverConstraint& contactConstraint); @@ -98,7 +98,7 @@ protected: protected: - virtual b3Scalar solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, btInertiaCL* inertias,int numBodies,b3Contact4* manifoldPtr, int numManifolds,b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal); + virtual b3Scalar solveGroupCacheFriendlySetup(b3RigidBodyCL* bodies, b3InertiaCL* inertias,int numBodies,b3Contact4* manifoldPtr, int numManifolds,b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal); virtual b3Scalar solveGroupCacheFriendlyIterations(b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal); @@ -106,27 +106,27 @@ protected: b3Scalar solveSingleIteration(int iteration, b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal); - virtual b3Scalar solveGroupCacheFriendlyFinish(b3RigidBodyCL* bodies, btInertiaCL* inertias,int numBodies,const b3ContactSolverInfo& infoGlobal); + virtual b3Scalar solveGroupCacheFriendlyFinish(b3RigidBodyCL* bodies, b3InertiaCL* inertias,int numBodies,const b3ContactSolverInfo& infoGlobal); public: - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); b3PgsJacobiSolver(); virtual ~b3PgsJacobiSolver(); -// void solveContacts(int numBodies, b3RigidBodyCL* bodies, btInertiaCL* inertias, int numContacts, b3Contact4* contacts); - void solveContacts(int numBodies, b3RigidBodyCL* bodies, btInertiaCL* inertias, int numContacts, b3Contact4* contacts, int numConstraints, b3TypedConstraint** constraints); +// void solveContacts(int numBodies, b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numContacts, b3Contact4* contacts); + void solveContacts(int numBodies, b3RigidBodyCL* bodies, b3InertiaCL* inertias, int numContacts, b3Contact4* contacts, int numConstraints, b3TypedConstraint** constraints); - b3Scalar solveGroup(b3RigidBodyCL* bodies,btInertiaCL* inertias,int numBodies,b3Contact4* manifoldPtr, int numManifolds,b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal); + b3Scalar solveGroup(b3RigidBodyCL* bodies,b3InertiaCL* inertias,int numBodies,b3Contact4* manifoldPtr, int numManifolds,b3TypedConstraint** constraints,int numConstraints,const b3ContactSolverInfo& infoGlobal); ///clear internal cached data and reset random seed virtual void reset(); - unsigned long btRand2(); + unsigned long b3Rand2(); - int btRandInt2 (int n); + int b3RandInt2 (int n); void setRandSeed(unsigned long seed) { @@ -142,5 +142,5 @@ public: }; -#endif //BT_PGS_JACOBI_SOLVER +#endif //B3_PGS_JACOBI_SOLVER diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp index 25e10e732..d3758ea9e 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp +++ b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.cpp @@ -51,12 +51,12 @@ void b3Point2PointConstraint::buildJacobian() } -void b3Point2PointConstraint::getInfo1 (btConstraintInfo1* info) +void b3Point2PointConstraint::getInfo1 (b3ConstraintInfo1* info) { getInfo1NonVirtual(info); } -void b3Point2PointConstraint::getInfo1NonVirtual (btConstraintInfo1* info) +void b3Point2PointConstraint::getInfo1NonVirtual (b3ConstraintInfo1* info) { if (m_useSolveConstraintObsolete) { @@ -72,7 +72,7 @@ void b3Point2PointConstraint::getInfo1NonVirtual (btConstraintInfo1* info) -void b3Point2PointConstraint::getInfo2 (btConstraintInfo2* info, const b3RigidBodyCL* bodies) +void b3Point2PointConstraint::getInfo2 (b3ConstraintInfo2* info, const b3RigidBodyCL* bodies) { b3Transform trA; trA.setIdentity(); @@ -87,9 +87,9 @@ void b3Point2PointConstraint::getInfo2 (btConstraintInfo2* info, const b3RigidBo getInfo2NonVirtual(info, trA,trB); } -void b3Point2PointConstraint::getInfo2NonVirtual (btConstraintInfo2* info, const b3Transform& body0_trans, const b3Transform& body1_trans) +void b3Point2PointConstraint::getInfo2NonVirtual (b3ConstraintInfo2* info, const b3Transform& body0_trans, const b3Transform& body1_trans) { - btAssert(!m_useSolveConstraintObsolete); + b3Assert(!m_useSolveConstraintObsolete); //retrieve matrices @@ -129,7 +129,7 @@ void b3Point2PointConstraint::getInfo2NonVirtual (btConstraintInfo2* info, const // set right hand side - b3Scalar currERP = (m_flags & BT_P2P_FLAGS_ERP) ? m_erp : info->erp; + b3Scalar currERP = (m_flags & B3_P2P_FLAGS_ERP) ? m_erp : info->erp; b3Scalar k = info->fps * currERP; int j; for (j=0; j<3; j++) @@ -137,7 +137,7 @@ void b3Point2PointConstraint::getInfo2NonVirtual (btConstraintInfo2* info, const info->m_constraintError[j*info->rowskip] = k * (a2[j] + body1_trans.getOrigin()[j] - a1[j] - body0_trans.getOrigin()[j]); //printf("info->m_constraintError[%d]=%f\n",j,info->m_constraintError[j]); } - if(m_flags & BT_P2P_FLAGS_CFM) + if(m_flags & B3_P2P_FLAGS_CFM) { for (j=0; j<3; j++) { @@ -172,24 +172,24 @@ void b3Point2PointConstraint::setParam(int num, b3Scalar value, int axis) { if(axis != -1) { - btAssertConstrParams(0); + b3AssertConstrParams(0); } else { switch(num) { - case BT_CONSTRAINT_ERP : - case BT_CONSTRAINT_STOP_ERP : + case B3_CONSTRAINT_ERP : + case B3_CONSTRAINT_STOP_ERP : m_erp = value; - m_flags |= BT_P2P_FLAGS_ERP; + m_flags |= B3_P2P_FLAGS_ERP; break; - case BT_CONSTRAINT_CFM : - case BT_CONSTRAINT_STOP_CFM : + case B3_CONSTRAINT_CFM : + case B3_CONSTRAINT_STOP_CFM : m_cfm = value; - m_flags |= BT_P2P_FLAGS_CFM; + m_flags |= B3_P2P_FLAGS_CFM; break; default: - btAssertConstrParams(0); + b3AssertConstrParams(0); } } } @@ -200,24 +200,24 @@ b3Scalar b3Point2PointConstraint::getParam(int num, int axis) const b3Scalar retVal(SIMD_INFINITY); if(axis != -1) { - btAssertConstrParams(0); + b3AssertConstrParams(0); } else { switch(num) { - case BT_CONSTRAINT_ERP : - case BT_CONSTRAINT_STOP_ERP : - btAssertConstrParams(m_flags & BT_P2P_FLAGS_ERP); + case B3_CONSTRAINT_ERP : + case B3_CONSTRAINT_STOP_ERP : + b3AssertConstrParams(m_flags & B3_P2P_FLAGS_ERP); retVal = m_erp; break; - case BT_CONSTRAINT_CFM : - case BT_CONSTRAINT_STOP_CFM : - btAssertConstrParams(m_flags & BT_P2P_FLAGS_CFM); + case B3_CONSTRAINT_CFM : + case B3_CONSTRAINT_STOP_CFM : + b3AssertConstrParams(m_flags & B3_P2P_FLAGS_CFM); retVal = m_cfm; break; default: - btAssertConstrParams(0); + b3AssertConstrParams(0); } } return retVal; diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h index d041dc6db..2c6e37ba5 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h @@ -13,27 +13,27 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_POINT2POINTCONSTRAINT_H -#define BT_POINT2POINTCONSTRAINT_H +#ifndef B3_POINT2POINTCONSTRAINT_H +#define B3_POINT2POINTCONSTRAINT_H #include "Bullet3Common/b3Vector3.h" //#include "b3JacobianEntry.h" #include "b3TypedConstraint.h" -class btRigidBody; +class b3RigidBody; -#ifdef BT_USE_DOUBLE_PRECISION -#define btPoint2PointConstraintData btPoint2PointConstraintDoubleData -#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData" +#ifdef B3_USE_DOUBLE_PRECISION +#define b3Point2PointConstraintData b3Point2PointConstraintDoubleData +#define b3Point2PointConstraintDataName "b3Point2PointConstraintDoubleData" #else -#define btPoint2PointConstraintData btPoint2PointConstraintFloatData -#define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData" -#endif //BT_USE_DOUBLE_PRECISION +#define b3Point2PointConstraintData b3Point2PointConstraintFloatData +#define b3Point2PointConstraintDataName "b3Point2PointConstraintFloatData" +#endif //B3_USE_DOUBLE_PRECISION -struct btConstraintSetting +struct b3ConstraintSetting { - btConstraintSetting() : + b3ConstraintSetting() : m_tau(b3Scalar(0.3)), m_damping(b3Scalar(1.)), m_impulseClamp(b3Scalar(0.)) @@ -44,10 +44,10 @@ struct btConstraintSetting b3Scalar m_impulseClamp; }; -enum btPoint2PointFlags +enum b3Point2PointFlags { - BT_P2P_FLAGS_ERP = 1, - BT_P2P_FLAGS_CFM = 2 + B3_P2P_FLAGS_ERP = 1, + B3_P2P_FLAGS_CFM = 2 }; /// point to point constraint between two rigidbodies each with a pivotpoint that descibes the 'ballsocket' location in local space @@ -66,12 +66,12 @@ public: public: - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); ///for backwards compatibility during the transition to 'getInfo/getInfo2' bool m_useSolveConstraintObsolete; - btConstraintSetting m_setting; + b3ConstraintSetting m_setting; b3Point2PointConstraint(int rbA,int rbB, const b3Vector3& pivotInA,const b3Vector3& pivotInB); @@ -80,13 +80,13 @@ public: virtual void buildJacobian(); - virtual void getInfo1 (btConstraintInfo1* info); + virtual void getInfo1 (b3ConstraintInfo1* info); - void getInfo1NonVirtual (btConstraintInfo1* info); + void getInfo1NonVirtual (b3ConstraintInfo1* info); - virtual void getInfo2 (btConstraintInfo2* info, const b3RigidBodyCL* bodies); + virtual void getInfo2 (b3ConstraintInfo2* info, const b3RigidBodyCL* bodies); - void getInfo2NonVirtual (btConstraintInfo2* info, const b3Transform& body0_trans, const b3Transform& body1_trans); + void getInfo2NonVirtual (b3ConstraintInfo2* info, const b3Transform& body0_trans, const b3Transform& body1_trans); void updateRHS(b3Scalar timeStep); @@ -119,45 +119,45 @@ public: // 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; }; ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 -struct btPoint2PointConstraintFloatData +struct b3Point2PointConstraintFloatData { - btTypedConstraintData m_typeConstraintData; - btVector3FloatData m_pivotInA; - btVector3FloatData m_pivotInB; + b3TypedConstraintData m_typeConstraintData; + b3Vector3FloatData m_pivotInA; + b3Vector3FloatData m_pivotInB; }; ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 -struct btPoint2PointConstraintDoubleData +struct b3Point2PointConstraintDoubleData { - btTypedConstraintData m_typeConstraintData; - btVector3DoubleData m_pivotInA; - btVector3DoubleData m_pivotInB; + b3TypedConstraintData m_typeConstraintData; + b3Vector3DoubleData m_pivotInA; + b3Vector3DoubleData m_pivotInB; }; /* SIMD_FORCE_INLINE int b3Point2PointConstraint::calculateSerializeBufferSize() const { - return sizeof(btPoint2PointConstraintData); + return sizeof(b3Point2PointConstraintData); } ///fills the dataBuffer and returns the struct name (and 0 on failure) -SIMD_FORCE_INLINE const char* b3Point2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const +SIMD_FORCE_INLINE const char* b3Point2PointConstraint::serialize(void* dataBuffer, b3Serializer* serializer) const { - btPoint2PointConstraintData* p2pData = (btPoint2PointConstraintData*)dataBuffer; + b3Point2PointConstraintData* p2pData = (b3Point2PointConstraintData*)dataBuffer; b3TypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer); m_pivotInA.serialize(p2pData->m_pivotInA); m_pivotInB.serialize(p2pData->m_pivotInB); - return btPoint2PointConstraintDataName; + return b3Point2PointConstraintDataName; } */ -#endif //BT_POINT2POINTCONSTRAINT_H +#endif //B3_POINT2POINTCONSTRAINT_H diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h b/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h index a8519e7c1..afd5a2b30 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3SolverBody.h @@ -13,10 +13,10 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_SOLVER_BODY_H -#define BT_SOLVER_BODY_H +#ifndef B3_SOLVER_BODY_H +#define B3_SOLVER_BODY_H -class btRigidBody; +class b3RigidBody; #include "Bullet3Common/b3Vector3.h" #include "Bullet3Common/b3Matrix3x3.h" @@ -24,26 +24,26 @@ class btRigidBody; #include "Bullet3Common/b3TransformUtil.h" ///Until we get other contributions, only use SIMD on Windows, when using Visual Studio 2008 or later, and not double precision -#ifdef BT_USE_SSE +#ifdef B3_USE_SSE #define USE_SIMD 1 #endif // #ifdef USE_SIMD -struct btSimdScalar +struct b3SimdScalar { - SIMD_FORCE_INLINE btSimdScalar() + SIMD_FORCE_INLINE b3SimdScalar() { } - SIMD_FORCE_INLINE btSimdScalar(float fl) + SIMD_FORCE_INLINE b3SimdScalar(float fl) :m_vec128 (_mm_set1_ps(fl)) { } - SIMD_FORCE_INLINE btSimdScalar(__m128 v128) + SIMD_FORCE_INLINE b3SimdScalar(__m128 v128) :m_vec128(v128) { } @@ -85,29 +85,29 @@ struct btSimdScalar }; -///@brief Return the elementwise product of two btSimdScalar -SIMD_FORCE_INLINE btSimdScalar -operator*(const btSimdScalar& v1, const btSimdScalar& v2) +///@brief Return the elementwise product of two b3SimdScalar +SIMD_FORCE_INLINE b3SimdScalar +operator*(const b3SimdScalar& v1, const b3SimdScalar& v2) { - return btSimdScalar(_mm_mul_ps(v1.get128(),v2.get128())); + return b3SimdScalar(_mm_mul_ps(v1.get128(),v2.get128())); } -///@brief Return the elementwise product of two btSimdScalar -SIMD_FORCE_INLINE btSimdScalar -operator+(const btSimdScalar& v1, const btSimdScalar& v2) +///@brief Return the elementwise product of two b3SimdScalar +SIMD_FORCE_INLINE b3SimdScalar +operator+(const b3SimdScalar& v1, const b3SimdScalar& v2) { - return btSimdScalar(_mm_add_ps(v1.get128(),v2.get128())); + return b3SimdScalar(_mm_add_ps(v1.get128(),v2.get128())); } #else -#define btSimdScalar b3Scalar +#define b3SimdScalar b3Scalar #endif ///The b3SolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance. ATTRIBUTE_ALIGNED64 (struct) b3SolverBody { - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); b3Transform m_worldTransform; b3Vector3 m_deltaLinearVelocity; b3Vector3 m_deltaAngularVelocity; @@ -281,7 +281,7 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody b3Transform newTransform; if (m_pushVelocity[0]!=0.f || m_pushVelocity[1]!=0 || m_pushVelocity[2]!=0 || m_turnVelocity[0]!=0.f || m_turnVelocity[1]!=0 || m_turnVelocity[2]!=0) { - // btQuaternion orn = m_worldTransform.getRotation(); + // b3Quaternion orn = m_worldTransform.getRotation(); b3TransformUtil::integrateTransform(m_worldTransform,m_pushVelocity,m_turnVelocity*splitImpulseTurnErp,timeStep,newTransform); m_worldTransform = newTransform; } @@ -294,6 +294,6 @@ ATTRIBUTE_ALIGNED64 (struct) b3SolverBody }; -#endif //BT_SOLVER_BODY_H +#endif //B3_SOLVER_BODY_H diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h index 1efb13e51..cf733926c 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3SolverConstraint.h @@ -13,13 +13,13 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_SOLVER_CONSTRAINT_H -#define BT_SOLVER_CONSTRAINT_H +#ifndef B3_SOLVER_CONSTRAINT_H +#define B3_SOLVER_CONSTRAINT_H -class btRigidBody; +class b3RigidBody; #include "Bullet3Common/b3Vector3.h" #include "Bullet3Common/b3Matrix3x3.h" -//#include "btJacobianEntry.h" +//#include "b3JacobianEntry.h" #include "Bullet3Common/b3AlignedObjectArray.h" //#define NO_FRICTION_TANGENTIALS 1 @@ -29,7 +29,7 @@ class btRigidBody; ///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints. ATTRIBUTE_ALIGNED16 (struct) b3SolverConstraint { - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); b3Vector3 m_relpos1CrossNormal; b3Vector3 m_contactNormal; @@ -40,8 +40,8 @@ ATTRIBUTE_ALIGNED16 (struct) b3SolverConstraint b3Vector3 m_angularComponentA; b3Vector3 m_angularComponentB; - mutable btSimdScalar m_appliedPushImpulse; - mutable btSimdScalar m_appliedImpulse; + mutable b3SimdScalar m_appliedPushImpulse; + mutable b3SimdScalar m_appliedImpulse; b3Scalar m_friction; b3Scalar m_jacDiagABInv; @@ -63,17 +63,17 @@ ATTRIBUTE_ALIGNED16 (struct) b3SolverConstraint int m_solverBodyIdB; - enum btSolverConstraintType + enum b3SolverConstraintType { - BT_SOLVER_CONTACT_1D = 0, - BT_SOLVER_FRICTION_1D + B3_SOLVER_CONTACT_1D = 0, + B3_SOLVER_FRICTION_1D }; }; -typedef b3AlignedObjectArray btConstraintArray; +typedef b3AlignedObjectArray b3ConstraintArray; -#endif //BT_SOLVER_CONSTRAINT_H +#endif //B3_SOLVER_CONSTRAINT_H diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp index fcc178888..570e0ead1 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp +++ b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.cpp @@ -15,15 +15,15 @@ subject to the following restrictions: #include "b3TypedConstraint.h" -//#include "Bullet3Common/btSerializer.h" +//#include "Bullet3Common/b3Serializer.h" #define DEFAULT_DEBUGDRAW_SIZE b3Scalar(0.3f) -b3TypedConstraint::b3TypedConstraint(btTypedConstraintType type, int rbA,int rbB) -:btTypedObject(type), +b3TypedConstraint::b3TypedConstraint(b3TypedConstraintType type, int rbA,int rbB) +:b3TypedObject(type), m_userConstraintType(-1), m_userConstraintId(-1), m_breakingImpulseThreshold(SIMD_INFINITY), @@ -92,16 +92,16 @@ b3Scalar b3TypedConstraint::getMotorFactor(b3Scalar pos, b3Scalar lowLim, b3Scal -void btAngularLimit::set(b3Scalar low, b3Scalar high, b3Scalar _softness, b3Scalar _biasFactor, b3Scalar _relaxationFactor) +void b3AngularLimit::set(b3Scalar low, b3Scalar high, b3Scalar _softness, b3Scalar _biasFactor, b3Scalar _relaxationFactor) { m_halfRange = (high - low) / 2.0f; - m_center = btNormalizeAngle(low + m_halfRange); + m_center = b3NormalizeAngle(low + m_halfRange); m_softness = _softness; m_biasFactor = _biasFactor; m_relaxationFactor = _relaxationFactor; } -void btAngularLimit::test(const b3Scalar angle) +void b3AngularLimit::test(const b3Scalar angle) { m_correction = 0.0f; m_sign = 0.0f; @@ -109,7 +109,7 @@ void btAngularLimit::test(const b3Scalar angle) if (m_halfRange >= 0.0f) { - b3Scalar deviation = btNormalizeAngle(angle - m_center); + b3Scalar deviation = b3NormalizeAngle(angle - m_center); if (deviation < -m_halfRange) { m_solveLimit = true; @@ -126,17 +126,17 @@ void btAngularLimit::test(const b3Scalar angle) } -b3Scalar btAngularLimit::getError() const +b3Scalar b3AngularLimit::getError() const { return m_correction * m_sign; } -void btAngularLimit::fit(b3Scalar& angle) const +void b3AngularLimit::fit(b3Scalar& angle) const { if (m_halfRange > 0.0f) { - b3Scalar relativeAngle = btNormalizeAngle(angle - m_center); - if (!btEqual(relativeAngle, m_halfRange)) + b3Scalar relativeAngle = b3NormalizeAngle(angle - m_center); + if (!b3Equal(relativeAngle, m_halfRange)) { if (relativeAngle > 0.0f) { @@ -150,12 +150,12 @@ void btAngularLimit::fit(b3Scalar& angle) const } } -b3Scalar btAngularLimit::getLow() const +b3Scalar b3AngularLimit::getLow() const { - return btNormalizeAngle(m_center - m_halfRange); + return b3NormalizeAngle(m_center - m_halfRange); } -b3Scalar btAngularLimit::getHigh() const +b3Scalar b3AngularLimit::getHigh() const { - return btNormalizeAngle(m_center + m_halfRange); + return b3NormalizeAngle(m_center + m_halfRange); } diff --git a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h index 983dfd127..3913b4726 100644 --- a/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h +++ b/src/Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h @@ -13,17 +13,17 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_TYPED_CONSTRAINT_H -#define BT_TYPED_CONSTRAINT_H +#ifndef B3_TYPED_CONSTRAINT_H +#define B3_TYPED_CONSTRAINT_H #include "Bullet3Common/b3Scalar.h" #include "b3SolverConstraint.h" -class btSerializer; +class b3Serializer; //Don't change any of the existing enum values, so add enum types at the end for serialization compatibility -enum btTypedConstraintType +enum b3TypedConstraintType { POINT2POINT_CONSTRAINT_TYPE=3, HINGE_CONSTRAINT_TYPE, @@ -37,22 +37,22 @@ enum btTypedConstraintType }; -enum btConstraintParams +enum b3ConstraintParams { - BT_CONSTRAINT_ERP=1, - BT_CONSTRAINT_STOP_ERP, - BT_CONSTRAINT_CFM, - BT_CONSTRAINT_STOP_CFM + B3_CONSTRAINT_ERP=1, + B3_CONSTRAINT_STOP_ERP, + B3_CONSTRAINT_CFM, + B3_CONSTRAINT_STOP_CFM }; #if 1 - #define btAssertConstrParams(_par) btAssert(_par) + #define b3AssertConstrParams(_par) b3Assert(_par) #else - #define btAssertConstrParams(_par) + #define b3AssertConstrParams(_par) #endif -ATTRIBUTE_ALIGNED16(struct) btJointFeedback +ATTRIBUTE_ALIGNED16(struct) b3JointFeedback { b3Vector3 m_appliedForceBodyA; b3Vector3 m_appliedTorqueBodyA; @@ -64,7 +64,7 @@ struct b3RigidBodyCL; ///TypedConstraint is the baseclass for Bullet constraints and vehicles -ATTRIBUTE_ALIGNED16(class) b3TypedConstraint : public btTypedObject +ATTRIBUTE_ALIGNED16(class) b3TypedConstraint : public b3TypedObject { int m_userConstraintType; @@ -82,7 +82,7 @@ ATTRIBUTE_ALIGNED16(class) b3TypedConstraint : public btTypedObject b3TypedConstraint& operator=(b3TypedConstraint& other) { - btAssert(0); + b3Assert(0); (void) other; return *this; } @@ -92,7 +92,7 @@ protected: int m_rbB; b3Scalar m_appliedImpulse; b3Scalar m_dbgDrawSize; - btJointFeedback* m_jointFeedback; + b3JointFeedback* m_jointFeedback; ///internal method used by the constraint solver, don't use them directly b3Scalar getMotorFactor(b3Scalar pos, b3Scalar lowLim, b3Scalar uppLim, b3Scalar vel, b3Scalar timeFact); @@ -100,18 +100,18 @@ protected: public: - BT_DECLARE_ALIGNED_ALLOCATOR(); + B3_DECLARE_ALIGNED_ALLOCATOR(); virtual ~b3TypedConstraint() {}; - b3TypedConstraint(btTypedConstraintType type, int bodyA,int bodyB); + b3TypedConstraint(b3TypedConstraintType type, int bodyA,int bodyB); - struct btConstraintInfo1 { + struct b3ConstraintInfo1 { int m_numConstraintRows,nub; }; - static btRigidBody& getFixedBody(); + static b3RigidBody& getFixedBody(); - struct btConstraintInfo2 { + struct b3ConstraintInfo2 { // integrator parameters: frames per second (1/stepsize), default error // reduction parameter (0..1). b3Scalar fps,erp; @@ -161,7 +161,7 @@ public: virtual void buildJacobian() {}; ///internal method used by the constraint solver, don't use them directly - virtual void setupSolverConstraint(btConstraintArray& ca, int solverBodyA,int solverBodyB, b3Scalar timeStep) + virtual void setupSolverConstraint(b3ConstraintArray& ca, int solverBodyA,int solverBodyB, b3Scalar timeStep) { (void)ca; (void)solverBodyA; @@ -170,10 +170,10 @@ public: } ///internal method used by the constraint solver, don't use them directly - virtual void getInfo1 (btConstraintInfo1* info)=0; + virtual void getInfo1 (b3ConstraintInfo1* info)=0; ///internal method used by the constraint solver, don't use them directly - virtual void getInfo2 (btConstraintInfo2* info, const b3RigidBodyCL* bodies)=0; + virtual void getInfo2 (b3ConstraintInfo2* info, const b3RigidBodyCL* bodies)=0; ///internal method used by the constraint solver, don't use them directly void internalSetAppliedImpulse(b3Scalar appliedImpulse) @@ -261,17 +261,17 @@ public: return m_userConstraintPtr; } - void setJointFeedback(btJointFeedback* jointFeedback) + void setJointFeedback(b3JointFeedback* jointFeedback) { m_jointFeedback = jointFeedback; } - const btJointFeedback* getJointFeedback() const + const b3JointFeedback* getJointFeedback() const { return m_jointFeedback; } - btJointFeedback* getJointFeedback() + b3JointFeedback* getJointFeedback() { return m_jointFeedback; } @@ -298,13 +298,13 @@ public: ///This feedback could be used to determine breaking constraints or playing sounds. b3Scalar getAppliedImpulse() const { - btAssert(m_needsFeedback); + b3Assert(m_needsFeedback); return m_appliedImpulse; } - btTypedConstraintType getConstraintType () const + b3TypedConstraintType getConstraintType () const { - return btTypedConstraintType(m_objectType); + return b3TypedConstraintType(m_objectType); } void setDbgDrawSize(b3Scalar dbgDrawSize) @@ -326,13 +326,13 @@ public: // 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; }; // returns angle in range [-SIMD_2_PI, SIMD_2_PI], closest to one of the limits // all arguments should be normalized angles (i.e. in range [-SIMD_PI, SIMD_PI]) -SIMD_FORCE_INLINE b3Scalar btAdjustAngleToLimits(b3Scalar angleInRadians, b3Scalar angleLowerLimitInRadians, b3Scalar angleUpperLimitInRadians) +SIMD_FORCE_INLINE b3Scalar b3AdjustAngleToLimits(b3Scalar angleInRadians, b3Scalar angleLowerLimitInRadians, b3Scalar angleUpperLimitInRadians) { if(angleLowerLimitInRadians >= angleUpperLimitInRadians) { @@ -340,14 +340,14 @@ SIMD_FORCE_INLINE b3Scalar btAdjustAngleToLimits(b3Scalar angleInRadians, b3Scal } else if(angleInRadians < angleLowerLimitInRadians) { - b3Scalar diffLo = btFabs(btNormalizeAngle(angleLowerLimitInRadians - angleInRadians)); - b3Scalar diffHi = btFabs(btNormalizeAngle(angleUpperLimitInRadians - angleInRadians)); + b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleLowerLimitInRadians - angleInRadians)); + b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleUpperLimitInRadians - angleInRadians)); return (diffLo < diffHi) ? angleInRadians : (angleInRadians + SIMD_2_PI); } else if(angleInRadians > angleUpperLimitInRadians) { - b3Scalar diffHi = btFabs(btNormalizeAngle(angleInRadians - angleUpperLimitInRadians)); - b3Scalar diffLo = btFabs(btNormalizeAngle(angleInRadians - angleLowerLimitInRadians)); + b3Scalar diffHi = b3Fabs(b3NormalizeAngle(angleInRadians - angleUpperLimitInRadians)); + b3Scalar diffLo = b3Fabs(b3NormalizeAngle(angleInRadians - angleLowerLimitInRadians)); return (diffLo < diffHi) ? (angleInRadians - SIMD_2_PI) : angleInRadians; } else @@ -357,7 +357,7 @@ SIMD_FORCE_INLINE b3Scalar btAdjustAngleToLimits(b3Scalar angleInRadians, b3Scal } ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 -struct btTypedConstraintData +struct b3TypedConstraintData { int m_bodyA; int m_bodyB; @@ -381,12 +381,12 @@ struct btTypedConstraintData /*SIMD_FORCE_INLINE int b3TypedConstraint::calculateSerializeBufferSize() const { - return sizeof(btTypedConstraintData); + return sizeof(b3TypedConstraintData); } */ -class btAngularLimit +class b3AngularLimit { private: b3Scalar @@ -403,7 +403,7 @@ private: public: /// Default constructor initializes limit as inactive, allowing free constraint movement - btAngularLimit() + b3AngularLimit() :m_center(0.0f), m_halfRange(-1.0f), m_softness(0.9f), @@ -480,4 +480,4 @@ public: -#endif //BT_TYPED_CONSTRAINT_H +#endif //B3_TYPED_CONSTRAINT_H diff --git a/src/Bullet3Geometry/b3AabbUtil.h b/src/Bullet3Geometry/b3AabbUtil.h index 3728fd75f..0772a54d3 100644 --- a/src/Bullet3Geometry/b3AabbUtil.h +++ b/src/Bullet3Geometry/b3AabbUtil.h @@ -14,8 +14,8 @@ subject to the following restrictions: -#ifndef BT_AABB_UTIL2 -#define BT_AABB_UTIL2 +#ifndef B3_AABB_UTIL2 +#define B3_AABB_UTIL2 #include "Bullet3Common/b3Transform.h" #include "Bullet3Common/b3Vector3.h" @@ -63,19 +63,19 @@ SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const b3Vector3 *vertices, const b3Vector3 &p2 = vertices[1]; const b3Vector3 &p3 = vertices[2]; - if (btMin(btMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false; - if (btMax(btMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false; + if (b3Min(b3Min(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false; + if (b3Max(b3Max(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false; - if (btMin(btMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false; - if (btMax(btMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false; + if (b3Min(b3Min(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false; + if (b3Max(b3Max(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false; - if (btMin(btMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false; - if (btMax(btMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false; + if (b3Min(b3Min(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false; + if (b3Max(b3Max(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false; return true; } -SIMD_FORCE_INLINE int btOutcode(const b3Vector3& p,const b3Vector3& halfExtent) +SIMD_FORCE_INLINE int b3Outcode(const b3Vector3& p,const b3Vector3& halfExtent) { return (p.getX() < -halfExtent.getX() ? 0x01 : 0x0) | (p.getX() > halfExtent.getX() ? 0x08 : 0x0) | @@ -87,7 +87,7 @@ SIMD_FORCE_INLINE int btOutcode(const b3Vector3& p,const b3Vector3& halfExtent) -SIMD_FORCE_INLINE bool btRayAabb2(const b3Vector3& rayFrom, +SIMD_FORCE_INLINE bool b3RayAabb2(const b3Vector3& rayFrom, const b3Vector3& rayInvDirection, const unsigned int raySign[3], const b3Vector3 bounds[2], @@ -122,7 +122,7 @@ SIMD_FORCE_INLINE bool btRayAabb2(const b3Vector3& rayFrom, return ( (tmin < lambda_max) && (tmax > lambda_min) ); } -SIMD_FORCE_INLINE bool btRayAabb(const b3Vector3& rayFrom, +SIMD_FORCE_INLINE bool b3RayAabb(const b3Vector3& rayFrom, const b3Vector3& rayTo, const b3Vector3& aabbMin, const b3Vector3& aabbMax, @@ -132,8 +132,8 @@ SIMD_FORCE_INLINE bool btRayAabb(const b3Vector3& rayFrom, b3Vector3 aabbCenter = (aabbMax+aabbMin)* b3Scalar(0.5); b3Vector3 source = rayFrom - aabbCenter; b3Vector3 target = rayTo - aabbCenter; - int sourceOutcode = btOutcode(source,aabbHalfExtent); - int targetOutcode = btOutcode(target,aabbHalfExtent); + int sourceOutcode = b3Outcode(source,aabbHalfExtent); + int targetOutcode = b3Outcode(target,aabbHalfExtent); if ((sourceOutcode & targetOutcode) == 0x0) { b3Scalar lambda_enter = b3Scalar(0.0); @@ -161,7 +161,7 @@ SIMD_FORCE_INLINE bool btRayAabb(const b3Vector3& rayFrom, else if (targetOutcode & bit) { b3Scalar lambda = (-source[i] - aabbHalfExtent[i]*normSign) / r[i]; - btSetMin(lambda_exit, lambda); + b3SetMin(lambda_exit, lambda); } bit<<=1; } @@ -179,7 +179,7 @@ SIMD_FORCE_INLINE bool btRayAabb(const b3Vector3& rayFrom, -SIMD_FORCE_INLINE void btTransformAabb(const b3Vector3& halfExtents, b3Scalar margin,const b3Transform& t,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) +SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& halfExtents, b3Scalar margin,const b3Transform& t,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) { b3Vector3 halfExtentsWithMargin = halfExtents+b3Vector3(margin,margin,margin); b3Matrix3x3 abs_b = t.getBasis().absolute(); @@ -190,11 +190,11 @@ SIMD_FORCE_INLINE void btTransformAabb(const b3Vector3& halfExtents, b3Scalar ma } -SIMD_FORCE_INLINE void btTransformAabb(const b3Vector3& localAabbMin,const b3Vector3& localAabbMax, b3Scalar margin,const b3Transform& trans,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) +SIMD_FORCE_INLINE void b3TransformAabb(const b3Vector3& localAabbMin,const b3Vector3& localAabbMax, b3Scalar margin,const b3Transform& trans,b3Vector3& aabbMinOut,b3Vector3& aabbMaxOut) { - btAssert(localAabbMin.getX() <= localAabbMax.getX()); - btAssert(localAabbMin.getY() <= localAabbMax.getY()); - btAssert(localAabbMin.getZ() <= localAabbMax.getZ()); + b3Assert(localAabbMin.getX() <= localAabbMax.getX()); + b3Assert(localAabbMin.getY() <= localAabbMax.getY()); + b3Assert(localAabbMin.getZ() <= localAabbMax.getZ()); b3Vector3 localHalfExtents = b3Scalar(0.5)*(localAabbMax-localAabbMin); localHalfExtents+=b3Vector3(margin,margin,margin); @@ -211,7 +211,7 @@ SIMD_FORCE_INLINE void btTransformAabb(const b3Vector3& localAabbMin,const b3Vec //This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360) SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(const unsigned short int* aabbMin1,const unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) { - return static_cast(btSelect((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0]) + return static_cast(b3Select((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0]) & (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2]) & (aabbMin1[1] <= aabbMax2[1]) & (aabbMax1[1] >= aabbMin2[1])), 1, 0)); @@ -227,6 +227,6 @@ SIMD_FORCE_INLINE void btTransformAabb(const b3Vector3& localAabbMin,const b3Vec } #endif //USE_BANCHLESS -#endif //BT_AABB_UTIL2 +#endif //B3_AABB_UTIL2 diff --git a/src/Bullet3Geometry/b3ConvexHullComputer.cpp b/src/Bullet3Geometry/b3ConvexHullComputer.cpp index b3a0e6094..10478b6f7 100644 --- a/src/Bullet3Geometry/b3ConvexHullComputer.cpp +++ b/src/Bullet3Geometry/b3ConvexHullComputer.cpp @@ -49,7 +49,7 @@ subject to the following restrictions: // Convex hull implementation based on Preparata and Hong // Ole Kniemeyer, MAXON Computer GmbH -class btConvexHullInternal +class b3ConvexHullInternal { public: @@ -495,7 +495,7 @@ class btConvexHullInternal } for (Face* f = src->firstNearbyFace; f; f = f->nextWithSameNearbyVertex) { - btAssert(f->nearbyVertex == src); + b3Assert(f->nearbyVertex == src); f->nearbyVertex = this; } src->firstNearbyFace = NULL; @@ -525,7 +525,7 @@ class btConvexHullInternal void link(Edge* n) { - btAssert(reverse->target == n->reverse->target); + b3Assert(reverse->target == n->reverse->target); next = n; n->prev = this; } @@ -673,12 +673,12 @@ class btConvexHullInternal PoolArray(int size): size(size), next(NULL) { - array = (T*) btAlignedAlloc(sizeof(T) * size, 16); + array = (T*) b3AlignedAlloc(sizeof(T) * size, 16); } ~PoolArray() { - btAlignedFree(array); + b3AlignedFree(array); } T* init() @@ -712,7 +712,7 @@ class btConvexHullInternal PoolArray* p = arrays; arrays = p->next; p->~PoolArray(); - btAlignedFree(p); + b3AlignedFree(p); } } @@ -739,7 +739,7 @@ class btConvexHullInternal } else { - p = new(btAlignedAlloc(sizeof(PoolArray), 16)) PoolArray(arraySize); + p = new(b3AlignedAlloc(sizeof(PoolArray), 16)) PoolArray(arraySize); p->next = arrays; arrays = p; } @@ -781,7 +781,7 @@ class btConvexHullInternal Edge* n = edge->next; Edge* r = edge->reverse; - btAssert(edge->target && r->target); + b3Assert(edge->target && r->target); if (n != edge) { @@ -835,7 +835,7 @@ class btConvexHullInternal }; -btConvexHullInternal::Int128 btConvexHullInternal::Int128::operator*(int64_t b) const +b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::operator*(int64_t b) const { bool negative = (int64_t) high < 0; Int128 a = negative ? -*this : *this; @@ -849,7 +849,7 @@ btConvexHullInternal::Int128 btConvexHullInternal::Int128::operator*(int64_t b) return negative ? -result : result; } -btConvexHullInternal::Int128 btConvexHullInternal::Int128::mul(int64_t a, int64_t b) +b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(int64_t a, int64_t b) { Int128 result; @@ -876,7 +876,7 @@ btConvexHullInternal::Int128 btConvexHullInternal::Int128::mul(int64_t a, int64_ #endif } -btConvexHullInternal::Int128 btConvexHullInternal::Int128::mul(uint64_t a, uint64_t b) +b3ConvexHullInternal::Int128 b3ConvexHullInternal::Int128::mul(uint64_t a, uint64_t b) { Int128 result; @@ -893,7 +893,7 @@ btConvexHullInternal::Int128 btConvexHullInternal::Int128::mul(uint64_t a, uint6 return result; } -int btConvexHullInternal::Rational64::compare(const Rational64& b) const +int b3ConvexHullInternal::Rational64::compare(const Rational64& b) const { if (sign != b.sign) { @@ -937,7 +937,7 @@ int btConvexHullInternal::Rational64::compare(const Rational64& b) const #endif } -int btConvexHullInternal::Rational128::compare(const Rational128& b) const +int b3ConvexHullInternal::Rational128::compare(const Rational128& b) const { if (sign != b.sign) { @@ -964,7 +964,7 @@ int btConvexHullInternal::Rational128::compare(const Rational128& b) const return nbdLow.ucmp(dbnLow) * sign; } -int btConvexHullInternal::Rational128::compare(int64_t b) const +int b3ConvexHullInternal::Rational128::compare(int64_t b) const { if (isInt64) { @@ -995,9 +995,9 @@ int btConvexHullInternal::Rational128::compare(int64_t b) const } -btConvexHullInternal::Edge* btConvexHullInternal::newEdgePair(Vertex* from, Vertex* to) +b3ConvexHullInternal::Edge* b3ConvexHullInternal::newEdgePair(Vertex* from, Vertex* to) { - btAssert(from && to); + b3Assert(from && to); Edge* e = edgePool.newObject(); Edge* r = edgePool.newObject(); e->reverse = r; @@ -1016,22 +1016,22 @@ btConvexHullInternal::Edge* btConvexHullInternal::newEdgePair(Vertex* from, Vert return e; } -bool btConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHull& h1, Vertex*& c0, Vertex*& c1) +bool b3ConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHull& h1, Vertex*& c0, Vertex*& c1) { Vertex* v0 = h0.maxYx; Vertex* v1 = h1.minYx; if ((v0->point.x == v1->point.x) && (v0->point.y == v1->point.y)) { - btAssert(v0->point.z < v1->point.z); + b3Assert(v0->point.z < v1->point.z); Vertex* v1p = v1->prev; if (v1p == v1) { c0 = v0; if (v1->edges) { - btAssert(v1->edges->next == v1->edges); + b3Assert(v1->edges->next == v1->edges); v1 = v1->edges->target; - btAssert(v1->edges->next == v1->edges); + b3Assert(v1->edges->next == v1->edges); } c1 = v1; return false; @@ -1201,7 +1201,7 @@ bool btConvexHullInternal::mergeProjection(IntermediateHull& h0, IntermediateHul return true; } -void btConvexHullInternal::computeInternal(int start, int end, IntermediateHull& result) +void b3ConvexHullInternal::computeInternal(int start, int end, IntermediateHull& result) { int n = end - start; switch (n) @@ -1229,7 +1229,7 @@ void btConvexHullInternal::computeInternal(int start, int end, IntermediateHull& w = v; v = t; } - btAssert(v->point.z < w->point.z); + b3Assert(v->point.z < w->point.z); v->next = v; v->prev = v; result.minXy = v; @@ -1318,7 +1318,7 @@ void btConvexHullInternal::computeInternal(int start, int end, IntermediateHull& } #ifdef DEBUG_CONVEX_HULL -void btConvexHullInternal::IntermediateHull::print() +void b3ConvexHullInternal::IntermediateHull::print() { printf(" Hull\n"); for (Vertex* v = minXy; v; ) @@ -1355,7 +1355,7 @@ void btConvexHullInternal::IntermediateHull::print() } } -void btConvexHullInternal::Vertex::printGraph() +void b3ConvexHullInternal::Vertex::printGraph() { print(); printf("\nEdges\n"); @@ -1382,18 +1382,18 @@ void btConvexHullInternal::Vertex::printGraph() } #endif -btConvexHullInternal::Orientation btConvexHullInternal::getOrientation(const Edge* prev, const Edge* next, const Point32& s, const Point32& t) +b3ConvexHullInternal::Orientation b3ConvexHullInternal::getOrientation(const Edge* prev, const Edge* next, const Point32& s, const Point32& t) { - btAssert(prev->reverse->target == next->reverse->target); + b3Assert(prev->reverse->target == next->reverse->target); if (prev->next == next) { if (prev->prev == next) { Point64 n = t.cross(s); Point64 m = (*prev->target - *next->reverse->target).cross(*next->target - *next->reverse->target); - btAssert(!m.isZero()); + b3Assert(!m.isZero()); int64_t dot = n.dot(m); - btAssert(dot != 0); + b3Assert(dot != 0); return (dot > 0) ? COUNTER_CLOCKWISE : CLOCKWISE; } return COUNTER_CLOCKWISE; @@ -1408,7 +1408,7 @@ btConvexHullInternal::Orientation btConvexHullInternal::getOrientation(const Edg } } -btConvexHullInternal::Edge* btConvexHullInternal::findMaxAngle(bool ccw, const Vertex* start, const Point32& s, const Point64& rxs, const Point64& sxrxs, Rational64& minCot) +b3ConvexHullInternal::Edge* b3ConvexHullInternal::findMaxAngle(bool ccw, const Vertex* start, const Point32& s, const Point64& rxs, const Point64& sxrxs, Rational64& minCot) { Edge* minEdge = NULL; @@ -1425,12 +1425,12 @@ btConvexHullInternal::Edge* btConvexHullInternal::findMaxAngle(bool ccw, const V Point32 t = *e->target - *start; Rational64 cot(t.dot(sxrxs), t.dot(rxs)); #ifdef DEBUG_CONVEX_HULL - printf(" Angle is %f (%d) for ", (float) btAtan(cot.toScalar()), (int) cot.isNaN()); + printf(" Angle is %f (%d) for ", (float) b3Atan(cot.toScalar()), (int) cot.isNaN()); e->print(); #endif if (cot.isNaN()) { - btAssert(ccw ? (t.dot(s) < 0) : (t.dot(s) > 0)); + b3Assert(ccw ? (t.dot(s) < 0) : (t.dot(s) > 0)); } else { @@ -1460,7 +1460,7 @@ btConvexHullInternal::Edge* btConvexHullInternal::findMaxAngle(bool ccw, const V return minEdge; } -void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge*& e0, Edge*& e1, Vertex* stop0, Vertex* stop1) +void b3ConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge*& e0, Edge*& e1, Vertex* stop0, Vertex* stop1) { Edge* start0 = e0; Edge* start1 = e1; @@ -1469,9 +1469,9 @@ void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge Point32 s = c1->point - c0->point; Point64 normal = ((start0 ? start0 : start1)->target->point - c0->point).cross(s); int64_t dist = c0->point.dot(normal); - btAssert(!start1 || (start1->target->point.dot(normal) == dist)); + b3Assert(!start1 || (start1->target->point.dot(normal) == dist)); Point64 perp = s.cross(normal); - btAssert(!perp.isZero()); + b3Assert(!perp.isZero()); #ifdef DEBUG_CONVEX_HULL printf(" Advancing %d %d (%p %p, %d %d)\n", c0->point.index, c1->point.index, start0, start1, start0 ? start0->target->point.index : -1, start1 ? start1->target->point.index : -1); @@ -1487,7 +1487,7 @@ void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge { break; } - btAssert(e->target->point.dot(normal) == dist); + b3Assert(e->target->point.dot(normal) == dist); if (e->copy == mergeStamp) { break; @@ -1513,7 +1513,7 @@ void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge { break; } - btAssert(e->target->point.dot(normal) == dist); + b3Assert(e->target->point.dot(normal) == dist); if (e->copy == mergeStamp) { break; @@ -1578,7 +1578,7 @@ void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge } else { - btAssert((e1 == start1) && (d1.dot(normal) < 0)); + b3Assert((e1 == start1) && (d1.dot(normal) < 0)); } } } @@ -1630,7 +1630,7 @@ void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge } else { - btAssert((e0 == start0) && (d0.dot(normal) < 0)); + b3Assert((e0 == start0) && (d0.dot(normal) < 0)); } } } @@ -1644,7 +1644,7 @@ void btConvexHullInternal::findEdgeForCoplanarFaces(Vertex* c0, Vertex* c1, Edge } -void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) +void b3ConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) { if (!h1.maxXy) { @@ -1675,7 +1675,7 @@ void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) Point32 s = *c1 - *c0; Point64 normal = Point32(0, 0, -1).cross(s); Point64 t = s.cross(normal); - btAssert(!t.isZero()); + b3Assert(!t.isZero()); Edge* e = c0->edges; Edge* start0 = NULL; @@ -1684,7 +1684,7 @@ void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) do { int64_t dot = (*e->target - *c0).dot(normal); - btAssert(dot <= 0); + b3Assert(dot <= 0); if ((dot == 0) && ((*e->target - *c0).dot(t) > 0)) { if (!start0 || (getOrientation(start0, e, s, Point32(0, 0, -1)) == CLOCKWISE)) @@ -1703,7 +1703,7 @@ void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) do { int64_t dot = (*e->target - *c1).dot(normal); - btAssert(dot <= 0); + b3Assert(dot <= 0); if ((dot == 0) && ((*e->target - *c1).dot(t) > 0)) { if (!start1 || (getOrientation(start1, e, s, Point32(0, 0, -1)) == COUNTER_CLOCKWISE)) @@ -1932,12 +1932,12 @@ void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1) } -static bool pointCmp(const btConvexHullInternal::Point32& p, const btConvexHullInternal::Point32& q) +static bool pointCmp(const b3ConvexHullInternal::Point32& p, const b3ConvexHullInternal::Point32& q) { return (p.y < q.y) || ((p.y == q.y) && ((p.x < q.x) || ((p.x == q.x) && (p.z < q.z)))); } -void btConvexHullInternal::compute(const void* coords, bool doubleCoords, int stride, int count) +void b3ConvexHullInternal::compute(const void* coords, bool doubleCoords, int stride, int count) { b3Vector3 min(b3Scalar(1e30), b3Scalar(1e30), b3Scalar(1e30)), max(b3Scalar(-1e30), b3Scalar(-1e30), b3Scalar(-1e30)); const char* ptr = (const char*) coords; @@ -2058,7 +2058,7 @@ void btConvexHullInternal::compute(const void* coords, bool doubleCoords, int st #endif } -b3Vector3 btConvexHullInternal::toBtVector(const Point32& v) +b3Vector3 b3ConvexHullInternal::toBtVector(const Point32& v) { b3Vector3 p; p[medAxis] = b3Scalar(v.x); @@ -2067,12 +2067,12 @@ b3Vector3 btConvexHullInternal::toBtVector(const Point32& v) return p * scaling; } -b3Vector3 btConvexHullInternal::getBtNormal(Face* face) +b3Vector3 b3ConvexHullInternal::getBtNormal(Face* face) { return toBtVector(face->dir0).cross(toBtVector(face->dir1)).normalized(); } -b3Vector3 btConvexHullInternal::getCoordinates(const Vertex* v) +b3Vector3 b3ConvexHullInternal::getCoordinates(const Vertex* v) { b3Vector3 p; p[medAxis] = v->xvalue(); @@ -2081,7 +2081,7 @@ b3Vector3 btConvexHullInternal::getCoordinates(const Vertex* v) return p * scaling + center; } -b3Scalar btConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) +b3Scalar b3ConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) { if (!vertexList) { @@ -2127,7 +2127,7 @@ b3Scalar btConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) if (a && b) { int64_t vol = (v->point - ref).dot((a->point - ref).cross(b->point - ref)); - btAssert(vol >= 0); + b3Assert(vol >= 0); Point32 c = v->point + a->point + b->point + ref; hullCenterX += vol * c.x; hullCenterY += vol * c.y; @@ -2135,7 +2135,7 @@ b3Scalar btConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) volume += vol; } - btAssert(f->copy != stamp); + b3Assert(f->copy != stamp); f->copy = stamp; f->face = face; @@ -2182,13 +2182,13 @@ b3Scalar btConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) return 0; } - amount = btMin(amount, minDist * clampAmount); + amount = b3Min(amount, minDist * clampAmount); } unsigned int seed = 243703; for (int i = 0; i < faceCount; i++, seed = 1664525 * seed + 1013904223) { - btSwap(faces[i], faces[seed % faceCount]); + b3Swap(faces[i], faces[seed % faceCount]); } for (int i = 0; i < faceCount; i++) @@ -2202,7 +2202,7 @@ b3Scalar btConvexHullInternal::shrink(b3Scalar amount, b3Scalar clampAmount) return amount; } -bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjectArray stack) +bool b3ConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjectArray stack) { b3Vector3 origShift = getBtNormal(face) * -amount; if (scaling[0] != 0) @@ -2230,7 +2230,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec int64_t origDot = face->origin.dot(normal); Point32 shiftedOrigin = face->origin + shift; int64_t shiftedDot = shiftedOrigin.dot(normal); - btAssert(shiftedDot <= origDot); + b3Assert(shiftedDot <= origDot); if (shiftedDot >= origDot) { return false; @@ -2258,7 +2258,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec n++; #endif Rational128 dot = e->target->dot(normal); - btAssert(dot.compare(origDot) <= 0); + b3Assert(dot.compare(origDot) <= 0); #ifdef DEBUG_CONVEX_HULL printf("Moving downwards, edge is "); e->print(); @@ -2294,7 +2294,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec n++; #endif Rational128 dot = e->target->dot(normal); - btAssert(dot.compare(origDot) <= 0); + b3Assert(dot.compare(origDot) <= 0); #ifdef DEBUG_CONVEX_HULL printf("Moving upwards, edge is "); e->print(); @@ -2426,7 +2426,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec n++; #endif e = e->reverse->prev; - btAssert(e != intersection->reverse); + b3Assert(e != intersection->reverse); cmp = e->target->dot(normal).compare(shiftedDot); #ifdef DEBUG_CONVEX_HULL printf("Testing edge "); @@ -2470,7 +2470,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec int64_t r0 = (intersection->face->origin - shiftedOrigin).dot(n0); int64_t r1 = (intersection->reverse->face->origin - shiftedOrigin).dot(n1); Int128 det = Int128::mul(m00, m11) - Int128::mul(m01, m10); - btAssert(det.getSign() != 0); + b3Assert(det.getSign() != 0); Vertex* v = vertexPool.newObject(); v->point.index = -1; v->copy = -1; @@ -2568,7 +2568,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec stack.push_back(NULL); } - btAssert(stack.size() > 0); + b3Assert(stack.size() > 0); vertexList = stack[0]; #ifdef DEBUG_CONVEX_HULL @@ -2623,7 +2623,7 @@ bool btConvexHullInternal::shiftFace(Face* face, b3Scalar amount, b3AlignedObjec } -static int getVertexCopy(btConvexHullInternal::Vertex* vertex, b3AlignedObjectArray& vertices) +static int getVertexCopy(b3ConvexHullInternal::Vertex* vertex, b3AlignedObjectArray& vertices) { int index = vertex->copy; if (index < 0) @@ -2648,7 +2648,7 @@ b3Scalar b3ConvexHullComputer::compute(const void* coords, bool doubleCoords, in return 0; } - btConvexHullInternal hull; + b3ConvexHullInternal hull; hull.compute(coords, doubleCoords, stride, count); b3Scalar shift = 0; @@ -2664,19 +2664,19 @@ b3Scalar b3ConvexHullComputer::compute(const void* coords, bool doubleCoords, in edges.resize(0); faces.resize(0); - b3AlignedObjectArray oldVertices; + b3AlignedObjectArray oldVertices; getVertexCopy(hull.vertexList, oldVertices); int copied = 0; while (copied < oldVertices.size()) { - btConvexHullInternal::Vertex* v = oldVertices[copied]; + b3ConvexHullInternal::Vertex* v = oldVertices[copied]; vertices.push_back(hull.getCoordinates(v)); - btConvexHullInternal::Edge* firstEdge = v->edges; + b3ConvexHullInternal::Edge* firstEdge = v->edges; if (firstEdge) { int firstCopy = -1; int prevCopy = -1; - btConvexHullInternal::Edge* e = firstEdge; + b3ConvexHullInternal::Edge* e = firstEdge; do { if (e->copy < 0) @@ -2714,11 +2714,11 @@ b3Scalar b3ConvexHullComputer::compute(const void* coords, bool doubleCoords, in for (int i = 0; i < copied; i++) { - btConvexHullInternal::Vertex* v = oldVertices[i]; - btConvexHullInternal::Edge* firstEdge = v->edges; + b3ConvexHullInternal::Vertex* v = oldVertices[i]; + b3ConvexHullInternal::Edge* firstEdge = v->edges; if (firstEdge) { - btConvexHullInternal::Edge* e = firstEdge; + b3ConvexHullInternal::Edge* e = firstEdge; do { if (e->copy >= 0) @@ -2727,7 +2727,7 @@ b3Scalar b3ConvexHullComputer::compute(const void* coords, bool doubleCoords, in printf("Vertex *%d has edge to *%d\n", i, edges[e->copy].getTargetVertex()); #endif faces.push_back(e->copy); - btConvexHullInternal::Edge* f = e; + b3ConvexHullInternal::Edge* f = e; do { #ifdef DEBUG_CONVEX_HULL diff --git a/src/Bullet3Geometry/b3ConvexHullComputer.h b/src/Bullet3Geometry/b3ConvexHullComputer.h index 48ce27c34..6dcc931a7 100644 --- a/src/Bullet3Geometry/b3ConvexHullComputer.h +++ b/src/Bullet3Geometry/b3ConvexHullComputer.h @@ -12,8 +12,8 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_CONVEX_HULL_COMPUTER_H -#define BT_CONVEX_HULL_COMPUTER_H +#ifndef B3_CONVEX_HULL_COMPUTER_H +#define B3_CONVEX_HULL_COMPUTER_H #include "Bullet3Common/b3Vector3.h" #include "Bullet3Common/b3AlignedObjectArray.h" @@ -99,5 +99,5 @@ class b3ConvexHullComputer }; -#endif //BT_CONVEX_HULL_COMPUTER_H +#endif //B3_CONVEX_HULL_COMPUTER_H diff --git a/src/Bullet3Geometry/b3GeometryUtil.cpp b/src/Bullet3Geometry/b3GeometryUtil.cpp index a9d93ffbe..dd80fed6b 100644 --- a/src/Bullet3Geometry/b3GeometryUtil.cpp +++ b/src/Bullet3Geometry/b3GeometryUtil.cpp @@ -24,9 +24,9 @@ subject to the following restrictions: */ extern "C" { - void btBulletMathProbe (); + void b3BulletMathProbe (); - void btBulletMathProbe () {} + void b3BulletMathProbe () {} } @@ -160,7 +160,7 @@ void b3GeometryUtil::getVerticesFromPlaneEquations(const b3AlignedObjectArray b3Scalar(0.000001)) + if (b3Fabs(quotient) > b3Scalar(0.000001)) { quotient = b3Scalar(-1.) / quotient; n2n3 *= N1[3]; diff --git a/src/Bullet3Geometry/b3GeometryUtil.h b/src/Bullet3Geometry/b3GeometryUtil.h index c3e7cb651..8b5fd7ad6 100644 --- a/src/Bullet3Geometry/b3GeometryUtil.h +++ b/src/Bullet3Geometry/b3GeometryUtil.h @@ -13,8 +13,8 @@ subject to the following restrictions: */ -#ifndef BT_GEOMETRY_UTIL_H -#define BT_GEOMETRY_UTIL_H +#ifndef B3_GEOMETRY_UTIL_H +#define B3_GEOMETRY_UTIL_H #include "Bullet3Common/b3Vector3.h" #include "Bullet3Common/b3AlignedObjectArray.h" @@ -38,5 +38,5 @@ class b3GeometryUtil }; -#endif //BT_GEOMETRY_UTIL_H +#endif //B3_GEOMETRY_UTIL_H diff --git a/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h b/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h index 1ed7e796b..a4d24aefc 100644 --- a/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h +++ b/src/Bullet3Geometry/b3GrahamScan2dConvexHull.h @@ -33,9 +33,9 @@ struct GrahamVector3 : public b3Vector3 }; -struct btAngleCompareFunc { +struct b3AngleCompareFunc { b3Vector3 m_anchor; - btAngleCompareFunc(const b3Vector3& anchor) + b3AngleCompareFunc(const b3Vector3& anchor) : m_anchor(anchor) { } @@ -59,7 +59,7 @@ struct btAngleCompareFunc { inline void GrahamScanConvexHull2D(b3AlignedObjectArray& originalPoints, b3AlignedObjectArray& hull, const b3Vector3& normalAxis) { b3Vector3 axis0,axis1; - btPlaneSpace1(normalAxis,axis0,axis1); + b3PlaneSpace1(normalAxis,axis0,axis1); if (originalPoints.size()<=1) @@ -87,11 +87,11 @@ inline void GrahamScanConvexHull2D(b3AlignedObjectArray& original { b3Vector3 xvec = axis0; b3Vector3 ar = originalPoints[i]-originalPoints[0]; - originalPoints[i].m_angle = btCross(xvec, ar).dot(normalAxis) / ar.length(); + originalPoints[i].m_angle = b3Cross(xvec, ar).dot(normalAxis) / ar.length(); } //step 2: sort all points, based on 'angle' with this anchor - btAngleCompareFunc comp(originalPoints[0]); + b3AngleCompareFunc comp(originalPoints[0]); originalPoints.quickSortInternal(comp,1,originalPoints.size()-1); int i; @@ -105,7 +105,7 @@ inline void GrahamScanConvexHull2D(b3AlignedObjectArray& original while (!isConvex&& hull.size()>1) { b3Vector3& a = hull[hull.size()-2]; b3Vector3& b = hull[hull.size()-1]; - isConvex = btCross(a-b,a-originalPoints[i]).dot(normalAxis)> 0; + isConvex = b3Cross(a-b,a-originalPoints[i]).dot(normalAxis)> 0; if (!isConvex) hull.pop_back(); else diff --git a/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h b/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h index 406ce09a1..e0b6a5525 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/autogenerated/bullet2.h @@ -27,59 +27,59 @@ typedef struct bInvalidHandle { }bInvalidHandle; class PointerArray; - class btPhysicsSystem; + class b3PhysicsSystem; class ListBase; - class btVector3FloatData; - class btVector3DoubleData; - class btMatrix3x3FloatData; - class btMatrix3x3DoubleData; - class btTransformFloatData; - class btTransformDoubleData; - class btBvhSubtreeInfoData; - class btOptimizedBvhNodeFloatData; - class btOptimizedBvhNodeDoubleData; - class btQuantizedBvhNodeData; - class btQuantizedBvhFloatData; - class btQuantizedBvhDoubleData; - class btCollisionShapeData; - class btStaticPlaneShapeData; - class btConvexInternalShapeData; - class btPositionAndRadius; - class btMultiSphereShapeData; - class btIntIndexData; - class btShortIntIndexData; - class btShortIntIndexTripletData; - class btCharIndexTripletData; - class btMeshPartData; - class btStridingMeshInterfaceData; - class btTriangleMeshShapeData; - class btScaledTriangleMeshShapeData; - class btCompoundShapeChildData; - class btCompoundShapeData; - class btCylinderShapeData; - class btCapsuleShapeData; - class btTriangleInfoData; - class btTriangleInfoMapData; - class btGImpactMeshShapeData; - class btConvexHullShapeData; - class btCollisionObjectDoubleData; - class btCollisionObjectFloatData; - class btDynamicsWorldDoubleData; - class btDynamicsWorldFloatData; - class btRigidBodyFloatData; - class btRigidBodyDoubleData; - class btConstraintInfo1; - class btTypedConstraintData; - class btPoint2PointConstraintFloatData; - class btPoint2PointConstraintDoubleData; - class btHingeConstraintDoubleData; - class btHingeConstraintFloatData; - class btConeTwistConstraintData; - class btGeneric6DofConstraintData; - class btGeneric6DofSpringConstraintData; - class btSliderConstraintData; - class btContactSolverInfoDoubleData; - class btContactSolverInfoFloatData; + class b3Vector3FloatData; + class b3Vector3DoubleData; + class b3Matrix3x3FloatData; + class b3Matrix3x3DoubleData; + class b3TransformFloatData; + class b3TransformDoubleData; + class b3BvhSubtreeInfoData; + class b3OptimizedBvhNodeFloatData; + class b3OptimizedBvhNodeDoubleData; + class b3QuantizedBvhNodeData; + class b3QuantizedBvhFloatData; + class b3QuantizedBvhDoubleData; + class b3CollisionShapeData; + class b3StaticPlaneShapeData; + class b3ConvexInternalShapeData; + class b3PositionAndRadius; + class b3MultiSphereShapeData; + class b3IntIndexData; + class b3ShortIntIndexData; + class b3ShortIntIndexTripletData; + class b3CharIndexTripletData; + class b3MeshPartData; + class b3StridingMeshInterfaceData; + class b3TriangleMeshShapeData; + class b3ScaledTriangleMeshShapeData; + class b3CompoundShapeChildData; + class b3CompoundShapeData; + class b3CylinderShapeData; + class b3CapsuleShapeData; + class b3TriangleInfoData; + class b3TriangleInfoMapData; + class b3GImpactMeshShapeData; + class b3ConvexHullShapeData; + class b3CollisionObjectDoubleData; + class b3CollisionObjectFloatData; + class b3DynamicsWorldDoubleData; + class b3DynamicsWorldFloatData; + class b3RigidBodyFloatData; + class b3RigidBodyDoubleData; + class b3ConstraintInfo1; + class b3TypedConstraintData; + class b3Point2PointConstraintFloatData; + class b3Point2PointConstraintDoubleData; + class b3HingeConstraintDoubleData; + class b3HingeConstraintFloatData; + class b3ConeTwistConstraintData; + class b3Generic6DofConstraintData; + class b3Generic6DofSpringConstraintData; + class b3SliderConstraintData; + class b3ContactSolverInfoDoubleData; + class b3ContactSolverInfoFloatData; class SoftBodyMaterialData; class SoftBodyNodeData; class SoftBodyLinkData; @@ -89,8 +89,8 @@ typedef struct bInvalidHandle { class SoftBodyConfigData; class SoftBodyPoseData; class SoftBodyClusterData; - class btSoftBodyJointData; - class btSoftBodyFloatData; + class b3SoftBodyJointData; + class b3SoftBodyFloatData; // -------------------------------------------------- // class PointerArray { @@ -102,7 +102,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btPhysicsSystem + class b3PhysicsSystem { public: PointerArray m_collisionShapes; @@ -121,7 +121,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btVector3FloatData + class b3Vector3FloatData { public: float m_floats[4]; @@ -129,7 +129,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btVector3DoubleData + class b3Vector3DoubleData { public: double m_floats[4]; @@ -137,41 +137,41 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btMatrix3x3FloatData + class b3Matrix3x3FloatData { public: - btVector3FloatData m_el[3]; + b3Vector3FloatData m_el[3]; }; // -------------------------------------------------- // - class btMatrix3x3DoubleData + class b3Matrix3x3DoubleData { public: - btVector3DoubleData m_el[3]; + b3Vector3DoubleData m_el[3]; }; // -------------------------------------------------- // - class btTransformFloatData + class b3TransformFloatData { public: - btMatrix3x3FloatData m_basis; - btVector3FloatData m_origin; + b3Matrix3x3FloatData m_basis; + b3Vector3FloatData m_origin; }; // -------------------------------------------------- // - class btTransformDoubleData + class b3TransformDoubleData { public: - btMatrix3x3DoubleData m_basis; - btVector3DoubleData m_origin; + b3Matrix3x3DoubleData m_basis; + b3Vector3DoubleData m_origin; }; // -------------------------------------------------- // - class btBvhSubtreeInfoData + class b3BvhSubtreeInfoData { public: int m_rootNodeIndex; @@ -182,11 +182,11 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btOptimizedBvhNodeFloatData + class b3OptimizedBvhNodeFloatData { public: - btVector3FloatData m_aabbMinOrg; - btVector3FloatData m_aabbMaxOrg; + b3Vector3FloatData m_aabbMinOrg; + b3Vector3FloatData m_aabbMaxOrg; int m_escapeIndex; int m_subPart; int m_triangleIndex; @@ -195,11 +195,11 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btOptimizedBvhNodeDoubleData + class b3OptimizedBvhNodeDoubleData { public: - btVector3DoubleData m_aabbMinOrg; - btVector3DoubleData m_aabbMaxOrg; + b3Vector3DoubleData m_aabbMinOrg; + b3Vector3DoubleData m_aabbMaxOrg; int m_escapeIndex; int m_subPart; int m_triangleIndex; @@ -208,7 +208,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btQuantizedBvhNodeData + class b3QuantizedBvhNodeData { public: short m_quantizedAabbMin[3]; @@ -218,45 +218,45 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btQuantizedBvhFloatData + class b3QuantizedBvhFloatData { public: - 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; }; // -------------------------------------------------- // - class btQuantizedBvhDoubleData + class b3QuantizedBvhDoubleData { public: - 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; }; // -------------------------------------------------- // - class btCollisionShapeData + class b3CollisionShapeData { public: char *m_name; @@ -266,51 +266,51 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btStaticPlaneShapeData + class b3StaticPlaneShapeData { public: - btCollisionShapeData m_collisionShapeData; - btVector3FloatData m_localScaling; - btVector3FloatData m_planeNormal; + b3CollisionShapeData m_collisionShapeData; + b3Vector3FloatData m_localScaling; + b3Vector3FloatData m_planeNormal; float m_planeConstant; char m_pad[4]; }; // -------------------------------------------------- // - class btConvexInternalShapeData + class b3ConvexInternalShapeData { public: - btCollisionShapeData m_collisionShapeData; - btVector3FloatData m_localScaling; - btVector3FloatData m_implicitShapeDimensions; + b3CollisionShapeData m_collisionShapeData; + b3Vector3FloatData m_localScaling; + b3Vector3FloatData m_implicitShapeDimensions; float m_collisionMargin; int m_padding; }; // -------------------------------------------------- // - class btPositionAndRadius + class b3PositionAndRadius { public: - btVector3FloatData m_pos; + b3Vector3FloatData m_pos; float m_radius; }; // -------------------------------------------------- // - class btMultiSphereShapeData + class b3MultiSphereShapeData { public: - btConvexInternalShapeData m_convexInternalShapeData; - btPositionAndRadius *m_localPositionArrayPtr; + b3ConvexInternalShapeData m_convexInternalShapeData; + b3PositionAndRadius *m_localPositionArrayPtr; int m_localPositionArraySize; char m_padding[4]; }; // -------------------------------------------------- // - class btIntIndexData + class b3IntIndexData { public: int m_value; @@ -318,7 +318,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btShortIntIndexData + class b3ShortIntIndexData { public: short m_value; @@ -327,7 +327,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btShortIntIndexTripletData + class b3ShortIntIndexTripletData { public: short m_values[3]; @@ -336,7 +336,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btCharIndexTripletData + class b3CharIndexTripletData { public: char m_values[3]; @@ -345,98 +345,98 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btMeshPartData + class b3MeshPartData { public: - btVector3FloatData *m_vertices3f; - btVector3DoubleData *m_vertices3d; - btIntIndexData *m_indices32; - btShortIntIndexTripletData *m_3indices16; - btCharIndexTripletData *m_3indices8; - btShortIntIndexData *m_indices16; + b3Vector3FloatData *m_vertices3f; + b3Vector3DoubleData *m_vertices3d; + b3IntIndexData *m_indices32; + b3ShortIntIndexTripletData *m_3indices16; + b3CharIndexTripletData *m_3indices8; + b3ShortIntIndexData *m_indices16; int m_numTriangles; int m_numVertices; }; // -------------------------------------------------- // - class btStridingMeshInterfaceData + class b3StridingMeshInterfaceData { public: - btMeshPartData *m_meshPartsPtr; - btVector3FloatData m_scaling; + b3MeshPartData *m_meshPartsPtr; + b3Vector3FloatData m_scaling; int m_numMeshParts; char m_padding[4]; }; // -------------------------------------------------- // - class btTriangleMeshShapeData + class b3TriangleMeshShapeData { public: - btCollisionShapeData m_collisionShapeData; - btStridingMeshInterfaceData m_meshInterface; - btQuantizedBvhFloatData *m_quantizedFloatBvh; - btQuantizedBvhDoubleData *m_quantizedDoubleBvh; - btTriangleInfoMapData *m_triangleInfoMap; + b3CollisionShapeData m_collisionShapeData; + b3StridingMeshInterfaceData m_meshInterface; + b3QuantizedBvhFloatData *m_quantizedFloatBvh; + b3QuantizedBvhDoubleData *m_quantizedDoubleBvh; + b3TriangleInfoMapData *m_triangleInfoMap; float m_collisionMargin; char m_pad3[4]; }; // -------------------------------------------------- // - class btScaledTriangleMeshShapeData + class b3ScaledTriangleMeshShapeData { public: - btTriangleMeshShapeData m_trimeshShapeData; - btVector3FloatData m_localScaling; + b3TriangleMeshShapeData m_trimeshShapeData; + b3Vector3FloatData m_localScaling; }; // -------------------------------------------------- // - class btCompoundShapeChildData + class b3CompoundShapeChildData { public: - btTransformFloatData m_transform; - btCollisionShapeData *m_childShape; + b3TransformFloatData m_transform; + b3CollisionShapeData *m_childShape; int m_childShapeType; float m_childMargin; }; // -------------------------------------------------- // - class btCompoundShapeData + class b3CompoundShapeData { public: - btCollisionShapeData m_collisionShapeData; - btCompoundShapeChildData *m_childShapePtr; + b3CollisionShapeData m_collisionShapeData; + b3CompoundShapeChildData *m_childShapePtr; int m_numChildShapes; float m_collisionMargin; }; // -------------------------------------------------- // - class btCylinderShapeData + class b3CylinderShapeData { public: - btConvexInternalShapeData m_convexInternalShapeData; + b3ConvexInternalShapeData m_convexInternalShapeData; int m_upAxis; char m_padding[4]; }; // -------------------------------------------------- // - class btCapsuleShapeData + class b3CapsuleShapeData { public: - btConvexInternalShapeData m_convexInternalShapeData; + b3ConvexInternalShapeData m_convexInternalShapeData; int m_upAxis; char m_padding[4]; }; // -------------------------------------------------- // - class btTriangleInfoData + class b3TriangleInfoData { public: int m_flags; @@ -447,12 +447,12 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btTriangleInfoMapData + class b3TriangleInfoMapData { public: int *m_hashTablePtr; int *m_nextPtr; - btTriangleInfoData *m_valueArrayPtr; + b3TriangleInfoData *m_valueArrayPtr; int *m_keyArrayPtr; float m_convexEpsilon; float m_planarEpsilon; @@ -468,42 +468,42 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btGImpactMeshShapeData + class b3GImpactMeshShapeData { public: - btCollisionShapeData m_collisionShapeData; - btStridingMeshInterfaceData m_meshInterface; - btVector3FloatData m_localScaling; + b3CollisionShapeData m_collisionShapeData; + b3StridingMeshInterfaceData m_meshInterface; + b3Vector3FloatData m_localScaling; float m_collisionMargin; int m_gimpactSubType; }; // -------------------------------------------------- // - class btConvexHullShapeData + class b3ConvexHullShapeData { public: - btConvexInternalShapeData m_convexInternalShapeData; - btVector3FloatData *m_unscaledPointsFloatPtr; - btVector3DoubleData *m_unscaledPointsDoublePtr; + b3ConvexInternalShapeData m_convexInternalShapeData; + b3Vector3FloatData *m_unscaledPointsFloatPtr; + b3Vector3DoubleData *m_unscaledPointsDoublePtr; int m_numUnscaledPoints; char m_padding3[4]; }; // -------------------------------------------------- // - class btCollisionObjectDoubleData + class b3CollisionObjectDoubleData { public: void *m_broadphaseHandle; void *m_collisionShape; - btCollisionShapeData *m_rootCollisionShape; + b3CollisionShapeData *m_rootCollisionShape; char *m_name; - btTransformDoubleData m_worldTransform; - btTransformDoubleData m_interpolationWorldTransform; - btVector3DoubleData m_interpolationLinearVelocity; - btVector3DoubleData m_interpolationAngularVelocity; - btVector3DoubleData m_anisotropicFriction; + b3TransformDoubleData m_worldTransform; + b3TransformDoubleData m_interpolationWorldTransform; + b3Vector3DoubleData m_interpolationLinearVelocity; + b3Vector3DoubleData m_interpolationAngularVelocity; + b3Vector3DoubleData m_anisotropicFriction; double m_contactProcessingThreshold; double m_deactivationTime; double m_friction; @@ -524,18 +524,18 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btCollisionObjectFloatData + class b3CollisionObjectFloatData { public: void *m_broadphaseHandle; void *m_collisionShape; - btCollisionShapeData *m_rootCollisionShape; + b3CollisionShapeData *m_rootCollisionShape; char *m_name; - btTransformFloatData m_worldTransform; - btTransformFloatData m_interpolationWorldTransform; - btVector3FloatData m_interpolationLinearVelocity; - btVector3FloatData m_interpolationAngularVelocity; - btVector3FloatData m_anisotropicFriction; + b3TransformFloatData m_worldTransform; + b3TransformFloatData m_interpolationWorldTransform; + b3Vector3FloatData m_interpolationLinearVelocity; + b3Vector3FloatData m_interpolationAngularVelocity; + b3Vector3FloatData m_anisotropicFriction; float m_contactProcessingThreshold; float m_deactivationTime; float m_friction; @@ -557,20 +557,20 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btRigidBodyFloatData + class b3RigidBodyFloatData { public: - btCollisionObjectFloatData m_collisionObjectData; - btMatrix3x3FloatData m_invInertiaTensorWorld; - btVector3FloatData m_linearVelocity; - btVector3FloatData m_angularVelocity; - btVector3FloatData m_angularFactor; - btVector3FloatData m_linearFactor; - btVector3FloatData m_gravity; - btVector3FloatData m_gravity_acceleration; - btVector3FloatData m_invInertiaLocal; - btVector3FloatData m_totalForce; - btVector3FloatData m_totalTorque; + b3CollisionObjectFloatData m_collisionObjectData; + b3Matrix3x3FloatData m_invInertiaTensorWorld; + b3Vector3FloatData m_linearVelocity; + b3Vector3FloatData m_angularVelocity; + b3Vector3FloatData m_angularFactor; + b3Vector3FloatData m_linearFactor; + b3Vector3FloatData m_gravity; + b3Vector3FloatData m_gravity_acceleration; + b3Vector3FloatData m_invInertiaLocal; + b3Vector3FloatData m_totalForce; + b3Vector3FloatData m_totalTorque; float m_inverseMass; float m_linearDamping; float m_angularDamping; @@ -585,20 +585,20 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btRigidBodyDoubleData + class b3RigidBodyDoubleData { public: - btCollisionObjectDoubleData m_collisionObjectData; - btMatrix3x3DoubleData m_invInertiaTensorWorld; - btVector3DoubleData m_linearVelocity; - btVector3DoubleData m_angularVelocity; - btVector3DoubleData m_angularFactor; - btVector3DoubleData m_linearFactor; - btVector3DoubleData m_gravity; - btVector3DoubleData m_gravity_acceleration; - btVector3DoubleData m_invInertiaLocal; - btVector3DoubleData m_totalForce; - btVector3DoubleData m_totalTorque; + b3CollisionObjectDoubleData m_collisionObjectData; + b3Matrix3x3DoubleData m_invInertiaTensorWorld; + b3Vector3DoubleData m_linearVelocity; + b3Vector3DoubleData m_angularVelocity; + b3Vector3DoubleData m_angularFactor; + b3Vector3DoubleData m_linearFactor; + b3Vector3DoubleData m_gravity; + b3Vector3DoubleData m_gravity_acceleration; + b3Vector3DoubleData m_invInertiaLocal; + b3Vector3DoubleData m_totalForce; + b3Vector3DoubleData m_totalTorque; double m_inverseMass; double m_linearDamping; double m_angularDamping; @@ -614,7 +614,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btConstraintInfo1 + class b3ConstraintInfo1 { public: int m_numConstraintRows; @@ -623,7 +623,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btTypedConstraintData + class b3TypedConstraintData { public: bInvalidHandle *m_rbA; @@ -643,32 +643,32 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btPoint2PointConstraintFloatData + class b3Point2PointConstraintFloatData { public: - btTypedConstraintData m_typeConstraintData; - btVector3FloatData m_pivotInA; - btVector3FloatData m_pivotInB; + b3TypedConstraintData m_typeConstraintData; + b3Vector3FloatData m_pivotInA; + b3Vector3FloatData m_pivotInB; }; // -------------------------------------------------- // - class btPoint2PointConstraintDoubleData + class b3Point2PointConstraintDoubleData { public: - btTypedConstraintData m_typeConstraintData; - btVector3DoubleData m_pivotInA; - btVector3DoubleData m_pivotInB; + b3TypedConstraintData m_typeConstraintData; + b3Vector3DoubleData m_pivotInA; + b3Vector3DoubleData m_pivotInB; }; // -------------------------------------------------- // - class btHingeConstraintDoubleData + class b3HingeConstraintDoubleData { public: - btTypedConstraintData m_typeConstraintData; - btTransformDoubleData m_rbAFrame; - btTransformDoubleData m_rbBFrame; + b3TypedConstraintData m_typeConstraintData; + b3TransformDoubleData m_rbAFrame; + b3TransformDoubleData m_rbBFrame; int m_useReferenceFrameA; int m_angularOnly; int m_enableAngularMotor; @@ -683,12 +683,12 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btHingeConstraintFloatData + class b3HingeConstraintFloatData { public: - btTypedConstraintData m_typeConstraintData; - btTransformFloatData m_rbAFrame; - btTransformFloatData m_rbBFrame; + b3TypedConstraintData m_typeConstraintData; + b3TransformFloatData m_rbAFrame; + b3TransformFloatData m_rbBFrame; int m_useReferenceFrameA; int m_angularOnly; int m_enableAngularMotor; @@ -703,12 +703,12 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btConeTwistConstraintData + class b3ConeTwistConstraintData { public: - btTypedConstraintData m_typeConstraintData; - btTransformFloatData m_rbAFrame; - btTransformFloatData m_rbBFrame; + b3TypedConstraintData m_typeConstraintData; + b3TransformFloatData m_rbAFrame; + b3TransformFloatData m_rbBFrame; float m_swingSpan1; float m_swingSpan2; float m_twistSpan; @@ -721,26 +721,26 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btGeneric6DofConstraintData + class b3Generic6DofConstraintData { public: - btTypedConstraintData m_typeConstraintData; - btTransformFloatData m_rbAFrame; - btTransformFloatData m_rbBFrame; - btVector3FloatData m_linearUpperLimit; - btVector3FloatData m_linearLowerLimit; - btVector3FloatData m_angularUpperLimit; - btVector3FloatData m_angularLowerLimit; + b3TypedConstraintData m_typeConstraintData; + b3TransformFloatData m_rbAFrame; + b3TransformFloatData m_rbBFrame; + b3Vector3FloatData m_linearUpperLimit; + b3Vector3FloatData m_linearLowerLimit; + b3Vector3FloatData m_angularUpperLimit; + b3Vector3FloatData m_angularLowerLimit; int m_useLinearReferenceFrameA; int m_useOffsetForConstraintFrame; }; // -------------------------------------------------- // - class btGeneric6DofSpringConstraintData + class b3Generic6DofSpringConstraintData { public: - btGeneric6DofConstraintData m_6dofData; + b3Generic6DofConstraintData m_6dofData; int m_springEnabled[6]; float m_equilibriumPoint[6]; float m_springStiffness[6]; @@ -749,12 +749,12 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btSliderConstraintData + class b3SliderConstraintData { public: - btTypedConstraintData m_typeConstraintData; - btTransformFloatData m_rbAFrame; - btTransformFloatData m_rbBFrame; + b3TypedConstraintData m_typeConstraintData; + b3TransformFloatData m_rbAFrame; + b3TransformFloatData m_rbBFrame; float m_linearUpperLimit; float m_linearLowerLimit; float m_angularUpperLimit; @@ -765,7 +765,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btContactSolverInfoDoubleData + class b3ContactSolverInfoDoubleData { public: double m_tau; @@ -794,7 +794,7 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btContactSolverInfoFloatData + class b3ContactSolverInfoFloatData { public: float m_tau; @@ -823,20 +823,20 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btDynamicsWorldDoubleData + class b3DynamicsWorldDoubleData { public: - btContactSolverInfoDoubleData m_solverInfo; - btVector3DoubleData m_gravity; + b3ContactSolverInfoDoubleData m_solverInfo; + b3Vector3DoubleData m_gravity; }; // -------------------------------------------------- // - class btDynamicsWorldFloatData + class b3DynamicsWorldFloatData { public: - btContactSolverInfoFloatData m_solverInfo; - btVector3FloatData m_gravity; + b3ContactSolverInfoFloatData m_solverInfo; + b3Vector3FloatData m_gravity; }; @@ -857,11 +857,11 @@ typedef struct bInvalidHandle { { public: SoftBodyMaterialData *m_material; - btVector3FloatData m_position; - btVector3FloatData m_previousPosition; - btVector3FloatData m_velocity; - btVector3FloatData m_accumulatedForce; - btVector3FloatData m_normal; + b3Vector3FloatData m_position; + b3Vector3FloatData m_previousPosition; + b3Vector3FloatData m_velocity; + b3Vector3FloatData m_accumulatedForce; + b3Vector3FloatData m_normal; float m_inverseMass; float m_area; int m_attach; @@ -884,7 +884,7 @@ typedef struct bInvalidHandle { class SoftBodyFaceData { public: - btVector3FloatData m_normal; + b3Vector3FloatData m_normal; SoftBodyMaterialData *m_material; int m_nodeIndices[3]; float m_restArea; @@ -895,7 +895,7 @@ typedef struct bInvalidHandle { class SoftBodyTetraData { public: - btVector3FloatData m_c0[4]; + b3Vector3FloatData m_c0[4]; SoftBodyMaterialData *m_material; int m_nodeIndices[4]; float m_restVolume; @@ -909,9 +909,9 @@ typedef struct bInvalidHandle { class SoftRigidAnchorData { public: - btMatrix3x3FloatData m_c0; - btVector3FloatData m_c1; - btVector3FloatData m_localFrame; + b3Matrix3x3FloatData m_c0; + b3Vector3FloatData m_c1; + b3Vector3FloatData m_localFrame; bInvalidHandle *m_rigidBody; int m_nodeIndex; float m_c2; @@ -955,11 +955,11 @@ typedef struct bInvalidHandle { class SoftBodyPoseData { public: - btMatrix3x3FloatData m_rot; - btMatrix3x3FloatData m_scale; - btMatrix3x3FloatData m_aqq; - btVector3FloatData m_com; - btVector3FloatData *m_positions; + b3Matrix3x3FloatData m_rot; + b3Matrix3x3FloatData m_scale; + b3Matrix3x3FloatData m_aqq; + b3Vector3FloatData m_com; + b3Vector3FloatData *m_positions; float *m_weights; int m_numPositions; int m_numWeigts; @@ -974,15 +974,15 @@ typedef struct bInvalidHandle { class SoftBodyClusterData { public: - btTransformFloatData m_framexform; - btMatrix3x3FloatData m_locii; - btMatrix3x3FloatData m_invwi; - btVector3FloatData m_com; - btVector3FloatData m_vimpulses[2]; - btVector3FloatData m_dimpulses[2]; - btVector3FloatData m_lv; - btVector3FloatData m_av; - btVector3FloatData *m_framerefs; + b3TransformFloatData m_framexform; + b3Matrix3x3FloatData m_locii; + b3Matrix3x3FloatData m_invwi; + b3Vector3FloatData m_com; + b3Vector3FloatData m_vimpulses[2]; + b3Vector3FloatData m_dimpulses[2]; + b3Vector3FloatData m_lv; + b3Vector3FloatData m_av; + b3Vector3FloatData *m_framerefs; int *m_nodeIndices; float *m_masses; int m_numFrameRefs; @@ -1005,17 +1005,17 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btSoftBodyJointData + class b3SoftBodyJointData { public: void *m_bodyA; void *m_bodyB; - btVector3FloatData m_refs[2]; + b3Vector3FloatData m_refs[2]; float m_cfm; float m_erp; float m_split; int m_delete; - btVector3FloatData m_relPosition[2]; + b3Vector3FloatData m_relPosition[2]; int m_bodyAtype; int m_bodyBtype; int m_jointType; @@ -1024,10 +1024,10 @@ typedef struct bInvalidHandle { // -------------------------------------------------- // - class btSoftBodyFloatData + class b3SoftBodyFloatData { public: - btCollisionObjectFloatData m_collisionObjectData; + b3CollisionObjectFloatData m_collisionObjectData; SoftBodyPoseData *m_pose; SoftBodyMaterialData **m_materials; SoftBodyNodeData *m_nodes; @@ -1036,7 +1036,7 @@ typedef struct bInvalidHandle { SoftBodyTetraData *m_tetrahedra; SoftRigidAnchorData *m_anchors; SoftBodyClusterData *m_clusters; - btSoftBodyJointData *m_joints; + b3SoftBodyJointData *m_joints; int m_numMaterials; int m_numNodes; int m_numLinks; diff --git a/src/Bullet3Serialize/Bullet2FileLoader/btBulletFile.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp similarity index 78% rename from src/Bullet3Serialize/Bullet2FileLoader/btBulletFile.cpp rename to src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp index 3ecf8851e..381bf905e 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/btBulletFile.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.cpp @@ -13,7 +13,7 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "btBulletFile.h" +#include "b3BulletFile.h" #include "bDefines.h" #include "bDNA.h" @@ -24,7 +24,7 @@ subject to the following restrictions: // 32 && 64 bit versions -#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES #ifdef _WIN64 extern char sBulletDNAstr64[]; extern int sBulletDNAlen64; @@ -32,18 +32,18 @@ extern int sBulletDNAlen64; extern char sBulletDNAstr[]; extern int sBulletDNAlen; #endif //_WIN64 -#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES extern char sBulletDNAstr64[]; extern int sBulletDNAlen64; extern char sBulletDNAstr[]; extern int sBulletDNAlen; -#endif //BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#endif //B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES using namespace bParse; -btBulletFile::btBulletFile() +b3BulletFile::b3BulletFile() :bFile("", "BULLET ") { mMemoryDNA = new bDNA(); //this memory gets released in the bFile::~bFile destructor,@todo not consistent with the rule 'who allocates it, has to deallocate it" @@ -51,35 +51,35 @@ btBulletFile::btBulletFile() m_DnaCopy = 0; -#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES #ifdef _WIN64 - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64,16); + m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16); memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64); #else//_WIN64 - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen,16); + m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16); memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); mMemoryDNA->init(m_DnaCopy,sBulletDNAlen); #endif//_WIN64 -#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { - m_DnaCopy = (char*) btAlignedAlloc(sBulletDNAlen64,16); + m_DnaCopy = (char*) b3AlignedAlloc(sBulletDNAlen64,16); memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); mMemoryDNA->init(m_DnaCopy,sBulletDNAlen64); } else { - m_DnaCopy =(char*) btAlignedAlloc(sBulletDNAlen,16); + m_DnaCopy =(char*) b3AlignedAlloc(sBulletDNAlen,16); memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); mMemoryDNA->init(m_DnaCopy,sBulletDNAlen); } -#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } -btBulletFile::btBulletFile(const char* fileName) +b3BulletFile::b3BulletFile(const char* fileName) :bFile(fileName, "BULLET ") { m_DnaCopy = 0; @@ -87,17 +87,17 @@ btBulletFile::btBulletFile(const char* fileName) -btBulletFile::btBulletFile(char *memoryBuffer, int len) +b3BulletFile::b3BulletFile(char *memoryBuffer, int len) :bFile(memoryBuffer,len, "BULLET ") { m_DnaCopy = 0; } -btBulletFile::~btBulletFile() +b3BulletFile::~b3BulletFile() { if (m_DnaCopy) - btAlignedFree(m_DnaCopy); + b3AlignedFree(m_DnaCopy); while (m_dataBlocks.size()) @@ -112,7 +112,7 @@ btBulletFile::~btBulletFile() // ----------------------------------------------------- // -void btBulletFile::parseData() +void b3BulletFile::parseData() { // printf ("Building datablocks"); // printf ("Chunk size = %d",CHUNK_HEADER_LEN); @@ -143,7 +143,7 @@ void btBulletFile::parseData() while (dataChunk.code != DNA1) { - if (!brokenDNA || (dataChunk.code != BT_QUANTIZED_BVH_CODE) ) + if (!brokenDNA || (dataChunk.code != B3_QUANTIZED_BVH_CODE) ) { // one behind @@ -169,42 +169,42 @@ void btBulletFile::parseData() // listID->push_back((bStructHandle*)id); } - if (dataChunk.code == BT_SOFTBODY_CODE) + if (dataChunk.code == B3_SOFTBODY_CODE) { m_softBodies.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_RIGIDBODY_CODE) + if (dataChunk.code == B3_RIGIDBODY_CODE) { m_rigidBodies.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_DYNAMICSWORLD_CODE) + if (dataChunk.code == B3_DYNAMICSWORLD_CODE) { m_dynamicsWorldInfo.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_CONSTRAINT_CODE) + if (dataChunk.code == B3_CONSTRAINT_CODE) { m_constraints.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_QUANTIZED_BVH_CODE) + if (dataChunk.code == B3_QUANTIZED_BVH_CODE) { m_bvhs.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_TRIANLGE_INFO_MAP) + if (dataChunk.code == B3_TRIANLGE_INFO_MAP) { m_triangleInfoMaps.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_COLLISIONOBJECT_CODE) + if (dataChunk.code == B3_COLLISIONOBJECT_CODE) { m_collisionObjects.push_back((bStructHandle*) id); } - if (dataChunk.code == BT_SHAPE_CODE) + if (dataChunk.code == B3_SHAPE_CODE) { m_collisionShapes.push_back((bStructHandle*) id); } @@ -221,7 +221,7 @@ void btBulletFile::parseData() } } else { - printf("skipping BT_QUANTIZED_BVH_CODE due to broken DNA\n"); + printf("skipping B3_QUANTIZED_BVH_CODE due to broken DNA\n"); } @@ -237,7 +237,7 @@ void btBulletFile::parseData() } -void btBulletFile::addDataBlock(char* dataBlock) +void b3BulletFile::addDataBlock(char* dataBlock) { m_dataBlocks.push_back(dataBlock); @@ -246,14 +246,14 @@ void btBulletFile::addDataBlock(char* dataBlock) -void btBulletFile::writeDNA(FILE* fp) +void b3BulletFile::writeDNA(FILE* fp) { bChunkInd dataChunk; dataChunk.code = DNA1; dataChunk.dna_nr = 0; dataChunk.nr = 1; -#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { #ifdef _WIN64 @@ -262,7 +262,7 @@ void btBulletFile::writeDNA(FILE* fp) fwrite(&dataChunk,sizeof(bChunkInd),1,fp); fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp); #else - btAssert(0); + b3Assert(0); #endif } else @@ -273,10 +273,10 @@ void btBulletFile::writeDNA(FILE* fp) fwrite(&dataChunk,sizeof(bChunkInd),1,fp); fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); #else//_WIN64 - btAssert(0); + b3Assert(0); #endif//_WIN64 } -#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { dataChunk.len = sBulletDNAlen64; @@ -291,24 +291,24 @@ void btBulletFile::writeDNA(FILE* fp) fwrite(&dataChunk,sizeof(bChunkInd),1,fp); fwrite(sBulletDNAstr, sBulletDNAlen,1,fp); } -#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES } -void btBulletFile::parse(int verboseMode) +void b3BulletFile::parse(int verboseMode) { -#ifdef BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#ifdef B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { #ifdef _WIN64 if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64,16); + m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16); memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); parseInternal(verboseMode,(char*)sBulletDNAstr64,sBulletDNAlen64); #else - btAssert(0); + b3Assert(0); #endif } else @@ -317,19 +317,19 @@ void btBulletFile::parse(int verboseMode) if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen,16); + m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16); memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen); #else - btAssert(0); + b3Assert(0); #endif } -#else//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#else//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES if (VOID_IS_8) { if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen64,16); + m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen64,16); memcpy(m_DnaCopy,sBulletDNAstr64,sBulletDNAlen64); parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen64); } @@ -337,11 +337,11 @@ void btBulletFile::parse(int verboseMode) { if (m_DnaCopy) delete m_DnaCopy; - m_DnaCopy = (char*)btAlignedAlloc(sBulletDNAlen,16); + m_DnaCopy = (char*)b3AlignedAlloc(sBulletDNAlen,16); memcpy(m_DnaCopy,sBulletDNAstr,sBulletDNAlen); parseInternal(verboseMode,m_DnaCopy,sBulletDNAlen); } -#endif//BT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES +#endif//B3_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES //the parsing will convert to cpu endian mFlags &=~FD_ENDIAN_SWAP; @@ -354,7 +354,7 @@ void btBulletFile::parse(int verboseMode) } // experimental -int btBulletFile::write(const char* fileName, bool fixupPointers) +int b3BulletFile::write(const char* fileName, bool fixupPointers) { FILE *fp = fopen(fileName, "wb"); if (fp) @@ -401,7 +401,7 @@ int btBulletFile::write(const char* fileName, bool fixupPointers) -void btBulletFile::addStruct(const char* structType,void* data, int len, void* oldPtr, int code) +void b3BulletFile::addStruct(const char* structType,void* data, int len, void* oldPtr, int code) { bParse::bChunkInd dataChunk; diff --git a/src/Bullet3Serialize/Bullet2FileLoader/btBulletFile.h b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h similarity index 86% rename from src/Bullet3Serialize/Bullet2FileLoader/btBulletFile.h rename to src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h index ef18ff5e1..e128453e6 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/btBulletFile.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3BulletFile.h @@ -13,22 +13,22 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_BULLET_FILE_H -#define BT_BULLET_FILE_H +#ifndef B3_BULLET_FILE_H +#define B3_BULLET_FILE_H #include "bFile.h" #include "Bullet3Common/b3AlignedObjectArray.h" #include "bDefines.h" -#include "Bullet3Serialize/Bullet2FileLoader/btSerializer.h" +#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h" namespace bParse { // ----------------------------------------------------- // - class btBulletFile : public bFile + class b3BulletFile : public bFile { @@ -55,13 +55,13 @@ namespace bParse { b3AlignedObjectArray m_dynamicsWorldInfo; b3AlignedObjectArray m_dataBlocks; - btBulletFile(); + b3BulletFile(); - btBulletFile(const char* fileName); + b3BulletFile(const char* fileName); - btBulletFile(char *memoryBuffer, int len); + b3BulletFile(char *memoryBuffer, int len); - virtual ~btBulletFile(); + virtual ~b3BulletFile(); virtual void addDataBlock(char* dataBlock); @@ -80,4 +80,4 @@ namespace bParse { }; }; -#endif //BT_BULLET_FILE_H +#endif //B3_BULLET_FILE_H diff --git a/src/Bullet3Serialize/Bullet2FileLoader/btSerializer.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.cpp similarity index 100% rename from src/Bullet3Serialize/Bullet2FileLoader/btSerializer.cpp rename to src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.cpp diff --git a/src/Bullet3Serialize/Bullet2FileLoader/btSerializer.h b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h similarity index 70% rename from src/Bullet3Serialize/Bullet2FileLoader/btSerializer.h rename to src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h index 2294debd0..adfeeb2be 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/btSerializer.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/b3Serializer.h @@ -13,8 +13,8 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#ifndef BT_SERIALIZER_H -#define BT_SERIALIZER_H +#ifndef B3_SERIALIZER_H +#define B3_SERIALIZER_H #include "Bullet3Common/b3Scalar.h" // has definitions like SIMD_FORCE_INLINE #include "Bullet3Common/b3StackAlloc.h" @@ -33,7 +33,7 @@ extern int sBulletDNAlen; extern char sBulletDNAstr64[]; extern int sBulletDNAlen64; -SIMD_FORCE_INLINE int btStrLen(const char* str) +SIMD_FORCE_INLINE int b3StrLen(const char* str) { if (!str) return(0); @@ -49,7 +49,7 @@ SIMD_FORCE_INLINE int btStrLen(const char* str) } -class btChunk +class b3Chunk { public: int m_chunkCode; @@ -59,27 +59,27 @@ public: int m_number; }; -enum btSerializationFlags +enum b3SerializationFlags { - BT_SERIALIZE_NO_BVH = 1, - BT_SERIALIZE_NO_TRIANGLEINFOMAP = 2, - BT_SERIALIZE_NO_DUPLICATE_ASSERT = 4 + B3_SERIALIZE_NO_BVH = 1, + B3_SERIALIZE_NO_TRIANGLEINFOMAP = 2, + B3_SERIALIZE_NO_DUPLICATE_ASSERT = 4 }; -class btSerializer +class b3Serializer { public: - virtual ~btSerializer() {} + virtual ~b3Serializer() {} virtual const unsigned char* getBufferPointer() const = 0; virtual int getCurrentBufferSize() const = 0; - virtual btChunk* allocate(size_t size, int numElements) = 0; + virtual b3Chunk* allocate(size_t size, int numElements) = 0; - virtual void finalizeChunk(btChunk* chunk, const char* structType, int chunkCode,void* oldPtr)= 0; + virtual void finalizeChunk(b3Chunk* chunk, const char* structType, int chunkCode,void* oldPtr)= 0; virtual void* findPointer(void* oldPtr) = 0; @@ -104,29 +104,29 @@ public: -#define BT_HEADER_LENGTH 12 +#define B3_HEADER_LENGTH 12 #if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__) -# define BT_MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) +# define B3_MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) #else -# define BT_MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) +# define B3_MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) #endif -#define BT_SOFTBODY_CODE BT_MAKE_ID('S','B','D','Y') -#define BT_COLLISIONOBJECT_CODE BT_MAKE_ID('C','O','B','J') -#define BT_RIGIDBODY_CODE BT_MAKE_ID('R','B','D','Y') -#define BT_CONSTRAINT_CODE BT_MAKE_ID('C','O','N','S') -#define BT_BOXSHAPE_CODE BT_MAKE_ID('B','O','X','S') -#define BT_QUANTIZED_BVH_CODE BT_MAKE_ID('Q','B','V','H') -#define BT_TRIANLGE_INFO_MAP BT_MAKE_ID('T','M','A','P') -#define BT_SHAPE_CODE BT_MAKE_ID('S','H','A','P') -#define BT_ARRAY_CODE BT_MAKE_ID('A','R','A','Y') -#define BT_SBMATERIAL_CODE BT_MAKE_ID('S','B','M','T') -#define BT_SBNODE_CODE BT_MAKE_ID('S','B','N','D') -#define BT_DYNAMICSWORLD_CODE BT_MAKE_ID('D','W','L','D') -#define BT_DNA_CODE BT_MAKE_ID('D','N','A','1') +#define B3_SOFTBODY_CODE B3_MAKE_ID('S','B','D','Y') +#define B3_COLLISIONOBJECT_CODE B3_MAKE_ID('C','O','B','J') +#define B3_RIGIDBODY_CODE B3_MAKE_ID('R','B','D','Y') +#define B3_CONSTRAINT_CODE B3_MAKE_ID('C','O','N','S') +#define B3_BOXSHAPE_CODE B3_MAKE_ID('B','O','X','S') +#define B3_QUANTIZED_BVH_CODE B3_MAKE_ID('Q','B','V','H') +#define B3_TRIANLGE_INFO_MAP B3_MAKE_ID('T','M','A','P') +#define B3_SHAPE_CODE B3_MAKE_ID('S','H','A','P') +#define B3_ARRAY_CODE B3_MAKE_ID('A','R','A','Y') +#define B3_SBMATERIAL_CODE B3_MAKE_ID('S','B','M','T') +#define B3_SBNODE_CODE B3_MAKE_ID('S','B','N','D') +#define B3_DYNAMICSWORLD_CODE B3_MAKE_ID('D','W','L','D') +#define B3_DNA_CODE B3_MAKE_ID('D','N','A','1') -struct btPointerUid +struct b3PointerUid { union { @@ -135,24 +135,24 @@ struct btPointerUid }; }; -///The btDefaultSerializer is the main Bullet serialization class. +///The b3DefaultSerializer is the main Bullet serialization class. ///The constructor takes an optional argument for backwards compatibility, it is recommended to leave this empty/zero. -class btDefaultSerializer : public btSerializer +class b3DefaultSerializer : public b3Serializer { b3AlignedObjectArray mTypes; b3AlignedObjectArray mStructs; b3AlignedObjectArray mTlens; - b3HashMap mStructReverse; - b3HashMap mTypeLookup; + b3HashMap mStructReverse; + b3HashMap mTypeLookup; - b3HashMap m_chunkP; + b3HashMap m_chunkP; - b3HashMap m_nameMap; + b3HashMap m_nameMap; - b3HashMap m_uniquePointers; + b3HashMap m_uniquePointers; int m_uniqueIdGenerator; int m_totalSize; @@ -164,7 +164,7 @@ class btDefaultSerializer : public btSerializer int m_serializationFlags; - b3AlignedObjectArray m_chunkPtrs; + b3AlignedObjectArray m_chunkPtrs; protected: @@ -182,15 +182,15 @@ protected: void writeDNA() { - btChunk* dnaChunk = allocate(m_dnaLength,1); + b3Chunk* dnaChunk = allocate(m_dnaLength,1); memcpy(dnaChunk->m_oldPtr,m_dna,m_dnaLength); - finalizeChunk(dnaChunk,"DNA1",BT_DNA_CODE, m_dna); + finalizeChunk(dnaChunk,"DNA1",B3_DNA_CODE, m_dna); } int getReverseType(const char *type) const { - btHashString key(type); + b3HashString key(type); const int* valuePtr = mTypeLookup.find(key); if (valuePtr) return *valuePtr; @@ -208,7 +208,7 @@ protected: littleEndian= ((char*)&littleEndian)[0]; - m_dna = btAlignedAlloc(dnalen,16); + m_dna = b3AlignedAlloc(dnalen,16); memcpy(m_dna,bdnaOrg,dnalen); m_dnaLength = dnalen; @@ -233,7 +233,7 @@ protected: // Parse names if (!littleEndian) - *intPtr = btSwapEndian(*intPtr); + *intPtr = b3SwapEndian(*intPtr); dataLen = *intPtr; @@ -247,7 +247,7 @@ protected: while (*cp)cp++; cp++; } - cp = btAlignPointer(cp,4); + cp = b3AlignPointer(cp,4); /* TYPE (4 bytes) @@ -257,10 +257,10 @@ protected: */ intPtr = (int*)cp; - btAssert(strncmp(cp, "TYPE", 4)==0); intPtr++; + b3Assert(strncmp(cp, "TYPE", 4)==0); intPtr++; if (!littleEndian) - *intPtr = btSwapEndian(*intPtr); + *intPtr = b3SwapEndian(*intPtr); dataLen = *intPtr; intPtr++; @@ -274,7 +274,7 @@ protected: cp++; } - cp = btAlignPointer(cp,4); + cp = b3AlignPointer(cp,4); /* @@ -285,7 +285,7 @@ protected: // Parse type lens intPtr = (int*)cp; - btAssert(strncmp(cp, "TLEN", 4)==0); intPtr++; + b3Assert(strncmp(cp, "TLEN", 4)==0); intPtr++; dataLen = (int)mTypes.size(); @@ -293,7 +293,7 @@ protected: for (i=0; im_length; + int curLength = sizeof(b3Chunk)+m_chunkPtrs[i]->m_length; memcpy(currentPtr,m_chunkPtrs[i], curLength); - btAlignedFree(m_chunkPtrs[i]); + b3AlignedFree(m_chunkPtrs[i]); currentPtr+=curLength; mysize+=curLength; } @@ -498,14 +498,14 @@ public: if (!oldPtr) return 0; - btPointerUid* uptr = (btPointerUid*)m_uniquePointers.find(oldPtr); + b3PointerUid* uptr = (b3PointerUid*)m_uniquePointers.find(oldPtr); if (uptr) { return uptr->m_ptr; } m_uniqueIdGenerator++; - btPointerUid uid; + b3PointerUid uid; uid.m_uniqueIds[0] = m_uniqueIdGenerator; uid.m_uniqueIds[1] = m_uniqueIdGenerator; m_uniquePointers.insert(oldPtr,uid); @@ -523,11 +523,11 @@ public: return m_currentSize; } - virtual void finalizeChunk(btChunk* chunk, const char* structType, int chunkCode,void* oldPtr) + virtual void finalizeChunk(b3Chunk* chunk, const char* structType, int chunkCode,void* oldPtr) { - if (!(m_serializationFlags&BT_SERIALIZE_NO_DUPLICATE_ASSERT)) + if (!(m_serializationFlags&B3_SERIALIZE_NO_DUPLICATE_ASSERT)) { - btAssert(!findPointer(oldPtr)); + b3Assert(!findPointer(oldPtr)); } chunk->m_dna_nr = getReverseType(structType); @@ -550,10 +550,10 @@ public: { ptr = m_buffer+m_currentSize; m_currentSize += int(size); - btAssert(m_currentSizem_chunkCode = 0; chunk->m_oldPtr = data; chunk->m_length = int(size)*numElements; @@ -602,7 +602,7 @@ public: if (findPointer((void*)name)) return; - int len = btStrLen(name); + int len = b3StrLen(name); if (len) { @@ -611,14 +611,14 @@ public: newLen += padding; //serialize name string now - btChunk* chunk = allocate(sizeof(char),newLen); + b3Chunk* chunk = allocate(sizeof(char),newLen); char* destinationName = (char*)chunk->m_oldPtr; for (int i=0;i bListBasePtr; - typedef b3HashMap bPtrMap; + typedef b3HashMap bPtrMap; } diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp b/src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp index a362767bb..140283191 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/bDNA.cpp @@ -93,7 +93,7 @@ int bDNA::getReverseType(short type) int bDNA::getReverseType(const char *type) { - btHashString key(type); + b3HashString key(type); int* valuePtr = mTypeLookup.find(key); if (valuePtr) return *valuePtr; @@ -514,7 +514,7 @@ void bDNA::init(char *data, int len, bool swap) } mStructReverse.insert(strc[0], i); - mTypeLookup.insert(btHashString(mTypes[strc[0]]),i); + mTypeLookup.insert(b3HashString(mTypes[strc[0]]),i); } } diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.h b/src/Bullet3Serialize/Bullet2FileLoader/bDNA.h index 4da7d4891..c0d701b02 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bDNA.h +++ b/src/Bullet3Serialize/Bullet2FileLoader/bDNA.h @@ -95,8 +95,8 @@ namespace bParse { b3AlignedObjectArray mTypes; b3AlignedObjectArray mStructs; b3AlignedObjectArray mTlens; - b3HashMap mStructReverse; - b3HashMap mTypeLookup; + b3HashMap mStructReverse; + b3HashMap mTypeLookup; int mPtrLen; diff --git a/src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp b/src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp index 124198800..89a5de49c 100644 --- a/src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp +++ b/src/Bullet3Serialize/Bullet2FileLoader/bFile.cpp @@ -20,7 +20,7 @@ subject to the following restrictions: #include #include #include "bDefines.h" -#include "Bullet3Serialize/Bullet2FileLoader/btSerializer.h" +#include "Bullet3Serialize/Bullet2FileLoader/b3Serializer.h" #include "Bullet3Common/b3AlignedAllocator.h" #include "Bullet3Common/b3MinMax.h" @@ -33,7 +33,7 @@ const char* getCleanName(const char* memName, char* buffer) { int slen = strlen(memName); assert(slenm_uniqueIds[0] == oldPtr->m_uniqueIds[1]) { @@ -957,8 +957,8 @@ void bFile::safeSwapPtr(char *dst, const char *src) } else if (ptrMem==8 && ptrFile==4) { - btPointerUid* oldPtr = (btPointerUid*)src; - btPointerUid* newPtr = (btPointerUid*)dst; + b3PointerUid* oldPtr = (b3PointerUid*)src; + b3PointerUid* newPtr = (b3PointerUid*)dst; if (oldPtr->m_uniqueIds[0] == oldPtr->m_uniqueIds[1]) { newPtr->m_uniqueIds[0] = oldPtr->m_uniqueIds[0]; @@ -1192,7 +1192,7 @@ void bFile::resolvePointersMismatch() int p = 0; while (blockLen-- > 0) { - btPointerUid dp = {0}; + b3PointerUid dp = {0}; safeSwapPtr((char*)dp.m_uniqueIds, oldPtr); void **tptr = (void**)(newPtr + p * ptrMem); @@ -1456,7 +1456,7 @@ void bFile::resolvePointers(int verboseMode) { printf("\n"); int numitems = m_chunks.size(); - printf("\n", btGetVersion(), numitems); + printf("\n", b3GetVersion(), numitems); } for (int i=0;i m_pointerPtrFixupArray; b3AlignedObjectArray m_chunks; - b3HashMap m_chunkPtrPtrMap; + b3HashMap m_chunkPtrPtrMap; //