Advertisement Jump to content
Sign in to follow this  

How to prevent sphere going through cloth model?

This topic is 3365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Can I get some help on cloth model please? I have created a "cloth" using particles connected by springs using the bend, shear and structural springs. I have it falling over a hemisphere on a ground plane. My problem is this: The hit detection works, but the cloth particles slide down the hemisphere anyway, stretching up a big "hole" such that the sphere goes through the cloth. Any tips for me please? As I see it, the spring equation does work, in the sense that it will attempt to return to rest length. I have tried different siffness and damping coefficient but it made little difference. Furthermore, hit collision and reaction for each single particle is correct: hit the sphere and slide over it. But in real life, the "partcles" of course do not slide down because the cloth itself holds provides friction and support for each point "particle". Not sure if I explained it clearly. Appreciate any help. thanks.

Share this post

Link to post
Share on other sites
is it that your cloth is a grid of verts and when its on the sphere, the grid gets stretched wide enough for the sphere to fit through?

If so you might try making a maximum distance constraint between the points on your cloth grid so that they never get so far apart that the sphere can go through them.

also, unfortunately, that will just make it so smaller spheres will be able to pass through it hehe.

It seems the only way to get around your problem 100% would be to do triangle tests of the cloth mesh against the sphere.

If im way off base of how your stuff works let me know though (:

Share this post

Link to post
Share on other sites
Thanks Atrix256,

Using your advice of setting positional constrain, I calculate something like this:

// calculate offset and positional correction
float offset = (distance_v1_to_v2 - rest_length);
Vec3 direction = normalize(v1.pos - v2.pos);
Vec3 correction = direction * offset / 2;
// bring the vertices back towards/away each other at rest_length apart.
v1.pos += correction;
v2.pos += -correction;

I think the logic is correct, no? but this caused the cloth to "blow up", if you know what i mean. This is really hard to debug...

But through your advice I accidentally realised that I could use up the stiffness all the way to 150 to make it work in THAT SCNENE ONLY more than 150, it "blows up" upon collision.

But with that setting, falling the cloth over a sphere in space would also cause the shpere to go through the cloth (intended behavior is cloth hang over the sphere), and then "blow up" upon collision with ground plane. So the stiffness only works for certain scenes. Apparently, the spring model i use builds up too much energy.

// Spring model (psuedocode)
Vec3 dx = v1.position- v2.position;
Vec3 dv = v1.velocity - v2.velocity ;
float dist = distance(v1.position, v2.position);
Vec3 force = (dx/dist) * -((dist - rest) * stiff + (dv_dot_dx / dist) * damp);

Because this is so difficult to debug, I was thinking someone with such experience before can provides tips on what to check on. But I know this is going to be difficult for you guys also. I'll continue to work on it to single out the problems first. Thanks =)

Share this post

Link to post
Share on other sites
In that case you have to limit the energy the system may gain from collision. Preferable zero ;) .

What kind of stabilization scheme do you use? Baumgarte? And how exactly do you perform the collision check?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!