diff options
| author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2023-05-03 20:11:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-03 20:11:08 +0200 |
| commit | 1f104b4a6095be28a00475315c7dcb8a6ea86d12 (patch) | |
| tree | 6f2d0063c330e2ad79789d398df7af411947f405 | |
| parent | 2816825e44218fbf35c57b1d771edcc474f3db27 (diff) | |
| parent | 2dbc5d95eb1f0bb59c0899a2e9d9d31b2c8ddd1b (diff) | |
| download | redot-engine-1f104b4a6095be28a00475315c7dcb8a6ea86d12.tar.gz | |
Merge pull request #76669 from smix8/fix_create_from_blend_shape_4.x
Fix SurfaceTool::create_from_blend_shape()
| -rw-r--r-- | scene/resources/surface_tool.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index ccb3ddee45..5ef3e09e3d 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -985,9 +985,21 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur } ERR_FAIL_COND(shape_idx == -1); ERR_FAIL_COND(shape_idx >= arr.size()); - Array mesh = arr[shape_idx]; - ERR_FAIL_COND(mesh.size() != RS::ARRAY_MAX); - _create_list_from_arrays(arr[shape_idx], &vertex_array, &index_array, format); + Array blendshape_mesh_arrays = arr[shape_idx]; + ERR_FAIL_COND(blendshape_mesh_arrays.size() != RS::ARRAY_MAX); + + Array source_mesh_arrays = p_existing->surface_get_arrays(p_surface); + ERR_FAIL_COND(source_mesh_arrays.size() != RS::ARRAY_MAX); + + // Copy BlendShape vertex data over while keeping e.g. bones, weights, index from existing mesh intact. + source_mesh_arrays[RS::ARRAY_VERTEX] = blendshape_mesh_arrays[RS::ARRAY_VERTEX]; + source_mesh_arrays[RS::ARRAY_NORMAL] = blendshape_mesh_arrays[RS::ARRAY_NORMAL]; + source_mesh_arrays[RS::ARRAY_TANGENT] = blendshape_mesh_arrays[RS::ARRAY_TANGENT]; + + _create_list_from_arrays(source_mesh_arrays, &vertex_array, &index_array, format); + + material = p_existing->surface_get_material(p_surface); + format = p_existing->surface_get_format(p_surface); for (int j = 0; j < RS::ARRAY_CUSTOM_COUNT; j++) { if (format & custom_mask[j]) { |
