diff options
author | K. S. Ernest (iFire) Lee <fire@users.noreply.github.com> | 2021-06-16 07:43:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-16 07:43:42 -0700 |
commit | 479737538b23ff36e81e9e1f6294464bba913e31 (patch) | |
tree | 618529ecc636d95dfa9cab1cbfec5424f3610738 /scene | |
parent | 34e308e044b7ac1996d9caf4959dd97276bb6d32 (diff) | |
parent | 291e7359725b1fd2491d18a81a3ac97b8481b5e3 (diff) |
Merge pull request #49401 from fire/8-weights
Fix 8 bone weights in glTF2
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/surface_tool.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 1e78561bec..fee9f92ad7 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -537,12 +537,16 @@ Array SurfaceTool::commit_to_arrays() { int count = skin_weights == SKIN_8_WEIGHTS ? 8 : 4; Vector<int> array; array.resize(varr_len * count); + array.fill(0); int *w = array.ptrw(); for (uint32_t idx = 0; idx < vertex_array.size(); idx++) { const Vertex &v = vertex_array[idx]; - ERR_CONTINUE(v.bones.size() != count); + if (v.bones.size() > count) { + ERR_PRINT_ONCE(vformat("Invalid bones size %d vs count %d", v.bones.size(), count)); + continue; + } for (int j = 0; j < count; j++) { w[idx * count + j] = v.bones[j]; @@ -557,12 +561,16 @@ Array SurfaceTool::commit_to_arrays() { int count = skin_weights == SKIN_8_WEIGHTS ? 8 : 4; array.resize(varr_len * count); + array.fill(0.0f); float *w = array.ptrw(); for (uint32_t idx = 0; idx < vertex_array.size(); idx++) { const Vertex &v = vertex_array[idx]; - ERR_CONTINUE(v.weights.size() != count); + if (v.weights.size() > count) { + ERR_PRINT_ONCE(vformat("Invalid weight size %d vs count %d", v.weights.size(), count)); + continue; + } for (int j = 0; j < count; j++) { w[idx * count + j] = v.weights[j]; |