1 // Copyright 2013 Blender Foundation. All rights reserved.
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.
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.
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.
17 // Author: Sergey Sharybin
19 #ifndef OPENSUBDIV_EVALUATOR_CAPI_H_
20 #define OPENSUBDIV_EVALUATOR_CAPI_H_
26 struct OpenSubdiv_EvaluatorInternal;
27 struct OpenSubdiv_TopologyRefiner;
29 typedef struct OpenSubdiv_Evaluator {
30 // Set coarse positions from a continuous array of coordinates.
31 void (*setCoarsePositions)(struct OpenSubdiv_Evaluator* evaluator,
32 const float* positions,
33 const int start_vertex_index,
34 const int num_vertices);
35 // Set varying data from a continuous array of data.
36 void (*setVaryingData)(struct OpenSubdiv_Evaluator* evaluator,
37 const float* varying_data,
38 const int start_vertex_index, const int num_vertices);
39 // Set face varying data from a continuous array of data.
41 // TODO(sergey): Find a better name for vertex here. It is not the vertex of
42 // geometry, but a vertex of UV map.
43 void (*setFaceVaryingData)(struct OpenSubdiv_Evaluator* evaluator,
44 const int face_varying_channel,
45 const float* face_varying_data,
46 const int start_vertex_index,
47 const int num_vertices);
49 // Set coarse vertex position from a continuous memory buffer where
50 // first coordinate starts at offset of `start_offset` and there is `stride`
51 // bytes between adjacent vertex coordinates.
52 void (*setCoarsePositionsFromBuffer)(struct OpenSubdiv_Evaluator* evaluator,
54 const int start_offset,
56 const int start_vertex_index,
57 const int num_vertices);
58 // Set varying data from a continuous memory buffer where
59 // first coordinate starts at offset of `start_offset` and there is `stride`
60 // bytes between adjacent vertex coordinates.
61 void (*setVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator* evaluator,
63 const int start_offset,
65 const int start_vertex_index,
66 const int num_vertices);
67 // Set face varying data from a continuous memory buffer where
68 // first coordinate starts at offset of `start_offset` and there is `stride`
69 // bytes between adjacent vertex coordinates.
71 // TODO(sergey): Find a better name for vertex here. It is not the vertex of
72 // geometry, but a vertex of UV map.
73 void (*setFaceVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator* evaluator,
74 const int face_varying_channel,
76 const int start_offset,
78 const int start_vertex_index,
79 const int num_vertices);
81 // Refine after coarse positions update.
82 void (*refine)(struct OpenSubdiv_Evaluator* evaluator);
84 // Evaluate given ptex face at given bilinear coordinate.
85 // If derivatives are NULL, they will not be evaluated.
86 void (*evaluateLimit)(struct OpenSubdiv_Evaluator* evaluator,
87 const int ptex_face_index,
88 float face_u, float face_v,
89 float P[3], float dPdu[3], float dPdv[3]);
91 // Evaluate varying data at a given bilinear coordinate of given ptex face.
92 void (*evaluateVarying)(struct OpenSubdiv_Evaluator* evaluator,
93 const int ptex_face_index,
94 float face_u, float face_v,
97 // Evaluate face-varying data at a given bilinear coordinate of given
99 void (*evaluateFaceVarying)(struct OpenSubdiv_Evaluator* evaluator,
100 const int face_varying_channel,
101 const int ptex_face_index,
102 float face_u, float face_v,
103 float face_varying[2]);
105 // Internal storage for the use in this module only.
107 // This is where actual OpenSubdiv's evaluator is living.
108 struct OpenSubdiv_EvaluatorInternal* internal;
109 } OpenSubdiv_Evaluator;
111 OpenSubdiv_Evaluator* openSubdiv_createEvaluatorFromTopologyRefiner(
112 struct OpenSubdiv_TopologyRefiner* topology_refiner);
114 void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator* evaluator);
120 #endif // OPENSUBDIV_EVALUATOR_CAPI_H_