Replies: 4 comments
-
For above mentioned example I did calculations (using school geometry) and collision should appear when cylinder is at |
Beta Was this translation helpful? Give feedback.
-
Well, ChatGPT answered: This is a very insightful observation — and what you're seeing is expected behavior in BepuPhysics2 under certain conditions. Why does this happen? In BepuPhysics2, speculative contacts are used for kinematic bodies and CCD-like behavior. This means: A negative penetration depth indicates that two shapes are not yet overlapping. But Bepu predicts that they will touch or slightly penetrate by the next timestep, so it generates a contact early. This allows BepuPhysics to:
Your cylinder is still above the box by ~0.08 units. But the engine anticipates that it will penetrate next frame. So it gives you early contact information (with negative depth). This is not a bug, it’s speculative contact working correctly. |
Beta Was this translation helpful? Give feedback.
-
Next, ChatGPT suggested the following: If you want real, actual contacts only (i.e. penetration has occurred):In ConfigureContactManifold, filter out negative depth contacts:
Tweak Precision if NeededYou can reduce how early speculative contacts occur by lowering the speculativeMargin, e.g.:
This makes speculative contacts more conservative (closer to true contact).
These measures helped, so it's resolved |
Beta Was this translation helpful? Give feedback.
-
I can confirm that chatgpt is correct; negative depths are expected for speculative contacts. You can indeed filter them out if you want to pay attention only to touching/penetrating contacts. And yes, you can modify the maximum speculative margin to clamp these to small or zero separation. Doing so would harm collision response stability for dynamics, but for a query-like use case it's fine. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created an application in C# WPF and Helix toolkit (as 3D renderer) to learn Bepu Physics 2 and physics of collision detection in general. Kynematic Cylinder moves all the way down to a Static Box with step of 0.1 . I observe that in some cases collision gets detected when it should not really be there, have a look at attached picture.
It's really interesting that collision depth in Narrow Phase Callback is reported to be negative.
On next step of simulation collision - depth is positive, when collision is observed on graphical display. Here are values from next two steps
Also in this case I observed such mesages from Narrow Phase Callback, for example:
What is mathematical meaning of observed phenomenons:
(I believe they may be related)
Beta Was this translation helpful? Give feedback.
All reactions