mirror of
https://github.com/Relintai/mesh_utils.git
synced 2024-11-14 10:27:45 +01:00
Check array sizes before trying to remove items from arrays in merge_mesh_array.
This commit is contained in:
parent
ca1f54268b
commit
de821908e9
@ -67,25 +67,37 @@ Array MeshUtils::merge_mesh_array(Array arr) const {
|
||||
int remk = rem - k;
|
||||
|
||||
verts.remove(remk);
|
||||
if (normals.size() > 0)
|
||||
normals.remove(remk);
|
||||
if (uvs.size() > 0)
|
||||
uvs.remove(remk);
|
||||
if (colors.size() > 0)
|
||||
colors.remove(remk);
|
||||
|
||||
if (bones.size() > 0) {
|
||||
int bindex = remk * 4;
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
bones.remove(bindex);
|
||||
}
|
||||
}
|
||||
|
||||
if (weights.size() > 0) {
|
||||
int bindex = remk * 4;
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
weights.remove(bindex);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < indices.size(); ++j) {
|
||||
int indx = indices[j];
|
||||
|
||||
if (indx == remk)
|
||||
if (indx == remk) {
|
||||
indices.set(j, i);
|
||||
else if (indx > remk)
|
||||
} else if (indx > remk) {
|
||||
indices.set(j, indx - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
@ -98,12 +110,12 @@ Array MeshUtils::merge_mesh_array(Array arr) const {
|
||||
arr[VisualServer::ARRAY_TEX_UV] = uvs;
|
||||
if (colors.size() > 0)
|
||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
||||
if (indices.size() > 0)
|
||||
arr[VisualServer::ARRAY_INDEX] = indices;
|
||||
if (bones.size() > 0)
|
||||
arr[VisualServer::ARRAY_BONES] = bones;
|
||||
if (weights.size() > 0)
|
||||
arr[VisualServer::ARRAY_WEIGHTS] = weights;
|
||||
if (indices.size() > 0)
|
||||
arr[VisualServer::ARRAY_INDEX] = indices;
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user