Joint Springyness?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
chebob69
Posts: 40
Joined: Thu Aug 16, 2012 7:27 pm

Joint Springyness?

Post by chebob69 »

I'm using a few revolute joints to help simulate physics on my character (hair, cloth etc). I'm sticking to revolute joints cos I wanted it to be fairly simple. The fewer degrees of freedom, the fewer places something can go wrong I guess.
However, the natural spring of the joints means it doesn't actually work out this way with a moving character. If the character is running, the joints will stretch all over the place and the spheres I'm using with them can become tangled (e.g with the hair).
What kind of settings do I use to keep the joints perfectly rigid? I'm wanting it to be like a hinge connecting rigid wooden poles. Thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Joint Springyness?

Post by Norbo »

I'm sticking to revolute joints cos I wanted it to be fairly simple. The fewer degrees of freedom, the fewer places something can go wrong I guess.
Careful here; overconstraining a system can actually make it less stable by being mostly unsolvable.
What kind of settings do I use to keep the joints perfectly rigid? I'm wanting it to be like a hinge connecting rigid wooden poles. Thanks!
Increase the spring constants. For example:
joint.SpringSettings.StiffnessConstant *= 1000;
joint.SpringSettings.DampingConstant *= 1000;
Watch out, though. This makes the system of constraints harder to solve in general. If it's already a difficult situation, you might end up with explosions depending on how stiff you try to make things.

Also, depending on how you set up your objects, you may be running into mass ratio issues. If a large amount of mass depends on an object with low mass, e.g. a heavy object at the end of a rope or just long chains of light objects which pull strongly on one other light object, then stability will suffer. Making joints stiffer will amplify this particular problem.

It may be useful to separate the hair/cloth simulation into its own space where you have fine grained control over the involved forces. Basically, instead of simulating in world space and trying to follow a speedy character's animations, it can all be simulated in the character's local space. Effects like swooshing due to character acceleration could be added back by just adding force to the hair/cloth pieces. The advantage would be that you have control over the stresses being input to the simulation, so you can help stop excessive separation or explosions.
chebob69
Posts: 40
Joined: Thu Aug 16, 2012 7:27 pm

Re: Joint Springyness?

Post by chebob69 »

Norbo wrote:It may be useful to separate the hair/cloth simulation into its own space where you have fine grained control over the involved forces. Basically, instead of simulating in world space and trying to follow a speedy character's animations, it can all be simulated in the character's local space. Effects like swooshing due to character acceleration could be added back by just adding force to the hair/cloth pieces. The advantage would be that you have control over the stresses being input to the simulation, so you can help stop excessive separation or explosions.
That's actually a really good idea! So I'll just set up a second character mesh that handles all of the physics and then copy the relevant data across to the one in view? How should I go about determining what force to apply to account for the character movement then?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Joint Springyness?

Post by Norbo »

So I'll just set up a second character mesh that handles all of the physics and then copy the relevant data across to the one in view?
Yup, basically.
How should I go about determining what force to apply to account for the character movement then?
Measuring the acceleration of the character body in world space and applying the opposite directly would be pretty close.

You may find that you don't need that much force to get the effect you want, though. It's possible that applying 0.2 * acceleration (or something along those lines) would look better in addition to being more stable. Some hand-tuned response that varies per object might be even better.
chebob69
Posts: 40
Joined: Thu Aug 16, 2012 7:27 pm

Re: Joint Springyness?

Post by chebob69 »

Norbo wrote: Measuring the acceleration of the character body in world space and applying the opposite directly would be pretty close.
Excellent. Is the acceleration of the body stored by the character controller or do I have to calculate it? Good old a=(v-u)/t?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Joint Springyness?

Post by Norbo »

It is not stored, so you will indeed need to calculate or approximate it.
Post Reply