79 const int ptex_face_index,
82 const MDisps **r_displacement_grid,
92 float corner_u, corner_v;
94 *r_displacement_grid = &
data->mdisps[start_grid_index +
corner];
98 *r_displacement_grid = &
data->mdisps[start_grid_index];
105 const int ptex_face_index,
107 const int corner_delta)
113 const int next_corner = (effective_corner + corner_delta + poly->
totloop) % poly->
totloop;
121 float r_tangent_D[3])
127 const int x = roundf(grid_u * (grid_size - 1));
128 const int y = roundf(grid_v * (grid_size - 1));
130 if (
x == 0 &&
y == 0) {
146 float *r_ptex_face_u,
147 float *r_ptex_face_v)
159 const int ptex_face_index,
163 float r_tangent_matrix[3][3])
165 const bool is_quad = (poly->
totloop == 4);
166 const int quad_corner = is_quad ?
corner : 0;
167 float dummy_P[3], dPdu[3], dPdv[3];
173 const MDisps *other_displacement_grid,
176 float r_tangent_D[3])
182 const MDisps *displacement_grid,
185 const int ptex_face_index,
186 const int corner_index,
197 float tangent_matrix[3][3];
199 data->subdiv, poly, ptex_face_index, corner_index, u,
v, tangent_matrix);
208 const int ptex_face_index,
210 const int corner_delta,
211 int *r_other_ptex_face_index,
212 int *r_other_corner_index)
216 const int num_corners = poly->
totloop;
217 const bool is_quad = (num_corners == 4);
218 const int poly_index = poly -
data->mpoly;
219 const int start_ptex_face_index =
data->face_ptex_offset[poly_index];
220 *r_other_corner_index = (
corner + corner_delta + num_corners) % num_corners;
221 *r_other_ptex_face_index = is_quad ? start_ptex_face_index :
222 start_ptex_face_index + *r_other_corner_index;
227 const int ptex_face_index,
231 const int corner_delta,
236 displacement, ptex_face_index,
corner, corner_delta);
237 int other_ptex_face_index, other_corner_index;
239 data, ptex_face_index,
corner, corner_delta, &other_ptex_face_index, &other_corner_index);
243 other_displacement_grid,
246 other_ptex_face_index,
255 const int ptex_face_index,
257 const float UNUSED(grid_u),
258 const float UNUSED(grid_v),
264 const int num_corners = poly->
totloop;
265 for (
int corner_delta = 1; corner_delta < num_corners; corner_delta++) {
271 const int ptex_face_index,
274 const float UNUSED(grid_v),
281 const int ptex_face_index,
283 const float UNUSED(grid_u),
292 const int ptex_face_index,
298 switch (average_with) {
314 const int ptex_face_index,
320 const int num_corners = poly->
totloop;
321 const bool is_quad = (num_corners == 4);
323 float dummy_corner_u, dummy_corner_v;
327 return poly_corner->
corner;
334 data->is_initialized =
true;
338 const int ptex_face_index,
347 const int grid_size =
data->grid_size;
349 const MDisps *displacement_grid;
350 float grid_u, grid_v;
352 displacement, ptex_face_index, u,
v, &displacement_grid, &grid_u, &grid_v);
357 displacement_grid, grid_size, grid_u, grid_v, tangent_D);
359 float tangent_matrix[3][3];
378 int num_ptex_faces = 0;
380 for (
int poly_index = 0; poly_index <
mesh->
totpoly; poly_index++) {
381 const MPoly *poly = &mpoly[poly_index];
384 return num_ptex_faces;
394 num_ptex_faces,
sizeof(*
data->ptex_poly_corner),
"ptex poly corner");
396 int ptex_face_index = 0;
398 for (
int poly_index = 0; poly_index <
mesh->
totpoly; poly_index++) {
399 const MPoly *poly = &mpoly[poly_index];
401 ptex_poly_corner[ptex_face_index].
poly_index = poly_index;
402 ptex_poly_corner[ptex_face_index].
corner = 0;
407 ptex_poly_corner[ptex_face_index].
poly_index = poly_index;
421 data->subdiv = subdiv;
428 data->is_initialized =
false;
452 "multires displacement");
454 "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], const int corner)
void multiresModifier_ensure_external_read(struct Mesh *mesh, const struct MultiresModifierData *mmd)
BLI_INLINE void BKE_subdiv_rotate_grid_to_quad(const int corner, const float grid_u, const float grid_v, float *r_quad_u, float *r_quad_v)
BLI_INLINE int BKE_subdiv_grid_size_from_level(const int level)
BLI_INLINE int BKE_subdiv_rotate_quad_to_corner(const float quad_u, const float quad_v, float *r_corner_u, float *r_corner_v)
int * BKE_subdiv_face_ptex_offset_get(Subdiv *subdiv)
void BKE_subdiv_displacement_detach(Subdiv *subdiv)
BLI_INLINE void BKE_subdiv_grid_uv_to_ptex_face_uv(const float grid_u, const float grid_v, float *r_ptex_u, float *r_ptex_v)
BLI_INLINE void BKE_subdiv_ptex_face_uv_to_grid_uv(const float ptex_u, const float ptex_v, float *r_grid_u, float *r_grid_v)
void BKE_subdiv_eval_limit_point_and_derivatives(struct Subdiv *subdiv, const int ptex_face_index, const float u, const 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)
struct CustomData pdata ldata
PolyCornerIndex * ptex_poly_corner
const MultiresModifierData * mmd
void(* eval_displacement)(struct 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])
void(* initialize)(struct SubdivDisplacement *displacement)
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])