mirror of
https://github.com/Relintai/mesh_utils.git
synced 2024-11-14 10:27:45 +01:00
Create a new Array in remove_doubles and remove_doubles to return so unsupported arrays get removed. Also fixed check for bones.
This commit is contained in:
parent
e0ee26fc61
commit
92b6066d02
@ -213,17 +213,25 @@ Array MeshUtils::remove_doubles(Array arr) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bones.size() != 0) {
|
if (bones.size() != 0) {
|
||||||
|
bool bequals = true;
|
||||||
|
|
||||||
int indx = i * 4;
|
int indx = i * 4;
|
||||||
|
|
||||||
for (int l = 0; l < 4; ++l) {
|
for (int l = 0; l < 4; ++l) {
|
||||||
if (bones[indx + l] != bone[l]) {
|
if (bones[indx + l] != bone[l]) {
|
||||||
continue;
|
bequals = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Math::is_equal_approx(weights[indx + l], weight[l])) {
|
if (!Math::is_equal_approx(weights[indx + l], weight[l])) {
|
||||||
continue;
|
bequals = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bequals) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vc.is_equal_approx(v)) {
|
if (vc.is_equal_approx(v)) {
|
||||||
@ -270,22 +278,26 @@ Array MeshUtils::remove_doubles(Array arr) const {
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr[VisualServer::ARRAY_VERTEX] = verts;
|
|
||||||
|
Array retarr;
|
||||||
|
retarr.resize(VisualServer::ARRAY_MAX);
|
||||||
|
|
||||||
|
retarr[VisualServer::ARRAY_VERTEX] = verts;
|
||||||
|
|
||||||
if (normals.size() > 0)
|
if (normals.size() > 0)
|
||||||
arr[VisualServer::ARRAY_NORMAL] = normals;
|
retarr[VisualServer::ARRAY_NORMAL] = normals;
|
||||||
if (uvs.size() > 0)
|
if (uvs.size() > 0)
|
||||||
arr[VisualServer::ARRAY_TEX_UV] = uvs;
|
retarr[VisualServer::ARRAY_TEX_UV] = uvs;
|
||||||
if (colors.size() > 0)
|
if (colors.size() > 0)
|
||||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
retarr[VisualServer::ARRAY_COLOR] = colors;
|
||||||
if (indices.size() > 0)
|
if (indices.size() > 0)
|
||||||
arr[VisualServer::ARRAY_INDEX] = indices;
|
retarr[VisualServer::ARRAY_INDEX] = indices;
|
||||||
if (bones.size() > 0)
|
if (bones.size() > 0)
|
||||||
arr[VisualServer::ARRAY_BONES] = bones;
|
retarr[VisualServer::ARRAY_BONES] = bones;
|
||||||
if (weights.size() > 0)
|
if (weights.size() > 0)
|
||||||
arr[VisualServer::ARRAY_WEIGHTS] = weights;
|
retarr[VisualServer::ARRAY_WEIGHTS] = weights;
|
||||||
|
|
||||||
return arr;
|
return retarr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Normals are always interpolated, merged
|
//Normals are always interpolated, merged
|
||||||
@ -353,17 +365,25 @@ Array MeshUtils::remove_doubles_interpolate_normals(Array arr) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bones.size() != 0) {
|
if (bones.size() != 0) {
|
||||||
|
bool bequals = true;
|
||||||
|
|
||||||
int indx = i * 4;
|
int indx = i * 4;
|
||||||
|
|
||||||
for (int l = 0; l < 4; ++l) {
|
for (int l = 0; l < 4; ++l) {
|
||||||
if (bones[indx + l] != bone[l]) {
|
if (bones[indx + l] != bone[l]) {
|
||||||
continue;
|
bequals = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Math::is_equal_approx(weights[indx + l], weight[l])) {
|
if (!Math::is_equal_approx(weights[indx + l], weight[l])) {
|
||||||
continue;
|
bequals = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bequals) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vc.is_equal_approx(v)) {
|
if (vc.is_equal_approx(v)) {
|
||||||
@ -418,22 +438,25 @@ Array MeshUtils::remove_doubles_interpolate_normals(Array arr) const {
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr[VisualServer::ARRAY_VERTEX] = verts;
|
Array retarr;
|
||||||
|
retarr.resize(VisualServer::ARRAY_MAX);
|
||||||
|
|
||||||
|
retarr[VisualServer::ARRAY_VERTEX] = verts;
|
||||||
|
|
||||||
if (normals.size() > 0)
|
if (normals.size() > 0)
|
||||||
arr[VisualServer::ARRAY_NORMAL] = normals;
|
retarr[VisualServer::ARRAY_NORMAL] = normals;
|
||||||
if (uvs.size() > 0)
|
if (uvs.size() > 0)
|
||||||
arr[VisualServer::ARRAY_TEX_UV] = uvs;
|
retarr[VisualServer::ARRAY_TEX_UV] = uvs;
|
||||||
if (colors.size() > 0)
|
if (colors.size() > 0)
|
||||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
retarr[VisualServer::ARRAY_COLOR] = colors;
|
||||||
if (indices.size() > 0)
|
if (indices.size() > 0)
|
||||||
arr[VisualServer::ARRAY_INDEX] = indices;
|
retarr[VisualServer::ARRAY_INDEX] = indices;
|
||||||
if (bones.size() > 0)
|
if (bones.size() > 0)
|
||||||
arr[VisualServer::ARRAY_BONES] = bones;
|
retarr[VisualServer::ARRAY_BONES] = bones;
|
||||||
if (weights.size() > 0)
|
if (weights.size() > 0)
|
||||||
arr[VisualServer::ARRAY_WEIGHTS] = weights;
|
retarr[VisualServer::ARRAY_WEIGHTS] = weights;
|
||||||
|
|
||||||
return arr;
|
return retarr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshUtils::MeshUtils() {
|
MeshUtils::MeshUtils() {
|
||||||
|
Loading…
Reference in New Issue
Block a user