Mitigating penetration of a squeezed entity

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Jullo
Posts: 4
Joined: Tue Dec 16, 2014 8:57 pm

Mitigating penetration of a squeezed entity

Post by Jullo »

Hi, I have a little question that I've tried to solve for some time now... I just got it to work one way but would like to know if it's a correct way.

Base problem is that there is a static Box entity representing ground. When I run this app, a kinematic Sphere falls down on ground for ~1sec. When I press a key to drop another kinematic Sphere (both spheres are of the same 3D model) right on the other Sphere it gets crushed into(?) the Box and never gets back on surface. By giving the Box a mass, the Sphere isn't crushed into it anymore but penetration and its fix is still way too big and takes too many frames. Although if I'll press a key and drop a Sphere soon enough after running app, everything works fine. I've wondered if this is caused by the resting ball becoming passive after it fell down on ground but don't know how to fix it properly...

To make things look more natural due to scales of my objects I've set gravity to -29.81. Mass of the crushed Sphere is 1.0 and mass of the dropping Sphere is 0.8. The Box is static.

So after googling I found out of some settings. I fiddled with many of those. These made it work MUCH better but are these the correct way to fix it:

Code: Select all

BEPUphysics.Settings.CollisionResponseSettings.MaximumPenetrationRecoverySpeed = 50f;
BEPUphysics.Settings.CollisionResponseSettings.BouncinessVelocityThreshold = 170f;
-Jullo-
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Mitigating penetration of a squeezed entity

Post by Norbo »

That doesn't sound like expected behavior, but I'm not immediately sure what the cause is. Could you reproduce the issue in a BEPUphysicsDemos demo and copy paste the code for me to look at?

(A side note to avoid future confusion: in the context of BEPUphysics, 'kinematic' refers to an entity that has effectively infinite mass. They are made by using the constructor overload that does not have a mass, or by using BecomeKinematic, or by setting the Mass property to a nonpositive number or infinity. Kinematic entities will not change velocities due to forces or collisions.)
Jullo
Posts: 4
Joined: Tue Dec 16, 2014 8:57 pm

Re: Mitigating penetration of a squeezed entity

Post by Jullo »

Ahh, ok. So the two Spheres are actually dynamic. Btw, I meant to say that the Box is a StaticMesh so not entity at all.

Sorry, I'm leaving tomorrow morning on a trip and I don't really have time to inject it into BEPUphysicsDemos :( But I tried to reproduce it in a smaller case and made it in GettingStartedDemo but I couldn't. I'll try to do it next week but I hope this new thing I found helps to clearify this. After testing in GettingStartedDemo I found out the reason causing this problem when I debugged unexpected places in my bugging app. Bounciness of material acts weirdly, seems to work differently than what I've thought. Setting bounciness of the crushing sphere for example to 500 still won't make it bounce at all unless bounciness of the crushed sphere is > 0. So the crushed sphere won't bounce off the ground when it falls down when the app is run.

So, when I set the bounciness value of both spheres to 3 they bounced off fast in vertical directions which crushed the ball into ground and finally hit the bottom (or right through it if it was thin). If I drop a sphere on the other sphere immediately after running app so that it's been lying on ground for only ~1sec, it won't be pushed under ground at all but will be if I waited like another second longer. This part is another mystery to me.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Mitigating penetration of a squeezed entity

Post by Norbo »

The default material blender is multiplicative. That means the friction of a pair of objects is, for example, materialA.KineticFriction * materialB.KineticFriction. So, if materialB.KineticFriction is 0, it doesn't matter what materialA.KineticFriction is- the result is zero.

The blending behavior can be changed by supplying your own MaterialManager.MaterialBlender delegate, or by specifying special rules using the MaterialManager.MaterialInteractions dictionary.

Also, note that bounceVelocity ~= -bounciness * impactVelocity. So, if both objects have a Bounciness coefficient of 3 and the default multiplicative blender is used, that means the bounce velocity will be 9 times higher than the impact velocity. In other words, physically realistic materials do not have a bounciness coefficient above 1.
If I drop a sphere on the other sphere immediately after running app so that it's been lying on ground for only ~1sec, it won't be pushed under ground at all but will be if I waited like another second longer. This part is another mystery to me.
This is very strange sounding. Maybe it's accumulating velocity and something external is holding the position in place nonphysically, but that doesn't really mesh well with the rest of the description. I don't think I can guess the problem, unfortunately.
Post Reply