Page 1 of 1

Soft-Body Objects fall apart

Posted: Fri Sep 23, 2016 9:45 am
by Silverlan
I'm trying to create a simple Soft-Body plane-shape, which works great, except for the collisions:
https://youtu.be/PO6sNKpmRfA

On contact, the entire thing just falls apart triangle by triangle. It's a nice effect, but not exactly what I'm aiming for...
What could be causing that? Here's my code for the creation of the soft-body object:

Code: Select all

PhysSoftBody *PhysEnv::CreateSoftBody(const std::vector<Vector3> &verts,const std::vector<uint16_t> &indices)
{
	btAlignedObjectArray<btVector3> vtx;
	vtx.reserve(verts.size());
	for(auto &v : verts)
		vtx.push_back({v.x *PhysEnv::WORLD_SCALE,v.y *PhysEnv::WORLD_SCALE,v.z *PhysEnv::WORLD_SCALE});

	auto *psb = new btSoftBody(m_softBodyWorldInfo.get(),vtx.size(),&vtx[0],0);
	auto *pm = psb->appendMaterial();
	pm->m_kLST = 0.55;
	pm->m_kAST = 0.2;
	pm->m_kVST = 0.55;
	for(auto i=decltype(indices.size()){0};i<indices.size();i+=3)
	{
		psb->appendLink(indices[i +2],indices[i],pm,true);
		psb->appendLink(indices[i],indices[i +1],pm,true);
		psb->appendLink(indices[i +1],indices[i +2],pm,true);

		psb->appendFace(indices[i],indices[i +1],indices[i +2],pm);
	}
   
	psb->generateBendingConstraints(2,pm);
	psb->m_cfg.piterations = 2;
	psb->m_cfg.collisions |= btSoftBody::fCollision::VF_SS;

	psb->randomizeConstraints();

	Vector3 origin {471.f,68.f,82.f};
	btTransform trans;
	trans.setIdentity();
	trans.setOrigin(uvec::create_bt(origin) *PhysEnv::WORLD_SCALE);
	psb->transform(trans);
	psb->setTotalMass(1.0,true);
	psb->generateClusters(64);  

	m_btWorld->addSoftBody(psb);

	auto *softBody = new PhysSoftBody(this,psb);
	softBody->Initialize();
	AddSoftBody(softBody);
	return softBody;
}

Re: Soft-Body Objects fall apart

Posted: Sat Sep 24, 2016 4:32 am
by Xcoder79
Hi,


I have noticed that inside your code, generateClusters is set to 64 this will create 64 individual softbody convex clusters for your object.
It seems like your object is breaking to its 64 individual collision triangular clusters.

Hope this helps

Cheers☺

Re: Soft-Body Objects fall apart

Posted: Sat Sep 24, 2016 8:24 am
by Silverlan
Xcoder79 wrote: I have noticed that inside your code, generateClusters is set to 64 this will create 64 individual softbody convex clusters for your object.
It seems like your object is breaking to its 64 individual collision triangular clusters.
It's actually a lot more than 64 pieces, changing the cluster count doesn't seem to have much of an effect. (I've changed it to 2 for testing purposes, result is the same.)

Re: Soft-Body Objects fall apart

Posted: Tue Aug 13, 2019 10:51 am
by Asiyeh
Hi. i have same problem, could you manage to solve this?