diff --git a/test/models/BLEND/subdivision_test_277.blend b/test/models/BLEND/subdivision_test_277.blend new file mode 100644 index 000000000..902adb895 Binary files /dev/null and b/test/models/BLEND/subdivision_test_277.blend differ diff --git a/test/unit/utBlenderImportExport.cpp b/test/unit/utBlenderImportExport.cpp index c220b7daa..12b1cc47c 100644 --- a/test/unit/utBlenderImportExport.cpp +++ b/test/unit/utBlenderImportExport.cpp @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include 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 spatialSortResult; + spatialSortVertices0.FindPositions(positionMesh1, 1.0e-6f, spatialSortResult); + + EXPECT_TRUE(scene->mMeshes[0]->mVertices[spatialSortResult[0]].Equal(positionMesh1)); + } +}