From 15fa86f100e1d4e4b71593198c408132fc827a97 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sun, 4 Mar 2018 00:12:53 +0100 Subject: [PATCH] Set primitive_type to point when PLY is a point cloud --- code/PlyLoader.cpp | 3 +++ test/unit/utPLYImportExport.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/code/PlyLoader.cpp b/code/PlyLoader.cpp index 88be670cc..1bdd6e694 100644 --- a/code/PlyLoader.cpp +++ b/code/PlyLoader.cpp @@ -244,6 +244,9 @@ void PLYImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSy // if no face list is existing we assume that the vertex // list is containing a list of points bool pointsOnly = mGeneratedMesh->mFaces == NULL ? true : false; + if (pointsOnly) { + mGeneratedMesh->mPrimitiveTypes = aiPrimitiveType::aiPrimitiveType_POINT; + } // now load a list of all materials std::vector avMaterials; diff --git a/test/unit/utPLYImportExport.cpp b/test/unit/utPLYImportExport.cpp index 4e4b4dce9..c19571199 100644 --- a/test/unit/utPLYImportExport.cpp +++ b/test/unit/utPLYImportExport.cpp @@ -97,6 +97,8 @@ TEST_F(utPLYImportExport, importerMultipleTest) { scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure); EXPECT_NE(nullptr, scene); + EXPECT_NE(nullptr, scene->mMeshes[0]); + EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces); } TEST_F(utPLYImportExport, importPLYwithUV) { @@ -145,6 +147,7 @@ TEST_F(utPLYImportExport, pointcloudTest) { EXPECT_EQ(1u, scene->mNumMeshes); EXPECT_NE(nullptr, scene->mMeshes[0]); EXPECT_EQ(24u, scene->mMeshes[0]->mNumVertices); + EXPECT_EQ(aiPrimitiveType::aiPrimitiveType_POINT, scene->mMeshes[0]->mPrimitiveTypes); EXPECT_EQ(0u, scene->mMeshes[0]->mNumFaces); }