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 | |
parent | 72cb7e2726453714b150d5b9c5005db07092de67 (diff) | |
parent | 75e2ae72c7771a89f3fe4e988d4deb30c9367313 (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | intern/cycles/render/object.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/render/object.h | 3 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 1 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d_toolbar.py | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_pbvh.h | 1 | ||||
-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 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/GPU_buffers.h | 13 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 58 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 22 |
17 files changed, 132 insertions, 27 deletions
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 20f57cc8d97..4c06654d756 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -473,8 +473,7 @@ void ObjectManager::device_update_object_transform_task( } } -void ObjectManager::device_update_transforms(Device *device, - DeviceScene *dscene, +void ObjectManager::device_update_transforms(DeviceScene *dscene, Scene *scene, uint *object_flag, Progress& progress) @@ -560,7 +559,7 @@ void ObjectManager::device_update(Device *device, DeviceScene *dscene, Scene *sc /* set object transform matrices, before applying static transforms */ progress.set_status("Updating Objects", "Copying Transformations to device"); - device_update_transforms(device, dscene, scene, object_flag, progress); + device_update_transforms(dscene, scene, object_flag, progress); if(progress.get_cancel()) return; diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h index 9f86c342acd..88645bc4a80 100644 --- a/intern/cycles/render/object.h +++ b/intern/cycles/render/object.h @@ -93,8 +93,7 @@ public: ~ObjectManager(); void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); - void device_update_transforms(Device *device, - DeviceScene *dscene, + void device_update_transforms(DeviceScene *dscene, Scene *scene, uint *object_flag, Progress& progress); diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index cd062a67647..9fd620eec76 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2046,6 +2046,7 @@ class VIEW3D_MT_sculpt(Menu): layout.prop(sculpt, "show_brush") layout.prop(sculpt, "use_deform_only") layout.prop(sculpt, "show_diffuse_color") + layout.prop(sculpt, "show_mask") class VIEW3D_MT_hide_mask(Menu): diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index a46358b2e38..e29971e1835 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1648,6 +1648,7 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): layout.prop(sculpt, "show_low_resolution") layout.prop(sculpt, "use_deform_only") layout.prop(sculpt, "show_diffuse_color") + layout.prop(sculpt, "show_mask") self.unified_paint_settings(layout, context) diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index b8fde8bd68e..b952859e508 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -196,6 +196,7 @@ typedef struct SculptSession { /* PBVH acceleration structure */ struct PBVH *pbvh; bool show_diffuse_color; + bool show_mask; /* Painting on deformed mesh */ bool modifiers_active; /* object is deformed with some modifiers */ diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 9aea5dc95a0..5f37aa25de7 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -375,5 +375,6 @@ bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node); bool pbvh_has_mask(PBVH *bvh); void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color); +void pbvh_show_mask_set(PBVH *bvh, bool show_mask); #endif /* __BKE_PBVH_H__ */ 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) { diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 73cb31bb1bd..004d2757a71 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1277,6 +1277,10 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PAINT_OT_mask_lasso_gesture", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + /* Toggle mask visibility */ + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, KM_CTRL, 0); + RNA_string_set(kmi->ptr, "data_path", "scene.tool_settings.sculpt.show_mask"); + /* Toggle dynamic topology */ WM_keymap_add_item(keymap, "SCULPT_OT_dynamic_topology_toggle", DKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 30fd4bd30b8..0d8a7a45ee9 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -238,10 +238,16 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading); /* update */ +enum { + GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR = (1 << 0), + GPU_PBVH_BUFFERS_SHOW_MASK = (1 << 1), +}; + void GPU_pbvh_mesh_buffers_update( GPU_PBVH_Buffers *buffers, const struct MVert *mvert, const int *vert_indices, int totvert, const float *vmask, - const int (*face_vert_indices)[3], bool show_diffuse_color); + const int (*face_vert_indices)[3], + const int update_flags); void GPU_pbvh_bmesh_buffers_update( GPU_PBVH_Buffers *buffers, @@ -249,13 +255,13 @@ void GPU_pbvh_bmesh_buffers_update( struct GSet *bm_faces, struct GSet *bm_unique_verts, struct GSet *bm_other_verts, - bool show_diffuse_color); + const int update_flags); void GPU_pbvh_grid_buffers_update( GPU_PBVH_Buffers *buffers, struct CCGElem **grids, const struct DMFlagMat *grid_flag_mats, int *grid_indices, int totgrid, const struct CCGKey *key, - bool show_diffuse_color); + const int update_flags); /* draw */ void GPU_pbvh_buffers_draw( @@ -267,6 +273,7 @@ struct Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fas void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos); bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GSet *bm_faces, bool show_diffuse_color); +bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask); void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers); void GPU_pbvh_multires_buffers_free(struct GridCommonGPUBuffer **grid_common_gpu_buffer); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 3a6b0a2a72d..095021c12d8 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -980,6 +980,8 @@ struct GPU_PBVH_Buffers { bool smooth; bool show_diffuse_color; + bool show_mask; + bool use_matcaps; float diffuse_color[4]; }; @@ -1053,10 +1055,15 @@ static void gpu_color_from_mask_quad_copy(const CCGKey *key, void GPU_pbvh_mesh_buffers_update( GPU_PBVH_Buffers *buffers, const MVert *mvert, const int *vert_indices, int totvert, const float *vmask, - const int (*face_vert_indices)[3], bool show_diffuse_color) + const int (*face_vert_indices)[3], + const int update_flags) { + const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0; + const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; + buffers->vmask = vmask; buffers->show_diffuse_color = show_diffuse_color; + buffers->show_mask = show_mask; buffers->use_matcaps = GPU_material_use_matcaps_get(); { @@ -1103,7 +1110,7 @@ void GPU_pbvh_mesh_buffers_update( const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; for (uint j = 0; j < 3; j++) { int vidx = face_vert_indices[i][j]; - if (vmask) { + if (vmask && show_mask) { int v_index = buffers->mloop[lt->tri[j]].v; uchar color_ub[3]; gpu_color_from_mask_copy(vmask[v_index], diffuse_color, color_ub); @@ -1142,7 +1149,7 @@ void GPU_pbvh_mesh_buffers_update( } uchar color_ub[3]; - if (vmask) { + if (vmask && show_mask) { float fmask = (vmask[vtri[0]] + vmask[vtri[1]] + vmask[vtri[2]]) / 3.0f; gpu_color_from_mask_copy(fmask, diffuse_color, color_ub); } @@ -1193,6 +1200,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( #endif buffers->show_diffuse_color = false; + buffers->show_mask = true; buffers->use_matcaps = false; /* Count the number of visible triangles */ @@ -1257,11 +1265,15 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( void GPU_pbvh_grid_buffers_update( GPU_PBVH_Buffers *buffers, CCGElem **grids, const DMFlagMat *grid_flag_mats, int *grid_indices, - int totgrid, const CCGKey *key, bool show_diffuse_color) + int totgrid, const CCGKey *key, + const int update_flags) { + const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0; + const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; int i, j, k, x, y; buffers->show_diffuse_color = show_diffuse_color; + buffers->show_mask = show_mask; buffers->use_matcaps = GPU_material_use_matcaps_get(); buffers->smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; @@ -1306,7 +1318,7 @@ void GPU_pbvh_grid_buffers_update( normal_float_to_short_v3(no_short, CCG_elem_no(key, elem)); GWN_vertbuf_attr_set(buffers->vert_buf, vbo_id.nor, vbo_index, no_short); - if (has_mask) { + if (has_mask && show_mask) { uchar color_ub[3]; gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), diffuse_color, color_ub); @@ -1483,6 +1495,7 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build( buffers->totgrid = totgrid; buffers->show_diffuse_color = false; + buffers->show_mask = true; buffers->use_matcaps = false; /* Count the number of quads */ @@ -1544,7 +1557,8 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( const float fno[3], const float *fmask, const int cd_vert_mask_offset, - const float diffuse_color[4]) + const float diffuse_color[4], + const bool show_mask) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { @@ -1559,9 +1573,17 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( { uchar color_ub[3]; + float effective_mask; + if (show_mask) { + effective_mask = fmask ? *fmask + : BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset); + } + else { + effective_mask = 0.0f; + } + gpu_color_from_mask_copy( - fmask ? *fmask : - BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset), + effective_mask, diffuse_color, color_ub); GWN_vertbuf_attr_set(vert_buf, vbo_id->col, *v_index, color_ub); @@ -1620,8 +1642,10 @@ void GPU_pbvh_bmesh_buffers_update( GSet *bm_faces, GSet *bm_unique_verts, GSet *bm_other_verts, - bool show_diffuse_color) + const int update_flags) { + const bool show_diffuse_color = (update_flags & GPU_PBVH_BUFFERS_SHOW_DIFFUSE_COLOR) != 0; + const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0; int tottri, totvert, maxvert = 0; float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; @@ -1629,6 +1653,7 @@ void GPU_pbvh_bmesh_buffers_update( const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); buffers->show_diffuse_color = show_diffuse_color; + buffers->show_mask = show_mask; buffers->use_matcaps = GPU_material_use_matcaps_get(); /* Count visible triangles */ @@ -1684,14 +1709,16 @@ void GPU_pbvh_bmesh_buffers_update( gpu_bmesh_vert_to_buffer_copy__gwn( BLI_gsetIterator_getKey(&gs_iter), buffers->vert_buf, &vbo_id, &v_index, NULL, NULL, - cd_vert_mask_offset, diffuse_color); + cd_vert_mask_offset, diffuse_color, + show_mask); } GSET_ITER (gs_iter, bm_other_verts) { gpu_bmesh_vert_to_buffer_copy__gwn( BLI_gsetIterator_getKey(&gs_iter), buffers->vert_buf, &vbo_id, &v_index, NULL, NULL, - cd_vert_mask_offset, diffuse_color); + cd_vert_mask_offset, diffuse_color, + show_mask); } maxvert = v_index; @@ -1724,7 +1751,8 @@ void GPU_pbvh_bmesh_buffers_update( gpu_bmesh_vert_to_buffer_copy__gwn( v[i], buffers->vert_buf, &vbo_id, &v_index, f->no, &fmask, - cd_vert_mask_offset, diffuse_color); + cd_vert_mask_offset, diffuse_color, + show_mask); } } } @@ -1796,6 +1824,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading) buffers->use_bmesh = true; buffers->smooth = smooth_shading; buffers->show_diffuse_color = false; + buffers->show_mask = true; buffers->use_matcaps = false; return buffers; @@ -1883,6 +1912,11 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, return !equals_v3v3(diffuse_color, buffers->diffuse_color); } +bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask) +{ + return (buffers->show_mask != show_mask); +} + void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers) { if (buffers) { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 2fa830dc42a..539b9fa45b4 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1028,13 +1028,13 @@ void IMB_exr_write_channels(void *handle) for (size_t i = 0; i < num_pixels; ++i, ++cur) { *cur = rect[i * echan->xstride]; } - half *rect_to_write = current_rect_half + (data->height - 1) * data->width; + half *rect_to_write = current_rect_half + (data->height - 1L) * data->width; frameBuffer.insert(echan->name, Slice(Imf::HALF, (char *)rect_to_write, sizeof(half), -data->width * sizeof(half))); current_rect_half += num_pixels; } else { - float *rect = echan->rect + echan->xstride * (data->height - 1) * data->width; + float *rect = echan->rect + echan->xstride * (data->height - 1L) * data->width; frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)rect, echan->xstride * sizeof(float), -echan->ystride * sizeof(float))); } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 065ee801b84..0dc640adb29 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2116,6 +2116,9 @@ typedef enum eSculptFlags { /* If set, dynamic-topology detail size will be constant in object space */ SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13), SCULPT_DYNTOPO_DETAIL_BRUSH = (1 << 14), + + /* Don't display mask in viewport, but still use it for strokes. */ + SCULPT_HIDE_MASK = (1 << 15), } eSculptFlags; typedef enum eImageePaintMode { diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index ddcf525c3c8..cc447f2a028 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -297,6 +297,22 @@ static void rna_Sculpt_ShowDiffuseColor_update(bContext *C, PointerRNA *UNUSED(p } } +static void rna_Sculpt_ShowMask_update(bContext *C, PointerRNA *UNUSED(ptr)) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *object = OBACT(view_layer); + if (object == NULL || object->sculpt == NULL) { + return; + } + Scene *scene = CTX_data_scene(C); + Sculpt *sd = scene->toolsettings->sculpt; + object->sculpt->show_mask = ((sd->flags & SCULPT_HIDE_MASK) == 0); + if (object->sculpt->pbvh != NULL) { + pbvh_show_mask_set(object->sculpt->pbvh, object->sculpt->show_mask); + } + WM_main_add_notifier(NC_OBJECT | ND_DRAW, object); +} + static char *rna_Sculpt_path(PointerRNA *UNUSED(ptr)) { return BLI_strdup("tool_settings.sculpt"); @@ -613,6 +629,12 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); + prop = RNA_def_property(srna, "show_mask", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", SCULPT_HIDE_MASK); + RNA_def_property_ui_text(prop, "Show Mask", "Show mask as overlay on object"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update"); + prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL); RNA_def_property_ui_range(prop, 0.5, 40.0, 10, 2); RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)"); |