Browse Source

MeshTools: recognize JointIds and Weights in removeDuplicatesFuzzy().

To be clear -- it would work even without, as it'd fall back to
calculating the range of the weights attribute and choosing an epsilon
based on that, but now it takes a shortcut as Weights are known to be in
a [0, 1] range.
pull/499/head
Vladimír Vondruš 4 years ago
parent
commit
0d2ee66c7f
  1. 2
      src/Magnum/MeshTools/RemoveDuplicates.cpp
  2. 26
      src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp

2
src/Magnum/MeshTools/RemoveDuplicates.cpp

@ -520,6 +520,7 @@ Trade::MeshData removeDuplicatesFuzzy(const Trade::MeshData& data, const Float f
applies), use epsilon as-is */
case Trade::MeshAttribute::TextureCoordinates:
case Trade::MeshAttribute::Color:
case Trade::MeshAttribute::Weights:
attributeEpsilon = floatEpsilon;
break;
@ -538,6 +539,7 @@ Trade::MeshData removeDuplicatesFuzzy(const Trade::MeshData& data, const Float f
/* These shouldn't be floating point */
/* LCOV_EXCL_START */
case Trade::MeshAttribute::ObjectId:
case Trade::MeshAttribute::JointIds:
CORRADE_INTERNAL_ASSERT_UNREACHABLE();
/* LCOV_EXCL_STOP */
}

26
src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp

@ -167,7 +167,31 @@ const struct {
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates,
VertexFormat::Vector2, 4*sizeof(Float), 10, 6*sizeof(Float)}
/* Fit into the epsilon again */
}), 0.0f, 10.0f, 10.0f*Math::TypeTraits<Float>::epsilon(), 7, false}
}), 0.0f, 10.0f, 10.0f*Math::TypeTraits<Float>::epsilon(), 7, false},
/* Nothing special here, just verifying these (array) attributes get
handled properly */
{"jointId[3] + weight[3], texcoord", Containers::array({
Trade::MeshAttributeData{Trade::MeshAttribute::JointIds,
/* It's a float, but interpreting as UnsignedInt. The first 2
floats out of 6 are bit-exact so integer comparison should work
as well; the second 2 are then with the epsilon. */
VertexFormat::UnsignedInt, 0, 10, 6*sizeof(Float), 2},
Trade::MeshAttributeData{Trade::MeshAttribute::Weights,
VertexFormat::Float, 2*sizeof(Float), 10, 6*sizeof(Float), 2},
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates,
VertexFormat::Vector2, 4*sizeof(Float), 10, 6*sizeof(Float)}
}), 0.0f, 1.0f, Math::TypeTraits<Float>::epsilon(), 7, false},
{"jointId[3] + weight[3], epsilon 0", Containers::array({
Trade::MeshAttributeData{Trade::MeshAttribute::JointIds,
/* It's a float, but interpreting as UnsignedInt. The first 2
floats out of 6 are bit-exact so integer comparison should work
as well; the second 2 are then with the epsilon. */
VertexFormat::UnsignedInt, 0, 10, 6*sizeof(Float), 2},
Trade::MeshAttributeData{Trade::MeshAttribute::Weights,
VertexFormat::Float, 2*sizeof(Float), 10, 6*sizeof(Float), 2},
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates,
VertexFormat::Vector2, 4*sizeof(Float), 10, 6*sizeof(Float)}
}), 0.0f, 1.0f, 0.0f, 9, false},
};
RemoveDuplicatesTest::RemoveDuplicatesTest() {

Loading…
Cancel
Save