diff --git a/src/Magnum/Trade/MeshData.cpp b/src/Magnum/Trade/MeshData.cpp index 22f164978..77286a6be 100644 --- a/src/Magnum/Trade/MeshData.cpp +++ b/src/Magnum/Trade/MeshData.cpp @@ -582,10 +582,10 @@ void MeshData::tangentsInto(const Containers::StridedArrayView1D destin format = VertexFormat::Vector3; else if(attribute._format == VertexFormat::Vector4h) format = VertexFormat::Vector3h; - else if(attribute._format == VertexFormat::Vector4ubNormalized) - format = VertexFormat::Vector3ubNormalized; - else if(attribute._format == VertexFormat::Vector4usNormalized) - format = VertexFormat::Vector3usNormalized; + else if(attribute._format == VertexFormat::Vector4bNormalized) + format = VertexFormat::Vector3bNormalized; + else if(attribute._format == VertexFormat::Vector4sNormalized) + format = VertexFormat::Vector3sNormalized; else format = attribute._format; tangentsOrNormalsInto(attributeDataViewInternal(attribute), destination, format); } diff --git a/src/Magnum/Trade/Test/MeshDataTest.cpp b/src/Magnum/Trade/Test/MeshDataTest.cpp index 278c562fc..81fea2ffb 100644 --- a/src/Magnum/Trade/Test/MeshDataTest.cpp +++ b/src/Magnum/Trade/Test/MeshDataTest.cpp @@ -316,8 +316,12 @@ MeshDataTest::MeshDataTest() { &MeshDataTest::positions3DIntoArrayInvalidSize, &MeshDataTest::tangentsAsArray, &MeshDataTest::tangentsAsArray, + &MeshDataTest::tangentsAsArray, + &MeshDataTest::tangentsAsArray, &MeshDataTest::tangentsAsArrayPackedSignedNormalized, &MeshDataTest::tangentsAsArrayPackedSignedNormalized, + &MeshDataTest::tangentsAsArrayPackedSignedNormalized, + &MeshDataTest::tangentsAsArrayPackedSignedNormalized, &MeshDataTest::tangentsIntoArrayInvalidSize, &MeshDataTest::bitangentSignsAsArray, &MeshDataTest::bitangentSignsAsArray, @@ -1747,6 +1751,10 @@ _c(Vector3ub) _c(Vector3b) _c(Vector3us) _c(Vector3s) +_c(Vector4) +_c(Vector4h) +_c(Vector4b) +_c(Vector4s) _c(Color3) _c(Color3h) _c(Color3ub) @@ -1986,9 +1994,9 @@ template void MeshDataTest::tangentsAsArray() { auto tangentView = Containers::arrayCast(vertexData); /* Needs to be sufficiently representable to have the test work also for half floats */ - tangentView[0] = {U(2.0f), U(1.0f), U(0.75f)}; - tangentView[1] = {U(0.0f), U(-1.0f), U(1.25f)}; - tangentView[2] = {U(-2.0f), U(3.0f), U(2.5f)}; + tangentView[0] = T::pad(Math::Vector3{U(2.0f), U(1.0f), U(0.75f)}); + tangentView[1] = T::pad(Math::Vector3{U(0.0f), U(-1.0f), U(1.25f)}); + tangentView[2] = T::pad(Math::Vector3{U(-2.0f), U(3.0f), U(2.5f)}); MeshData data{MeshPrimitive::Points, std::move(vertexData), {MeshAttributeData{MeshAttribute::Tangent, tangentView}}}; CORRADE_COMPARE_AS(data.tangentsAsArray(), Containers::arrayView({ @@ -1998,11 +2006,12 @@ template void MeshDataTest::tangentsAsArray() { template void MeshDataTest::tangentsAsArrayPackedSignedNormalized() { setTestCaseTemplateName(NameTraits::name()); + typedef typename T::Type U; Containers::Array vertexData{2*sizeof(T)}; auto tangentsView = Containers::arrayCast(vertexData); - tangentsView[0] = {Math::pack(1.0f), 0, Math::pack(1.0f)}; - tangentsView[1] = {0, Math::pack(-1.0f), 0}; + tangentsView[0] = T::pad(Math::Vector3{Math::pack(1.0f), 0, Math::pack(1.0f)}); + tangentsView[1] = T::pad(Math::Vector3{0, Math::pack(-1.0f), 0}); MeshData data{MeshPrimitive::Points, std::move(vertexData), {MeshAttributeData{MeshAttribute::Tangent, /* Assuming the normalized enum is always after the non-normalized */