Blender  V3.3
opensubdiv_converter_capi.h
Go to the documentation of this file.
1 // Copyright 2015 Blender Foundation. All rights reserved.
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software Foundation,
15 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 //
17 // Author: Sergey Sharybin
18 
19 #ifndef OPENSUBDIV_CONVERTER_CAPI_H_
20 #define OPENSUBDIV_CONVERTER_CAPI_H_
21 
22 #include <stdint.h> // for bool
23 
24 #include "opensubdiv_capi_type.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct OpenSubdiv_Converter {
32 
34  const struct OpenSubdiv_Converter *converter);
36  const struct OpenSubdiv_Converter *converter);
37 
38  // Denotes whether this converter specifies full topology, which includes
39  // vertices, edges, faces, vertices+edges of a face and edges/faces of a
40  // vertex.
41  // Otherwise this converter will only provide number of vertices and faces,
42  // and vertices of faces. The rest of topology will be created by OpenSubdiv.
43  //
44  // NOTE: Even if converter does not provide full topology, it still needs
45  // to provide number of edges and vertices-of-edge. Those are used to assign
46  // topology tags.
47  bool (*specifiesFullTopology)(const struct OpenSubdiv_Converter *converter);
48 
50  // Global geometry counters.
51 
52  // Number of faces/edges/vertices in the base mesh.
53  int (*getNumFaces)(const struct OpenSubdiv_Converter *converter);
54  int (*getNumEdges)(const struct OpenSubdiv_Converter *converter);
55  int (*getNumVertices)(const struct OpenSubdiv_Converter *converter);
56 
58  // Face relationships.
59 
60  // Number of vertices the face consists of.
61  int (*getNumFaceVertices)(const struct OpenSubdiv_Converter *converter, const int face_index);
62  // Array of vertex indices the face consists of.
63  void (*getFaceVertices)(const struct OpenSubdiv_Converter *converter,
64  const int face_index,
65  int *face_vertices);
66  // Array of edge indices the face consists of.
67  // Aligned with the vertex indices array, edge i connects face vertex i
68  // with face index i+1.
69  void (*getFaceEdges)(const struct OpenSubdiv_Converter *converter,
70  const int face_index,
71  int *face_edges);
72 
74  // Edge relationships.
75 
76  // Vertices the edge consists of.
77  void (*getEdgeVertices)(const struct OpenSubdiv_Converter *converter,
78  const int edge_index,
79  int edge_vertices[2]);
80  // Number of faces which are sharing the given edge.
81  int (*getNumEdgeFaces)(const struct OpenSubdiv_Converter *converter, const int edge_index);
82  // Array of face indices which are sharing the given edge.
83  void (*getEdgeFaces)(const struct OpenSubdiv_Converter *converter,
84  const int edge,
85  int *edge_faces);
86  // Edge sharpness (aka crease).
87  float (*getEdgeSharpness)(const struct OpenSubdiv_Converter *converter, const int edge_index);
88 
90  // Vertex relationships.
91 
92  // Number of edges which are adjacent to the given vertex.
93  int (*getNumVertexEdges)(const struct OpenSubdiv_Converter *converter, const int vertex_index);
94  // Array fo edge indices which are adjacent to the given vertex.
95  void (*getVertexEdges)(const struct OpenSubdiv_Converter *converter,
96  const int vertex_index,
97  int *vertex_edges);
98  // Number of faces which are adjacent to the given vertex.
99  int (*getNumVertexFaces)(const struct OpenSubdiv_Converter *converter, const int vertex_index);
100  // Array fo face indices which are adjacent to the given vertex.
101  void (*getVertexFaces)(const struct OpenSubdiv_Converter *converter,
102  const int vertex_index,
103  int *vertex_faces);
104 
105  // Check whether vertex is to be marked as an infinite sharp.
106  // This is a way to make sharp vertices which are adjacent to a loose edges.
107  bool (*isInfiniteSharpVertex)(const struct OpenSubdiv_Converter *converter,
108  const int vertex_index);
109 
110  // If vertex is not infinitely sharp, this is its actual sharpness.
111  float (*getVertexSharpness)(const struct OpenSubdiv_Converter *converter,
112  const int vertex_index);
113 
115  // Face-varying data.
116 
118  // UV coordinates.
119 
120  // Number of UV layers.
121  int (*getNumUVLayers)(const struct OpenSubdiv_Converter *converter);
122 
123  // We need some corner connectivity information, which might not be trivial
124  // to be gathered (might require multiple matching calculations per corver
125  // query).
126  // precalc() is called before any corner connectivity or UV coordinate is
127  // queried from the given layer, allowing converter to calculate and cache
128  // complex complex-to-calculate information.
129  // finish() is called after converter is done porting UV layer to OpenSubdiv,
130  // allowing to free cached data.
131  void (*precalcUVLayer)(const struct OpenSubdiv_Converter *converter, const int layer_index);
132  void (*finishUVLayer)(const struct OpenSubdiv_Converter *converter);
133 
134  // Get number of UV coordinates in the current layer (layer which was
135  // specified in precalcUVLayer().
136  int (*getNumUVCoordinates)(const struct OpenSubdiv_Converter *converter);
137  // For the given face index and its corner (known as loop in Blender)
138  // get corresponding UV coordinate index.
139  int (*getFaceCornerUVIndex)(const struct OpenSubdiv_Converter *converter,
140  const int face_index,
141  const int corner_index);
142 
144  // User data associated with this converter.
145 
146  void (*freeUserData)(const struct OpenSubdiv_Converter *converter);
147  void *user_data;
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* OPENSUBDIV_CONVERTER_CAPI_H_ */
typedef float(TangentPoint)[2]
SyclQueue void void size_t num_bytes void
OpenSubdiv_FVarLinearInterpolation
OpenSubdiv_VtxBoundaryInterpolation
OpenSubdiv_SchemeType
struct OpenSubdiv_Converter OpenSubdiv_Converter
int(* getNumVertexFaces)(const struct OpenSubdiv_Converter *converter, const int vertex_index)
bool(* specifiesFullTopology)(const struct OpenSubdiv_Converter *converter)
void(* freeUserData)(const struct OpenSubdiv_Converter *converter)
void(* getFaceVertices)(const struct OpenSubdiv_Converter *converter, const int face_index, int *face_vertices)
float(* getVertexSharpness)(const struct OpenSubdiv_Converter *converter, const int vertex_index)
void(* getFaceEdges)(const struct OpenSubdiv_Converter *converter, const int face_index, int *face_edges)
int(* getNumUVLayers)(const struct OpenSubdiv_Converter *converter)
int(* getNumVertexEdges)(const struct OpenSubdiv_Converter *converter, const int vertex_index)
OpenSubdiv_FVarLinearInterpolation(* getFVarLinearInterpolation)(const struct OpenSubdiv_Converter *converter)
void(* getEdgeVertices)(const struct OpenSubdiv_Converter *converter, const int edge_index, int edge_vertices[2])
OpenSubdiv_SchemeType(* getSchemeType)(const struct OpenSubdiv_Converter *converter)
bool(* isInfiniteSharpVertex)(const struct OpenSubdiv_Converter *converter, const int vertex_index)
void(* getVertexFaces)(const struct OpenSubdiv_Converter *converter, const int vertex_index, int *vertex_faces)
int(* getNumVertices)(const struct OpenSubdiv_Converter *converter)
float(* getEdgeSharpness)(const struct OpenSubdiv_Converter *converter, const int edge_index)
int(* getNumEdges)(const struct OpenSubdiv_Converter *converter)
int(* getNumFaces)(const struct OpenSubdiv_Converter *converter)
int(* getNumEdgeFaces)(const struct OpenSubdiv_Converter *converter, const int edge_index)
int(* getNumUVCoordinates)(const struct OpenSubdiv_Converter *converter)
void(* getVertexEdges)(const struct OpenSubdiv_Converter *converter, const int vertex_index, int *vertex_edges)
void(* finishUVLayer)(const struct OpenSubdiv_Converter *converter)
void(* getEdgeFaces)(const struct OpenSubdiv_Converter *converter, const int edge, int *edge_faces)
OpenSubdiv_VtxBoundaryInterpolation(* getVtxBoundaryInterpolation)(const struct OpenSubdiv_Converter *converter)
void(* precalcUVLayer)(const struct OpenSubdiv_Converter *converter, const int layer_index)
int(* getFaceCornerUVIndex)(const struct OpenSubdiv_Converter *converter, const int face_index, const int corner_index)
int(* getNumFaceVertices)(const struct OpenSubdiv_Converter *converter, const int face_index)