Refactor: Move PBVH update tag out of MVert

This is part of the project of converting `MVert` into `float3`.
(more details in T93602), The pbvh update flag is removed and
replaced with a bitmap stored in the PBVH structure. This
patch is similar to D13878. This is mainly setup for an eventual
performance improvement by removing the extra data from
mesh vertices, but if it's consistent with testing in the other patch
doing the same thing for another "temp tag", then it may actually
increase the speed of sculpt code slightly, since less memory needs
to be loaded when checking/changing the flags.

Differential Revision: https://developer.blender.org/D14000
This commit is contained in:
Hans Goudey 2022-02-10 10:58:35 -06:00
parent 2cd1472f86
commit 7682d7de04
Notes: blender-bot 2023-06-26 11:58:59 +02:00
Referenced by issue #96810, Regression: Shading artefacts in sculpt mode
Referenced by issue #93602, Struct of Arrays Refactor for Mesh Vertices
23 changed files with 84 additions and 80 deletions

View File

@ -299,6 +299,8 @@ bool BKE_pbvh_node_fully_masked_get(PBVHNode *node);
void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked);
bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index);
void BKE_pbvh_node_get_grids(PBVH *pbvh,
PBVHNode *node,
int **grid_indices,

View File

@ -610,7 +610,9 @@ void BKE_pbvh_build_mesh(PBVH *pbvh,
}
MEM_freeN(prim_bbc);
MEM_freeN(pbvh->vert_bitmap);
/* Clear the bitmap so it can be used as an update tag later on. */
BLI_bitmap_set_all(pbvh->vert_bitmap, false, totvert);
}
void BKE_pbvh_build_grids(PBVH *pbvh,
@ -714,6 +716,8 @@ void BKE_pbvh_free(PBVH *pbvh)
MEM_freeN(pbvh->prim_indices);
}
MEM_SAFE_FREE(pbvh->vert_bitmap);
MEM_freeN(pbvh);
}
@ -1021,8 +1025,7 @@ static void pbvh_update_normals_clear_task_cb(void *__restrict userdata,
const int totvert = node->uniq_verts;
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
const MVert *mvert = &pbvh->verts[v];
if (mvert->flag & ME_VERT_PBVH_UPDATE) {
if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
zero_v3(vnors[v]);
}
}
@ -1065,7 +1068,7 @@ static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
for (int j = sides; j--;) {
const int v = vtri[j];
if (pbvh->verts[v].flag & ME_VERT_PBVH_UPDATE) {
if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
/* NOTE: This avoids `lock, add_v3_v3, unlock`
* and is five to ten times quicker than a spin-lock.
* Not exact equivalent though, since atomicity is only ensured for one component
@ -1094,13 +1097,12 @@ static void pbvh_update_normals_store_task_cb(void *__restrict userdata,
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
MVert *mvert = &pbvh->verts[v];
/* No atomics necessary because we are iterating over uniq_verts only,
* so we know only this thread will handle this vertex. */
if (mvert->flag & ME_VERT_PBVH_UPDATE) {
if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
normalize_v3(vnors[v]);
mvert->flag &= ~ME_VERT_PBVH_UPDATE;
BLI_BITMAP_DISABLE(pbvh->vert_bitmap, v);
}
}
@ -1117,7 +1119,7 @@ static void pbvh_faces_update_normals(PBVH *pbvh, PBVHNode **nodes, int totnode)
* bounding box of its adjacent faces will be as well.
* - However this is only true for the vertices that have actually been
* edited, not for all vertices in the nodes marked for update, so we
* can only update vertices marked with ME_VERT_PBVH_UPDATE.
* can only update vertices marked in the `vert_bitmap`.
*/
PBVHUpdateData data = {
@ -1826,6 +1828,12 @@ 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)
{
BLI_assert(pbvh->type == PBVH_FACES);
BLI_BITMAP_ENABLE(pbvh->vert_bitmap, index);
}
void BKE_pbvh_node_get_verts(PBVH *pbvh,
PBVHNode *node,
const int **r_vert_indices,
@ -1971,9 +1979,8 @@ bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node)
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
const MVert *mvert = &pbvh->verts[v];
if (mvert->flag & ME_VERT_PBVH_UPDATE) {
if (BLI_BITMAP_TEST(pbvh->vert_bitmap, v)) {
return true;
}
}
@ -2827,7 +2834,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]);
mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(pbvh, a);
}
}

View File

@ -153,8 +153,8 @@ struct PBVH {
int totgrid;
BLI_bitmap **grid_hidden;
/* Only used during BVH build and update,
* don't need to remain valid after */
/* Used during BVH build and later to mark that a vertex needs to update
* (its normal must be recalculated). */
BLI_bitmap *vert_bitmap;
#ifdef PERFCNTRS

View File

@ -1428,7 +1428,7 @@ static void project_line_gesture_apply_task_cb(void *__restrict userdata,
}
add_v3_v3(vd.co, disp);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(sgcontext->ss->pbvh, vd.index);
}
any_updated = true;
}

View File

@ -349,7 +349,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);
ss->mvert[index].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index);
break;
case PBVH_BMESH:
BM_elem_flag_set(BM_vert_at_index(ss->bm, index), BM_ELEM_HIDDEN, !visible);
@ -592,7 +592,7 @@ 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]]);
}
}
ss->mvert[index].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index);
}
void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss)
@ -1398,7 +1398,7 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata,
}
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2988,7 +2988,7 @@ static void do_gravity_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -688,7 +688,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -734,7 +734,7 @@ static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata,
strength);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -780,7 +780,7 @@ static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata,
strength);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -823,7 +823,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -877,7 +877,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -936,7 +936,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -334,7 +334,7 @@ static void do_draw_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -428,7 +428,7 @@ static void do_fill_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -526,7 +526,7 @@ static void do_scrape_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -644,7 +644,7 @@ static void do_clay_thumb_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -795,7 +795,7 @@ static void do_flatten_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
}
@ -952,7 +952,7 @@ static void do_clay_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1078,7 +1078,7 @@ static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1278,7 +1278,7 @@ static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata,
}
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1364,7 +1364,7 @@ static void do_thumb_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1442,7 +1442,7 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata,
sub_v3_v3(proxy[vd.i], orig_data.co);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1557,7 +1557,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
SCULPT_clip(sd, ss, vd.co, final_co);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1630,7 +1630,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1689,7 +1689,7 @@ static void do_nudge_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1781,7 +1781,7 @@ static void do_crease_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3v3(proxy[vd.i], val1, val2);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1900,7 +1900,7 @@ static void do_pinch_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], disp_center, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2009,7 +2009,7 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2117,7 +2117,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
copy_v3_v3(proxy[vd.i], final_disp);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2190,7 +2190,7 @@ static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2301,7 +2301,7 @@ static void do_topology_slide_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], final_disp, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2427,7 +2427,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2507,7 +2507,7 @@ static void do_displacement_eraser_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], disp, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2619,7 +2619,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2732,7 +2732,7 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
SCULPT_clip(sd, ss, vd.co, val);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -2806,7 +2806,7 @@ static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata,
*vd.mask = clamp_f(*vd.mask, 0.0f, 1.0f);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
BKE_pbvh_vertex_iter_end;
}

View File

@ -814,7 +814,7 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
copy_v3_v3(vd.co, cloth_sim->pos[vd.index]);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -240,7 +240,6 @@ static void SCULPT_dynamic_topology_disable_ex(
/* Sync the visibility to vertices manually as the pmap is still not initialized. */
for (int i = 0; i < me->totvert; i++) {
me->mvert[i].flag &= ~ME_HIDE;
me->mvert[i].flag |= ME_VERT_PBVH_UPDATE;
}
}

View File

@ -1253,7 +1253,7 @@ 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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -1333,7 +1333,7 @@ static void sculpt_expand_colors_update_task_cb(void *__restrict userdata,
copy_v4_v4(vd.col, final_color);
any_changed = true;
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -234,7 +234,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -205,7 +205,7 @@ static void color_filter_task_cb(void *__restrict userdata,
copy_v3_v3(vd.col, final_color);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -179,7 +179,7 @@ static void mask_filter_task_cb(void *__restrict userdata,
update = true;
}
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -403,7 +403,7 @@ static void dirty_mask_apply_task_cb(void *__restrict userdata,
*vd.mask = CLAMPIS(mask, 0.0f, 1.0f);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -468,7 +468,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
}
copy_v3_v3(vd.co, final_pos);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -153,7 +153,7 @@ static void sculpt_expand_task_cb(void *__restrict userdata,
if (*vd.mask != final_mask) {
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
*vd.mask = final_mask;
BKE_pbvh_node_mark_update_mask(node);

View File

@ -216,7 +216,7 @@ static void do_multiplane_scrape_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -873,7 +873,7 @@ static void do_mask_by_color_contiguous_update_nodes_cb(
}
update_node = true;
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -980,7 +980,7 @@ static void do_mask_by_color_task_cb(void *__restrict userdata,
}
update_node = true;
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -104,7 +104,7 @@ static void do_color_smooth_task_cb_exec(void *__restrict userdata,
blend_color_interpolate_float(vd.col, vd.col, smooth_color, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -198,7 +198,7 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata,
CLAMP4(vd.col, 0.0f, 1.0f);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -436,7 +436,7 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata,
blend_color_interpolate_float(vd.col, ss->cache->prev_colors[vd.index], interp_color, fade);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -212,7 +212,7 @@ static void do_pose_brush_task_cb_ex(void *__restrict userdata,
copy_v3_v3(target_co, final_pos);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -247,7 +247,7 @@ static void do_enhance_details_brush_task_cb_ex(void *__restrict userdata,
SCULPT_clip(sd, ss, vd.co, disp);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -337,7 +337,7 @@ static void do_smooth_brush_task_cb_ex(void *__restrict userdata,
SCULPT_clip(sd, ss, vd.co, val);
}
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;
@ -494,7 +494,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) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -162,7 +162,7 @@ static void sculpt_transform_task_cb(void *__restrict userdata,
add_v3_v3v3(vd.co, orig_co, disp);
if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, vd.index);
}
}
BKE_pbvh_vertex_iter_end;

View File

@ -134,7 +134,7 @@ struct PartialUpdateData {
};
/**
* A version of #update_cb that tests for 'ME_VERT_PBVH_UPDATE'
* A version of #update_cb that tests for the update tag in #PBVH.vert_bitmap.
*/
static void update_cb_partial(PBVHNode *node, void *userdata)
{
@ -250,20 +250,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);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index[i]);
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index[i]);
}
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
swap_v3_v3(mvert[index[i]].co, unode->co[i]);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index[i]);
}
}
}
@ -307,7 +307,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;
v->flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, unode->index[i]);
}
}
}
@ -331,12 +331,11 @@ static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode)
if (unode->maxvert) {
/* regular mesh restore */
int *index = unode->index;
MVert *mvert = ss->mvert;
MPropCol *vcol = ss->vcol;
for (int i = 0; i < unode->totvert; i++) {
copy_v4_v4(vcol[index[i]].color, unode->col[i]);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index[i]);
}
}
return true;
@ -348,7 +347,6 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
Object *ob = OBACT(view_layer);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
MVert *mvert;
float *vmask;
int *index;
@ -356,13 +354,12 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
/* Regular mesh restore. */
index = unode->index;
mvert = ss->mvert;
vmask = ss->vmask;
for (int i = 0; i < unode->totvert; i++) {
if (vmask[index[i]] != unode->mask[i]) {
SWAP(float, vmask[index[i]], unode->mask[i]);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
BKE_pbvh_vert_mark_update(ss->pbvh, index[i]);
}
}
}

View File

@ -51,7 +51,6 @@ enum {
ME_HIDE = (1 << 4),
ME_VERT_FACEDOT = (1 << 5),
/* ME_VERT_MERGED = (1 << 6), */
ME_VERT_PBVH_UPDATE = (1 << 7),
};
/**