Browse Source

sceneconverter: test mesh bounds printing better.

The main property of this feature is that it prints the bounds *in a
canonical type*, not of the actual type that's used. Yet however that
wasn't ever tested. Now it is, and it's also testing behavior for custom
attributes, which don't get their bounds printed (because the canonical
type isn't known for those).
pull/499/head
Vladimír Vondruš 4 years ago
parent
commit
07a8edb03d
  1. 16
      src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp
  2. 15
      src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-meshes-bounds.txt

16
src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp

@ -735,13 +735,23 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
Trade::MeshAttributeData{Trade::MeshAttribute::Tangent, Containers::arrayView(vertexData->tangent)},
Trade::MeshAttributeData{Trade::MeshAttribute::Bitangent, Containers::arrayView(vertexData->bitangent)},
Trade::MeshAttributeData{Trade::MeshAttribute::ObjectId, Containers::arrayView(vertexData->objectId)},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, Containers::arrayView(vertexData->normal)},
Trade::MeshAttributeData{Trade::MeshAttribute::Normal, VertexFormat::Vector3bNormalized, Containers::arrayView(vertexData->normal)},
/* This has the same data as Normal, but it won't have its
bounds printed as it's custom -- there it's unknown what
the canonical type should be and printing a range of
an arbitrary packed type is useless in most cases */
Trade::MeshAttributeData{Trade::meshAttributeCustom(25), Containers::arrayView(vertexData->normal)},
Trade::MeshAttributeData{Trade::MeshAttribute::TextureCoordinates, Containers::arrayView(vertexData->textureCoordinates)},
Trade::MeshAttributeData{Trade::MeshAttribute::Color, Containers::arrayView(vertexData->color)},
Trade::MeshAttributeData{Trade::MeshAttribute::ObjectId, Containers::arrayView(vertexData->objectIdSecondary)},
}};
}
Containers::String doMeshAttributeName(UnsignedShort name) override {
if(name == 25) return "NormalButCustomSoNoBoundsPrinted";
return "";
}
UnsignedByte indexData[3]{15, 3, 176};
struct {
@ -749,7 +759,7 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
Vector3 tangent[2];
Vector3 bitangent[2];
UnsignedShort objectId[2];
Vector3 normal[2];
Vector3b normal[2];
Vector2 textureCoordinates[2];
Vector4 color[2];
UnsignedInt objectIdSecondary[2];
@ -758,7 +768,7 @@ void SceneConverterImplementationTest::infoMeshesBounds() {
{{0.2f, -0.2f, 0.8f}, {0.3f, 0.8f, 0.2f}},
{{0.4f, 0.2f, 1.0f}, {0.3f, 0.9f, 0.0f}},
{155, 12},
{{0.0f, 1.0f, 0.0f}, {1.0f, 0.0f, 1.0f}},
{{0, 127, 0}, {-127, 0, 127}},
{{0.5f, 0.5f}, {1.5f, 0.5f}},
{0x99336600_rgbaf, 0xff663333_rgbaf},
{15, 337},

15
src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-meshes-bounds.txt

@ -1,5 +1,5 @@
Mesh 0:
Level 0: 2 vertices @ Lines (0.2 kB, {})
Level 0: 2 vertices @ Lines (0.1 kB, {})
Position @ Vector3, offset 0, stride 12
Bounds: ({0.1, -0.1, -0.2}, {0.2, 0, 0.2})
Tangent @ Vector3, offset 24, stride 12
@ -8,14 +8,15 @@ Mesh 0:
Bounds: ({0.3, 0.2, 0}, {0.4, 0.9, 1})
ObjectId @ UnsignedShort, offset 72, stride 2
Bounds: (12, 155)
Normal @ Vector3, offset 76, stride 12
Bounds: ({0, 0, 0}, {1, 1, 1})
TextureCoordinates @ Vector2, offset 100, stride 8
Normal @ Vector3bNormalized, offset 76, stride 3
Bounds: ({-1, 0, 0}, {0, 1, 1})
Custom(25:NormalButCustomSoNoBoundsPrinted) @ Vector3b, offset 76, stride 3
TextureCoordinates @ Vector2, offset 84, stride 8
Bounds: ({0.5, 0.5}, {1.5, 0.5})
Color @ Vector4, offset 116, stride 16
Color @ Vector4, offset 100, stride 16
Bounds: ({0.6, 0.2, 0.2, 0}, {1, 0.4, 0.4, 0.2})
ObjectId @ UnsignedInt, offset 148, stride 4
ObjectId @ UnsignedInt, offset 132, stride 4
Bounds: (15, 337)
3 indices @ UnsignedByte, offset 0, stride 1 (0.0 kB, {})
Bounds: (3, 176)
Total mesh data size: 0.2 kB
Total mesh data size: 0.1 kB

Loading…
Cancel
Save