From 0e2487742ec333bf110738e95ad7d110942fc40a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 13 May 2013 14:17:58 +0000 Subject: Fix sculpt getting slower as you paint a longer stroke. Partial redraw was redrawing the whole area that was painted on from the start of the stroke, should only do the last part. --- source/blender/editors/sculpt_paint/sculpt.c | 31 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 6c57296ae3a..a7bc58daf54 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -500,11 +500,26 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob) /*** BVH Tree ***/ +static void sculpt_extend_redraw_rect_previous(Object *ob, rcti *rect) +{ + /* expand redraw rect with redraw rect from previous step to + * prevent partial-redraw issues caused by fast strokes. This is + * needed here (not in sculpt_flush_update) as it was before + * because redraw rectangle should be the same in both of + * optimized PBVH draw function and 3d view redraw (if not -- some + * mesh parts could disappear from screen (sergey) */ + SculptSession *ss = ob->sculpt; + + if (ss->cache) { + if (!BLI_rcti_is_empty(&ss->cache->previous_r)) + BLI_rcti_union(rect, &ss->cache->previous_r); + } +} + /* Get a screen-space rectangle of the modified area */ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, Object *ob, rcti *rect) { - SculptSession *ss; PBVH *pbvh = ob->sculpt->pbvh; float bb_min[3], bb_max[3]; @@ -524,17 +539,6 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, return 0; } - /* expand redraw rect with redraw rect from previous step to - * prevent partial-redraw issues caused by fast strokes. This is - * needed here (not in sculpt_flush_update) as it was before - * because redraw rectangle should be the same in both of - * optimized PBVH draw function and 3d view redraw (if not -- some - * mesh parts could disappear from screen (sergey) */ - ss = ob->sculpt; - if (ss->cache) { - if (!BLI_rcti_is_empty(&ss->cache->previous_r)) - BLI_rcti_union(rect, &ss->cache->previous_r); - } return 1; } @@ -546,6 +550,7 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, rcti rect; sculpt_get_redraw_rect(ar, rv3d, ob, &rect); + sculpt_extend_redraw_rect_previous(ob, &rect); paint_calc_redraw_planes(planes, ar, rv3d, ob, &rect); @@ -4223,6 +4228,8 @@ static void sculpt_flush_update(bContext *C) if (ss->cache) ss->cache->previous_r = r; + sculpt_extend_redraw_rect_previous(ob, &r); + r.xmin += ar->winrct.xmin + 1; r.xmax += ar->winrct.xmin - 1; r.ymin += ar->winrct.ymin + 1; -- cgit v1.2.3