[Bf-blender-cvs] [cc8dd08] opensubdiv-modifier: OpenSubdiv: Enable topology verification when making a debug build
Sergey Sharybin
noreply at git.blender.org
Sat Jul 11 20:02:02 CEST 2015
Commit: cc8dd08bd3bd18df554205787f3baf98b1cda11b
Author: Sergey Sharybin
Date: Fri Jul 10 11:41:11 2015 +0200
Branches: opensubdiv-modifier
https://developer.blender.org/rBcc8dd08bd3bd18df554205787f3baf98b1cda11b
OpenSubdiv: Enable topology verification when making a debug build
===================================================================
M intern/opensubdiv/CMakeLists.txt
M intern/opensubdiv/opensubdiv_capi.cc
M intern/opensubdiv/opensubdiv_evaluator_capi.cc
A intern/opensubdiv/opensubdiv_intern.h
===================================================================
diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index deb4e0a..d01ca75 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -50,6 +50,7 @@ set(SRC
opensubdiv_converter.h
opensubdiv_device_context_cuda.h
opensubdiv_device_context_opencl.h
+ opensubdiv_intern.h
opensubdiv_partitioned.h
)
diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
index db6af86..b7d3b23 100644
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ b/intern/opensubdiv/opensubdiv_capi.cc
@@ -69,6 +69,7 @@
#include <opensubdiv/far/stencilTable.h>
#include "opensubdiv_converter.h"
+#include "opensubdiv_intern.h"
#include "opensubdiv_partitioned.h"
#include "MEM_guardedalloc.h"
@@ -218,6 +219,7 @@ struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromEvaluator(
int /*scheme*/,
int /*subdivide_uvs*/)
{
+ using OpenSubdiv::Far::TopologyRefinerFactory;
MeshBitset bits;
/* TODO(sergey): Adaptive subdivisions are not currently
* possible because of the lack of tessellation shader.
@@ -236,9 +238,13 @@ struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromEvaluator(
GLMeshInterface *mesh = NULL;
OsdBlenderConverter conv(dm);
- OpenSubdiv::Far::TopologyRefiner * refiner =
- OpenSubdiv::Far::TopologyRefinerFactory<OsdBlenderConverter>::Create(conv,
- OpenSubdiv::Far::TopologyRefinerFactory<OsdBlenderConverter>::Options(conv.get_type(), conv.get_options()));
+ TopologyRefinerFactory<OsdBlenderConverter>::Options topology_options(conv.get_type(),
+ conv.get_options());
+#ifdef OPENSUBDIV_VALIDATE_TOPOLOGY
+ topology_options.validateFullTopology = true;
+#endif
+ OpenSubdiv::Far::TopologyRefiner *refiner =
+ TopologyRefinerFactory<OsdBlenderConverter>::Create(conv, topology_options);
mesh = new OsdCpuMesh(refiner,
num_vertex_elements,
diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.cc b/intern/opensubdiv/opensubdiv_evaluator_capi.cc
index 2820b50..e791592 100644
--- a/intern/opensubdiv/opensubdiv_evaluator_capi.cc
+++ b/intern/opensubdiv/opensubdiv_evaluator_capi.cc
@@ -39,6 +39,7 @@
#include <opensubdiv/osd/types.h>
#include "opensubdiv_converter.h"
+#include "opensubdiv_intern.h"
#include "MEM_guardedalloc.h"
@@ -489,11 +490,18 @@ OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr(DerivedMesh *dm,
/* TODO(sergey): Look into re-using refiner with GLMesh. */
TopologyRefinerFactory<OsdBlenderConverter>::Options topology_options(conv.get_type(),
conv.get_options());
- // topology_options.validateFullTopology = true;
+#ifdef OPENSUBDIV_VALIDATE_TOPOLOGY
+ topology_options.validateFullTopology = true;
+#endif
TopologyRefiner *refiner =
TopologyRefinerFactory<OsdBlenderConverter>::Create(conv,
topology_options);
+ if(refiner == NULL) {
+ /* Happens on bad topology. */
+ return NULL;
+ }
+
const StencilTable *vertex_stencils = NULL;
const StencilTable *varying_stencils = NULL;
int num_total_verts = 0;
diff --git a/intern/opensubdiv/opensubdiv_intern.h b/intern/opensubdiv/opensubdiv_intern.h
new file mode 100644
index 0000000..bcfd005
--- /dev/null
+++ b/intern/opensubdiv/opensubdiv_intern.h
@@ -0,0 +1,36 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2015 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Sergey Sharybin.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __OPENSUBDIV_INTERN_H__
+#define __OPENSUBDIV_INTERN_H__
+
+/* Perform full topology validation when exporting it to OpenSubdiv. */
+#ifdef NDEBUG
+# under OPENSUBDIV_VALIDATE_TOPOLOGY
+#else
+# define OPENSUBDIV_VALIDATE_TOPOLOGY
+#endif
+
+#endif /* __OPENSUBDIV_INTERN_H__ */
More information about the Bf-blender-cvs
mailing list