Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-07-16 10:28:05 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-07-16 10:52:37 +0300
commitd9203820467665ba19e1956e035de663849e695c (patch)
tree62d01753cafe31ac739c27f45272e2e4c0938c80 /intern/opensubdiv/opensubdiv_converter_capi.h
parentb29b73a67eca3e5ac71c4b7c89f25bf3fb694cc3 (diff)
OpenSubdiv: Re-work C-API integration
Main goal is to make API simpler to follow (at least ion terms what is defined/declared where, as opposite of handful big headers which includes all the declarations), and also avoid a big set of long and obscure functions. Now C-API files are split into smaller ones, following OpenSubdiv behavior more closely, and also function pointers in structures used a lot more, which shortens functions names, UV integration part in GL Mesh is mainly stripped away, it needs to be done differently. On a related topic, UV coordinates API in converter needs to be removed as well, we do not need coordinates, only island connectivity information there. Additional changes: - Varying interpolation in evaluator API are temporarily disabled, need to extend API somewhere (probably, evaluator's API) to inform layout information of vertex data (whether it contains varying data, width, stride and such). - Evaluator now can interpolate face-varying data. Only works for adaptive refiner, since some issues in OpenSubdiv itself. Planned changes: - Remove uv coordinates from TopologyConverter. - Support evaluation of patches (as opposite to individual coordinates as it happens currently). - Support more flexible layout of varying and face-varying data. It is stupid to assume varying is 3 floats and face-varying 2 floats. - Support of second order derivatives. - Everything else what i'm missing in this list.
Diffstat (limited to 'intern/opensubdiv/opensubdiv_converter_capi.h')
-rw-r--r--intern/opensubdiv/opensubdiv_converter_capi.h263
1 files changed, 132 insertions, 131 deletions
diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h
index ea4f20c5961..1d76da4d76b 100644
--- a/intern/opensubdiv/opensubdiv_converter_capi.h
+++ b/intern/opensubdiv/opensubdiv_converter_capi.h
@@ -1,149 +1,150 @@
-/*
- * ***** 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_CONVERTER_CAPI_H__
-#define __OPENSUBDIV_CONVERTER_CAPI_H__
+// Copyright 2015 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_CAPI_H_
+#define OPENSUBDIV_CONVERTER_CAPI_H_
#ifdef __cplusplus
extern "C" {
#endif
-struct OpenSubdiv_TopologyRefinerDescr;
-typedef struct OpenSubdiv_TopologyRefinerDescr OpenSubdiv_TopologyRefinerDescr;
-
-typedef struct OpenSubdiv_Converter OpenSubdiv_Converter;
-
typedef enum OpenSubdiv_SchemeType {
- OSD_SCHEME_BILINEAR,
- OSD_SCHEME_CATMARK,
- OSD_SCHEME_LOOP,
+ OSD_SCHEME_BILINEAR,
+ OSD_SCHEME_CATMARK,
+ OSD_SCHEME_LOOP,
} OpenSubdiv_SchemeType;
typedef enum OpenSubdiv_FVarLinearInterpolation {
- OSD_FVAR_LINEAR_INTERPOLATION_NONE,
- OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY,
- OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES,
- OSD_FVAR_LINEAR_INTERPOLATION_ALL,
+ OSD_FVAR_LINEAR_INTERPOLATION_NONE,
+ OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY,
+ OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES,
+ OSD_FVAR_LINEAR_INTERPOLATION_ALL,
} OpenSubdiv_FVarLinearInterpolation;
typedef struct OpenSubdiv_Converter {
- /* TODO(sergey): Needs to be implemented. */
- /* OpenSubdiv::Sdc::Options get_options() const; */
-
- OpenSubdiv_SchemeType (*get_scheme_type)(
- const OpenSubdiv_Converter *converter);
-
- OpenSubdiv_FVarLinearInterpolation (*get_fvar_linear_interpolation)(
- const OpenSubdiv_Converter *converter);
-
- int (*get_num_faces)(const OpenSubdiv_Converter *converter);
- int (*get_num_edges)(const OpenSubdiv_Converter *converter);
- int (*get_num_verts)(const OpenSubdiv_Converter *converter);
-
- /* Face relationships. */
- int (*get_num_face_verts)(const OpenSubdiv_Converter *converter,
- int face);
- void (*get_face_verts)(const OpenSubdiv_Converter *converter,
- int face,
- int *face_verts);
- void (*get_face_edges)(const OpenSubdiv_Converter *converter,
- int face,
- int *face_edges);
-
- /* Edge relationships. */
- void (*get_edge_verts)(const OpenSubdiv_Converter *converter,
- int edge,
- int *edge_verts);
- int (*get_num_edge_faces)(const OpenSubdiv_Converter *converter,
- int edge);
- void (*get_edge_faces)(const OpenSubdiv_Converter *converter,
- int edge,
- int *edge_faces);
- float (*get_edge_sharpness)(const OpenSubdiv_Converter *converter,
- int edge);
-
- /* Vertex relationships. */
- int (*get_num_vert_edges)(const OpenSubdiv_Converter *converter, int vert);
- void (*get_vert_edges)(const OpenSubdiv_Converter *converter,
- int vert,
- int *vert_edges);
- int (*get_num_vert_faces)(const OpenSubdiv_Converter *converter, int vert);
- void (*get_vert_faces)(const OpenSubdiv_Converter *converter,
- int vert,
- int *vert_faces);
-
- /* Face-varying data. */
- int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter);
-
- void (*precalc_uv_layer)(const OpenSubdiv_Converter *converter, int layer);
- void (*finish_uv_layer)(const OpenSubdiv_Converter *converter);
-
- int (*get_num_uvs)(const OpenSubdiv_Converter *converter);
- void (*get_uvs)(const OpenSubdiv_Converter *converter, float *uvs);
-
- int (*get_face_corner_uv_index)(const OpenSubdiv_Converter *converter,
- int face,
- int corner);
-
- /* User data associated with this converter. */
- void (*free_user_data)(const OpenSubdiv_Converter *converter);
- void *user_data;
+ OpenSubdiv_SchemeType (*getSchemeType)(
+ const struct OpenSubdiv_Converter* converter);
+
+ OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)(
+ const struct OpenSubdiv_Converter* converter);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Global geometry counters.
+ // Number of faces/edges/vertices in the base mesh.
+ int (*getNumFaces)(const struct OpenSubdiv_Converter* converter);
+ int (*getNumEdges)(const struct OpenSubdiv_Converter* converter);
+ int (*getNumVertices)(const struct OpenSubdiv_Converter* converter);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Face relationships.
+
+ // Number of vertices the face consists of.
+ int (*getNumFaceVertices)(const struct OpenSubdiv_Converter* converter,
+ const int face_index);
+ // Array of vertex indices the face consists of.
+ void (*getFaceVertices)(const struct OpenSubdiv_Converter* converter,
+ const int face_index,
+ int* face_vertices);
+ // Array of edge indices the face consists of.
+ // Aligned with the vertex indices array, edge i connects face vertex i
+ // with face index i+1.
+ void (*getFaceEdges)(const struct OpenSubdiv_Converter *converter,
+ const int face_index,
+ int *face_edges);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Edge relationships.
+
+ // Vertices the edge consists of.
+ void (*getEdgeVertices)(const struct OpenSubdiv_Converter* converter,
+ const int edge_index,
+ int edge_vertices[2]);
+ // Number of faces which are sharing the given edge.
+ int (*getNumEdgeFaces)(const struct OpenSubdiv_Converter* converter,
+ const int edge_index);
+ // Array of face indices which are sharing the given edge.
+ void (*getEdgeFaces)(const struct OpenSubdiv_Converter* converter,
+ const int edge,
+ int* edge_faces);
+ // Edge sharpness (aka crease).
+ float (*getEdgeSharpness)(const struct OpenSubdiv_Converter* converter,
+ const int edge_index);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Vertex relationships.
+
+ // Number of edges which are adjacent to the given vertex.
+ int (*getNumVertexEdges)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index);
+ // Array fo edge indices which are adjacent to the given vertex.
+ void (*getVertexEdges)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index,
+ int* vertex_edges);
+ // Number of faces which are adjacent to the given vertex.
+ int (*getNumVertexFaces)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index);
+ // Array fo face indices which are adjacent to the given vertex.
+ void (*getVertexFaces)(const struct OpenSubdiv_Converter* converter,
+ const int vertex_index,
+ int* vertex_faces);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Face-varying data.
+
+ /////////////////////////////////////
+ // UV coordinates.
+
+ // Number of UV layers.
+ int (*getNumUVLayers)(const struct OpenSubdiv_Converter* converter);
+
+ // We need some corner connectivity information, which might not be trivial
+ // to be gathered (might require multiple matching calculations per corver
+ // query).
+ // precalc() is called before any corner connectivity or UV coordinate is
+ // queried from the given layer, allowing converter to calculate and cache
+ // complex complex-to-calculate information.
+ // finish() is called after converter is done porting UV layer to OpenSubdiv,
+ // allowing to free cached data.
+ void (*precalcUVLayer)(const struct OpenSubdiv_Converter* converter,
+ const int layer_index);
+ void (*finishUVLayer)(const struct OpenSubdiv_Converter* converter);
+
+ // Get number of UV coordinates in the current layer (layer which was
+ // specified in precalcUVLayer().
+ int (*getNumUVCoordinates)(const struct OpenSubdiv_Converter* converter);
+ // Get cooridnates themselves.
+ void (*getUVCoordinates)(const struct OpenSubdiv_Converter* converter,
+ float* uvs_coordinates);
+ // For the given face index and its corner (known as loop in Blender)
+ // get corrsponding UV coordinate index.
+ int (*getFaceCornerUVIndex)(const struct OpenSubdiv_Converter* converter,
+ const int face_index,
+ const int corner_index);
+
+ //////////////////////////////////////////////////////////////////////////////
+ // User data associated with this converter.
+
+ void (*freeUserData)(const struct OpenSubdiv_Converter* converter);
+ void* user_data;
} OpenSubdiv_Converter;
-OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr(
- OpenSubdiv_Converter *converter);
-
-void openSubdiv_deleteTopologyRefinerDescr(
- OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-/* TODO(sergey): Those calls are not strictly related to conversion.
- * needs some dedicated file perhaps.
- */
-
-int openSubdiv_topologyRefinerGetSubdivLevel(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumVerts(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumEdges(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumFaces(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
-
-int openSubdiv_topologyRefinerGetNumFaceVerts(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- int face);
-
-int openSubdiv_topologyRefnerCompareConverter(
- const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
- OpenSubdiv_Converter *converter);
-
#ifdef __cplusplus
}
#endif
-#endif /* __OPENSUBDIV_CONVERTER_CAPI_H__ */
+#endif /* OPENSUBDIV_CONVERTER_CAPI_H_ */