Help! softbody nodes can not update after stepsimulate

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
ekcool
Posts: 1
Joined: Wed Aug 21, 2019 8:27 am

Help! softbody nodes can not update after stepsimulate

Post by ekcool »

I follow SoftDemo,and create a btSoftRigidDynamicsWorld and create a softbody with trimesh from my mesh sucessuflly.
Details as follows:
1)
btDefaultSoftBodySolver* softSolver = new btDefaultSoftBodySolver();
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
btSoftRigidDynamicsWorld* _sworld = new btSoftRigidDynamicsWorld(m_dispatcher, m_broadphase,solver, collisionConfig, softSolver);
m_dynamicsWorld = (btSoftRigidDynamicsWorld*)_sworld;
///setting here

m_dynamicsWorld->setGravity(btVector3(0, -9.8, 0));
m_dynamicsWorld->getDispatchInfo().m_useContinuous = true;
m_dynamicsWorld->getSolverInfo().m_erp2 = 0.f;
m_dynamicsWorld->getSolverInfo().m_globalCfm = 0.f;
m_dynamicsWorld->setSynchronizeAllMotionStates(true);
///////////////////////////////////fill softinfo for create softbody///////////////////// m_softBodyWorldInfo.m_broadphase = m_broadphase;
m_softBodyWorldInfo.m_dispatcher = m_dispatcher;
m_softBodyWorldInfo.m_sparsesdf.Initialize();
m_softBodyWorldInfo.m_gravity.setValue(0, -9.8, 0);
m_softBodyWorldInfo.air_density = (btScalar)1.2;
m_softBodyWorldInfo.water_density = 0;
m_softBodyWorldInfo.water_offset = 0;
m_softBodyWorldInfo.water_normal = btVector3(0, 0, 0);

2)////create a softbody and add it into sofrigiddynamicsworld :
m_psb = btSoftBodyHelpers::CreateFromTriMesh(softBodyWorldInfo, meshVecs, indices, numTrigs);
if (m_psb == NULL)
assert(false);
btSoftBody::Material* pm = m_psb->appendMaterial();
pm->m_kLST = 0.1;

m_psb->transform(psbTrans);//this works well,it can move the softbody mesh location
m_psb->setTotalMass(5, true);
m_psb->m_cfg.kDP = 0.0;// Damping coefficient [0,1]
m_psb->m_cfg.kDF = /*0.2*/ 1.0;// Dynamic friction coefficient [0,1]
m_psb->m_cfg.kMT = 0.05;// Pose matching coefficient [0,1]
m_psb->m_cfg.kCHR = 1.0;// Rigid contacts hardness [0,1]
m_psb->m_cfg.kKHR = 0.1;// Kinetic contacts hardness [0,1]
m_psb->m_cfg.kSHR = 0.0;// Soft contacts hardness [0,1]
m_psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_SELF;
m_psb->m_cfg.piterations = 7;
m_psb->m_materials[0]->m_kLST = 1.0;
m_psb->m_materials[0]->m_kAST = 0.2;
m_psb->m_materials[0]->m_kVST = 1.0;
m_psb->setPose(true, true);
m_psb->generateBendingConstraints(2);
m_psb->randomizeConstraints();
3)////in my game loop I try to setupsimulate, and get softbody m_nodes' position to update my mesh vertices ,but failed :

void SkinnedMeshRenderer::lateUpdate() //update for every frame
{
if (!_mesh)
{
return;
}
if (_pWorld)
{
_pWorld->stepSimulate(1.0f / 60.0f);
this->updateVerticesFromSim();//get softbody nodes and update mesh vertices,but all nodes location's value had no changes
}
this->updateBones();
this->updateBlendShapes();

}


so, reslut is showed as old state, the mesh cloth had no change ,anyone can give me an advice? thanks...
Post Reply