The Godot Community Forums are back up and running! Please read the the announcement post for important information on what happened. Thanks!

Why a surface cannot be re-added to mesh with blend shapes?

UnknownUserUnknownUser Posts: 0

Hello, I am having some trouble handling meshes which contain blend shapes. My idea was to read in the vertex array and the blend shape data, clear the blend shapes, use the saved data to modify the mesh and re-add the surface. But trying even the basic steps toward this, the vertex array of the added surface ends up empty. Testing with this script:

extends MeshInstance

func _ready():
    print("blend shape count: ", mesh.get_blend_shape_count())
    mesh.clear_blend_shapes()
    print("blend shape count: ", mesh.get_blend_shape_count())

    var arrays = mesh.surface_get_arrays(0)
    print("vertex array length: ", mesh.surface_get_array_len(0))
    mesh.surface_remove(0)
    mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
    print("vertex array length: ", mesh.surface_get_array_len(0))

Attaching this script to an imported cube mesh without blend shapes, the result is expected:

blend shape count: 0
blend shape count: 0
vertex array length: 24
vertex array length: 24

However, a cube with a blend shape gives this:

blend shape count: 1
blend shape count: 1
vertex array length: 24
vertex array length: 0

The clear_blend_shapes() call is not really related to the vertex array issue, it's just another thing I found strange during my tests that the blend shape count is actually not decreased.

Anyways, are there some additional steps I should take when working with meshes with blend shapes, or what is going on?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file