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.
This commit is contained in:
Sergey Sharybin 2020-05-18 15:53:44 +02:00
parent 54665233eb
commit 22f68f85a4
5 changed files with 0 additions and 189 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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_