Recently I use the OpenMaya.MFnMesh.getClosestPoint() to get the closest point on the mesh, but when I have lots of inputs, the data starts to go wrong. Even though there is the mesh in the scene, I still got the error: kFailure : object does not exist.
I noticed that in the documentation of maya api, the OpenMaya.MFnMesh.getClosestPoint() is not a threadsafe function, so I replace it with MMeshIntersector.getClosestPoint() then the problem is fixed.
I think it’s a question about thread safety but don’t know exactly what’s going on internally.
If anyone understands the difference between the two methods, or has ever encountered the same problem, feel free to leave your answers or discuss, thanks!