I am new to bullet and have a question regarding to the run-time soft body mesh modification.
I need to change the shape of the tetrahedron mesh in the run-time. I took a look at the method btSoftBody::refine (which is used to refine and cut a circle from a cloth mesh in the sample code) and realized it is possible to add a tetrahedron using method btSoftBody::appendTetra, and remove a tetrahedron by calling pop_back() for the array of tetrahedra.
I wrote a simple piece of code (by clicking the mouse, remove all tetrahedra whose any vertex has a negative Z coordinate) and verified those method works. The issue was that after the tetrahedra were removed, all the vertices were still there and I had to remove vertices separately. So I added another piece of code to pop back all unused vertices. This time vertices were removed as expected, but the mesh could only keep stable for a couple of seconds, and then "exploded" (vertices quickly flying to all directions and crazily stretching the connected tetrahedra).
I guess there should be something I need to be careful when editing the mesh (especially when removing vertices), but I can't figure out where exactly the problem is. I was wondering the inertia of the mesh should be reset, as we need to do that for the rigid body. But I couldn't find any related method. I set zero for m_f, m_v or m_q fields of the soft body but none of them helped. Also I tried a bunch of update method (like updateClusters(), updateBounds(), updateNormals() and so forth) but no obvious improvement observed.
So did anyone have the similar issue before and solved already? Or can anybody kindly show me some some piece of code which is able to change the vertices array of the soft body in a stable way?
1 post • Page 1 of 1