Next, I set up a rigid kinematic body at the same position as the vertex and appended it as an anchor. I tried setting anchor hardness to 1, but the whole simulation jumps around the point even before I try to move the kinematic body. How do I solve this:
Here's the code from the demos itself:
Code: Select all
static void Init_ClothAttach(SoftDemo* pdemo)
{
//TRACEDEMO
const btScalar s=4;
const btScalar h=6;
const int r=9;
btSoftBody* psb=btSoftBodyHelpers::CreatePatch(pdemo->m_softBodyWorldInfo,btVector3(-s,h,-s),
btVector3(+s,h,-s),
btVector3(-s,h,+s),
btVector3(+s,h,+s),r,r,4+8,true);
psb->m_cfg.kAHR = 0.99;
psb->m_cfg.kCHR = 0;
psb->m_cfg.kKHR = 0;
pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(psb->m_nodes[0].m_x);
for(unsigned int i = 1; i < psb->m_nodes.size(); ++i)
{
if (psb->checkLink(&psb->m_nodes[0], &psb->m_nodes[i]));
}
btRigidBody* body=pdemo->localCreateRigidBody(0,startTransform,new btSphereShape(0.2));
psb->appendAnchor(0,body, true);
body1 = body;
//pdemo->m_cutting=true;
}