summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2021-06-07 12:30:07 -0700
committerK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2021-06-07 14:33:44 -0700
commit291e7359725b1fd2491d18a81a3ac97b8481b5e3 (patch)
tree05ef4eebbb1f426286d0f62bde00f8429b79d98e /scene/resources
parenta19439734e0efcd764b3da81bb238c6cd8c10b6d (diff)
Fix 8 bone weights in glTF2
Don't spam in glTF2 import either. Clear() in SurfaceTool does not keep 8 weights.
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/surface_tool.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index f728376310..740784c6a5 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];