[V1] About PenetrationDepth

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
snoopyuj
Posts: 6
Joined: Fri Jun 22, 2018 9:33 am

[V1] About PenetrationDepth

Post by snoopyuj » Wed Aug 01, 2018 8:25 am

Hi all, it's me again.

I'm just curious about why PenetrationDepth in PairTouched() gives me PenertrationDepth1, not Depth2. If I tried to push the green box out of the ground after space.Update(), I really want is Depth2. After PositionUpdater(), Depth1 seems ...... useless for me. Is there a reason to keep the old data?

By the way, how can I get both hit points' normal from the objects? Contact.Normal is just the one of them. :(

Thanks!

Image

Norbo
Site Admin
Posts: 4558
Joined: Tue Jul 04, 2006 4:45 am

Re: [V1] About PenetrationDepth

Post by Norbo » Wed Aug 01, 2018 10:48 pm

The deferred event dispatcher does nothing more than provide a deferred copy of the most recent events. Since Depth1 is the latest available value, that's what you see. In the above example, Depth2 has not yet been computed; that's what the next frame will compute.

The choice of stage execution order is somewhat arbitrary, but they all come with tradeoffs. For example, in v2, the current default layout is position integration->narrowphase->solver, so at the end of the frame the contacts and body positions are consistent. The downside is that a velocity modified outside the update will be directly integrated without a narrowphase/solve to stop it from pushing through other objects.

Note that the simulation loop is the same either way. If you ran the simulation without frame interruptions, it would just be a long sequence of:

Code: Select all

...->solver->integration->broadphase->narrowphase->solver->integration->broadphase->narrowphase->solver->integration->broadphase->...
So, if you really wanted to, you could hook a callback for arbitrary logic in between any of those stages. Nothing fundamentally special about being outside Space.Update.
By the way, how can I get both hit points' normal from the objects? Contact.Normal is just the one of them.
Enumerating the Contacts collection on a pair handler should show all the existing different contacts. Note that in a convex manifold, all of the normals should be equal outside of a few corner cases involving old persistent contacts. (Mathematically, two touching convex rigid bodies can only have a single contact patch, and that patch is guaranteed to be flat.)

snoopyuj
Posts: 6
Joined: Fri Jun 22, 2018 9:33 am

Re: [V1] About PenetrationDepth

Post by snoopyuj » Fri Aug 03, 2018 12:39 am

Got it! Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests