Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/subdiv_ccg.c
| Show First 20 Lines • Show All 956 Lines • ▼ Show 20 Lines | |||||
| static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg, | static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg, | ||||
| CCGKey *key, | CCGKey *key, | ||||
| SubdivCCGFace *face) | SubdivCCGFace *face) | ||||
| { | { | ||||
| CCGElem **grids = subdiv_ccg->grids; | CCGElem **grids = subdiv_ccg->grids; | ||||
| const int num_face_grids = face->num_grids; | const int num_face_grids = face->num_grids; | ||||
| const int grid_size = subdiv_ccg->grid_size; | const int grid_size = subdiv_ccg->grid_size; | ||||
| CCGElem *prev_grid = grids[face->start_grid_index + num_face_grids - 1]; | CCGElem *prev_grid = grids[face->start_grid_index + num_face_grids - 1]; | ||||
| /* Average boundary between neighbor grid. */ | |||||
| for (int corner = 0; corner < num_face_grids; corner++) { | for (int corner = 0; corner < num_face_grids; corner++) { | ||||
| CCGElem *grid = grids[face->start_grid_index + corner]; | CCGElem *grid = grids[face->start_grid_index + corner]; | ||||
| for (int i = 0; i < grid_size; i++) { | for (int i = 1; i < grid_size; i++) { | ||||
| CCGElem *prev_grid_element = CCG_grid_elem(key, prev_grid, i, 0); | CCGElem *prev_grid_element = CCG_grid_elem(key, prev_grid, i, 0); | ||||
| CCGElem *grid_element = CCG_grid_elem(key, grid, 0, i); | CCGElem *grid_element = CCG_grid_elem(key, grid, 0, i); | ||||
| average_grid_element(subdiv_ccg, key, prev_grid_element, grid_element); | average_grid_element(subdiv_ccg, key, prev_grid_element, grid_element); | ||||
| } | } | ||||
| prev_grid = grid; | prev_grid = grid; | ||||
| } | } | ||||
| /* Average all grids centers into a single accumulator, and share it. | |||||
| * Guarantees corrent and smooth averaging in the center. */ | |||||
| GridElementAccumulator center_accumulator; | |||||
| element_accumulator_init(¢er_accumulator); | |||||
| for (int corner = 0; corner < num_face_grids; corner++) { | |||||
| CCGElem *grid = grids[face->start_grid_index + corner]; | |||||
| CCGElem *grid_center_element = CCG_grid_elem(key, grid, 0, 0); | |||||
| element_accumulator_add(¢er_accumulator, subdiv_ccg, key, grid_center_element); | |||||
| } | |||||
| element_accumulator_mul_fl(¢er_accumulator, 1.0f / (float)num_face_grids); | |||||
| for (int corner = 0; corner < num_face_grids; corner++) { | |||||
| CCGElem *grid = grids[face->start_grid_index + corner]; | |||||
| CCGElem *grid_center_element = CCG_grid_elem(key, grid, 0, 0); | |||||
| element_accumulator_copy(subdiv_ccg, key, grid_center_element, ¢er_accumulator); | |||||
| } | |||||
| } | } | ||||
| static void subdiv_ccg_average_inner_grids_task(void *__restrict userdata_v, | static void subdiv_ccg_average_inner_grids_task(void *__restrict userdata_v, | ||||
| const int face_index, | const int face_index, | ||||
| const ParallelRangeTLS *__restrict UNUSED(tls_v)) | const ParallelRangeTLS *__restrict UNUSED(tls_v)) | ||||
| { | { | ||||
| AverageInnerGridsData *data = userdata_v; | AverageInnerGridsData *data = userdata_v; | ||||
| SubdivCCG *subdiv_ccg = data->subdiv_ccg; | SubdivCCG *subdiv_ccg = data->subdiv_ccg; | ||||
| ▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines | |||||