Merge branch 'blender-v3.3-release'

This commit is contained in:
Hans Goudey 2022-08-02 11:09:22 -05:00
commit 2d4498e457
20 changed files with 124 additions and 113 deletions

View File

@ -427,7 +427,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, PBVHVertRef vertex);
void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, PBVHVertRef vertex);
void BKE_pbvh_node_get_grids(PBVH *pbvh,
PBVHNode *node,
@ -648,7 +648,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]);

View File

@ -1953,10 +1953,10 @@ 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, PBVHVertRef index)
void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, PBVHVertRef vertex)
{
BLI_assert(pbvh->header.type == PBVH_FACES);
pbvh->vert_bitmap[index.i] = true;
pbvh->vert_bitmap[vertex.i] = true;
}
void BKE_pbvh_node_get_loops(PBVH *pbvh,
@ -2112,7 +2112,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->header.type == PBVH_FACES);
const int *verts = node->vert_indices;
@ -2980,7 +2980,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, BKE_pbvh_make_vref(a));
BKE_pbvh_vert_tag_update_normal(pbvh, BKE_pbvh_make_vref(a));
}
}

View File

@ -1439,7 +1439,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.vertex);
BKE_pbvh_vert_tag_update_normal(sgcontext->ss->pbvh, vd.vertex);
}
any_updated = true;
}

View File

@ -346,7 +346,6 @@ void SCULPT_vertex_visible_set(SculptSession *ss, PBVHVertRef vertex, bool visib
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
SET_FLAG_FROM_TEST(ss->mvert[vertex.i].flag, !visible, ME_HIDE);
BKE_pbvh_vert_mark_update(ss->pbvh, vertex);
break;
case PBVH_BMESH: {
BMVert *v = (BMVert *)vertex.i;
@ -591,7 +590,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, vertex);
}
void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss)
@ -1444,6 +1442,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.vertex);
}
}
else if (orig_data.unode->type == SCULPT_UNDO_MASK) {
*vd.mask = orig_data.mask;
@ -1451,10 +1452,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.vertex, orig_data.col);
}
if (vd.mvert) {
BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
}
@ -3081,7 +3078,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -706,7 +706,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -752,7 +752,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -798,7 +798,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -841,7 +841,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -895,7 +895,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -954,7 +954,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
}
@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -1552,7 +1552,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -1625,7 +1625,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -1684,7 +1684,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -1778,7 +1778,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -1897,7 +1897,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2006,7 +2006,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2114,7 +2114,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2192,7 +2192,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2305,7 +2305,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2431,7 +2431,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2512,7 +2512,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2624,7 +2624,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2739,7 +2739,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -2811,12 +2811,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.vertex);
}
BKE_pbvh_vertex_iter_end;
}
BKE_pbvh_vertex_iter_end;
}
void SCULPT_do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)

View File

@ -805,7 +805,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -1274,9 +1274,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.vertex);
}
}
BKE_pbvh_vertex_iter_end;
if (any_changed) {
@ -1355,9 +1352,6 @@ static void sculpt_expand_colors_update_task_cb(void *__restrict userdata,
SCULPT_vertex_color_set(ss, vd.vertex, final_color);
any_changed = true;
if (vd.mvert) {
BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
if (any_changed) {

View File

@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -225,10 +225,6 @@ static void color_filter_task_cb(void *__restrict userdata,
}
SCULPT_vertex_color_set(ss, vd.vertex, final_color);
if (vd.mvert) {
BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
BKE_pbvh_node_mark_update_color(data->nodes[n]);

View File

@ -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.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -387,10 +384,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.vertex);
}
}
BKE_pbvh_vertex_iter_end;
BKE_pbvh_node_mark_update_mask(node);

View File

@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -139,9 +139,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.vertex);
}
*vd.mask = final_mask;
BKE_pbvh_node_mark_update_mask(node);
}

View File

@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -887,9 +887,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.vertex);
}
}
BKE_pbvh_vertex_iter_end;
if (update_node) {
@ -1009,13 +1006,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.vertex);
}
}
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]);
}
}

View File

@ -90,10 +90,6 @@ static void do_color_smooth_task_cb_exec(void *__restrict userdata,
SCULPT_vertex_color_get(ss, vd.vertex, col);
blend_color_interpolate_float(col, col, smooth_color, fade);
SCULPT_vertex_color_set(ss, vd.vertex, col);
if (vd.mvert) {
BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
}
}
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.vertex, col);
if (vd.mvert) {
BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
}
}
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.vertex, col);
blend_color_interpolate_float(col, ss->cache->prev_colors[vd.index], interp_color, fade);
SCULPT_vertex_color_set(ss, vd.vertex, col);
if (vd.mvert) {
BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
}

View File

@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -237,7 +237,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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;
@ -327,9 +327,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.vertex);
if (vd.mvert) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
}
BKE_pbvh_vertex_iter_end;
@ -491,7 +491,7 @@ static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(
ss, disp, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.vertex, 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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
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.vertex);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -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, BKE_pbvh_make_vref(index[i]));
BKE_pbvh_vert_tag_update_normal(ss->pbvh, BKE_pbvh_make_vref(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, BKE_pbvh_make_vref(index[i]));
BKE_pbvh_vert_tag_update_normal(ss->pbvh, BKE_pbvh_make_vref(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, BKE_pbvh_make_vref(index[i]));
BKE_pbvh_vert_tag_update_normal(ss->pbvh, BKE_pbvh_make_vref(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, BKE_pbvh_make_vref(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, BKE_pbvh_index_to_vertex(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, BKE_pbvh_make_vref(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);
}