BasePart:GetClosestPointOnSurface() should respect skinned mesh geometry
rfc format drawn from rfcs/TEMPLATE.md at master · luau-lang/rfcs · GitHub .
Summary
This feature request addresses an intended behavior described in a 2020 post, where “… Skinned mesh deformation does not affect physics - it’s purely visual. Collision geometry is not affected.”.
Motivation
BasePart:GetClosestPointOnSurface()
, when called on a deformed skinned mesh, regardless of its CollisionFidelity, does not respect the skinned mesh geometry, and solves for the closest point as if the meshpart is still in its non-deformed state. This behavior, although intended, can become a pain point for developers doing precision-intensive work on meshparts.
For my own case, I use MeshPart:GetClosestPointOnSurface()
and a ispointinbox(point: Vector3, cframe: CFrame, size: Vector3)
function to solve for collisions against meshpart-based rigs without doing spatial queries, which also do not respect deformed mesh geometries.
Design
BasePart:GetClosestPointOnSurface()
, when called on a deformed skinned mesh, should solve for the closest point with respect to its deformed geometry/vertices, instead of solving for the closest point with respect to its original geometry.
Drawbacks
Solving for the closest point wrt deformed geometry might become more resource-intensive, although this is just conjecture because I don’t know how the function works under the hood.
Alternatives
Spatial queries workspace:Raycast()
, workspace:GetXBoundsInY()
, workspace:Block/Spherecast()
, BasePart:GetTouchingParts()
, do not respect deformed mesh geometry.
As an aside it seems like a very tall order to upend these alternatives, however because of the relative recency of BasePart:GetClosestPointOnSurface()
(i believe it was recently enabled) it seems most logical to visit this first as it’s still fresh-out-the-oven.