void generatedGeometryShouldBeConsistent() { // GIVEN Qt3DExtras::QCuboidGeometry geometry; const QVector<Qt3DRender::QAttribute *> attributes = geometry.attributes(); Qt3DRender::QAttribute *positionAttribute = geometry.positionAttribute(); Qt3DRender::QAttribute *normalAttribute = geometry.normalAttribute(); Qt3DRender::QAttribute *texCoordAttribute = geometry.texCoordAttribute(); Qt3DRender::QAttribute *tangentAttribute = geometry.tangentAttribute(); Qt3DRender::QAttribute *indexAttribute = geometry.indexAttribute(); // WHEN QFETCH(float, xExtent); QFETCH(float, yExtent); QFETCH(float, zExtent); QFETCH(QSize, xyMeshResolution); QFETCH(QSize, yzMeshResolution); QFETCH(QSize, xzMeshResolution); geometry.setXExtent(xExtent); geometry.setYExtent(yExtent); geometry.setZExtent(zExtent); geometry.setXYMeshResolution(xyMeshResolution); geometry.setYZMeshResolution(yzMeshResolution); geometry.setXZMeshResolution(xzMeshResolution); generateGeometry(geometry); // THEN // Check buffer of each attribute is valid and actually has some data for (const auto &attribute : attributes) { Qt3DRender::QBuffer *buffer = attribute->buffer(); QVERIFY(buffer != nullptr); QVERIFY(buffer->data().size() != 0); } // Check some data in the buffers // Check specific indices and vertex attributes of triangle under test QFETCH(int, triangleIndex); QFETCH(QVector<quint16>, indices); QFETCH(QVector<QVector3D>, positions); QFETCH(QVector<QVector3D>, normals); QFETCH(QVector<QVector2D>, texCoords); QFETCH(QVector<QVector4D>, tangents); int i = 0; for (auto index : indices) { const auto testIndex = extractIndexData<quint16>(indexAttribute, 3 * triangleIndex + i); QCOMPARE(testIndex, indices.at(i)); const auto position = extractVertexData<QVector3D, quint32>(positionAttribute, index); QCOMPARE(position, positions.at(i)); const auto normal = extractVertexData<QVector3D, quint32>(normalAttribute, index); QCOMPARE(normal, normals.at(i)); const auto texCoord = extractVertexData<QVector2D, quint32>(texCoordAttribute, index); QCOMPARE(texCoord, texCoords.at(i)); const auto tangent = extractVertexData<QVector4D, quint32>(tangentAttribute, index); QCOMPARE(tangent, tangents.at(i)); ++i; } }