Fix sculpt getting slower as you paint a longer stroke. Partial redraw was
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 13 May 2013 14:17:58 +0000 (14:17 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 13 May 2013 14:17:58 +0000 (14:17 +0000)
redrawing the whole area that was painted on from the start of the stroke,
should only do the last part.

source/blender/editors/screen/area.c
source/blender/editors/sculpt_paint/sculpt.c

index 749fa40a76c68989d7df631abec6ad142dcd6545..3009cd0e758dea802fc81b5a3f74bf0e689d77fc 100644 (file)
@@ -458,7 +458,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
 #if 0
        glEnable(GL_BLEND);
        glColor4f(drand48(), drand48(), drand48(), 0.1f);
-       glRectf(ar->drawrct.xmin - 1, ar->drawrct.ymin - 1, ar->drawrct.xmax + 1, ar->drawrct.ymax + 1);
+       glRectf(ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
+                       ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin);
        glDisable(GL_BLEND);
 #endif
 
index 6c57296ae3a5f71ea88affba99929d5787bd9f34..a7bc58daf546a7b6d86ee99e966b3f25bf209014 100644 (file)
@@ -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;