Breaking Joints?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Breaking Joints?

Post by needshelprendering »

Hi,

I am using Bepu to simulate rag dolls. I am using joints to attach limbs and such. Animals in my game can remove limbs of other animals. Is there an already built in way to remove a joint when a threshold of force is applied to it? If not, does there exist a way to tell how much force is being applied to the joint?

Thank you.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Breaking Joints?

Post by Norbo »

Joints and constraints have a TotalImpulse property which refers to the total change in momentum caused by the constraint in the previous frame. Comparing the length of that vector to a threshold and removing the constraint from the space if it is exceeded would do the trick.

TotalImpulse is time step duration dependent, though. Constraint impulses are an instant change in momentum applied per frame. If you wanted to compare it against a maximum force threshold (that is, change in momentum over time), divide the TotalImpulse length by the Space.TimeStepSettings.TimeStepDuration.
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Re: Breaking Joints?

Post by needshelprendering »

Great, I'll try this out when I get a chance. Thank you Norbo.
JusTiCe8
Posts: 52
Joined: Mon Jun 01, 2015 9:02 am

Re: Breaking Joints?

Post by JusTiCe8 »

( Code archeology is annoying, but thread archeology is less ;) )

Please allow me to give some life to this one as I've made simple contraption with WeldJoint:

One is simple four stands "glued" to the ground with default settings except one and a small platform lying on top of them (without any joint). Each beam is 100 unit mass, platform mass is 500 units.

Another is a sphere with two boxes glued on its sides, and drop from a height of 1500 units, sphere is 1000 units of mass and boxes 500 units each, welded with default anchor position.

According to your post, I display this value of the joint: BallSocketJoint.TotalImpulse.Length() / Space.TimeStepSettings.TimeStepDuration

and I got this sequence (before, after ground collision for the sphere/boxes thing):
tj1=143884,900
tj2=143884,900

tj1=666662,900
tj2=666662,300

tj1=709833,200
tj2=709832,700

and values like: 155411.200 at rest and 263219.300 or 299571.600 after a collision (with a 200 mass units kaboom with a linear velocity set to 200 following camera forward vector) for the beams.

Could you explain those values (not exactly of course), please and how I can check for before and after some joint breaking point ?
I'm aware constraints create a force to keep entities in defined limits and I think I may first check for a few seconds the value above and use it as "default/at rest/no force(s)" reference value and subtract it maybe from what I could get after a collision or a stress applied to them.

Thanks.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Breaking Joints?

Post by Norbo »

It's just a measure of force- consider a single box hung on a BallSocketJoint with no other interactions or damping:

Code: Select all

            Box box = new Box(new Vector3(0, 5, 5), 1, 2, 1, 100);
            box.LinearDamping = 0;
            box.ActivityInformation.AllowStabilization = false;
            ballSocketJoint = new BallSocketJoint(box, null, box.Position);
            Space.Add(box);
            Space.Add(ballSocketJoint);
With a gravity of -9.81, the force (ballSocketJoint.TotalImpulse.Length() / Space.TimeStepSettings.TimeStepDuration) applied by this constraint is 981. That is exactly the force applied by gravity, from force = mass * acceleration. That makes sense- the box isn't moving, so the constraint must be completely counteracting gravity's force.

One somewhat intuitive way to think about a breaking threshold is in terms of g-force. The constraint above was applying 1g of acceleration. Maybe you want it to break under a load of 50g- an acceleration 50 times stronger than earth's gravity. In that case, the maximum force for the above constraint and entity would just be (mass = 100) * (max g-force = 50) * (gravitational acceleration = 9.81) = 49050.

If you're seeing really high values with no clear physical interpretation, there may be constraint fighting going on. For example, if an object is constrained to be partially inside another object, the contacts and constraints will fight and the forces can get pretty huge.
Post Reply