Joint separation/gap/stretch

Official forum for the Chipmunk2D Physics Library.
Post Reply
faraday
Posts: 5
Joined: Mon Feb 16, 2009 10:32 pm
Contact:

Joint separation/gap/stretch

Post by faraday »

Hi,
Thanks for this great library! I love playing around with it.

My question: I've built a ragdoll with torso, head, arms, hands, legs, feet with pivot joints and slide joints for angle constraints. When I click the mouse I apply an impulse to the torso body to throw the actor around. Such fun! Now, if if click a few times, the actor's velocity gets faster and the torso stretches at the shoulder, hip and neck joints. The other joints stay intact (elbow, wrist, knee, ankle). So basically, the torso is way out in front and the head and limbs trail behind. Once the actor slows down and comes to rest, the joints realign.

Is there anything I can do to mitigate the amount of joint stretching?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Joint separation/gap/stretch

Post by slembcke »

They stay stretched even when the body doesn't have any forces applied to it? When it's just in freefall?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
faraday
Posts: 5
Joined: Mon Feb 16, 2009 10:32 pm
Contact:

Re: Joint separation/gap/stretch

Post by faraday »

All the joints look ok, when in free fall or under mild velocity. They only seem to stretch out after applying several impulses. Attached a few screens.
The joint types I've used are
Pivot Joints - shoulder, elbow, wrist, hip, knee, ankle, and neck
Slide Joints - hip, elbow, wrist, neck (these are only for angle constraints)
faraday
Posts: 5
Joined: Mon Feb 16, 2009 10:32 pm
Contact:

Re: Joint separation/gap/stretch

Post by faraday »

I've found that if I call cpSpaceStep more frequently, the joints stay tighter. Is that a good approach though?

I havent tried this yet, but maybe applying the same impulse to each cpBody member of the ragdoll would keep the joints together better. I'll test it out.
faraday
Posts: 5
Joined: Mon Feb 16, 2009 10:32 pm
Contact:

Re: Joint separation/gap/stretch

Post by faraday »

Found another tip from the docs. Increasing the cp_joint_bias_coef. I put mine at .8 and it seems to keep the joints tighter. This also seems like it performs better (fps) than calling cpSpaceStep more often.
faraday
Posts: 5
Joined: Mon Feb 16, 2009 10:32 pm
Contact:

Re: Joint separation/gap/stretch

Post by faraday »

Ok, final update! The source of the problem was my own blunder :oops: . I added the torso's cpBody and cpShape to the space twice. For whatever reason, that caused the torso to be off sync (under med-high velocity) with the rest of the body (as seen in the screens). Now everything looks awesome! I love it. :D
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Joint separation/gap/stretch

Post by slembcke »

Ah, yes. That would make things pretty wonky. That would update the body's velocity and position twice per frame. It would sort of work, but would make the problem much much more noticeable for sure.

A note on changing cp_joint_bias_coef: The closer you get to 1.0, the faster the joints will fix themselves, but it can also make it much worse and oscillate like mad if your joint gets separated by a large amount.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests