Page 1 of 1

Body Penetration Correction

Posted: Wed Jun 26, 2013 3:08 am
by mike.vant
So I'm having a small issue with my main body correcting it's penetration into surfaces. Normal penetration works perfectly fine, but If I replace a mesh with a higher LOD mesh, and that mesh happens to be a litter higher than where the character is standing (thus causing a penetration) it doesn't seem to pop the body out. I'm pretty sure I have just configured something incorrectly. Hopefully you may have seen this before. Thank you in advance!

Re: Body Penetration Correction

Posted: Wed Jun 26, 2013 4:30 am
by Norbo
My guess would be that the shape was changed, but the pairs were not cleared and the old contacts stuck around. Those old contacts weren't deeply penetrating and the new contacts are stopped from generating by the old contacts (to some extent, anyway).

If that's correct, then forcing a clear one way or another would do the trick. You can do this by calling ClearContacts. Here's a snippet from the CharacterController, which has to clear contacts to prevent old contacts from interfering with behavior in some cases:

Code: Select all

foreach (var pair in Body.CollisionInformation.Pairs)
       pair.ClearContacts();
It's also possible that the object was simply asleep. Waking up nearby objects would help if this was the cause. To implement something like this, you could cycle through the pairs as before, calling activate on each pair's EntityA and EntityB (if the entity isn't null).

If I remember correctly, v1.3.0 has better handling of this sort of thing than v1.2.0 (e.g. some additional automatic wake-ups), but there are probably still a few cases where you will need to handle things directly.

Re: Body Penetration Correction

Posted: Wed Jun 26, 2013 4:50 pm
by mike.vant
That worked perfect, as always, thank you for the help!