How do you get a mesh's vertex positions with blend shapes applied?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sparrow_alto

I need to retrieve a list of all of the vertices which are transformed by any given blend shape. To do this, I’m applying the blend shapes and keeping track of which vertices changed. However, it seems like global_transform.xform() just returns a vertex position from the base mesh, without taking blend shapes into account. Here’s a simplified version of my code in case I’m doing something wrong:

func _ready():
    var MDT = MeshDataTool.new()
    MDT.create_from_surface(mesh, 0)
    var old_verts = []
    var new_verts = []
    for v in MDT.get_vertex_count():
        old_verts.append(global_transform.xform(MDT.get_vertex(v)))
    set_blend_shape("Blend Shape 1", 1) # this function just sets a blend shape's value
    for v in MDT.get_vertex_count():
        new_verts.append(global_transform.xform(MDT.get_vertex(v)))
    for v in old_verts.size():
        if old_verts[v] != new_verts[v]:
            print("!") # this never happens, so old_verts must be identical to new_verts
:bust_in_silhouette: Reply From: DaddyMonster

You need to reference the mesh in question. Try mesh.set("blend_shapes/blend_shape_1", 1) instead of set_blend_shape. Also, remove the spaces in the name, that’s asking for trouble.

Let me know if it works.