diff options
20 files changed, 124 insertions, 112 deletions
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index f517ff3a949..5641ff0ba34 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -308,7 +308,7 @@ void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked); bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node); void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh); -void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index); +void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index); void BKE_pbvh_node_get_grids(PBVH *pbvh, PBVHNode *node, @@ -526,7 +526,7 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node, * however this is important to avoid having to recalculate bound-box & sync the buffers to the * GPU (which is far more expensive!) See: T47232. */ -bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node); +bool BKE_pbvh_node_has_vert_with_normal_update_tag(PBVH *pbvh, PBVHNode *node); // void BKE_pbvh_node_BB_reset(PBVHNode *node); // void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]); diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 6cebcdfea4e..8c1f19f0909 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1964,7 +1964,7 @@ bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node) return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyUnmasked); } -void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index) +void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index) { BLI_assert(pbvh->type == PBVH_FACES); pbvh->vert_bitmap[index] = true; @@ -2123,7 +2123,7 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node, *r_orco_coords = node->bm_orco; } -bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node) +bool BKE_pbvh_node_has_vert_with_normal_update_tag(PBVH *pbvh, PBVHNode *node) { BLI_assert(pbvh->type == PBVH_FACES); const int *verts = node->vert_indices; @@ -2991,7 +2991,7 @@ void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], const int /* no need for float comparison here (memory is exactly equal or not) */ if (memcmp(mvert->co, vertCos[a], sizeof(float[3])) != 0) { copy_v3_v3(mvert->co, vertCos[a]); - BKE_pbvh_vert_mark_update(pbvh, a); + BKE_pbvh_vert_tag_update_normal(pbvh, a); } } diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 89bbf2a3c92..b861d0c84da 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -1437,7 +1437,7 @@ static void project_line_gesture_apply_task_cb(void *__restrict userdata, } add_v3_v3(vd.co, disp); if (vd.mvert) { - BKE_pbvh_vert_mark_update(sgcontext->ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(sgcontext->ss->pbvh, vd.index); } any_updated = true; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7cb370efb94..4b902b7fca9 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -343,7 +343,7 @@ void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible) switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: SET_FLAG_FROM_TEST(ss->mvert[index].flag, !visible, ME_HIDE); - BKE_pbvh_vert_mark_update(ss->pbvh, index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, index); break; case PBVH_BMESH: BM_elem_flag_set(BM_vert_at_index(ss->bm, index), BM_ELEM_HIDDEN, !visible); @@ -586,7 +586,6 @@ static void UNUSED_FUNCTION(sculpt_visibility_sync_vertex_to_face_sets)(SculptSe ss->face_sets[vert_map->indices[i]] = -abs(ss->face_sets[vert_map->indices[i]]); } } - BKE_pbvh_vert_mark_update(ss->pbvh, index); } void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss) @@ -1408,6 +1407,9 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata, else { copy_v3_v3(vd.fno, orig_data.no); } + if (vd.mvert) { + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); + } } else if (orig_data.unode->type == SCULPT_UNDO_MASK) { *vd.mask = orig_data.mask; @@ -1415,10 +1417,6 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata, else if (orig_data.unode->type == SCULPT_UNDO_COLOR) { SCULPT_vertex_color_set(ss, vd.index, orig_data.col); } - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; } @@ -3045,7 +3043,7 @@ static void do_gravity_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], offset, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c index 44e2dfae480..390fcb9648a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.c +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c @@ -671,7 +671,7 @@ static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata, add_v3_v3(target_co, boundary->bend.pivot_positions[vd.index]); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -717,7 +717,7 @@ static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata, strength); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -763,7 +763,7 @@ static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata, strength); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -806,7 +806,7 @@ static void do_boundary_brush_grab_task_cb_ex(void *__restrict userdata, boundary->edit_info[vd.index].strength_factor * mask * automask * strength); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -860,7 +860,7 @@ static void do_boundary_brush_twist_task_cb_ex(void *__restrict userdata, add_v3_v3(target_co, boundary->twist.pivot_position); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -919,7 +919,7 @@ static void do_boundary_brush_smooth_task_cb_ex(void *__restrict userdata, target_co, vd.co, disp, boundary->edit_info[vd.index].strength_factor * mask * strength); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.c b/source/blender/editors/sculpt_paint/sculpt_brush_types.c index cba97f9b968..c607dd02a77 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.c +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.c @@ -320,7 +320,7 @@ static void do_draw_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], offset, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -418,7 +418,7 @@ static void do_fill_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -516,7 +516,7 @@ static void do_scrape_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -634,7 +634,7 @@ static void do_clay_thumb_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -789,7 +789,7 @@ static void do_flatten_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } } @@ -946,7 +946,7 @@ static void do_clay_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1072,7 +1072,7 @@ static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1272,7 +1272,7 @@ static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata, } if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1358,7 +1358,7 @@ static void do_thumb_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], cono, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1436,7 +1436,7 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata, sub_v3_v3(proxy[vd.i], orig_data.co); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1551,7 +1551,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata, SCULPT_clip(sd, ss, vd.co, final_co); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1624,7 +1624,7 @@ static void do_inflate_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1683,7 +1683,7 @@ static void do_nudge_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], cono, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1777,7 +1777,7 @@ static void do_crease_brush_task_cb_ex(void *__restrict userdata, add_v3_v3v3(proxy[vd.i], val1, val2); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -1896,7 +1896,7 @@ static void do_pinch_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], disp_center, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2005,7 +2005,7 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], grab_delta, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2113,7 +2113,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata, copy_v3_v3(proxy[vd.i], final_disp); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2191,7 +2191,7 @@ static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], offset, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2304,7 +2304,7 @@ static void do_topology_slide_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], final_disp, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2430,7 +2430,7 @@ static void do_topology_relax_task_cb_ex(void *__restrict userdata, SCULPT_relax_vertex(ss, &vd, fade * bstrength, false, vd.co); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2511,7 +2511,7 @@ static void do_displacement_eraser_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], disp, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2623,7 +2623,7 @@ static void do_displacement_smear_brush_task_cb_ex(void *__restrict userdata, interp_v3_v3v3(vd.co, vd.co, new_co, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2736,7 +2736,7 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, SCULPT_clip(sd, ss, vd.co, val); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -2808,12 +2808,8 @@ static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata, (*vd.mask) += fade * bstrength * (*vd.mask); } *vd.mask = clamp_f(*vd.mask, 0.0f, 1.0f); - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } - BKE_pbvh_vertex_iter_end; } + BKE_pbvh_vertex_iter_end; } void SCULPT_do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index bf3e8a24fdf..e29b2172ea7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -802,7 +802,7 @@ static void do_cloth_brush_solve_simulation_task_cb_ex( copy_v3_v3(vd.co, cloth_sim->pos[vd.index]); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c index 9648f558049..da2c346cf82 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_expand.c @@ -1236,9 +1236,6 @@ static void sculpt_expand_mask_update_task_cb(void *__restrict userdata, *vd.mask = clamp_f(new_mask, 0.0f, 1.0f); any_changed = true; - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; if (any_changed) { @@ -1317,9 +1314,6 @@ static void sculpt_expand_colors_update_task_cb(void *__restrict userdata, SCULPT_vertex_color_set(ss, vd.index, final_color); any_changed = true; - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; if (any_changed) { diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c index ce704e619ea..91763a15e37 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.c +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -215,7 +215,7 @@ static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata, SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c index a9186010a9f..27092bf9a04 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c @@ -225,10 +225,6 @@ static void color_filter_task_cb(void *__restrict userdata, } SCULPT_vertex_color_set(ss, vd.index, final_color); - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; BKE_pbvh_node_mark_update_color(data->nodes[n]); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c index ea3f56d0859..a21656435a3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.c @@ -162,9 +162,6 @@ static void mask_filter_task_cb(void *__restrict userdata, if (*vd.mask != prev_val) { update = true; } - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; @@ -386,10 +383,6 @@ static void dirty_mask_apply_task_cb(void *__restrict userdata, mask = fminf(mask, 0.5f) * 2.0f; } *vd.mask = CLAMPIS(mask, 0.0f, 1.0f); - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; BKE_pbvh_node_mark_update_mask(node); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index c0adf5aef20..9e84d9ac65d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -457,7 +457,7 @@ static void mesh_filter_task_cb(void *__restrict userdata, } copy_v3_v3(vd.co, final_pos); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c index 4593c6a8b60..03243f00c49 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c @@ -136,9 +136,6 @@ static void sculpt_expand_task_cb(void *__restrict userdata, } if (*vd.mask != final_mask) { - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } *vd.mask = final_mask; BKE_pbvh_node_mark_update_mask(node); } diff --git a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c index ddc1a0e1db0..50cb75e8089 100644 --- a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c +++ b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c @@ -200,7 +200,7 @@ static void do_multiplane_scrape_brush_task_cb_ex(void *__restrict userdata, mul_v3_v3fl(proxy[vd.i], val, fade); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index f16763be735..8f96f5cddea 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -882,9 +882,6 @@ static void do_mask_by_color_contiguous_update_nodes_cb( continue; } update_node = true; - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; if (update_node) { @@ -1001,13 +998,10 @@ static void do_mask_by_color_task_cb(void *__restrict userdata, continue; } update_node = true; - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; if (update_node) { - BKE_pbvh_node_mark_redraw(data->nodes[n]); + BKE_pbvh_node_mark_update_mask(data->nodes[n]); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index 7e813590e21..1a46c542b42 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -90,10 +90,6 @@ static void do_color_smooth_task_cb_exec(void *__restrict userdata, SCULPT_vertex_color_get(ss, vd.index, col); blend_color_interpolate_float(col, col, smooth_color, fade); SCULPT_vertex_color_set(ss, vd.index, col); - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; } @@ -186,10 +182,6 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata, IMB_blend_color_float(col, orig_data.col, buffer_color, brush->blend); CLAMP4(col, 0.0f, 1.0f); SCULPT_vertex_color_set(ss, vd.index, col); - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; } @@ -505,10 +497,6 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata, SCULPT_vertex_color_get(ss, vd.index, col); blend_color_interpolate_float(col, ss->cache->prev_colors[vd.index], interp_color, fade); SCULPT_vertex_color_set(ss, vd.index, col); - - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); - } } BKE_pbvh_vertex_iter_end; } diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c index 479ed43c6bf..6f600489729 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.c +++ b/source/blender/editors/sculpt_paint/sculpt_pose.c @@ -196,7 +196,7 @@ static void do_pose_brush_task_cb_ex(void *__restrict userdata, copy_v3_v3(target_co, final_pos); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c index c31863d892f..d6b9b500501 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.c +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c @@ -235,7 +235,7 @@ static void do_enhance_details_brush_task_cb_ex(void *__restrict userdata, SCULPT_clip(sd, ss, vd.co, disp); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -323,9 +323,9 @@ static void do_smooth_brush_task_cb_ex(void *__restrict userdata, sub_v3_v3v3(val, avg, vd.co); madd_v3_v3v3fl(val, vd.co, val, fade); SCULPT_clip(sd, ss, vd.co, val); - } - if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + if (vd.mvert) { + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); + } } } BKE_pbvh_vertex_iter_end; @@ -482,7 +482,7 @@ static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex( ss, disp, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.index, orig_data.co, alpha); madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f)); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.c b/source/blender/editors/sculpt_paint/sculpt_transform.c index 3b810d02b84..2a7c6c8d0e0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.c +++ b/source/blender/editors/sculpt_paint/sculpt_transform.c @@ -179,7 +179,7 @@ static void sculpt_transform_task_cb(void *__restrict userdata, add_v3_v3v3(vd.co, start_co, disp); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; @@ -253,7 +253,7 @@ static void sculpt_elastic_transform_task_cb(void *__restrict userdata, copy_v3_v3(proxy[vd.i], final_disp); if (vd.mvert) { - BKE_pbvh_vert_mark_update(ss->pbvh, vd.index); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index); } } BKE_pbvh_vertex_iter_end; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 1e050fedf8e..7110a5aae66 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -144,6 +144,9 @@ struct PartialUpdateData { PBVH *pbvh; bool rebuild; char *modified_grids; + bool *modified_hidden_vertices; + bool *modified_mask_vertices; + bool *modified_color_vertices; }; /** @@ -167,8 +170,39 @@ static void update_cb_partial(PBVHNode *node, void *userdata) } } else { - if (BKE_pbvh_node_vert_update_check_any(data->pbvh, node)) { - update_cb(node, &(data->rebuild)); + if (BKE_pbvh_node_has_vert_with_normal_update_tag(data->pbvh, node)) { + BKE_pbvh_node_mark_normals_update(node); + } + int verts_num; + const int *vert_indices; + BKE_pbvh_node_num_verts(data->pbvh, node, NULL, &verts_num); + BKE_pbvh_node_get_verts(data->pbvh, node, &vert_indices, NULL); + if (data->modified_mask_vertices != NULL) { + for (int i = 0; i < verts_num; i++) { + if (data->modified_mask_vertices[vert_indices[i]]) { + BKE_pbvh_node_mark_update_mask(node); + break; + } + } + } + if (data->modified_color_vertices != NULL) { + for (int i = 0; i < verts_num; i++) { + if (data->modified_color_vertices[vert_indices[i]]) { + BKE_pbvh_node_mark_update_color(node); + break; + } + } + } + if (data->modified_hidden_vertices != NULL) { + for (int i = 0; i < verts_num; i++) { + if (data->modified_hidden_vertices[vert_indices[i]]) { + if (data->rebuild) { + BKE_pbvh_node_mark_update_visibility(node); + } + BKE_pbvh_node_fully_hidden_set(node, 0); + break; + } + } } } } @@ -263,20 +297,20 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt if (ss->deform_modifiers_active) { for (int i = 0; i < unode->totvert; i++) { sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); - BKE_pbvh_vert_mark_update(ss->pbvh, index[i]); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, index[i]); } } else { for (int i = 0; i < unode->totvert; i++) { swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); - BKE_pbvh_vert_mark_update(ss->pbvh, index[i]); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, index[i]); } } } else { for (int i = 0; i < unode->totvert; i++) { swap_v3_v3(mvert[index[i]].co, unode->co[i]); - BKE_pbvh_vert_mark_update(ss->pbvh, index[i]); + BKE_pbvh_vert_tag_update_normal(ss->pbvh, index[i]); } } } @@ -305,7 +339,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt return true; } -static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode) +static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode, bool *modified_vertices) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); @@ -320,7 +354,7 @@ static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode) if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != ((v->flag & ME_HIDE) != 0)) { BLI_BITMAP_FLIP(unode->vert_hidden, i); v->flag ^= ME_HIDE; - BKE_pbvh_vert_mark_update(ss->pbvh, unode->index[i]); + modified_vertices[unode->index[i]] = true; } } } @@ -335,7 +369,7 @@ static bool sculpt_undo_restore_hidden(bContext *C, SculptUndoNode *unode) return true; } -static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode) +static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode, bool *modified_vertices) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); @@ -360,14 +394,14 @@ static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode) if (modified) { for (int i = 0; i < unode->totvert; i++) { - BKE_pbvh_vert_mark_update(ss->pbvh, unode->index[i]); + modified_vertices[unode->index[i]] = true; } } return modified; } -static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode) +static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode, bool *modified_vertices) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); @@ -385,7 +419,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode) for (int i = 0; i < unode->totvert; i++) { if (vmask[index[i]] != unode->mask[i]) { SWAP(float, vmask[index[i]], unode->mask[i]); - BKE_pbvh_vert_mark_update(ss->pbvh, index[i]); + modified_vertices[index[i]] = true; } } } @@ -731,6 +765,12 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } } + /* The PBVH already keeps track of which vertices need updated normals, but it doesn't keep track + * of other updated. In order to tell the corresponding PBVH nodes to update, keep track of which + * elements were updated for specific layers. */ + bool *modified_hidden_vertices = NULL; + bool *modified_mask_vertices = NULL; + bool *modified_color_vertices = NULL; char *undo_modified_grids = NULL; bool use_multires_undo = false; @@ -763,13 +803,19 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } break; case SCULPT_UNDO_HIDDEN: - if (sculpt_undo_restore_hidden(C, unode)) { + if (modified_hidden_vertices == NULL) { + modified_hidden_vertices = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__); + } + if (sculpt_undo_restore_hidden(C, unode, modified_hidden_vertices)) { rebuild = true; update_visibility = true; } break; case SCULPT_UNDO_MASK: - if (sculpt_undo_restore_mask(C, unode)) { + if (modified_mask_vertices == NULL) { + modified_mask_vertices = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__); + } + if (sculpt_undo_restore_mask(C, unode, modified_mask_vertices)) { update = true; update_mask = true; } @@ -777,7 +823,10 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase case SCULPT_UNDO_FACE_SETS: break; case SCULPT_UNDO_COLOR: - if (sculpt_undo_restore_color(C, unode)) { + if (modified_color_vertices == NULL) { + modified_color_vertices = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__); + } + if (sculpt_undo_restore_color(C, unode, modified_color_vertices)) { update = true; } @@ -828,6 +877,10 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase .rebuild = rebuild, .pbvh = ss->pbvh, .modified_grids = undo_modified_grids, + .modified_hidden_vertices = modified_hidden_vertices, + .modified_mask_vertices = modified_mask_vertices, + .modified_color_vertices = modified_color_vertices, + }; BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb_partial, &data); BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw); @@ -873,6 +926,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase } } + MEM_SAFE_FREE(modified_hidden_vertices); + MEM_SAFE_FREE(modified_mask_vertices); + MEM_SAFE_FREE(modified_color_vertices); MEM_SAFE_FREE(undo_modified_grids); } |