Blender  V2.93
evaluator_capi.cc
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 
20 
21 #include "MEM_guardedalloc.h"
22 #include <new>
23 
25 
26 namespace {
27 
28 void setCoarsePositions(OpenSubdiv_Evaluator *evaluator,
29  const float *positions,
30  const int start_vertex_index,
31  const int num_vertices)
32 {
33  evaluator->impl->eval_output->setCoarsePositions(positions, start_vertex_index, num_vertices);
34 }
35 
36 void setVaryingData(OpenSubdiv_Evaluator *evaluator,
37  const float *varying_data,
38  const int start_vertex_index,
39  const int num_vertices)
40 {
41  evaluator->impl->eval_output->setVaryingData(varying_data, start_vertex_index, num_vertices);
42 }
43 
44 void setFaceVaryingData(OpenSubdiv_Evaluator *evaluator,
45  const int face_varying_channel,
46  const float *face_varying_data,
47  const int start_vertex_index,
48  const int num_vertices)
49 {
50  evaluator->impl->eval_output->setFaceVaryingData(
51  face_varying_channel, face_varying_data, start_vertex_index, num_vertices);
52 }
53 
54 void setCoarsePositionsFromBuffer(OpenSubdiv_Evaluator *evaluator,
55  const void *buffer,
56  const int start_offset,
57  const int stride,
58  const int start_vertex_index,
59  const int num_vertices)
60 {
62  buffer, start_offset, stride, start_vertex_index, num_vertices);
63 }
64 
65 void setVaryingDataFromBuffer(OpenSubdiv_Evaluator *evaluator,
66  const void *buffer,
67  const int start_offset,
68  const int stride,
69  const int start_vertex_index,
70  const int num_vertices)
71 {
73  buffer, start_offset, stride, start_vertex_index, num_vertices);
74 }
75 
76 void setFaceVaryingDataFromBuffer(OpenSubdiv_Evaluator *evaluator,
77  const int face_varying_channel,
78  const void *buffer,
79  const int start_offset,
80  const int stride,
81  const int start_vertex_index,
82  const int num_vertices)
83 {
85  face_varying_channel, buffer, start_offset, stride, start_vertex_index, num_vertices);
86 }
87 
88 void refine(OpenSubdiv_Evaluator *evaluator)
89 {
90  evaluator->impl->eval_output->refine();
91 }
92 
93 void evaluateLimit(OpenSubdiv_Evaluator *evaluator,
94  const int ptex_face_index,
95  const float face_u,
96  const float face_v,
97  float P[3],
98  float dPdu[3],
99  float dPdv[3])
100 {
101  evaluator->impl->eval_output->evaluateLimit(ptex_face_index, face_u, face_v, P, dPdu, dPdv);
102 }
103 
104 void evaluatePatchesLimit(OpenSubdiv_Evaluator *evaluator,
105  const OpenSubdiv_PatchCoord *patch_coords,
106  const int num_patch_coords,
107  float *P,
108  float *dPdu,
109  float *dPdv)
110 {
112  patch_coords, num_patch_coords, P, dPdu, dPdv);
113 }
114 
115 void evaluateVarying(OpenSubdiv_Evaluator *evaluator,
116  const int ptex_face_index,
117  float face_u,
118  float face_v,
119  float varying[3])
120 {
121  evaluator->impl->eval_output->evaluateVarying(ptex_face_index, face_u, face_v, varying);
122 }
123 
124 void evaluateFaceVarying(OpenSubdiv_Evaluator *evaluator,
125  const int face_varying_channel,
126  const int ptex_face_index,
127  float face_u,
128  float face_v,
129  float face_varying[2])
130 {
131  evaluator->impl->eval_output->evaluateFaceVarying(
132  face_varying_channel, ptex_face_index, face_u, face_v, face_varying);
133 }
134 
135 void assignFunctionPointers(OpenSubdiv_Evaluator *evaluator)
136 {
137  evaluator->setCoarsePositions = setCoarsePositions;
138  evaluator->setVaryingData = setVaryingData;
139  evaluator->setFaceVaryingData = setFaceVaryingData;
140 
141  evaluator->setCoarsePositionsFromBuffer = setCoarsePositionsFromBuffer;
142  evaluator->setVaryingDataFromBuffer = setVaryingDataFromBuffer;
143  evaluator->setFaceVaryingDataFromBuffer = setFaceVaryingDataFromBuffer;
144 
145  evaluator->refine = refine;
146 
147  evaluator->evaluateLimit = evaluateLimit;
148  evaluator->evaluateVarying = evaluateVarying;
149  evaluator->evaluateFaceVarying = evaluateFaceVarying;
150 
151  evaluator->evaluatePatchesLimit = evaluatePatchesLimit;
152 }
153 
154 } // namespace
155 
157  OpenSubdiv_TopologyRefiner *topology_refiner)
158 {
159  OpenSubdiv_Evaluator *evaluator = OBJECT_GUARDED_NEW(OpenSubdiv_Evaluator);
160  assignFunctionPointers(evaluator);
161  evaluator->impl = openSubdiv_createEvaluatorInternal(topology_refiner);
162  return evaluator;
163 }
164 
166 {
168  OBJECT_GUARDED_DELETE(evaluator, OpenSubdiv_Evaluator);
169 }
_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
Read Guarded memory(de)allocation.
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)
void setVaryingData(const float *varying_data, const int start_vertex_index, const int num_vertices)
OpenSubdiv_Evaluator * openSubdiv_createEvaluatorFromTopologyRefiner(OpenSubdiv_TopologyRefiner *topology_refiner)
void openSubdiv_deleteEvaluator(OpenSubdiv_Evaluator *evaluator)
void openSubdiv_deleteEvaluatorInternal(OpenSubdiv_EvaluatorImpl *evaluator)
OpenSubdiv_EvaluatorImpl * openSubdiv_createEvaluatorInternal(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
void(* setVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator *evaluator, const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void(* setVaryingData)(struct OpenSubdiv_Evaluator *evaluator, const float *varying_data, const int start_vertex_index, const int num_vertices)
void(* setCoarsePositionsFromBuffer)(struct OpenSubdiv_Evaluator *evaluator, const void *buffer, const int start_offset, const int stride, const int start_vertex_index, const int num_vertices)
void(* setCoarsePositions)(struct OpenSubdiv_Evaluator *evaluator, const float *positions, const int start_vertex_index, const int num_vertices)
void(* evaluateLimit)(struct OpenSubdiv_Evaluator *evaluator, const int ptex_face_index, float face_u, float face_v, float P[3], float dPdu[3], float dPdv[3])
void(* setFaceVaryingDataFromBuffer)(struct OpenSubdiv_Evaluator *evaluator, 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(* setFaceVaryingData)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, const float *face_varying_data, const int start_vertex_index, const int num_vertices)
struct OpenSubdiv_EvaluatorImpl * impl
void(* evaluateFaceVarying)(struct OpenSubdiv_Evaluator *evaluator, const int face_varying_channel, const int ptex_face_index, float face_u, float face_v, float face_varying[2])
void(* evaluateVarying)(struct OpenSubdiv_Evaluator *evaluator, const int ptex_face_index, float face_u, float face_v, float varying[3])
void(* evaluatePatchesLimit)(struct OpenSubdiv_Evaluator *evaluator, const struct OpenSubdiv_PatchCoord *patch_coords, const int num_patch_coords, float *P, float *dPdu, float *dPdv)
void(* refine)(struct OpenSubdiv_Evaluator *evaluator)