Page 1 of 1

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

Posted: Wed Apr 01, 2020 6:49 am
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.

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

Posted: Wed Apr 01, 2020 9:41 pm
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.