I reproduced this issue in Bullet trunk version demos (revision 2644).
With the default model from soft demo it behaves as expected:
http://youtu.be/Ki8YcJDk7vU
With my own cube model (it's different from default) I get an unxepected behavior:
http://youtu.be/9VY_wiyX1ms
There is a modified Init_TetraCube from demo:
Code: Select all
static void Init_TetraCube(SoftDemo* pdemo)
{
/*btSoftBody* psb=btSoftBodyHelpers::CreateFromTetGenData(pdemo->m_softBodyWorldInfo,
TetraCube::getElements(),
0,
TetraCube::getNodes(),
false,true,true);*/
btSoftBody* psb=btSoftBodyHelpers::CreateFromTetGenData(pdemo->m_softBodyWorldInfo,
"cube.1.ele",
"cube.1.node",
false,true,true);
pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
psb->scale(btVector3(0.3,0.3,0.3));
//psb->scale(btVector3(4,4,4));
psb->translate(btVector3(0,5,0));
//psb->setVolumeMass(30000);
for(size_t i=0; i<psb->m_nodes.size(); ++i){
psb->m_nodes[i].m_im = 1/0.01;
}
///fix one vertex
//psb->setMass(0,0);
//psb->setMass(10,0);
//psb->setMass(20,0);
psb->m_cfg.piterations=4;
//psb->generateClusters(128);
psb->generateClusters(64);
//psb->getCollisionShape()->setMargin(0.5);
psb->getCollisionShape()->setMargin(0.01);
psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS
//+ btSoftBody::fCollision::CL_SELF
;
psb->m_materials[0]->m_kLST=1;
pdemo->m_cutting=false;
/*psb=btSoftBodyHelpers::CreateFromTetGenData(pdemo->m_softBodyWorldInfo,
TetraCube::getElements(),
0,
TetraCube::getNodes(),
false,true,true);*/
psb=btSoftBodyHelpers::CreateFromTetGenData(pdemo->m_softBodyWorldInfo,
"cube.1.ele",
"cube.1.node",
false,true,true);
pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
psb->scale(btVector3(0.3,0.3,0.3));
//psb->scale(btVector3(4,4,4));
psb->translate(btVector3(0,40,0));
//psb->setVolumeMass(30000);
for(size_t i=0; i<psb->m_nodes.size(); ++i){
psb->m_nodes[i].m_im = 1/0.01;
}
///fix one vertex
//psb->setMass(0,0);
//psb->setMass(10,0);
//psb->setMass(20,0);
psb->m_cfg.piterations=4;
//psb->generateClusters(128);
psb->generateClusters(64);
//psb->getCollisionShape()->setMargin(0.5);
psb->getCollisionShape()->setMargin(0.01);
psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS
//+ btSoftBody::fCollision::CL_SELF
;
psb->m_materials[0]->m_kLST=1;
pdemo->m_cutting=false;
}
Tet and ele files ale attached.
Loading tet and ele files is performed by this function:
Code: Select all
/* Create from TetGen .ele, .face, .node data */
btSoftBody* btSoftBodyHelpers::CreateFromTetGenData(btSoftBodyWorldInfo& worldInfo,
const char* ele,
const char* node,
bool bfacelinks,
bool btetralinks,
bool bfacesfromtetras)
{
std::ifstream in_node(node);
std::ifstream in_ele(ele);
std::string node_string;
std::string ele_string;
while(!in_node.eof()){
char c;
in_node.get(c);
node_string+=c;
}
while(!in_ele.eof()){
char c;
in_ele.get(c);
ele_string+=c;
}
return btSoftBodyHelpers::CreateFromTetGenData(worldInfo, ele_string.c_str(), 0, node_string.c_str(), bfacelinks, btetralinks, bfacesfromtetras);
}
I'll post this issue in tracker soon.
UPD: related issue:
http://code.google.com/p/bullet/issues/detail?id=730
You do not have the required permissions to view the files attached to this post.