diff --git a/Demos/AllBulletDemos/Makefile.am b/Demos/AllBulletDemos/Makefile.am index ff057b9ed..aab8b9854 100644 --- a/Demos/AllBulletDemos/Makefile.am +++ b/Demos/AllBulletDemos/Makefile.am @@ -26,8 +26,9 @@ AllBulletDemo_CXXFLAGS=\ -I@top_builddir@/src \ -I@top_builddir@/Extras/GIMPACTUtils \ -I@top_builddir@/Extras/ConvexDecomposition \ + -I@top_builddir@/Extras/HACD \ -I@top_builddir@/Extras \ -I@top_builddir@/Demos/OpenGL \ -I@top_builddir@/Demos/SoftDemo \ $(CXXFLAGS) -AllBulletDemo_LDADD=-L../OpenGL -lbulletopenglsupport -L../../src -L../../Extras -lgimpactutils -lconvexdecomposition -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lglui @opengl_LIBS@ +AllBulletDemo_LDADD=-L../OpenGL -lbulletopenglsupport -L../../src -L../../Extras -lgimpactutils -lconvexdecomposition -lHACD -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lglui @opengl_LIBS@ diff --git a/Demos/SoftDemo/SoftDemo.cpp b/Demos/SoftDemo/SoftDemo.cpp index 59a343c5a..2fb399492 100644 --- a/Demos/SoftDemo/SoftDemo.cpp +++ b/Demos/SoftDemo/SoftDemo.cpp @@ -52,7 +52,7 @@ static btRigidBody* staticBody = 0; static float waveheight = 5.f; const float TRIANGLE_SIZE=8.f; -unsigned current_demo=12; +int current_demo=29; #define DEMO_MODE_TIMEOUT 15.f //15 seconds for each demo @@ -1258,7 +1258,7 @@ static void Init_TetraBunny(SoftDemo* pdemo) psb->setVolumeMass(150); psb->m_cfg.piterations=2; //psb->m_cfg.piterations=1; - pdemo->m_cutting=true; + pdemo->m_cutting=false; //psb->getCollisionShape()->setMargin(0.01); psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS //+ btSoftBody::fCollision::CL_SELF @@ -1302,7 +1302,7 @@ static void Init_TetraCube(SoftDemo* pdemo) //+ btSoftBody::fCollision::CL_SELF ; psb->m_materials[0]->m_kLST=0.8; - pdemo->m_cutting=true; + pdemo->m_cutting=false; } @@ -1391,6 +1391,14 @@ void SoftDemo::clientResetScene() btCollisionObject* newOb = new btCollisionObject(); newOb->setWorldTransform(tr); newOb->setInterpolationWorldTransform( tr); + int lastDemo = (sizeof(demofncs)/sizeof(demofncs[0]))-1; + + if (current_demo<0) + current_demo = lastDemo; + if (current_demo > lastDemo) + current_demo =0; + + if (current_demo>19) { newOb->setCollisionShape(m_collisionShapes[0]); @@ -1403,7 +1411,8 @@ void SoftDemo::clientResetScene() m_softBodyWorldInfo.m_sparsesdf.Reset(); - current_demo=current_demo%(sizeof(demofncs)/sizeof(demofncs[0])); + + @@ -1789,7 +1798,7 @@ void SoftDemo::mouseFunc(int button, int state, int x, int y) { switch(state) { - case 0: + case 0: { m_results.fraction=1.f; DemoApplication::mouseFunc(button,state,x,y); @@ -1811,12 +1820,26 @@ void SoftDemo::mouseFunc(int button, int state, int x, int y) if(m_results.fraction<1.f) { m_impact = rayFrom+(rayTo-rayFrom)*m_results.fraction; - m_drag = false; + m_drag = m_cutting ? false : true; m_lastmousepos[0] = x; m_lastmousepos[1] = y; m_node = 0; switch(m_results.feature) { + case btSoftBody::eFeature::Tetra: + { + btSoftBody::Tetra& tet=m_results.body->m_tetras[m_results.index]; + m_node=tet.m_n[0]; + for(int i=1;i<4;++i) + { + if( (m_node->m_x-m_impact).length2()> + (tet.m_n[i]->m_x-m_impact).length2()) + { + m_node=tet.m_n[i]; + } + } + break; + } case btSoftBody::eFeature::Face: { btSoftBody::Face& f=m_results.body->m_faces[m_results.index]; diff --git a/Extras/Makefile.am b/Extras/Makefile.am index 8628c3945..f4cd5eac8 100644 --- a/Extras/Makefile.am +++ b/Extras/Makefile.am @@ -1,4 +1,4 @@ -noinst_LIBRARIES = libgimpactutils.a libconvexdecomposition.a libglui.a +noinst_LIBRARIES = libgimpactutils.a libconvexdecomposition.a libHACD.a libglui.a libglui_a_CXXFLAGS = ${CXXFLAGS} -Iglui libglui_a_SOURCES =\ @@ -73,6 +73,23 @@ libconvexdecomposition_a_SOURCES =\ ConvexDecomposition/bestfitobb.h\ ConvexDecomposition/meshvolume.h +libHACD_a_CXXFLAGS = ${CXXFLAGS} -IHACD/ -I../src +libHACD_a_SOURCES =\ + HACD/hacdGraph.cpp\ + HACD/hacdHACD.cpp\ + HACD/hacdICHull.cpp\ + HACD/hacdManifoldMesh.cpp\ + HACD/hacdCircularList.h\ + HACD/hacdGraph.h\ + HACD/hacdHACD.h\ + HACD/hacdICHull.h\ + HACD/hacdManifoldMesh.h\ + HACD/hacdVector.h\ + HACD/hacdVersion.h\ + HACD/hacdCircularList.inl\ + HACD/hacdVector.inl + + libgimpactutils_a_CXXFLAGS = ${CXXFLAGS} -I../src -IGIMPACTUtils -IConvexDecomposition libgimpactutils_a_SOURCES = GIMPACTUtils/btGImpactConvexDecompositionShape.cpp GIMPACTUtils/btGImpactConvexDecompositionShape.h diff --git a/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.cpp b/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.cpp index 5c4f1edc8..fccafa1ab 100644 --- a/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.cpp +++ b/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.cpp @@ -1503,7 +1503,34 @@ cl_kernel CLFunctions::compileCLKernelFromString( const char* kernelSource, cons kernel = clCreateKernel(m_cpProgram, kernelName, &ciErrNum); if (ciErrNum != CL_SUCCESS) { - printf("Error in clCreateKernel, Line %u in file %s !!!\n\n", __LINE__, __FILE__); + const char* msg = ""; + switch(ciErrNum) + { + case CL_INVALID_PROGRAM: + msg = "Program is not a valid program object."; + break; + case CL_INVALID_PROGRAM_EXECUTABLE: + msg = "There is no successfully built executable for program."; + break; + case CL_INVALID_KERNEL_NAME: + msg = "kernel_name is not found in program."; + break; + case CL_INVALID_KERNEL_DEFINITION: + msg = "the function definition for __kernel function given by kernel_name such as the number of arguments, the argument types are not the same for all devices for which the program executable has been built."; + break; + case CL_INVALID_VALUE: + msg = "kernel_name is NULL."; + break; + case CL_OUT_OF_HOST_MEMORY: + msg = "Failure to allocate resources required by the OpenCL implementation on the host."; + break; + default: + { + } + } + + printf("Error in clCreateKernel for kernel '%s', error is \"%s\", Line %u in file %s !!!\n\n", kernelName, msg, __LINE__, __FILE__); + #ifndef BT_SUPPRESS_OPENCL_ASSERTS btAssert(0); #endif //BT_SUPPRESS_OPENCL_ASSERTS