Blender V4.3
evaluator_impl.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Foundation
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 *
5 * Author: Sergey Sharybin. */
6
7#ifndef OPENSUBDIV_EVALUATOR_IMPL_H_
8#define OPENSUBDIV_EVALUATOR_IMPL_H_
9
10#ifdef _MSC_VER
11# include <iso646.h>
12#endif
13
14#include <opensubdiv/far/patchMap.h>
15#include <opensubdiv/far/patchTable.h>
16
18
20
25
26namespace blender::opensubdiv {
27
28class TopologyRefinerImpl;
29class PatchMap;
30
31// Wrapper around implementation, which defines API which we are capable to
32// provide over the implementation.
33//
34// TODO(sergey): It is almost the same as C-API object, so ideally need to
35// merge them somehow, but how to do this and keep files with all the templates
36// and such separate?
38 public:
39 // Anonymous forward declaration of actual evaluator implementation.
40 class EvalOutput;
41
42 // NOTE: PatchMap is not owned, only referenced.
43 EvalOutputAPI(EvalOutput *implementation, PatchMap *patch_map);
44
46
47 // Set settings for data buffers.
48 void setSettings(const OpenSubdiv_EvaluatorSettings *settings);
49
50 // Set coarse positions from a continuous array of coordinates.
51 void setCoarsePositions(const float *positions,
52 const int start_vertex_index,
53 const int num_vertices);
54 // Set vertex data from a continuous array of data.
55 void setVertexData(const float *data, const int start_vertex_index, const int num_vertices);
56 // Set varying data from a continuous array of data.
57 void setVaryingData(const float *varying_data,
58 const int start_vertex_index,
59 const int num_vertices);
60 // Set face varying data from a continuous array of data.
61 //
62 // TODO(sergey): Find a better name for vertex here. It is not the vertex of
63 // geometry, but a vertex of UV map.
64 void setFaceVaryingData(const int face_varying_channel,
65 const float *varying_data,
66 const int start_vertex_index,
67 const int num_vertices);
68
69 // Set coarse vertex position from a continuous memory buffer where
70 // first coordinate starts at offset of `start_offset` and there is `stride`
71 // bytes between adjacent vertex coordinates.
72 void setCoarsePositionsFromBuffer(const void *buffer,
73 const int start_offset,
74 const int stride,
75 const int start_vertex_index,
76 const int num_vertices);
77 // Set varying data from a continuous memory buffer where
78 // first coordinate starts at offset of `start_offset` and there is `stride`
79 // bytes between adjacent vertex coordinates.
80 void setVaryingDataFromBuffer(const void *buffer,
81 const int start_offset,
82 const int stride,
83 const int start_vertex_index,
84 const int num_vertices);
85 // Set face varying data from a continuous memory buffer where
86 // first coordinate starts at offset of `start_offset` and there is `stride`
87 // bytes between adjacent vertex coordinates.
88 //
89 // TODO(sergey): Find a better name for vertex here. It is not the vertex of
90 // geometry, but a vertex of UV map.
91 void setFaceVaryingDataFromBuffer(const int face_varying_channel,
92 const void *buffer,
93 const int start_offset,
94 const int stride,
95 const int start_vertex_index,
96 const int num_vertices);
97
98 // Refine after coarse positions update.
99 void refine();
100
101 // Evaluate given ptex face at given bilinear coordinate.
102 // If derivatives are NULL, they will not be evaluated.
103 void evaluateLimit(const int ptex_face_index,
104 float face_u,
105 float face_v,
106 float P[3],
107 float dPdu[3],
108 float dPdv[3]);
109
110 // Evaluate varying data at a given bilinear coordinate of given ptex face.
111 void evaluateVertexData(const int ptes_face_index, float face_u, float face_v, float data[]);
112
113 // Evaluate varying data at a given bilinear coordinate of given ptex face.
114 void evaluateVarying(const int ptes_face_index, float face_u, float face_v, float varying[3]);
115
116 // Evaluate facee-varying data at a given bilinear coordinate of given
117 // ptex face.
118 void evaluateFaceVarying(const int face_varying_channel,
119 const int ptes_face_index,
120 float face_u,
121 float face_v,
122 float face_varying[2]);
123
124 // Batched evaluation of multiple input coordinates.
125
126 // Evaluate given ptex face at given bilinear coordinate.
127 // If derivatives are NULL, they will not be evaluated.
128 //
129 // NOTE: Output arrays must point to a memory of size float[3]*num_patch_coords.
130 void evaluatePatchesLimit(const OpenSubdiv_PatchCoord *patch_coords,
131 const int num_patch_coords,
132 float *P,
133 float *dPdu,
134 float *dPdv);
135
136 // Fill the output buffers and variables with data from the PatchMap.
137 void getPatchMap(OpenSubdiv_Buffer *patch_map_handles,
138 OpenSubdiv_Buffer *patch_map_quadtree,
139 int *min_patch_face,
140 int *max_patch_face,
141 int *max_depth,
142 int *patches_are_triangular);
143
144 // Copy the patch arrays buffer used by OpenSubDiv for the source data to the given buffer.
145 void fillPatchArraysBuffer(OpenSubdiv_Buffer *patch_arrays_buffer);
146
147 // Wrap the patch index buffer used by OpenSubDiv for the source data with the given buffer.
148 void wrapPatchIndexBuffer(OpenSubdiv_Buffer *patch_index_buffer);
149
150 // Wrap the patch param buffer used by OpenSubDiv for the source data with the given buffer.
151 void wrapPatchParamBuffer(OpenSubdiv_Buffer *patch_param_buffer);
152
153 // Wrap the buffer used by OpenSubDiv for the source data with the given buffer.
154 void wrapSrcBuffer(OpenSubdiv_Buffer *src_buffer);
155
156 // Wrap the buffer used by OpenSubDiv for the extra source data with the given buffer.
158
159 // Copy the patch arrays buffer used by OpenSubDiv for the face varying channel with the given
160 // buffer.
161 void fillFVarPatchArraysBuffer(const int face_varying_channel,
162 OpenSubdiv_Buffer *patch_arrays_buffer);
163
164 // Wrap the patch index buffer used by OpenSubDiv for the face varying channel with the given
165 // buffer.
166 void wrapFVarPatchIndexBuffer(const int face_varying_channel,
167 OpenSubdiv_Buffer *patch_index_buffer);
168
169 // Wrap the patch param buffer used by OpenSubDiv for the face varying channel with the given
170 // buffer.
171 void wrapFVarPatchParamBuffer(const int face_varying_channel,
172 OpenSubdiv_Buffer *patch_param_buffer);
173
174 // Wrap thebuffer used by OpenSubDiv for the face varying channel with the given buffer.
175 void wrapFVarSrcBuffer(const int face_varying_channel, OpenSubdiv_Buffer *src_buffer);
176
177 // Return true if source vertex data has been set.
178 bool hasVertexData() const;
179
180 protected:
183};
184
185} // namespace blender::opensubdiv
186
198
201 eOpenSubdivEvaluator evaluator_type,
202 OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr);
203
205
206#endif // OPENSUBDIV_EVALUATOR_IMPL_H_
void setVaryingData(const float *varying_data, const int start_vertex_index, const int num_vertices)
void wrapSrcBuffer(OpenSubdiv_Buffer *src_buffer)
void wrapFVarSrcBuffer(const int face_varying_channel, OpenSubdiv_Buffer *src_buffer)
void evaluatePatchesLimit(const OpenSubdiv_PatchCoord *patch_coords, const int num_patch_coords, float *P, float *dPdu, float *dPdv)
void wrapPatchIndexBuffer(OpenSubdiv_Buffer *patch_index_buffer)
void fillPatchArraysBuffer(OpenSubdiv_Buffer *patch_arrays_buffer)
void setSettings(const OpenSubdiv_EvaluatorSettings *settings)
void wrapPatchParamBuffer(OpenSubdiv_Buffer *patch_param_buffer)
void evaluateLimit(const int ptex_face_index, float face_u, float face_v, float P[3], float dPdu[3], float dPdv[3])
void evaluateFaceVarying(const int face_varying_channel, const int ptes_face_index, float face_u, float face_v, float face_varying[2])
void setFaceVaryingData(const int face_varying_channel, const float *varying_data, const int start_vertex_index, const int num_vertices)
void getPatchMap(OpenSubdiv_Buffer *patch_map_handles, OpenSubdiv_Buffer *patch_map_quadtree, int *min_patch_face, int *max_patch_face, int *max_depth, int *patches_are_triangular)
void wrapFVarPatchIndexBuffer(const int face_varying_channel, OpenSubdiv_Buffer *patch_index_buffer)
void fillFVarPatchArraysBuffer(const int face_varying_channel, OpenSubdiv_Buffer *patch_arrays_buffer)
void wrapSrcVertexDataBuffer(OpenSubdiv_Buffer *src_buffer)
void evaluateVertexData(const int ptes_face_index, float face_u, float face_v, float data[])
void setCoarsePositionsFromBuffer(const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void wrapFVarPatchParamBuffer(const int face_varying_channel, OpenSubdiv_Buffer *patch_param_buffer)
void setVaryingDataFromBuffer(const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
EvalOutputAPI(EvalOutput *implementation, PatchMap *patch_map)
void evaluateVarying(const int ptes_face_index, float face_u, float face_v, float varying[3])
void setFaceVaryingDataFromBuffer(const int face_varying_channel, const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void setVertexData(const float *data, const int start_vertex_index, const int num_vertices)
void setCoarsePositions(const float *positions, const int start_vertex_index, const int num_vertices)
An quadtree-based map connecting coarse faces to their sub-patches.
Definition patch_map.h:25
void openSubdiv_deleteEvaluatorInternal(OpenSubdiv_EvaluatorImpl *evaluator)
OpenSubdiv_EvaluatorImpl * openSubdiv_createEvaluatorInternal(blender::opensubdiv::TopologyRefinerImpl *topology_refiner, eOpenSubdivEvaluator evaluator_type, OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr)
eOpenSubdivEvaluator
const blender::opensubdiv::PatchMap * patch_map
blender::opensubdiv::EvalOutputAPI * eval_output
const OpenSubdiv::Far::PatchTable * patch_table
MEM_CXX_CLASS_ALLOC_FUNCS("OpenSubdiv_EvaluatorImpl")