Merge pull request #49401 from fire/8-weights

Fix 8 bone weights in glTF2
This commit is contained in:
K. S. Ernest (iFire) Lee
2021-06-16 07:43:42 -07:00
committed by GitHub
2 changed files with 12 additions and 4 deletions

View File

@@ -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];