Why is self collision not working when I try to run simple cloth on ball example (NVCloth)?

I was trying to run simple ball on cloth experiment (I let a square mesh fall on sphere) to run on NVCloth. The cloth is able to detect and collide with ball but the self collision fails. I read some where that I had to set the setSelfCollisionDistance and setSelfCollisionDistance to non-zero. I did that but the self collision still does not happen, the cloth simply pass through itself.

Am I missing something here, do I need to do something extra to make sure cloth self collision is triggered?

// Code part

cloth->setSelfCollisionDistance(0.1f); // I tried number between 0-1
cloth->setSelfCollisionStiffness(0.1f); // I tried number between 0-1

// phase config that I used
phases[i].mStiffness = 0.1f;
phases[i].mStiffnessMultiplier = 1.0f;
phases[i].mCompressionLimit = 1.0f;
phases[i].mStretchLimit = 1.0f;

I don’t see any issue with the code you posted.
Did you look at the SelfCollisionScene.cpp in the samples?

The self collision distance doesn’t have to be between 0.0 and 1.0, it should depend on the mesh.
In general it should be set to the smallest distance between any two particles in the cloth mesh, which is the biggest value that doesn’t cause jitters (that is why having uniform mesh density is especially important with self collision).

Setting the stiffness to a value around 0.9 should make it clear when the self collision has any effect.

Self collision is known for not being very reliable as it can allow intersection when big enough forces are applied, even when everything else is setup correctly.

Thank you mtamis. You were right about “The self collision distance doesn’t have to be between 0.0 and 1.0, it should depend on the mesh.” so increasing the length to the min edge length of the elements did the trick.

cloth->setSelfCollisionDistance(4.0); // eg (-24,28,0),(-20,28,0),(-24,24,0)