Chain stretch gaps problem

Discuss any Chipmunk bugs here.
Post Reply
ARme
Posts: 3
Joined: Tue Apr 08, 2008 10:33 am
Contact:

Chain stretch gaps problem

Post by ARme »

Hi

I'm playing with Chipmunk since a couple of days now and i found it quite easy and nice, so first thanks a lot to his author :)

Now i'm using the CPSlideJoint joint type to create a nice chain which work perfectly.
I can attach them to bodies and static bodies with infinite mass (i hope it's a good setup for static bodies).

But when i attach the end of this chain to a dynamic body that I control
(think about the chomp thing in mario)
Image
and when o try to pull the string to his maximum every links stretch and tremble.
I try to stop this by changing the iteration step and set the max CPSlideJoint to a reasonable maximum (just before Gaps).
Here is a screen with some more informations :
Image
So here's my questions :
- How can i determine which joint has too much streching force so i can break it ? (I think about compare distance between GetBodyA and GetBodyB but...)
- How can i stop stretching gaps appearing with my chain when breaking is unwanted ?

I also made a long tails to my player with 2 CPPinJoint from A to B and from B to A which seem's to be the only way i know to stop the streching gaps problem when is tails get stuck. But this require 2 Joint for each link and it's probably not the best solution.

Can you help me please ?

Thanks
(i'm using blitzmax)
By the way, is Chipmunk still in development ? Cause there is no more noise here or on the front page... Would love a solution for the Elastic shapes stacking problem :D
ARme
Posts: 3
Joined: Tue Apr 08, 2008 10:33 am
Contact:

Re: Chain stretch gaps problem

Post by ARme »

The length between BodyA and BodyB with CPSlideJoint give me an idea of the stretching force.
So when a certain distance is exceeded i simply break the link.
Also increasing the friction of every links solidify my chain but it's also harder to manipulate it :|

Here is a nice screenshot :
Image

I found a weird bug when playing a lot with chains and my "breaking system".
It's maybe my fault but when i'm adding a huge amount of bodies and chains, when i break a random joints the whole simulation Collapse and many bodies fall through every statics shapes.

And here at my blog you can find the executable to play with :
http://arm42.free.fr/blog/index.php
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Chain stretch gaps problem

Post by maximile »

If the mass of the ball at the end of the chain is much larger than the mass of the chain links, stretching will happen. (Don't know if there are any plans to fix this. Apparently it's a problem common to most physics engines.) Increasing the mass of the chain links or reducing the mass of the monster at the end should help (but might not be ideal for your game).

Breakable chains were mentioned in http://www.slembcke.net/forums/viewtopi ... kable#p421 , but you'd have to ask Slembcke for more info on that.

Chipmunk is still being developed as far as I know. The forums have been quiet for a while now for some reason.

Very nice-looking screenshots by the way.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Chain stretch gaps problem

Post by slembcke »

Yes. I'm still developing Chipmunk. I add features when I need them or because they sound fun to implement. Development pace is far slower than anyone would like I'm sure. :p

First of all, nice work so far. It was pretty cool to play around with.

Chains: Maxamile is correct, chains are computationally expensive with any rigid body physics library. There are a number of things you can do to help keep things stable:
  • Don't heavy objects on a chain with very light links.
  • Use fewer links.
  • Attach a slide joint with a max length the same as the chain length from the start to the end of the chain. (to the objects on the end of the chain, not the first and last links)
  • Attach the centers of shapes together instead of the ends.
I've had good luck with creating a chain of circles with an infinite moment of inertia (so they can't roll) together with slide joints. This works like a bunch of beads on a string instead of a chain with hard links. They act pretty much the same, but it is much more stable. The disadvantage is that collision wise, it's much more bumpy. Again, if you put an object on the end of the chain, attach that object directly to the other end.

Official support for "breaking" joints: It wouldn't be hard. I've never gotten around to it because I haven't had a need for it. I guess what you are doing works, but is less than ideal.

Stackable elastic objects: I hacked together a proof of concept that worked pretty well once, but it had some side effects that would break compatibility. It would only affect the current elastic behavior a little, and the same people that would be affected are probably the same that want stacking fixed. I suppose I could just put it in anyway...

Does that answer your questions?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ARme
Posts: 3
Joined: Tue Apr 08, 2008 10:33 am
Contact:

Re: Chain stretch gaps problem

Post by ARme »

YEs :)
I have successfully realise what i was thinking about and now can go on with my prototyping.
Thanks slembcke and maximile for these precisions.
scorp
Posts: 29
Joined: Sat May 10, 2008 1:41 pm
Contact:

Re: Chain stretch gaps problem

Post by scorp »

I need breakable joints for my projects.
Is there a way to determine force, which is being applied to the joint?
Measuring stretch is not an option in my case.



BTW. Why does stretch happen? Is that a bug or a feature? :mrgreen:
I'm using slide joints as limitations for my ragdoll and I don't want them to stretch.
Not really a critical issue, but anyway... Is it possible to make them absolutely unstretchable?

p.s. (couple of hrs later): Did some testing. More iterations and smaller step solve the stretching problem. It’s not the best solution, might really slow things down, that's why I won't be using it for my project. But at least the nature of stretching is clear to me now.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests