Blender  V2.93
evaluator_impl.h
Go to the documentation of this file.
1 // Copyright 2018 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_EVALUATOR_IMPL_H_
20 #define OPENSUBDIV_EVALUATOR_IMPL_H_
21 
22 #ifdef _MSC_VER
23 # include <iso646.h>
24 #endif
25 
26 #include <opensubdiv/far/patchMap.h>
27 #include <opensubdiv/far/patchTable.h>
28 
29 #include "internal/base/memory.h"
30 
33 
34 namespace blender {
35 namespace opensubdiv {
36 
37 // Anonymous forward declaration of actual evaluator implementation.
38 class CpuEvalOutput;
39 
40 // Wrapper around implementaiton, which defines API which we are capable to
41 // provide over the implementation.
42 //
43 // TODO(sergey): It is almost the same as C-API object, so ideally need to
44 // merge them somehow, but how to do this and keep files with all the templates
45 // and such separate?
47  public:
48  // NOTE: API object becomes an owner of evaluator. Patch we are referencing.
49  CpuEvalOutputAPI(CpuEvalOutput *implementation, OpenSubdiv::Far::PatchMap *patch_map);
51 
52  // Set coarse positions from a continuous array of coordinates.
53  void setCoarsePositions(const float *positions,
54  const int start_vertex_index,
55  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 evaluateVarying(const int ptes_face_index, float face_u, float face_v, float varying[3]);
112 
113  // Evaluate facee-varying data at a given bilinear coordinate of given
114  // ptex face.
115  void evaluateFaceVarying(const int face_varying_channel,
116  const int ptes_face_index,
117  float face_u,
118  float face_v,
119  float face_varying[2]);
120 
121  // Batched evaluation of multiple input coordinates.
122 
123  // Evaluate given ptex face at given bilinear coordinate.
124  // If derivatives are NULL, they will not be evaluated.
125  //
126  // NOTE: Output arrays must point to a memory of size float[3]*num_patch_coords.
127  void evaluatePatchesLimit(const OpenSubdiv_PatchCoord *patch_coords,
128  const int num_patch_coords,
129  float *P,
130  float *dPdu,
131  float *dPdv);
132 
133  protected:
135  OpenSubdiv::Far::PatchMap *patch_map_;
136 };
137 
138 } // namespace opensubdiv
139 } // namespace blender
140 
142  public:
145 
147  const OpenSubdiv::Far::PatchMap *patch_map;
148  const OpenSubdiv::Far::PatchTable *patch_table;
149 
150  MEM_CXX_CLASS_ALLOC_FUNCS("OpenSubdiv_EvaluatorImpl");
151 };
152 
154  struct OpenSubdiv_TopologyRefiner *topology_refiner);
155 
157 
158 #endif // OPENSUBDIV_EVALUATOR_IMPL_H_
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
OpenSubdiv::Far::PatchMap * patch_map_
void setFaceVaryingData(const int face_varying_channel, const float *varying_data, const int start_vertex_index, const int num_vertices)
void evaluateFaceVarying(const int face_varying_channel, const int ptes_face_index, float face_u, float face_v, float face_varying[2])
void setCoarsePositions(const float *positions, const int start_vertex_index, const int num_vertices)
void evaluateLimit(const int ptex_face_index, float face_u, float face_v, float P[3], float dPdu[3], float dPdv[3])
void setCoarsePositionsFromBuffer(const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void setVaryingDataFromBuffer(const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void evaluateVarying(const int ptes_face_index, float face_u, float face_v, float varying[3])
void evaluatePatchesLimit(const OpenSubdiv_PatchCoord *patch_coords, const int num_patch_coords, float *P, float *dPdu, float *dPdv)
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)
CpuEvalOutputAPI(CpuEvalOutput *implementation, OpenSubdiv::Far::PatchMap *patch_map)
void setVaryingData(const float *varying_data, const int start_vertex_index, const int num_vertices)
void openSubdiv_deleteEvaluatorInternal(OpenSubdiv_EvaluatorImpl *evaluator)
OpenSubdiv_EvaluatorImpl * openSubdiv_createEvaluatorInternal(struct OpenSubdiv_TopologyRefiner *topology_refiner)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
static float P(float k)
Definition: math_interp.c:41
blender::opensubdiv::CpuEvalOutputAPI * eval_output
const OpenSubdiv::Far::PatchMap * patch_map
const OpenSubdiv::Far::PatchTable * patch_table
MEM_CXX_CLASS_ALLOC_FUNCS("OpenSubdiv_EvaluatorImpl")