Add unit test for subdivision modifier on Blender importer

Blend file is composed of default cube with subdivision modifier applied
and same cube with subdivision modifier.
pull/5345/head
Alexandre Avenel 2018-09-24 23:42:20 +02:00
parent 77a8f019e3
commit df825528ad
2 changed files with 27 additions and 0 deletions

Binary file not shown.

View File

@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/SpatialSort.h>
using namespace Assimp;
@ -221,3 +222,29 @@ TEST(utBlenderImporter, importFleurOptonl) {
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/BLEND/fleurOptonl.blend", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
/*
This test contains a default cube with subdivision surface modifier
and a default cube with subdivision surface applied.
Vertices should be identical.
*/
TEST_F(utBlenderImporterExporter, importBlendWithSubdivisionSurface) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/subdivision_test_277.blend", aiProcess_ValidateDataStructure);
EXPECT_NE(nullptr, scene);
EXPECT_EQ(scene->mNumMeshes, 2);
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, scene->mMeshes[1]->mNumVertices);
SpatialSort spatialSortVertices0;
spatialSortVertices0.Fill(scene->mMeshes[0]->mVertices, scene->mMeshes[0]->mNumVertices, sizeof(aiVector3D), true);
for (unsigned int i = 0; i < scene->mMeshes[1]->mNumVertices; ++i)
{
auto positionMesh1 = scene->mMeshes[1]->mVertices[i];
std::vector<unsigned int> spatialSortResult;
spatialSortVertices0.FindPositions(positionMesh1, 1.0e-6f, spatialSortResult);
EXPECT_TRUE(scene->mMeshes[0]->mVertices[spatialSortResult[0]].Equal(positionMesh1));
}
}