[Bf-blender-cvs] [22f68f85a45] master: OpenSubdiv: Cleanup, remove unused topology orientation code

Sergey Sharybin noreply at git.blender.org
Mon May 18 17:16:06 CEST 2020


Commit: 22f68f85a458903d40111d083578485a7bf3e787
Author: Sergey Sharybin
Date:   Mon May 18 15:53:44 2020 +0200
Branches: master
https://developer.blender.org/rB22f68f85a458903d40111d083578485a7bf3e787

OpenSubdiv: Cleanup, remove unused topology orientation code

The code was trying to make winding consistent and manifold, same as
OpenSubdiv expects it to.

Unfortunately, the code was having some issues in corner cases so the
winding wasn't really correct.
Fortunately, the latter (compared to when this code was originally
written) supports orientation on OpenSubdiv side.

Removing code which is currently unused in Blender and which had
known issues. Is simple enough to bring the code from Git history
if the functionality is needed in the future.

===================================================================

M	intern/opensubdiv/CMakeLists.txt
M	intern/opensubdiv/internal/opensubdiv_converter_factory.cc
D	intern/opensubdiv/internal/opensubdiv_converter_orient.cc
D	intern/opensubdiv/internal/opensubdiv_converter_orient.h
D	intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h

===================================================================

diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index e7292872e9c..d68013b3e07 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -54,7 +54,6 @@ if(WITH_OPENSUBDIV)
     internal/opensubdiv.cc
     internal/opensubdiv_converter_factory.cc
     internal/opensubdiv_converter_internal.cc
-    internal/opensubdiv_converter_orient.cc
     internal/opensubdiv_device_context_cuda.cc
     internal/opensubdiv_device_context_opencl.cc
     internal/opensubdiv_evaluator.cc
@@ -69,8 +68,6 @@ if(WITH_OPENSUBDIV)
 
     internal/opensubdiv_converter_factory.h
     internal/opensubdiv_converter_internal.h
-    internal/opensubdiv_converter_orient.h
-    internal/opensubdiv_converter_orient_impl.h
     internal/opensubdiv_device_context_cuda.h
     internal/opensubdiv_device_context_opencl.h
     internal/opensubdiv_edge_map.h
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
index ab93b5ce952..4344bfe8305 100644
--- a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
+++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
@@ -28,7 +28,6 @@
 #include <opensubdiv/far/topologyRefinerFactory.h>
 
 #include "internal/opensubdiv_converter_internal.h"
-#include "internal/opensubdiv_converter_orient.h"
 #include "internal/opensubdiv_internal.h"
 #include "internal/opensubdiv_util.h"
 #include "opensubdiv_converter_capi.h"
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient.cc b/intern/opensubdiv/internal/opensubdiv_converter_orient.cc
deleted file mode 100644
index e3367fc6314..00000000000
--- a/intern/opensubdiv/internal/opensubdiv_converter_orient.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2018 Blender Foundation. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// Author: Sergey Sharybin
-
-#include "internal/opensubdiv_converter_orient.h"
-
-#include "internal/opensubdiv_internal.h"
-
-namespace opensubdiv_capi {
-
-void checkOrientedVertexConnectivity(const int num_vertex_edges,
-                                     const int num_vertex_faces,
-                                     const int *vertex_edges,
-                                     const int *vertex_faces,
-                                     const int *dst_vertex_edges,
-                                     const int *dst_vertex_faces)
-{
-#ifndef NDEBUG
-  for (int i = 0; i < num_vertex_faces; ++i) {
-    bool found = false;
-    for (int j = 0; j < num_vertex_faces; ++j) {
-      if (vertex_faces[i] == dst_vertex_faces[j]) {
-        found = true;
-        break;
-      }
-    }
-    if (!found) {
-      assert(!"vert-faces connectivity ruined");
-    }
-  }
-  for (int i = 0; i < num_vertex_edges; ++i) {
-    bool found = false;
-    for (int j = 0; j < num_vertex_edges; ++j) {
-      if (vertex_edges[i] == dst_vertex_edges[j]) {
-        found = true;
-        break;
-      }
-    }
-    if (!found) {
-      assert(!"vert-edges connectivity ruined");
-    }
-  }
-#else
-  (void)num_vertex_edges;
-  (void)num_vertex_faces;
-  (void)vertex_edges;
-  (void)vertex_faces;
-  (void)dst_vertex_edges;
-  (void)dst_vertex_faces;
-#endif
-}
-
-}  // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient.h b/intern/opensubdiv/internal/opensubdiv_converter_orient.h
deleted file mode 100644
index 967871845cb..00000000000
--- a/intern/opensubdiv/internal/opensubdiv_converter_orient.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2018 Blender Foundation. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// Author: Sergey Sharybin
-
-#ifndef OPENSUBDIV_CONVERTER_ORIENT_H_
-#  define OPENSUBDIV_CONVERTER_ORIENT_H_
-
-#  include <opensubdiv/far/types.h>
-
-// Set of utility functions which are needed to bring topology to an orientation
-// (or, winding, if you wish) which OpenSubdiv expects.
-
-namespace opensubdiv_capi {
-
-inline void reverseFaceVertices(int *face_vertices, const int num_vertices);
-
-// TODO(sergey): Document which value corresponds to which winding.
-inline int getLoopWinding(int vert0_of_face, int vert1_of_face);
-
-inline void reverseFaceLoops(OpenSubdiv::Far::IndexArray *face_vertices,
-                             OpenSubdiv::Far::IndexArray *face_edges);
-
-// Used for debugging, checks whether orientation happened correct.
-void checkOrientedVertexConnectivity(const int num_vertex_edges,
-                                     const int num_vertex_faces,
-                                     const int *vertex_edges,
-                                     const int *vertex_faces,
-                                     const int *dst_vertex_edges,
-                                     const int *dst_vertex_faces);
-
-}  // namespace opensubdiv_capi
-
-#endif  // OPENSUBDIV_CONVERTER_ORIENT_H_
-
-#include "internal/opensubdiv_converter_orient_impl.h"
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
deleted file mode 100644
index aa717f5d99d..00000000000
--- a/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 Blender Foundation. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// Author: Sergey Sharybin
-
-#ifndef OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_
-#define OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_
-
-#include "internal/opensubdiv_converter_orient.h"
-
-#include <cmath>
-
-#include "internal/opensubdiv_util.h"
-
-namespace opensubdiv_capi {
-
-inline void reverseFaceVertices(int *face_vertices, const int num_vertices)
-{
-  int last_vert = face_vertices[num_vertices - 1];
-  for (int i = num_vertices - 1; i > 0; --i) {
-    face_vertices[i] = face_vertices[i - 1];
-  }
-  face_vertices[0] = last_vert;
-}
-
-inline int getLoopWinding(int vert0_of_face, int vert1_of_face)
-{
-  int delta_face = vert1_of_face - vert0_of_face;
-  if (abs(delta_face) != 1) {
-    if (delta_face > 0) {
-      delta_face = -1;
-    }
-    else {
-      delta_face = 1;
-    }
-  }
-  return delta_face;
-}
-
-inline void reverseFaceLoops(OpenSubdiv::Far::IndexArray *face_vertices,
-                             OpenSubdiv::Far::IndexArray *face_edges)
-{
-  const int num_face_vertices = face_vertices->size();
-  for (int i = 0; i < num_face_vertices / 2; ++i) {
-    const int j = num_face_vertices - i - 1;
-    if (i != j) {
-      swap((*face_vertices)[i], (*face_vertices)[j]);
-      swap((*face_edges)[i], (*face_edges)[j]);
-    }
-  }
-  reverseFaceVertices(&(*face_vertices)[0], num_face_vertices);
-}
-
-}  // namespace opensubdiv_capi
-
-#endif  // OPENSUBDIV_CONVERTER_ORIENT_IMPL_H_



More information about the Bf-blender-cvs mailing list