diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-15 15:55:52 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-15 15:55:52 +0300 |
commit | ec3248437dc52c641a914fd1245f778ac45f3a26 (patch) | |
tree | 127dd81f34e9a5412cca22b6630d598119ffd46b /source/blender/blenkernel/intern | |
parent | 72cb7e2726453714b150d5b9c5005db07092de67 (diff) | |
parent | 75e2ae72c7771a89f3fe4e988d4deb30c9367313 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 34 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 4 |
5 files changed, 38 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index d1282c1a0fe..1a97f8f07f4 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -288,6 +288,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) ob->sculpt->cd_face_node_offset); pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color); + pbvh_show_mask_set(cddm->pbvh, ob->sculpt->show_mask); } @@ -318,6 +319,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) looptri, looptris_num); pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color); + pbvh_show_mask_set(cddm->pbvh, ob->sculpt->show_mask); deformed = check_sculpt_object_deformed(ob, true); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 47df20906c7..152a882de97 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -888,6 +888,7 @@ void BKE_sculpt_update_mesh_elements( ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob); ss->show_diffuse_color = (sd->flags & SCULPT_SHOW_DIFFUSE) != 0; + ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0; ss->building_vp_handle = false; @@ -942,6 +943,7 @@ void BKE_sculpt_update_mesh_elements( ss->pmap = (need_pmap && dm->getPolyMap) ? dm->getPolyMap(ob, dm) : NULL; pbvh_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color); + pbvh_show_mask_set(ss->pbvh, ss->show_mask); if (ss->modifiers_active) { if (!ss->orig_cos) { diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 37fdfd68dab..63f2c7e5452 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1104,6 +1104,14 @@ void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings); } +static int pbvh_get_buffers_update_flags(PBVH *bvh) +{ + int update_flags = 0; + update_flags |= bvh->show_diffuse_color ? GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR : 0; + update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0; + return update_flags; +} + static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) { /* can't be done in parallel with OpenGL */ @@ -1139,6 +1147,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) } if (node->flag & PBVH_UpdateDrawBuffers) { + const int update_flags = pbvh_get_buffers_update_flags(bvh); switch (bvh->type) { case PBVH_GRIDS: GPU_pbvh_grid_buffers_update( @@ -1148,7 +1157,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) node->prim_indices, node->totprim, &bvh->gridkey, - bvh->show_diffuse_color); + update_flags); break; case PBVH_FACES: GPU_pbvh_mesh_buffers_update( @@ -1159,7 +1168,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) node->face_verts, CustomData_get_layer(bvh->vdata, CD_PAINT_MASK), node->face_vert_indices, - bvh->show_diffuse_color); + update_flags); break; case PBVH_BMESH: GPU_pbvh_bmesh_buffers_update( @@ -1168,7 +1177,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) node->bm_faces, node->bm_unique_verts, node->bm_other_verts, - bvh->show_diffuse_color); + update_flags); break; } @@ -2085,6 +2094,16 @@ static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node) node->flag |= PBVH_UpdateDrawBuffers; } +static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node) +{ + if (!node->draw_buffers) { + return; + } + if (GPU_pbvh_buffers_mask_changed(node->draw_buffers, bvh->show_mask)) { + node->flag |= PBVH_UpdateDrawBuffers; + } +} + void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*fnors)[3], DMSetMaterial setMaterial, bool wireframe, bool fast) { @@ -2092,8 +2111,10 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*fnors)[3], PBVHNode **nodes; int totnode; - for (int a = 0; a < bvh->totnode; a++) + for (int a = 0; a < bvh->totnode; a++) { pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]); + pbvh_node_check_mask_changed(bvh, &bvh->nodes[a]); + } BKE_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), &nodes, &totnode); @@ -2404,3 +2425,8 @@ void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color) { bvh->show_diffuse_color = !pbvh_has_mask(bvh) || show_diffuse_color; } + +void pbvh_show_mask_set(PBVH *bvh, bool show_mask) +{ + bvh->show_mask = show_mask; +} diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index e05a3068682..afd539b2273 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -164,6 +164,7 @@ struct PBVH { bool deformed; bool show_diffuse_color; + bool show_mask; /* Dynamic topology */ BMesh *bm; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 84b82ed53bb..5e2fb220327 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -4258,8 +4258,10 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) looptri, looptris_num); } - if (ccgdm->pbvh) + if (ccgdm->pbvh != NULL) { pbvh_show_diffuse_color_set(ccgdm->pbvh, ob->sculpt->show_diffuse_color); + pbvh_show_mask_set(ccgdm->pbvh, ob->sculpt->show_mask); + } /* For vertex paint, keep track of ccgdm */ if (!(ob->mode & OB_MODE_SCULPT) && ccgdm->pbvh) { |