Soft Body Cloth Simulation Stretching Problem

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
RorschachGames
Posts: 2
Joined: Sat Aug 29, 2020 12:55 pm

Soft Body Cloth Simulation Stretching Problem

Post by RorschachGames »

I have a simple flat mesh made up of many triangles to simulate a curtain. Each vertex is a node. I am able to set up physics and it behaves as you would expect for the most part. When ran, it collapses and appears to be cloth (for the most part).
When I take the top row of vertices and set their mass to 0.0f they do not move as one would expect. However, the rest of the vertices in the mesh continue to fall, stretching the curtain.

Do I need to link each node of the curtain to each other so the nodes don't continue to fall?
(Parts of the code below is cut and pasted from various sources as I was looking for any combination that could possibly work.)

Code: Select all

btSoftBody * psb = btSoftBodyHelpers::CreateFromTriMesh(*worldInfo,&fVerts[0],&iMeshIndices[0],msh->iFaceCount);
btSoftBody::Material* pm = psb->appendMaterial();
psb->m_cfg.kDP = 0.0;
psb->m_cfg.kDF = 0.0;
psb->m_cfg.kMT = 0.0;
psb->m_cfg.kCHR = 0.0;
psb->m_cfg.kKHR = 0.0;
psb->m_cfg.kSHR = 0.0;
psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_SELF;
psb->m_cfg.piterations = 1;
psb->m_materials[0]->m_kLST = 0.1;
psb->m_materials[0]->m_kAST = 0.1;
psb->m_materials[0]->m_kVST = 0.1;
psb->setPose(true, true);
psb->generateBendingConstraints(2);
psb->randomizeConstraints();
psb->getCollisionShape()->setMargin(0.5);
((btSoftRigidDynamicsWorld*)world)->addSoftBody(psb);
Here is an example of what I mean:
Image
RorschachGames
Posts: 2
Joined: Sat Aug 29, 2020 12:55 pm

Re: Soft Body Cloth Simulation Stretching Problem

Post by RorschachGames »

I finally brought myself to downloading and building the Bullet Physics project examples. Would have saved me a whole lot of time if I did that from the beginning. :roll:
I was using CreateFromTriMesh, when I should have been using CreatePatch.
That not only works, but it is also a whole lot easier to implement too. The nodes are in order and easy to set to OpenGL vertices.
The only plus to all the time I spent on this was that I learned a lot. So I guess it was not all a waste.
Post Reply