Here I duplicate meshes and set their vertices to a new position.
When I output vertex list it is the same as original. I also see mesh faces correctly.
But vertextopolgy is not the same and it shifts from frame to frame:
Mesh[] tempMeshes = new Mesh[meshes.Length];
int loop = 0;
for (int k = 0; k < meshes.Length; k++)
{
Mesh tempMesh = meshes[k].DuplicateMesh();
var tp = meshes[k].TopologyVertices;
for (int i = 0; i < tp.Count; i++)
{
int index = tp.TopologyVertexIndex(i);
tempMesh.Vertices.SetVertex(i, PS.GetPosition(loop + index));
}
loop += meshes[k].Vertices.Count;
tempMeshes[k]=tempMesh;
}
The mesh topology calculation involves sorting the vertex locations to match up vertices that are in the same place. This sorting is based on the coordinates of the vertices and can be different if the locations are changed. It seems that the topology is being recreated each time you move points, or maybe each time you copy the mesh. That may be necessary.
What happens if you get the topology of the copied mesh before you change the vertex locations? You would have to be sure that you kept all vertices that correspond to the same topological vertex equal. I don’t know if this is possible, but if it is, it may work for you.
I remember that we made changes to prevent some changes of TopologyVertices, mostly the ones relating to vertex relocation. However, if a mesh face is removed, vertices are added, etc, they will still change.