btRigidBody seems be enlarged when collide with btSoftBody

riaqn
Posts: 1
Joined: Wed Jan 13, 2016 11:57 am

btRigidBody seems be enlarged when collide with btSoftBody

Post by riaqn »

Hello all,
I 'm using Bullet library to develop a billiards game, to solve the collision between balls, tables, etc.
Now I want to hang a flag(i.e. cloth) above the table, so I created a btSoftBody by btSoftBodyHelper::createFromTriMesh, etc. Now the problem is, when the bullet calculating the collision between the cloth and any other btRigidBody, the sizes of the btRigidBody seem to be enlarged. The cloth bends as if the balls is about 2x large than it should be.

I 've uploaded a picture about this issue. In this picture, it seems every btRigidBody is enlarged. The cloth just floats above the table, as if the table(which is a triangles mesh, single layer) is expanded.

Code: Select all

Cloth::Cloth(btSoftBodyWorldInfo &worldinfo,
             const std::vector<glm::vec2> &nodes,
             const std::vector<glm::ivec3> &faces,
             const glm::vec3 &base,
             const glm::vec3 &x,
             const glm::vec3 &y) {
  std::vector<glm::vec3> nodes0;
  for (auto &node : nodes)
    nodes0.push_back(base + node.x * x + node.y * y);
  sb_ = std::unique_ptr<btSoftBody>(btSoftBodyHelpers::CreateFromTriMesh(worldinfo, &nodes0[0].x, &faces[0].x, faces.size()));
  sb_->setUserPointer(this);
  sb_->m_cfg.kDP = 0.0;// Damping coefficient [0,1]
  sb_->m_cfg.kDF = 0.2;// Dynamic friction coefficient [0,1]
  sb_->m_cfg.kMT = 0.01;// Pose matching coefficient [0,1]
  sb_->m_cfg.kCHR = 1.0;// Rigid contacts hardness [0,1]
  sb_->m_cfg.kKHR = 0.8;// Kinetic contacts hardness [0,1]
  sb_->m_cfg.kSHR = 1.0;// Soft contacts hardness [0,1]
  sb_->m_cfg.piterations=2;
  sb_->m_materials[0]->m_kLST = 0.8;
  sb_->m_materials[0]->m_kAST = 0.8;
  sb_->m_materials[0]->m_kVST = 0.8;
  //sb_->scale(btVector3(1,1,1));
  //        sb_->setPose(true, true);
  sb_->generateBendingConstraints(2);
  sb_->randomizeConstraints();
  //        sb_->m_cfg.collisions =  btSoftBody::fCollision::CL_SS+
  //							                                    btSoftBody::fCollision::CL_RS;
  sb_->generateClusters(1);
  sb_->m_clusters[0]->m_matching	=	0.01;
  sb_->m_clusters[0]->m_ndamping	=	0.01;
  sb_->setTotalMass(0.01,true);
  sb_->setPose(false,true);
}
Any comment is appreciated.
You do not have the required permissions to view the files attached to this post.