Hopefully you are not yet much annoyed with my posts )
I'm a bit confused by a behaviour of cloth lying on the box-shaped ground. I could be seen in bullet soft body demos. I modified code of Init_ClusterCollide1 in this manner:
Code: Select all
static void Init_ClusterCollide1(SoftDemo* pdemo)
{
const btScalar s=8;
btSoftBody* psb=btSoftBodyHelpers::CreatePatch( pdemo->m_softBodyWorldInfo,btVector3(-s,0,-s),
btVector3(+s,0,-s),
btVector3(-s,0,+s),
btVector3(+s,0,+s),
17,17,//9,9,//31,31,
0,
true);
btSoftBody::Material* pm=psb->appendMaterial();
pm->m_kLST = 1.0;
pm->m_flags -= btSoftBody::fMaterial::DebugDraw;
psb->m_cfg.kDF = 1;
psb->m_cfg.kSRHR_CL = 1;
psb->m_cfg.kSR_SPLT_CL = 1;
psb->m_cfg.kSKHR_CL = 1;
psb->m_cfg.kSK_SPLT_CL = 1;
psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS | btSoftBody::fCollision::CL_RS;
psb->generateBendingConstraints(4,pm);
psb->randomizeConstraints();
psb->getCollisionShape()->setMargin(2);
psb->setTotalMass(1, true);
///pass zero in generateClusters to create cluster for each tetrahedron or triangle
//psb->generateClusters(0);
psb->generateClusters(64);
pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
//Ctor_RbUpStack(pdemo,10);
}
http://youtu.be/qqz9Bzn4TmI
When there are only 3 clusters, I see this:
http://youtu.be/GOPkskRQAm0
I was a bit confused by jerking in 3-clusters case. I want to ask if my understanding of reasons of these jerks is correct.
Let's have a part of cloth with cluster:
It falls on the ground affected by the gravity force. The cluster then gets an impulse to move away from the ground. The impulse, the gravity force and mass-spring forces are applied to vertices of cluster like this:
Then vertices are above the ground and convex cluster shape doesn't collide with ground:
A bit later the lowest vertices hit the ground causing the bottom border of cluster collide with ground:
The cluster gets a new impulse from this collision and applies it to all own vertices (including the ones which are already in air):
Then collided vertices jump in air again, and the next ones hit the ground:
The new impulses are applied to all vertices again:
This process repeats endless for different groups of colliding vertices. This could explain why the corners of cloth are flying in air in the 3-clusters case.
I want to know, if I'm understanding the process correct.
If I don't make a mistake, the solution could be to generate much more clusters but it slows the simulation. And even with generateClusters(0) I see the jerking with smaller amplitude and higher frequency. Is there any way to avoid it?