Преглед изворни кода

Set primitive_type to point when PLY is a point cloud

Alexandre Avenel пре 7 година
родитељ
комит
15fa86f100
2 измењених фајлова са 6 додато и 0 уклоњено
  1. 3 0
      code/PlyLoader.cpp
  2. 3 0
      test/unit/utPLYImportExport.cpp

+ 3 - 0
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<aiMaterial*> avMaterials;

+ 3 - 0
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);
 }