mirror of
https://github.com/Relintai/mesh_utils.git
synced 2025-02-04 16:05:55 +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;
|
int remk = rem - k;
|
||||||
|
|
||||||
verts.remove(remk);
|
verts.remove(remk);
|
||||||
|
if (normals.size() > 0)
|
||||||
normals.remove(remk);
|
normals.remove(remk);
|
||||||
|
if (uvs.size() > 0)
|
||||||
uvs.remove(remk);
|
uvs.remove(remk);
|
||||||
|
if (colors.size() > 0)
|
||||||
colors.remove(remk);
|
colors.remove(remk);
|
||||||
|
|
||||||
|
if (bones.size() > 0) {
|
||||||
int bindex = remk * 4;
|
int bindex = remk * 4;
|
||||||
for (int l = 0; l < 4; ++l) {
|
for (int l = 0; l < 4; ++l) {
|
||||||
bones.remove(bindex);
|
bones.remove(bindex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weights.size() > 0) {
|
||||||
|
int bindex = remk * 4;
|
||||||
|
for (int l = 0; l < 4; ++l) {
|
||||||
weights.remove(bindex);
|
weights.remove(bindex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int j = 0; j < indices.size(); ++j) {
|
for (int j = 0; j < indices.size(); ++j) {
|
||||||
int indx = indices[j];
|
int indx = indices[j];
|
||||||
|
|
||||||
if (indx == remk)
|
if (indx == remk) {
|
||||||
indices.set(j, i);
|
indices.set(j, i);
|
||||||
else if (indx > remk)
|
} else if (indx > remk) {
|
||||||
indices.set(j, indx - 1);
|
indices.set(j, indx - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -98,12 +110,12 @@ Array MeshUtils::merge_mesh_array(Array arr) const {
|
|||||||
arr[VisualServer::ARRAY_TEX_UV] = uvs;
|
arr[VisualServer::ARRAY_TEX_UV] = uvs;
|
||||||
if (colors.size() > 0)
|
if (colors.size() > 0)
|
||||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
arr[VisualServer::ARRAY_COLOR] = colors;
|
||||||
if (indices.size() > 0)
|
|
||||||
arr[VisualServer::ARRAY_INDEX] = indices;
|
|
||||||
if (bones.size() > 0)
|
if (bones.size() > 0)
|
||||||
arr[VisualServer::ARRAY_BONES] = bones;
|
arr[VisualServer::ARRAY_BONES] = bones;
|
||||||
if (weights.size() > 0)
|
if (weights.size() > 0)
|
||||||
arr[VisualServer::ARRAY_WEIGHTS] = weights;
|
arr[VisualServer::ARRAY_WEIGHTS] = weights;
|
||||||
|
if (indices.size() > 0)
|
||||||
|
arr[VisualServer::ARRAY_INDEX] = indices;
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user