Hello,
I’ve got a hell of an headache trying to debug that during 3 days.

So there is the problem :
First of all, I’m working with unity script (C#).
I’ve got 2 prefabs which contain a meshfilter. I’m trying to compare the vertices positions, vertex per vertex, between these two prefabs.
Basically, I’m using gameObject.transform.GetComponent().mesh.vertices to get the vertices of each mesh.
As these vertice are in local coordinates, I’m using gameObject.transform.TransformPoint() to put it in world space, and gameObject.transform.InverseTransformPoint() to put it back in local space.
So there is my algorithm :

// Run through vertices
for(int j = 0; j < mesh1vertices.Count; j++)
{
Vector3 mesh1worldpoint = mesh1transform.TransformPoint(mesh1vertices[j]);
Vector3 mesh2worldpoint = mesh2transform.TransformPoint(mesh2vertices[j]);
// Check if points are equals, if not, fix that mess !
if( Vector3.Distance(mesh1worldpoint, mesh2worldpoint) < Mathf.Epsilon )
{
mesh1vertices[j] = mesh1transform.InverseTransformPoint(mesh2worldpoint);
}
}
// Update mesh
mesh1.vertices = mesh1vertices;
mesh1.RecalculateNormals();
mesh1.RecalculateBounds();

When I compared points in world coordinate, they’re differents (not far from each other, but still different). But when I go back to local coordinates, mesh1transform.InverseTransformPoint(mesh2worldpoint) is exactly the same value than mesh1vertices[j] which means that InverseTransformPoint() has some crappy rounds or I just didn’t get it.

If someone can give me a clue or a solution, it’ll prevent me from killing myself…

Thanks for the answer but I already know that
That’s not my problem here. I’ve got troubles with InverseTransformPoint() which returns me exactly the same local coordinates for 2 differents Vector3 in world coordinates.

There is an example :

Vector3 A = new Vector3(-2.0f, -2.0f, 47.4f);
Vector3 B = new Vector3(-2.0f, -2.0f, 47.5f);

Why bother doing the InverseTransformPoint at all? If they are close enough in world space then just set mesh1vertices[j] to mesh2vertices[j]. Unless I’m misunderstanding what you’re trying to do?

I didn’t tried that because for me mesh2vertices[j] is in local space of mesh2 and mesh1vertices[j] is in local space of mesh1 which is different.
I tried it and that’s still not working.

Here is the value in local space I was able to log :
mesh2vertices[j] ----> (-0.02488029, -0.06023789, -0.025)
mesh1transform.InverseTransformPoint(mesh2worldpoint) → (-0.0248803, -0.06023791, -0.02499962)

So values are differents but the graphic result is exactly the same…

Glad you got it working. Just a note - those values are different but floats will almost always be different by very small amounts that you won’t notice visually. Take the X component of those 2 vectors. The difference between them is 0.00000001. Different yes, but you’ll never see that ingame.