Soft body parts disappear

Eaglegor
Posts: 9
Joined: Tue Jun 18, 2013 2:20 pm
Location: Russia, Samara

Soft body parts disappear

Post by Eaglegor »

The problem can be seen in this video:
http://youtu.be/8HCf_Si3yMQ

When I touch the softbody with two different kinematic bodies (instruments) some parts of it seem to disappear. I have no exact idea of what is wrong.
Both instruments are using compound shapes. The tube-linke instrument contains the single box shape. The grasping instrument contains one capsule-shape for each part.
Floor is static and contains a compound shape with single box in it.

The parameters of soft body are:

Code: Select all

m_cfg.kDP = 0; // Damping coefficient [0,1]
m_cfg.kPR = 0; // Pressure coefficient [-inf,+inf]
m_cfg.kDF = 1; // Dynamic friction coefficient [0,1]
m_cfg.kCHR = 1; // Rigid contacts hardness [0,1]
m_cfg.kKHR = 1; // Kinetic contacts hardness [0,1]
m_cfg.kSHR = 1; // Soft contacts hardness [0,1]
m_cfg.kSRHR_CL =  1; // Soft vs rigid hardness [0,1] (cluster only)
m_cfg.kSKHR_CL = 1; // Soft vs kinetic hardness [0,1] (cluster only)
m_cfg.kSSHR_CL = 1; // Soft vs soft hardness [0,1] (cluster only)
m_cfg.viterations = 0; // Velocities solver iterations
m_cfg.piterations = 8; // Positions solver iterations
m_cfg.collisions = btSoftBody::fCollision::CL_RS | btSoftBody::fCollision::CL_SS; // Collision flags
When I use SDF_RS as a collision flag I don't see such effect.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Soft body parts disappear

Post by Erwin Coumans »

Some issues might be fixed in very latest SVN version, can you test with the trunk version at http://bullet.googlecode.com?

The softbody clusters have issues indeed. You could try to reproduce it in one of the demos?
For example, you could try this:
Make the bug reproducible in your own software (disable user input and other random factors, for example recording the user input and playback next time).
Then serialize the simulation to a .bullet file, right before things go wrong. See http://bulletphysics.org/mediawiki-1.5. ... ialization
Then load the serialized .bullet file in the Bullet SerializeDemo (with softbody enabled) and see if it happens there too.
Then file an issue in the issue tracker.
Eaglegor
Posts: 9
Joined: Tue Jun 18, 2013 2:20 pm
Location: Russia, Samara

Re: Soft body parts disappear

Post by Eaglegor »

Thanks for an answer! I'll try do it in the near future when I'll have some free time.
Eaglegor
Posts: 9
Joined: Tue Jun 18, 2013 2:20 pm
Location: Russia, Samara

Re: Soft body parts disappear

Post by Eaglegor »

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.