Does Bepu v1 supports find closest point on boundsbox or shape?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
starlaoxmelgs
Posts: 15
Joined: Mon Jan 13, 2020 8:26 am

Does Bepu v1 supports find closest point on boundsbox or shape?

Post by starlaoxmelgs »

Similar to Unity's Collider.ClosestPointOnBounds, Collider.ClosestPoint.
https://docs.unity3d.com/ScriptReferenc ... Point.html
https://docs.unity3d.com/ScriptReferenc ... ounds.html

public Vector3 ClosestPoint(Vector3 position);
Returns a point on the collider that is closest to a given location.

public Vector3 ClosestPointOnBounds(Vector3 position)
The closest point to the bounding box of the attached collider.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Does Bepu v1 supports find closest point on boundsbox or shape?

Post by Norbo »

Not in a single function call.

ClosetPointOnBounds is a very simple function:

Code: Select all

closestPointOnBounds = Vector3.Max(bounds.Min, Vector3.Min(bounds.Max, point));
For the closest point on a collider, it's a little trickier. The underlying algorithm is there, but it's not exposed directly for this use case. You could create a large Sphere and test pairs with it and the desired query targets. It would be equivalent to a closest point test.
Post Reply