41 struct CCGFace **effected_faces,
42 int num_effected_faces);
79 int layer_offset =
sizeof(
float[3]);
84 layer_offset +=
sizeof(
float);
97 layer_offset +=
sizeof(
float[3]);
108 const int num_faces = topology_refiner->
getNumFaces(topology_refiner);
110 for (
int face_index = 0; face_index < num_faces; face_index++) {
123 const int num_faces = topology_refiner->
getNumFaces(topology_refiner);
126 const int grid_area = grid_size * grid_size;
131 num_grids, ((
size_t)grid_area) * element_size,
"subdiv ccg grids storage");
132 const size_t grid_size_in_bytes = (size_t)grid_area * element_size;
133 for (
int grid_index = 0; grid_index < num_grids; grid_index++) {
134 const size_t grid_offset = grid_size_in_bytes * grid_index;
139 num_grids,
sizeof(
DMFlagMat),
"ccg grid material flags");
142 num_grids,
sizeof(
BLI_bitmap *),
"ccg grid material flags");
143 for (
int grid_index = 0; grid_index < num_grids; grid_index++) {
152 num_grids,
sizeof(
SubdivCCGFace *),
"Subdiv CCG grid faces");
171 const int ptex_face_index,
195 const int ptex_face_index,
206 *mask_value_ptr =
data->mask_evaluator->eval_mask(
data->mask_evaluator, ptex_face_index, u,
v);
209 *mask_value_ptr = 0.0f;
214 const int ptex_face_index,
226 const int ptex_face_index =
data->face_ptex_offset[face_index];
227 const int grid_size = subdiv_ccg->
grid_size;
228 const float grid_size_1_inv = 1.0f / (grid_size - 1);
235 unsigned char *grid = (
unsigned char *)subdiv_ccg->
grids[grid_index];
236 for (
int y = 0;
y < grid_size;
y++) {
237 const float grid_v =
y * grid_size_1_inv;
238 for (
int x = 0;
x < grid_size;
x++) {
239 const float grid_u =
x * grid_size_1_inv;
242 const size_t grid_element_index = (size_t)
y * grid_size +
x;
243 const size_t grid_element_offset = grid_element_index * element_size;
248 grid_faces[grid_index] = &
faces[face_index];
250 subdiv_ccg->
grid_flag_mats[grid_index] =
data->material_flags_evaluator->eval_material_flags(
251 data->material_flags_evaluator, face_index);
258 const int grid_size = subdiv_ccg->
grid_size;
259 const float grid_size_1_inv = 1.0f / (grid_size - 1);
266 const int ptex_face_index =
data->face_ptex_offset[face_index] +
corner;
267 unsigned char *grid = (
unsigned char *)subdiv_ccg->
grids[grid_index];
268 for (
int y = 0;
y < grid_size;
y++) {
269 const float u = 1.0f - (
y * grid_size_1_inv);
270 for (
int x = 0;
x < grid_size;
x++) {
271 const float v = 1.0f - (
x * grid_size_1_inv);
272 const size_t grid_element_index = (size_t)
y * grid_size +
x;
273 const size_t grid_element_offset = grid_element_index * element_size;
278 grid_faces[grid_index] = &
faces[face_index];
280 subdiv_ccg->
grid_flag_mats[grid_index] =
data->material_flags_evaluator->eval_material_flags(
281 data->material_flags_evaluator, face_index);
286 const int face_index,
306 const int num_faces = topology_refiner->
getNumFaces(topology_refiner);
309 data.subdiv_ccg = subdiv_ccg;
310 data.subdiv = subdiv;
312 data.mask_evaluator = mask_evaluator;
313 data.material_flags_evaluator = material_flags_evaluator;
333 const int num_faces = subdiv_ccg->
num_faces;
334 int corner_index = 0;
335 for (
int face_index = 0; face_index < num_faces; face_index++) {
336 const int num_corners = topology_refiner->
getNumFaceVertices(topology_refiner, face_index);
339 corner_index += num_corners;
361 if (heap_len <= storage->static_storage_len) {
402 const int grid_size = subdiv_ccg->
grid_size * 2;
419 const int num_edges = topology_refiner->
getNumEdges(topology_refiner);
420 const int grid_size = subdiv_ccg->
grid_size;
421 if (num_edges == 0) {
432 const int num_faces = subdiv_ccg->
num_faces;
433 for (
int face_index = 0; face_index < num_faces; face_index++) {
435 const int num_face_grids = face->
num_grids;
436 const int num_face_edges = num_face_grids;
438 topology_refiner->
getFaceVertices(topology_refiner, face_index, face_vertices);
442 topology_refiner->
getFaceEdges(topology_refiner, face_index, face_edges);
445 const int vertex_index = face_vertices[
corner];
446 const int edge_index = face_edges[
corner];
447 int edge_vertices[2];
448 topology_refiner->
getEdgeVertices(topology_refiner, edge_index, edge_vertices);
449 const bool is_edge_flipped = (edge_vertices[0] != vertex_index);
459 int boundary_element_index = 0;
460 if (is_edge_flipped) {
461 for (
int i = 0; i < grid_size; i++) {
463 next_grid_index, grid_size - i - 1, grid_size - 1);
465 for (
int i = 0; i < grid_size; i++) {
467 current_grid_index, grid_size - 1, i);
471 for (
int i = 0; i < grid_size; i++) {
473 current_grid_index, grid_size - 1, grid_size - i - 1);
475 for (
int i = 0; i < grid_size; i++) {
477 next_grid_index, i, grid_size - 1);
492 "ccg adjacent vertices");
514 const int num_vertices = topology_refiner->
getNumVertices(topology_refiner);
515 const int grid_size = subdiv_ccg->
grid_size;
516 if (num_vertices == 0) {
528 const int num_faces = subdiv_ccg->
num_faces;
529 for (
int face_index = 0; face_index < num_faces; face_index++) {
531 const int num_face_grids = face->
num_grids;
532 const int num_face_edges = num_face_grids;
534 topology_refiner->
getFaceVertices(topology_refiner, face_index, face_vertices);
536 const int vertex_index = face_vertices[
corner];
568 subdiv_ccg->
subdiv = subdiv;
586 const Mesh *coarse_mesh)
602 subdiv, settings, has_mask ? &mask_evaluator :
NULL, &material_flags_evaluator);
604 mask_evaluator.
free(&mask_evaluator);
606 material_flags_evaluator.
free(&material_flags_evaluator);
607 if (subdiv_ccg ==
NULL) {
611 result->runtime.subdiv_ccg = subdiv_ccg;
617 const int num_grids = subdiv_ccg->
num_grids;
624 for (
int grid_index = 0; grid_index < num_grids; grid_index++) {
637 for (
int face_index = 0; face_index < adjacent_edge->
num_adjacent_faces; face_index++) {
696 const int grid_index)
698 const int grid_size = subdiv_ccg->
grid_size;
699 const int grid_size_1 = grid_size - 1;
703 grid_size_1 * grid_size_1,
sizeof(
float[3]),
"CCG TLS normals");
705 for (
int y = 0;
y < grid_size - 1;
y++) {
706 for (
int x = 0;
x < grid_size - 1;
x++) {
719 const int face_index =
y * grid_size_1 +
x;
730 const int grid_index)
732 const int grid_size = subdiv_ccg->
grid_size;
733 const int grid_size_1 = grid_size - 1;
736 for (
int y = 0;
y < grid_size;
y++) {
737 for (
int x = 0;
x < grid_size;
x++) {
738 float normal_acc[3] = {0.0f, 0.0f, 0.0f};
741 if (
x < grid_size_1 &&
y < grid_size_1) {
742 add_v3_v3(normal_acc, face_normals[
y * grid_size_1 +
x]);
746 if (
y < grid_size_1) {
747 add_v3_v3(normal_acc, face_normals[
y * grid_size_1 + (
x - 1)]);
751 add_v3_v3(normal_acc, face_normals[(
y - 1) * grid_size_1 + (
x - 1)]);
755 if (
y >= 1 &&
x < grid_size_1) {
756 add_v3_v3(normal_acc, face_normals[(
y - 1) * grid_size_1 +
x]);
766 const int grid_index,
776 void *__restrict tls_v)
788 .subdiv_ccg = subdiv_ccg,
801 ¶llel_range_settings);
821 const int face_index,
830 const int num_face_grids = face->
num_grids;
831 for (
int i = 0; i < num_face_grids; i++) {
840 void *__restrict tls_v)
847 struct CCGFace **effected_faces,
848 int num_effected_faces)
853 .subdiv_ccg = subdiv_ccg,
867 ¶llel_range_settings);
871 struct CCGFace **effected_faces,
872 int num_effected_faces)
878 if (num_effected_faces == 0) {
888 subdiv_ccg, &key, effected_faces, num_effected_faces);
939 accumulator->
mask = 0.0f;
960 accumulator->
mask *= f;
982 const int num_face_grids = face->
num_grids;
983 const int grid_size = subdiv_ccg->
grid_size;
988 for (
int i = 1; i < grid_size; i++) {
1013 const int face_index,
1042 const int grid_size2 = subdiv_ccg->
grid_size * 2;
1043 if (num_adjacent_faces == 1) {
1052 for (
int i = 1; i < grid_size2 - 1; i++) {
1056 for (
int face_index = 0; face_index < num_adjacent_faces; face_index++) {
1057 for (
int i = 1; i < grid_size2 - 1; i++) {
1063 for (
int i = 1; i < grid_size2 - 1; i++) {
1067 for (
int face_index = 0; face_index < num_adjacent_faces; face_index++) {
1068 for (
int i = 1; i < grid_size2 - 1; i++) {
1081 const int adjacent_edge_index =
data->adjacent_edge_index_map ?
1082 data->adjacent_edge_index_map[n] :
1093 void *__restrict tls_v)
1112 if (num_adjacent_faces == 1) {
1118 for (
int face_index = 0; face_index < num_adjacent_faces; face_index++) {
1120 key, subdiv_ccg, &adjacent_vertex->
corner_coords[face_index]);
1125 for (
int face_index = 0; face_index < num_adjacent_faces; face_index++) {
1127 key, subdiv_ccg, &adjacent_vertex->
corner_coords[face_index]);
1137 const int adjacent_vertex_index =
data->adjacent_vert_index_map ?
1138 data->adjacent_vert_index_map[n] :
1148 const int *adjacent_edge_index_map,
1149 int num_adjacent_edges)
1154 .
subdiv_ccg = subdiv_ccg, .key = key, .adjacent_edge_index_map = adjacent_edge_index_map};
1163 ¶llel_range_settings);
1173 const int *adjacent_vert_index_map,
1174 int num_adjacent_vertices)
1179 .
subdiv_ccg = subdiv_ccg, .key = key, .adjacent_vert_index_map = adjacent_vert_index_map};
1181 num_adjacent_vertices,
1184 ¶llel_range_settings);
1213 ¶llel_range_settings);
1218 struct CCGFace **effected_faces,
1219 int num_effected_faces,
1220 GSet *r_adjacent_vertices,
1221 GSet *r_adjacent_edges)
1232 for (
int i = 0; i < num_effected_faces; i++) {
1234 int face_index = face - subdiv_ccg->
faces;
1235 const int num_face_grids = face->
num_grids;
1236 const int num_face_edges = num_face_grids;
1238 topology_refiner->
getFaceVertices(topology_refiner, face_index, face_vertices);
1243 topology_refiner->
getFaceEdges(topology_refiner, face_index, face_edges);
1245 const int vertex_index = face_vertices[
corner];
1246 const int edge_index = face_edges[
corner];
1248 int edge_vertices[2];
1249 topology_refiner->
getEdgeVertices(topology_refiner, edge_index, edge_vertices);
1265 struct CCGFace **effected_faces,
1266 int num_effected_faces)
1273 subdiv_ccg, effected_faces, num_effected_faces, adjacent_vertices, adjacent_edges);
1275 int *adjacent_vertex_index_map;
1276 int *adjacent_edge_index_map;
1288 adjacent_edge_index_map[i] = adjacent_edge - subdiv_ccg->
adjacent_edges;
1291 subdiv_ccg, key, adjacent_edge_index_map,
BLI_gset_len(adjacent_edges));
1302 subdiv_ccg, key, adjacent_vertex_index_map,
BLI_gset_len(adjacent_vertices));
1316 void *__restrict userdata_v,
1317 const int face_index,
1323 struct CCGFace **effected_ccg_faces =
data->effected_ccg_faces;
1324 struct CCGFace *effected_ccg_face = effected_ccg_faces[face_index];
1330 struct CCGFace **effected_faces,
1331 int num_effected_faces)
1336 .subdiv_ccg = subdiv_ccg,
1338 .effected_ccg_faces = effected_faces,
1346 ¶llel_range_settings);
1353 int *r_num_vertices,
1358 const int num_grids = subdiv_ccg->
num_grids;
1359 const int grid_size = subdiv_ccg->
grid_size;
1360 const int grid_area = grid_size * grid_size;
1361 const int num_edges_per_grid = 2 * (grid_size * (grid_size - 1));
1362 *r_num_vertices = num_grids * grid_area;
1363 *r_num_edges = num_grids * num_edges_per_grid;
1364 *r_num_faces = num_grids * (grid_size - 1) * (grid_size - 1);
1365 *r_num_loops = *r_num_faces * 4;
1376 printf(
"%s: grid index: %d, coord: (%d, %d)\n", message, coord->
grid_index, coord->
x, coord->
y);
1384 const int grid_size = subdiv_ccg->
grid_size;
1385 if (coord->
x < 0 || coord->
x >= grid_size) {
1388 if (coord->
y < 0 || coord->
y >= grid_size) {
1395 const int num_unique,
1396 const int num_duplicates)
1398 const int size = num_unique + num_duplicates;
1406 "SubdivCCGNeighbors.coords");
1413 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1414 return (coord->
x == 0 && coord->
y == 0) || (coord->
x == 0 && coord->
y == grid_size_1) ||
1415 (coord->
x == grid_size_1 && coord->
y == grid_size_1) ||
1416 (coord->
x == grid_size_1 && coord->
y == 0);
1422 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1423 return coord->
x == 0 || coord->
y == 0 || coord->
x == grid_size_1 || coord->
y == grid_size_1;
1430 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1431 if (coord->
x == 0) {
1432 return coord->
y > 0 && coord->
y < grid_size_1;
1434 if (coord->
y == 0) {
1435 return coord->
x > 0 && coord->
x < grid_size_1;
1482 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1483 if (
result.x == grid_size_1) {
1486 else if (
result.y == grid_size_1) {
1489 else if (
result.x == 0) {
1492 else if (
result.y == 0) {
1505 const int face_grid_index = coord->
grid_index;
1507 if (next_face_grid_index == face->
num_grids) {
1508 next_face_grid_index = 0;
1515 const int face_grid_index = coord->
grid_index;
1517 if (prev_face_grid_index < 0) {
1518 prev_face_grid_index = face->
num_grids - 1;
1527 const bool include_duplicates,
1531 const int num_adjacent_grids = face->
num_grids;
1534 r_neighbors, num_adjacent_grids, (include_duplicates) ? num_adjacent_grids - 1 : 0);
1536 int duplicate_face_grid_index = num_adjacent_grids;
1537 for (
int face_grid_index = 0; face_grid_index < num_adjacent_grids; ++face_grid_index) {
1540 neighbor_coord.
x = 1;
1541 neighbor_coord.
y = 0;
1542 r_neighbors->
coords[face_grid_index] = neighbor_coord;
1545 neighbor_coord.
x = 0;
1546 r_neighbors->
coords[duplicate_face_grid_index++] = neighbor_coord;
1559 const int face_index = face - subdiv_ccg->
faces;
1561 const int num_face_grids = face->
num_grids;
1562 const int num_face_vertices = num_face_grids;
1568 topology_refiner->
getFaceVertices(topology_refiner, face_index, face_vertices);
1570 const int adjacent_vertex_index = face_vertices[face_grid_index];
1572 return adjacent_vertex_index;
1578 const bool include_duplicates,
1586 BLI_assert(adjacent_vertex_index < subdiv_ccg->num_adjacent_vertices);
1587 const int num_vertex_edges = topology_refiner->
getNumVertexEdges(topology_refiner,
1588 adjacent_vertex_index);
1594 r_neighbors, num_vertex_edges, (include_duplicates) ? num_adjacent_faces - 1 : 0);
1600 topology_refiner->
getVertexEdges(topology_refiner, adjacent_vertex_index, vertex_edges);
1602 for (
int i = 0; i < num_vertex_edges; ++i) {
1603 const int edge_index = vertex_edges[i];
1606 const int edge_face_index = 0;
1609 int edge_vertices_indices[2];
1610 topology_refiner->
getEdgeVertices(topology_refiner, edge_index, edge_vertices_indices);
1611 int edge_point_index, duplicate_edge_point_index;
1612 if (edge_vertices_indices[0] == adjacent_vertex_index) {
1613 duplicate_edge_point_index = 0;
1614 edge_point_index = duplicate_edge_point_index + 1;
1620 duplicate_edge_point_index = subdiv_ccg->
grid_size * 2 - 1;
1621 edge_point_index = duplicate_edge_point_index - 1;
1628 if (include_duplicates) {
1630 for (
int i = 0, duplicate_i = num_vertex_edges; i < num_adjacent_faces; i++) {
1633 r_neighbors->
coords[duplicate_i++] = neighbor_coord;
1648 const int face_index = face - subdiv_ccg->
faces;
1649 const int num_face_edges = topology_refiner->
getNumFaceEdges(topology_refiner, face_index);
1654 topology_refiner->
getFaceEdges(topology_refiner, face_index, face_edges_indices);
1656 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1657 int adjacent_edge_index = -1;
1658 if (coord->
x == grid_size_1) {
1659 adjacent_edge_index = face_edges_indices[face_grid_index];
1663 adjacent_edge_index =
1664 face_edges_indices[face_grid_index == 0 ? face->
num_grids - 1 : face_grid_index - 1];
1669 return adjacent_edge_index;
1674 const int adjacent_edge_index)
1680 int edge_vertices_indices[2];
1681 topology_refiner->
getEdgeVertices(topology_refiner, adjacent_edge_index, edge_vertices_indices);
1687 int directional_edge_vertex_index = -1;
1689 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1690 int adjacent_edge_point_index = -1;
1691 if (coord->
x == grid_size_1) {
1692 adjacent_edge_point_index = subdiv_ccg->
grid_size - coord->
y - 1;
1693 directional_edge_vertex_index = edge_vertices_indices[0];
1697 adjacent_edge_point_index = subdiv_ccg->
grid_size + coord->
x;
1698 directional_edge_vertex_index = edge_vertices_indices[1];
1702 if (adjacent_vertex_index != directional_edge_vertex_index) {
1703 const int num_edge_points = subdiv_ccg->
grid_size * 2;
1704 adjacent_edge_point_index = num_edge_points - adjacent_edge_point_index - 1;
1707 return adjacent_edge_point_index;
1745 const bool include_duplicates,
1752 BLI_assert(adjacent_edge_index < subdiv_ccg->num_adjacent_edges);
1757 int num_duplicates = 0;
1758 if (include_duplicates) {
1759 num_duplicates += num_adjacent_faces - 1;
1763 num_duplicates += num_adjacent_faces;
1769 subdiv_ccg, coord, adjacent_edge_index);
1776 int duplicate_i = num_adjacent_faces;
1777 for (
int i = 0; i < num_adjacent_faces; ++i) {
1785 r_neighbors->
coords[0] = boundary_coords[prev_point_index];
1786 r_neighbors->
coords[1] = boundary_coords[next_point_index];
1788 else if (include_duplicates) {
1790 r_neighbors->
coords[duplicate_i + 2] = grid_coord;
1795 if (include_duplicates && is_corner) {
1796 SubdivCCGCoord duplicate_corner_grid_coord = boundary_coords[point_index_duplicate];
1797 r_neighbors->
coords[duplicate_i + 2] = duplicate_corner_grid_coord;
1801 BLI_assert(duplicate_i - num_adjacent_faces == num_duplicates);
1807 const bool include_duplicates,
1816 const bool include_duplicates,
1819 if (coord->
x == 0 && coord->
y == 0) {
1823 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1824 if (coord->
x == grid_size_1 && coord->
y == grid_size_1) {
1838 const bool include_duplicates,
1843 if (coord->
x == 0) {
1849 r_neighbors->
coords[3].
x = coord->
y;
1852 if (include_duplicates) {
1857 else if (coord->
y == 0) {
1864 r_neighbors->
coords[3].
y = coord->
x;
1866 if (include_duplicates) {
1876 const bool include_duplicates,
1887 const bool include_duplicates,
1913 const bool include_duplicates,
1934 for (
int i = 0; i < r_neighbors->
size; i++) {
1943 const int face_index = face - subdiv_ccg->
faces;
1952 if (topology_refiner ==
NULL) {
1956 const int num_coarse_faces = topology_refiner->
getNumFaces(topology_refiner);
1959 num_coarse_faces,
sizeof(
int),
"start_face_grid_index");
1961 int start_grid_index = 0;
1962 for (
int face_index = 0; face_index < num_coarse_faces; face_index++) {
1966 start_grid_index += num_face_grids;
1985 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
1987 const MPoly *p = &mpoly[poly_index];
1991 if (coord->
x == grid_size_1) {
1995 if (coord->
y == grid_size_1) {
2009 const int grid_size_1 = subdiv_ccg->
grid_size - 1;
2011 if (coord->
x == 0 && coord->
y == 0) {
2015 if (coord->
x == grid_size_1 && coord->
y == grid_size_1) {
2048 int *r_ptex_face_index,
2054 const float grid_size = subdiv_ccg->
grid_size;
2055 const float grid_size_1_inv = 1.0f / (grid_size - 1);
2057 const float grid_u = coord->
x * grid_size_1_inv;
2058 const float grid_v = coord->
y * grid_size_1_inv;
2064 *r_ptex_face_index = face_ptex_offset[face_index];
2072 *r_ptex_face_index +=
corner;
2073 *r_u = 1.0f - grid_v;
2074 *r_v = 1.0f - grid_u;
2083 int ptex_face_index;
typedef float(TangentPoint)[2]
BLI_INLINE CCGElem * CCG_grid_elem(const CCGKey *key, CCGElem *elem, int x, int y)
BLI_INLINE float * CCG_elem_mask(const CCGKey *key, CCGElem *elem)
BLI_INLINE float * CCG_grid_elem_no(const CCGKey *key, CCGElem *elem, int x, int y)
BLI_INLINE float * CCG_elem_no(const CCGKey *key, CCGElem *elem)
BLI_INLINE float * CCG_elem_co(const CCGKey *key, CCGElem *elem)
struct Mesh * BKE_mesh_new_nomain_from_template(const struct Mesh *me_src, int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
int poly_find_loop_from_vert(const struct MPoly *poly, const struct MLoop *loopstart, uint vert)
@ SUBDIV_STATS_SUBDIV_TO_CCG
void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value)
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)
void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value)
void BKE_subdiv_free(Subdiv *subdiv)
int * BKE_subdiv_face_ptex_offset_get(Subdiv *subdiv)
bool BKE_subdiv_ccg_mask_init_from_paint(SubdivCCGMaskEvaluator *mask_evaluator, const struct Mesh *mesh)
@ SUBDIV_CCG_ADJACENT_EDGE
@ SUBDIV_CCG_ADJACENT_VERTEX
@ SUBDIV_CCG_ADJACENT_NONE
void BKE_subdiv_ccg_material_flags_init_from_mesh(SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator, const struct Mesh *mesh)
void BKE_subdiv_eval_limit_point_and_normal(struct Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3], float r_N[3])
@ SUBDIV_EVALUATOR_TYPE_CPU
void BKE_subdiv_eval_final_point(struct Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3])
void BKE_subdiv_eval_limit_point(struct Subdiv *subdiv, int ptex_face_index, float u, float v, float r_P[3])
bool BKE_subdiv_eval_begin_from_mesh(struct Subdiv *subdiv, const struct Mesh *mesh, const float(*coarse_vertex_cos)[3], eSubdivEvaluatorType evaluator_type, struct OpenSubdiv_EvaluatorCache *evaluator_cache)
#define BLI_assert_msg(a, msg)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define GSET_ITER_INDEX(gs_iter_, gset_, i_)
GSet * BLI_gset_ptr_new(const char *info)
unsigned int BLI_gset_len(const GSet *gs) ATTR_WARN_UNUSED_RESULT
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
bool BLI_gset_add(GSet *gs, void *key)
MINLINE int bitscan_forward_i(int a)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[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 mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
#define UNUSED_VARS_NDEBUG(...)
#define ME_POLY_LOOP_PREV(mloop, mp, i)
#define ME_POLY_LOOP_NEXT(mloop, mp, i)
_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.
#define MEM_reallocN(vmemh, len)
ATTR_WARN_UNUSED_RESULT const void * element
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
ccl_gpu_kernel_postfix ccl_global int * counter
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
SymEdge< T > * prev(const SymEdge< T > *se)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
const int * adjacent_edge_index_map
GridElementAccumulator * accumulators
const int * adjacent_vert_index_map
SubdivCCGMaskEvaluator * mask_evaluator
SubdivCCGMaterialFlagsEvaluator * material_flags_evaluator
int(* getNumVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int vertex_index)
int(* getNumFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index)
void(* getFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index, int *face_edges_indices)
void(* getFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index, int *face_vertices_indices)
void(* getVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int vertex_index, int *vertex_edges_indices)
void(* getEdgeVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int edge_index, int edge_vertices_indices[2])
int(* getNumFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index)
int(* getNumFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getNumEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getNumVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
SubdivCCGFace ** effected_ccg_faces
struct CCGFace ** effected_ccg_faces
struct SubdivCCGCoord ** boundary_coords
struct SubdivCCGCoord * corner_coords
void(* free)(struct SubdivCCGMaskEvaluator *mask_evaluator)
void(* free)(struct SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator)
SubdivCCGCoord coords_fixed[256]
unsigned char * grids_storage
SubdivCCGAdjacentVertex * adjacent_vertices
struct SubdivCCG::@70 cache_
int * start_face_grid_index
int num_adjacent_vertices
SubdivCCGFace ** grid_faces
BLI_bitmap ** grid_hidden
SubdivCCGAdjacentEdge * adjacent_edges
struct DMFlagMat * grid_flag_mats
struct CCGElem * vertices
struct SubdivDisplacement * displacement_evaluator
struct OpenSubdiv_TopologyRefiner * topology_refiner
TaskParallelFreeFunc func_free
size_t userdata_chunk_size
static void subdiv_ccg_recalc_modified_inner_normal_free(const void *__restrict UNUSED(userdata), void *__restrict tls_v)
static void subdiv_ccg_stitch_face_inner_grids_task(void *__restrict userdata_v, const int face_index, const TaskParallelTLS *__restrict UNUSED(tls_v))
static void subdiv_ccg_average_boundaries(SubdivCCG *subdiv_ccg, CCGKey *key, const int *adjacent_edge_index_map, int num_adjacent_edges)
static void neighbor_coords_inner_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, SubdivCCGNeighbors *r_neighbors)
BLI_INLINE int prev_grid_index_from_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
void BKE_subdiv_ccg_recalc_normals(SubdivCCG *subdiv_ccg)
static void neighbor_coords_edge_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
static int next_adjacent_edge_point_index(const SubdivCCG *subdiv_ccg, const int point_index)
static void subdiv_ccg_init_faces_edge_neighborhood(SubdivCCG *subdiv_ccg)
BLI_INLINE bool is_boundary_grid_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void subdiv_ccg_eval_grids_task(void *__restrict userdata_v, const int face_index, const TaskParallelTLS *__restrict UNUSED(tls))
static void subdiv_ccg_alloc_elements(SubdivCCG *subdiv_ccg, Subdiv *subdiv)
static void element_accumulator_copy(SubdivCCG *subdiv_ccg, CCGKey *key, CCGElem *destination, const GridElementAccumulator *accumulator)
static void subdiv_ccg_eval_grid_element(CCGEvalGridsData *data, const int ptex_face_index, const float u, const float v, unsigned char *element)
static void subdiv_ccg_eval_grid_element_limit(CCGEvalGridsData *data, const int ptex_face_index, const float u, const float v, unsigned char *element)
static void subdiv_ccg_average_all_boundaries_and_corners(SubdivCCG *subdiv_ccg, CCGKey *key)
BLI_INLINE bool is_inner_edge_grid_coordinate(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void neighbor_coords_boundary_inner_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
static void subdiv_ccg_recalc_inner_normal_task(void *__restrict userdata_v, const int grid_index, const TaskParallelTLS *__restrict tls_v)
SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const MLoop *mloop, const MPoly *mpoly, int *r_v1, int *r_v2)
static void static_or_heap_storage_free(StaticOrHeapIntStorage *storage)
struct AverageGridsBoundariesTLSData AverageGridsBoundariesTLSData
struct StaticOrHeapIntStorage StaticOrHeapIntStorage
struct AverageGridsBoundariesData AverageGridsBoundariesData
struct RecalcInnerNormalsData RecalcInnerNormalsData
struct RecalcInnerNormalsTLSData RecalcInnerNormalsTLSData
const int * BKE_subdiv_ccg_start_face_grid_index_get(const SubdivCCG *subdiv_ccg)
BLI_INLINE int next_grid_index_from_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static int num_element_float_get(const SubdivCCG *subdiv_ccg)
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
static void element_accumulator_add(GridElementAccumulator *accumulator, const SubdivCCG *subdiv_ccg, CCGKey *key, CCGElem *grid_element)
static void subdiv_ccg_init_faces(SubdivCCG *subdiv_ccg)
static void subdiv_ccg_affected_face_adjacency(SubdivCCG *subdiv_ccg, struct CCGFace **effected_faces, int num_effected_faces, GSet *r_adjacent_vertices, GSet *r_adjacent_edges)
BLI_INLINE SubdivCCGCoord coord_at_prev_col(const SubdivCCG *UNUSED(subdiv_ccg), const SubdivCCGCoord *coord)
static SubdivCCGCoord * subdiv_ccg_adjacent_edge_add_face(SubdivCCG *subdiv_ccg, SubdivCCGAdjacentEdge *adjacent_edge)
void BKE_subdiv_ccg_eval_limit_point(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, float r_point[3])
static void subdiv_ccg_allocate_adjacent_vertices(SubdivCCG *subdiv_ccg, const int num_vertices)
static void element_accumulator_init(GridElementAccumulator *accumulator)
static void subdiv_ccg_average_grids_boundaries_task(void *__restrict userdata_v, const int n, const TaskParallelTLS *__restrict tls_v)
void BKE_subdiv_ccg_average_grids(SubdivCCG *subdiv_ccg)
struct GridElementAccumulator GridElementAccumulator
static void subdiv_ccg_eval_regular_grid(CCGEvalGridsData *data, const int face_index)
static int prev_adjacent_edge_point_index(const SubdivCCG *subdiv_ccg, const int point_index)
static CCGElem * subdiv_ccg_coord_to_elem(const CCGKey *key, const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg, CCGKey *key, SubdivCCGFace *face)
struct AverageInnerGridsData AverageInnerGridsData
BLI_INLINE SubdivCCGCoord coord_at_next_row(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
void BKE_subdiv_ccg_destroy(SubdivCCG *subdiv_ccg)
static void subdiv_ccg_average_grids_boundaries_free(const void *__restrict UNUSED(userdata), void *__restrict tls_v)
BLI_INLINE bool is_corner_grid_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static SubdivCCGCoord coord_step_inside_from_boundary(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void neighbor_coords_corner_center_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg, CCGKey *key, struct CCGFace **effected_faces, int num_effected_faces)
static void subdiv_ccg_average_grids_boundary(SubdivCCG *subdiv_ccg, CCGKey *key, SubdivCCGAdjacentEdge *adjacent_edge, AverageGridsBoundariesTLSData *tls)
const int * BKE_subdiv_ccg_start_face_grid_index_ensure(SubdivCCG *subdiv_ccg)
static int adjacent_vertex_index_from_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void subdiv_ccg_average_corners(SubdivCCG *subdiv_ccg, CCGKey *key, const int *adjacent_vert_index_map, int num_adjacent_vertices)
static int adjacent_grid_corner_point_index_on_edge(const SubdivCCG *subdiv_ccg, const int point_index)
void BKE_subdiv_ccg_key_top_level(CCGKey *key, const SubdivCCG *subdiv_ccg)
static void neighbor_coords_corner_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
static void subdiv_ccg_eval_grid_element_mask(CCGEvalGridsData *data, const int ptex_face_index, const float u, const float v, unsigned char *element)
static int adjacent_edge_point_index_from_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const int adjacent_edge_index)
void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg, struct CCGFace **effected_faces, int num_effected_faces)
void BKE_subdiv_ccg_key(CCGKey *key, const SubdivCCG *subdiv_ccg, int level)
BLI_INLINE SubdivCCGCoord coord_at_prev_row(const SubdivCCG *UNUSED(subdiv_ccg), const SubdivCCGCoord *coord)
static void element_accumulator_mul_fl(GridElementAccumulator *accumulator, const float f)
struct StitchFacesInnerGridsData StitchFacesInnerGridsData
static void adjacet_vertices_index_from_adjacent_edge(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const MLoop *mloop, const MPoly *mpoly, int *r_v1, int *r_v2)
static void average_grid_element_value_v3(float a[3], float b[3])
static void subdiv_ccg_recalc_inner_normal_free(const void *__restrict UNUSED(userdata), void *__restrict tls_v)
static void subdiv_ccg_eval_special_grid(CCGEvalGridsData *data, const int face_index)
static void subdiv_ccg_average_all_corners(SubdivCCG *subdiv_ccg, CCGKey *key)
static SubdivCCGCoord subdiv_ccg_coord(int grid_index, int x, int y)
Mesh * BKE_subdiv_to_ccg_mesh(Subdiv *subdiv, const SubdivToCCGSettings *settings, const Mesh *coarse_mesh)
static void subdiv_ccg_average_inner_grids_task(void *__restrict userdata_v, const int face_index, const TaskParallelTLS *__restrict UNUSED(tls_v))
void BKE_subdiv_ccg_average_stitch_faces(SubdivCCG *subdiv_ccg, struct CCGFace **effected_faces, int num_effected_faces)
void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index)
void BKE_subdiv_ccg_topology_counters(const SubdivCCG *subdiv_ccg, int *r_num_vertices, int *r_num_edges, int *r_num_faces, int *r_num_loops)
static void subdiv_ccg_average_grids_corners(SubdivCCG *subdiv_ccg, CCGKey *key, SubdivCCGAdjacentVertex *adjacent_vertex)
static bool subdiv_ccg_evaluate_grids(SubdivCCG *subdiv_ccg, Subdiv *subdiv, SubdivCCGMaskEvaluator *mask_evaluator, SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator)
static void neighbor_coords_corner_vertex_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
static void neighbor_coords_boundary_outer_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int grid_index)
static void neighbor_coords_corner_edge_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
static void average_grid_element(SubdivCCG *subdiv_ccg, CCGKey *key, CCGElem *grid_element_a, CCGElem *grid_element_b)
static int topology_refiner_count_face_corners(OpenSubdiv_TopologyRefiner *topology_refiner)
static void subdiv_ccg_coord_to_ptex_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, int *r_ptex_face_index, float *r_u, float *r_v)
void BKE_subdiv_ccg_print_coord(const char *message, const SubdivCCGCoord *coord)
BLI_INLINE void subdiv_ccg_neighbors_init(SubdivCCGNeighbors *neighbors, const int num_unique, const int num_duplicates)
static void subdiv_ccg_recalc_inner_grid_normals(SubdivCCG *subdiv_ccg)
static void subdiv_ccg_recalc_inner_face_normals(SubdivCCG *subdiv_ccg, CCGKey *key, RecalcInnerNormalsTLSData *tls, const int grid_index)
static void subdiv_ccg_recalc_modified_inner_normal_task(void *__restrict userdata_v, const int face_index, const TaskParallelTLS *__restrict tls_v)
static int adjacent_edge_index_from_coord(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void subdiv_ccg_average_all_boundaries(SubdivCCG *subdiv_ccg, CCGKey *key)
static void neighbor_coords_boundary_get(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord, const bool include_duplicates, SubdivCCGNeighbors *r_neighbors)
SubdivCCG * BKE_subdiv_to_ccg(Subdiv *subdiv, const SubdivToCCGSettings *settings, SubdivCCGMaskEvaluator *mask_evaluator, SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator)
struct CCGEvalGridsData CCGEvalGridsData
static void static_or_heap_storage_init(StaticOrHeapIntStorage *storage)
static int * static_or_heap_storage_get(StaticOrHeapIntStorage *storage, int heap_len)
bool BKE_subdiv_ccg_check_coord_valid(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void subdiv_ccg_average_grids_corners_task(void *__restrict userdata_v, const int n, const TaskParallelTLS *__restrict UNUSED(tls_v))
BLI_INLINE SubdivCCGCoord coord_at_next_col(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord)
static void subdiv_ccg_init_layers(SubdivCCG *subdiv_ccg, const SubdivToCCGSettings *settings)
static void subdiv_ccg_average_inner_face_normals(SubdivCCG *subdiv_ccg, CCGKey *key, RecalcInnerNormalsTLSData *tls, const int grid_index)
static SubdivCCGCoord * subdiv_ccg_adjacent_vertex_add_face(SubdivCCGAdjacentVertex *adjacent_vertex)
static void subdiv_ccg_init_faces_vertex_neighborhood(SubdivCCG *subdiv_ccg)
static int element_size_bytes_get(const SubdivCCG *subdiv_ccg)
static void subdiv_ccg_init_faces_neighborhood(SubdivCCG *subdiv_ccg)
struct RecalcModifiedInnerNormalsData RecalcModifiedInnerNormalsData
struct AverageGridsCornerData AverageGridsCornerData
static void subdiv_ccg_allocate_adjacent_edges(SubdivCCG *subdiv_ccg, const int num_edges)
static void subdiv_ccg_recalc_modified_inner_grid_normals(SubdivCCG *subdiv_ccg, struct CCGFace **effected_faces, int num_effected_faces)