diff options
author | Antonioya <blendergit@gmail.com> | 2019-07-23 10:46:29 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-07-23 10:46:29 +0300 |
commit | 2204bfcf9e1c3a38e60830bd97775dd72158f4d6 (patch) | |
tree | 4f9c827389a23a431f8771b4ca02f410860c0242 /source/blender/blenkernel/intern/subdiv_ccg.c | |
parent | f64db794ee690f05905ace0a66d81d2e75549b90 (diff) | |
parent | 34ad6da4a06ef46cd19945f61cc5f968538546a8 (diff) |
Merge branch 'master' into temp-gpencil-drw-engine
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_ccg.c')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_ccg.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index 41ef2bd4b04..fac1e1dbe75 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -962,15 +962,31 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG *subdiv_ccg, const int num_face_grids = face->num_grids; const int grid_size = subdiv_ccg->grid_size; 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++) { 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 *grid_element = CCG_grid_elem(key, grid, 0, i); average_grid_element(subdiv_ccg, key, prev_grid_element, grid_element); } 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, |