From 22f68f85a458903d40111d083578485a7bf3e787 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 May 2020 15:53:44 +0200 Subject: 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. --- .../internal/opensubdiv_converter_factory.cc | 1 - .../internal/opensubdiv_converter_orient.cc | 67 --------------------- .../internal/opensubdiv_converter_orient.h | 49 --------------- .../internal/opensubdiv_converter_orient_impl.h | 69 ---------------------- 4 files changed, 186 deletions(-) delete mode 100644 intern/opensubdiv/internal/opensubdiv_converter_orient.cc delete mode 100644 intern/opensubdiv/internal/opensubdiv_converter_orient.h delete mode 100644 intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h (limited to 'intern/opensubdiv/internal') 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 #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 - -// 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 - -#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_ -- cgit v1.2.3