diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-31 15:04:16 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-31 18:17:03 +0300 |
commit | 692891f69ea42af0ba890f5f92cbd1a3260442c9 (patch) | |
tree | 1aeb9469b7a2b26a8a25a09c6045faa51d34944b /source/blender/blenkernel | |
parent | 9899999e944c0d954dbe5a7aa96c8e1680e7b3f8 (diff) |
Fix sculpt mode drawing with modifiers still being wrong in some cases
Centralize logic for when to use the PBVH for drawing, fix missing tests in
mask drawing, fix missing tests for multiple windows, only do more expensive
update for all viewports at end of the stroke.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 20 |
2 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 56c92b731b7..b92ce8a001f 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -54,6 +54,7 @@ struct SubdivCCG; struct Tex; struct ToolSettings; struct UnifiedPaintSettings; +struct View3D; struct ViewLayer; struct bContext; struct bToolRef; @@ -250,9 +251,6 @@ typedef struct SculptSession { float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */ float (*deform_imats)[3][3]; /* crazyspace deformation matrices */ - /* Partial redraw */ - bool partial_redraw; - /* Used to cache the render of the active texture */ unsigned int texcache_side, *texcache, texcache_actual; struct ImagePool *tex_pool; @@ -308,6 +306,8 @@ struct PBVH *BKE_sculpt_object_pbvh_ensure(struct Depsgraph *depsgraph, struct O void BKE_sculpt_bvh_update_from_ccg(struct PBVH *pbvh, struct SubdivCCG *subdiv_ccg); +bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d); + enum { SCULPT_MASK_LAYER_CALC_VERT = (1 << 0), SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1), diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 5849d691b03..4de425acfc0 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1512,3 +1512,23 @@ void BKE_sculpt_bvh_update_from_ccg(PBVH *pbvh, SubdivCCG *subdiv_ccg) subdiv_ccg->grid_flag_mats, subdiv_ccg->grid_hidden); } + +/* Test if PBVH can be used directly for drawing, which is faster than + * drawing the mesh and all updates that come with it. */ +bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const View3D *v3d) +{ + SculptSession *ss = ob->sculpt; + if (ss == NULL || ss->pbvh == NULL || ss->mode_type != OB_MODE_SCULPT) { + return false; + } + + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + /* Regular mesh only draws from PBVH without modifiers and shape keys. */ + const bool full_shading = (v3d && (v3d->shading.type > OB_SOLID)); + return !(ss->kb || ss->modifiers_active || full_shading); + } + else { + /* Multires and dyntopo always draw directly from the PBVH. */ + return true; + } +} |