Skip to content

Commit

Permalink
Fix SurfaceTool::create_from_blend_shape()
Browse files Browse the repository at this point in the history
Fixes SurfaceTool::create_from_blend_shape().
  • Loading branch information
smix8 committed May 2, 2023
1 parent 9f12e7b commit 2dbc5d9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions scene/resources/surface_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down

0 comments on commit 2dbc5d9

Please sign in to comment.