diff options
author | Lyuma <xn.lyuma@gmail.com> | 2020-12-24 00:01:07 -0800 |
---|---|---|
committer | Lyuma <xn.lyuma@gmail.com> | 2020-12-24 00:01:07 -0800 |
commit | d976003b16a8dd364372529e47df5aee3f00818a (patch) | |
tree | af8ef24a3cda910fc54625aeb110219d269649d0 /servers | |
parent | 3fdf4bfe71311000bf706c16d79b475308a200ac (diff) |
Fix blendshapes and calculation of bone_aabbs
Blendshapes without a skeleton already worked.
However, due to a faulty ERR_FAIL_COND, it was impossible to create a mesh with both bones and blendshapes.
This also fixes an assumption that all surfaces reference the same number of bones as surface 0.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/renderer_storage_rd.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 60c0bd1603..61b390b956 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -2408,9 +2408,6 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); - //ensure blend shape consistency - ERR_FAIL_COND(mesh->blend_shape_count && p_surface.bone_aabbs.size() != mesh->bone_aabbs.size()); - #ifdef DEBUG_ENABLED //do a validation, to catch errors first { @@ -2576,6 +2573,11 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su mesh->bone_aabbs = p_surface.bone_aabbs; mesh->aabb = p_surface.aabb; } else { + if (mesh->bone_aabbs.size() < p_surface.bone_aabbs.size()) { + // ArrayMesh::_surface_set_data only allocates bone_aabbs up to max_bone + // Each surface may affect different numbers of bones. + mesh->bone_aabbs.resize(p_surface.bone_aabbs.size()); + } for (int i = 0; i < p_surface.bone_aabbs.size(); i++) { mesh->bone_aabbs.write[i].merge_with(p_surface.bone_aabbs[i]); } |