63 const int ptex_face_index,
66 const MDisps **r_displacement_grid,
76 float corner_u, corner_v;
78 *r_displacement_grid = &
data->mdisps[start_grid_index +
corner];
82 *r_displacement_grid = &
data->mdisps[start_grid_index];
89 const int ptex_face_index,
91 const int corner_delta)
97 const int next_corner = (effective_corner + corner_delta + poly->
totloop) % poly->
totloop;
105 float r_tangent_D[3])
111 const int x = roundf(grid_u * (grid_size - 1));
112 const int y = roundf(grid_v * (grid_size - 1));
114 if (
x == 0 &&
y == 0) {
130 float *r_ptex_face_u,
131 float *r_ptex_face_v)
143 const int ptex_face_index,
147 float r_tangent_matrix[3][3])
149 const bool is_quad = (poly->
totloop == 4);
150 const int quad_corner = is_quad ?
corner : 0;
151 float dummy_P[3], dPdu[3], dPdv[3];
157 const MDisps *other_displacement_grid,
160 float r_tangent_D[3])
166 const MDisps *displacement_grid,
169 const int ptex_face_index,
170 const int corner_index,
181 float tangent_matrix[3][3];
183 data->subdiv, poly, ptex_face_index, corner_index, u,
v, tangent_matrix);
192 const int ptex_face_index,
194 const int corner_delta,
195 int *r_other_ptex_face_index,
196 int *r_other_corner_index)
200 const int num_corners = poly->
totloop;
201 const bool is_quad = (num_corners == 4);
202 const int poly_index = poly -
data->mpoly;
203 const int start_ptex_face_index =
data->face_ptex_offset[poly_index];
204 *r_other_corner_index = (
corner + corner_delta + num_corners) % num_corners;
205 *r_other_ptex_face_index = is_quad ? start_ptex_face_index :
206 start_ptex_face_index + *r_other_corner_index;
211 const int ptex_face_index,
215 const int corner_delta,
220 displacement, ptex_face_index,
corner, corner_delta);
221 int other_ptex_face_index, other_corner_index;
223 data, ptex_face_index,
corner, corner_delta, &other_ptex_face_index, &other_corner_index);
227 other_displacement_grid,
230 other_ptex_face_index,
239 const int ptex_face_index,
241 const float UNUSED(grid_u),
242 const float UNUSED(grid_v),
248 const int num_corners = poly->
totloop;
249 for (
int corner_delta = 1; corner_delta < num_corners; corner_delta++) {
255 const int ptex_face_index,
258 const float UNUSED(grid_v),
265 const int ptex_face_index,
267 const float UNUSED(grid_u),
276 const int ptex_face_index,
282 switch (average_with) {
298 const int ptex_face_index,
304 const int num_corners = poly->
totloop;
305 const bool is_quad = (num_corners == 4);
307 float dummy_corner_u, dummy_corner_v;
311 return poly_corner->
corner;
318 data->is_initialized =
true;
322 const int ptex_face_index,
331 const int grid_size =
data->grid_size;
333 const MDisps *displacement_grid;
334 float grid_u, grid_v;
336 displacement, ptex_face_index, u,
v, &displacement_grid, &grid_u, &grid_v);
341 displacement_grid, grid_size, grid_u, grid_v, tangent_D);
343 float tangent_matrix[3][3];
362 int num_ptex_faces = 0;
364 for (
int poly_index = 0; poly_index <
mesh->
totpoly; poly_index++) {
365 const MPoly *poly = &mpoly[poly_index];
368 return num_ptex_faces;
378 num_ptex_faces,
sizeof(*
data->ptex_poly_corner),
"ptex poly corner");
380 int ptex_face_index = 0;
382 for (
int poly_index = 0; poly_index <
mesh->
totpoly; poly_index++) {
383 const MPoly *poly = &mpoly[poly_index];
385 ptex_poly_corner[ptex_face_index].
poly_index = poly_index;
386 ptex_poly_corner[ptex_face_index].
corner = 0;
391 ptex_poly_corner[ptex_face_index].
poly_index = poly_index;
405 data->subdiv = subdiv;
412 data->is_initialized =
false;
436 "multires displacement");
438 "multires displacement data");
CustomData interface, see also DNA_customdata_types.h.
bool CustomData_has_layer(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3], const float dPdu[3], const float dPdv[3], int corner)
void multiresModifier_ensure_external_read(struct Mesh *mesh, const struct MultiresModifierData *mmd)
BLI_INLINE void BKE_subdiv_ptex_face_uv_to_grid_uv(float ptex_u, float ptex_v, float *r_grid_u, float *r_grid_v)
BLI_INLINE int BKE_subdiv_grid_size_from_level(int level)
BLI_INLINE void BKE_subdiv_rotate_grid_to_quad(int corner, float grid_u, float grid_v, float *r_quad_u, float *r_quad_v)
BLI_INLINE void BKE_subdiv_grid_uv_to_ptex_face_uv(float grid_u, float grid_v, float *r_ptex_u, float *r_ptex_v)
int * BKE_subdiv_face_ptex_offset_get(Subdiv *subdiv)
BLI_INLINE int BKE_subdiv_rotate_quad_to_corner(float quad_u, float quad_v, float *r_corner_u, float *r_corner_v)
void BKE_subdiv_displacement_detach(Subdiv *subdiv)
void BKE_subdiv_eval_limit_point_and_derivatives(struct Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3], float r_dPdu[3], float r_dPdv[3])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
Object is a sort of wrapper for general info.
_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 y
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
PolyCornerIndex * ptex_poly_corner
const MultiresModifierData * mmd
void(* initialize)(struct SubdivDisplacement *displacement)
void(* eval_displacement)(struct SubdivDisplacement *displacement, int ptex_face_index, float u, float v, const float dPdu[3], const float dPdv[3], float r_D[3])
void(* free)(struct SubdivDisplacement *displacement)
struct SubdivDisplacement * displacement_evaluator
static void average_read_displacement_object(MultiresDisplacementData *data, const MDisps *displacement_grid, const float grid_u, const float grid_v, const int ptex_face_index, const int corner_index, float r_D[3])
void BKE_subdiv_displacement_attach_from_multires(Subdiv *subdiv, Mesh *mesh, const MultiresModifierData *mmd)
static void displacement_data_init_mapping(SubdivDisplacement *displacement, const Mesh *mesh)
static const MDisps * displacement_get_other_grid(SubdivDisplacement *displacement, const int ptex_face_index, const int corner, const int corner_delta)
static void average_read_displacement_tangent(MultiresDisplacementData *data, const MDisps *other_displacement_grid, const float grid_u, const float grid_v, float r_tangent_D[3])
static int displacement_get_grid_and_coord(SubdivDisplacement *displacement, const int ptex_face_index, const float u, const float v, const MDisps **r_displacement_grid, float *grid_u, float *grid_v)
static void average_with_other(SubdivDisplacement *displacement, const int ptex_face_index, const int corner, const float grid_u, const float grid_v, const int corner_delta, float r_D[3])
static void average_displacement(SubdivDisplacement *displacement, eAverageWith average_with, const int ptex_face_index, const int corner, const float grid_u, const float grid_v, float r_D[3])
static void displacement_init_functions(SubdivDisplacement *displacement)
static void average_with_next(SubdivDisplacement *displacement, const int ptex_face_index, const int corner, const float grid_u, const float UNUSED(grid_v), float r_D[3])
static int count_num_ptex_faces(const Mesh *mesh)
static void free_displacement(SubdivDisplacement *displacement)
static void average_construct_tangent_matrix(Subdiv *subdiv, const MPoly *poly, const int ptex_face_index, const int corner, const float u, const float v, float r_tangent_matrix[3][3])
static void average_get_other_ptex_and_corner(MultiresDisplacementData *data, const int ptex_face_index, const int corner, const int corner_delta, int *r_other_ptex_face_index, int *r_other_corner_index)
static void average_with_all(SubdivDisplacement *displacement, const int ptex_face_index, const int corner, const float UNUSED(grid_u), const float UNUSED(grid_v), float r_D[3])
struct MultiresDisplacementData MultiresDisplacementData
static int displacement_get_face_corner(MultiresDisplacementData *data, const int ptex_face_index, const float u, const float v)
static void initialize(SubdivDisplacement *displacement)
static void average_convert_grid_coord_to_ptex(const MPoly *poly, const int corner, const float grid_u, const float grid_v, float *r_ptex_face_u, float *r_ptex_face_v)
struct PolyCornerIndex PolyCornerIndex
static void average_with_prev(SubdivDisplacement *displacement, const int ptex_face_index, const int corner, const float UNUSED(grid_u), const float grid_v, float r_D[3])
static void displacement_init_data(SubdivDisplacement *displacement, Subdiv *subdiv, Mesh *mesh, const MultiresModifierData *mmd)
static void eval_displacement(SubdivDisplacement *displacement, const int ptex_face_index, const float u, const float v, const float dPdu[3], const float dPdv[3], float r_D[3])
BLI_INLINE eAverageWith read_displacement_grid(const MDisps *displacement_grid, const int grid_size, const float grid_u, const float grid_v, float r_tangent_D[3])