Soft-Body Objects fall apart

Post Reply
Silverlan
Posts: 27
Joined: Thu Oct 30, 2014 9:15 pm

Soft-Body Objects fall apart

Post by Silverlan » Fri Sep 23, 2016 9:45 am

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;
}

Xcoder79
Posts: 42
Joined: Sun Aug 07, 2011 5:27 am

Re: Soft-Body Objects fall apart

Post by Xcoder79 » Sat Sep 24, 2016 4:32 am

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☺

Silverlan
Posts: 27
Joined: Thu Oct 30, 2014 9:15 pm

Re: Soft-Body Objects fall apart

Post by Silverlan » Sat Sep 24, 2016 8:24 am

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.)

Asiyeh
Posts: 7
Joined: Wed Aug 07, 2019 9:24 am

Re: Soft-Body Objects fall apart

Post by Asiyeh » Tue Aug 13, 2019 10:51 am

Hi. i have same problem, could you manage to solve this?

Post Reply