浏览代码

Merge pull request #2044 from loebl/bug/keep_small_triangles_in_triangulation

Keep small triangles in triangulation
Kim Kulling 7 年之前
父节点
当前提交
32abf9294a
共有 2 个文件被更改,包括 22 次插入18 次删除
  1. 6 3
      code/PostStepRegistry.cpp
  2. 16 15
      code/TriangulateProcess.cpp

+ 6 - 3
code/PostStepRegistry.cpp

@@ -164,9 +164,6 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
 #if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
 #if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
     out.push_back( new OptimizeGraphProcess());
     out.push_back( new OptimizeGraphProcess());
 #endif
 #endif
-#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
-    out.push_back( new FindDegeneratesProcess());
-#endif
 #ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
 #ifndef ASSIMP_BUILD_NO_GENUVCOORDS_PROCESS
     out.push_back( new ComputeUVMappingProcess());
     out.push_back( new ComputeUVMappingProcess());
 #endif
 #endif
@@ -179,6 +176,12 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
 #if (!defined ASSIMP_BUILD_NO_TRIANGULATE_PROCESS)
 #if (!defined ASSIMP_BUILD_NO_TRIANGULATE_PROCESS)
     out.push_back( new TriangulateProcess());
     out.push_back( new TriangulateProcess());
 #endif
 #endif
+#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
+    //find degenerates should run after triangulation (to sort out small
+    //generated triangles) but before sort by p types (in case there are lines
+    //and points generated and inserted into a mesh)
+    out.push_back( new FindDegeneratesProcess());
+#endif
 #if (!defined ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS)
 #if (!defined ASSIMP_BUILD_NO_SORTBYPTYPE_PROCESS)
     out.push_back( new SortByPTypeProcess());
     out.push_back( new SortByPTypeProcess());
 #endif
 #endif

+ 16 - 15
code/TriangulateProcess.cpp

@@ -485,21 +485,22 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
         for(aiFace* f = last_face; f != curOut; ) {
         for(aiFace* f = last_face; f != curOut; ) {
             unsigned int* i = f->mIndices;
             unsigned int* i = f->mIndices;
 
 
-            //  drop dumb 0-area triangles
-            if (std::fabs(GetArea2D(temp_verts[i[0]],temp_verts[i[1]],temp_verts[i[2]])) < 1e-5f) {
-                ASSIMP_LOG_DEBUG("Dropping triangle with area 0");
-                --curOut;
-
-                delete[] f->mIndices;
-                f->mIndices = NULL;
-
-                for(aiFace* ff = f; ff != curOut; ++ff) {
-                    ff->mNumIndices = (ff+1)->mNumIndices;
-                    ff->mIndices = (ff+1)->mIndices;
-                    (ff+1)->mIndices = NULL;
-                }
-                continue;
-            }
+            //  drop dumb 0-area triangles - deactivated for now:
+            //FindDegenerates post processing step can do the same thing
+            //if (std::fabs(GetArea2D(temp_verts[i[0]],temp_verts[i[1]],temp_verts[i[2]])) < 1e-5f) {
+            //    ASSIMP_LOG_DEBUG("Dropping triangle with area 0");
+            //    --curOut;
+
+            //    delete[] f->mIndices;
+            //    f->mIndices = nullptr;
+
+            //    for(aiFace* ff = f; ff != curOut; ++ff) {
+            //        ff->mNumIndices = (ff+1)->mNumIndices;
+            //        ff->mIndices = (ff+1)->mIndices;
+            //        (ff+1)->mIndices = nullptr;
+            //    }
+            //    continue;
+            //}
 
 
             i[0] = idx[i[0]];
             i[0] = idx[i[0]];
             i[1] = idx[i[1]];
             i[1] = idx[i[1]];