[Bf-blender-cvs] [1ca105ebdcc] master: Sculpt: disable workbench anti-aliasing during stroke painting

Brecht Van Lommel noreply at git.blender.org
Sun Sep 29 16:24:04 CEST 2019


Commit: 1ca105ebdccc386aa0a49e5d323be65123881243
Author: Brecht Van Lommel
Date:   Sat Sep 28 23:37:16 2019 +0200
Branches: master
https://developer.blender.org/rB1ca105ebdccc386aa0a49e5d323be65123881243

Sculpt: disable workbench anti-aliasing during stroke painting

This mostly happens automatically anyway since there is usually not enough
time left over for it. But when it does it happen it breaks partial redraw,
and may also have a negative impact on responsiveness.

Ref T70295

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/draw/engines/workbench/workbench_effect_taa.c
M	source/blender/draw/engines/workbench/workbench_private.h
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/makesdna/DNA_view3d_types.h

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3b957b24c29..609fa9459ee 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7152,6 +7152,8 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
         rv3d->render_engine = NULL;
         rv3d->sms = NULL;
         rv3d->smooth_timer = NULL;
+
+        rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
       }
     }
   }
diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c
index 06442060623..772d859392b 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_taa.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c
@@ -139,7 +139,7 @@ void workbench_taa_engine_init(WORKBENCH_Data *vedata)
 
   /* reset complete drawing when navigating. */
   if (effect_info->jitter_index != 0) {
-    if (rv3d && rv3d->rflag & RV3D_NAVIGATING) {
+    if (rv3d && rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING)) {
       effect_info->jitter_index = 0;
     }
   }
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index f51da581827..252be3570d7 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -75,7 +75,8 @@
         V3D_SHADING_VERTEX_COLOR))
 
 #define IS_NAVIGATING(wpd) \
-  ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING))
+  ((DRW_context_state_get()->rv3d) && \
+   (DRW_context_state_get()->rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING)))
 
 #define OBJECT_OUTLINE_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_OBJECT_OUTLINE)
 #define OBJECT_ID_PASS_ENABLED(wpd) (OBJECT_OUTLINE_ENABLED(wpd) || CURVATURE_ENABLED(wpd))
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 137d7bd9d6c..d8be345cc84 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -862,6 +862,7 @@ PaintStroke *paint_stroke_new(bContext *C,
   UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
   Paint *p = BKE_paint_get_active_from_context(C);
   Brush *br = stroke->brush = BKE_paint_brush(p);
+  RegionView3D *rv3d = CTX_wm_region_view3d(C);
   float zoomx, zoomy;
 
   ED_view3d_viewcontext_init(C, &stroke->vc, depsgraph);
@@ -887,6 +888,10 @@ PaintStroke *paint_stroke_new(bContext *C,
   ups->overlap_factor = 1.0;
   ups->stroke_active = true;
 
+  if (rv3d) {
+    rv3d->rflag |= RV3D_PAINTING;
+  }
+
   zero_v3(ups->average_stroke_accum);
   ups->average_stroke_counter = 0;
 
@@ -903,12 +908,17 @@ PaintStroke *paint_stroke_new(bContext *C,
 
 void paint_stroke_free(bContext *C, wmOperator *op)
 {
+  RegionView3D *rv3d = CTX_wm_region_view3d(C);
   PaintStroke *stroke = op->customdata;
   UnifiedPaintSettings *ups = stroke->ups;
 
   ups->draw_anchored = false;
   ups->stroke_active = false;
 
+  if (rv3d) {
+    rv3d->rflag &= ~RV3D_PAINTING;
+  }
+
   if (stroke->timer) {
     WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer);
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 51ca0ec3403..9e5660fc6fe 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -6741,6 +6741,12 @@ static void sculpt_flush_update_step(bContext *C)
   ARegion *ar = CTX_wm_region(C);
   MultiresModifierData *mmd = ss->multires;
   View3D *v3d = CTX_wm_view3d(C);
+  RegionView3D *rv3d = CTX_wm_region_view3d(C);
+
+  if (rv3d) {
+    /* Mark for faster 3D viewport redraws. */
+    rv3d->rflag |= RV3D_PAINTING;
+  }
 
   if (mmd != NULL) {
     multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED);
@@ -6791,10 +6797,15 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob)
    * expensive depsgraph tag to update geometry. */
   wmWindowManager *wm = CTX_wm_manager(C);
   View3D *current_v3d = CTX_wm_view3d(C);
+  RegionView3D *rv3d = CTX_wm_region_view3d(C);
   SculptSession *ss = ob->sculpt;
   Mesh *mesh = ob->data;
   bool need_tag = (mesh->id.us > 1); /* Always needed for linked duplicates. */
 
+  if (rv3d) {
+    rv3d->rflag &= ~RV3D_PAINTING;
+  }
+
   for (wmWindow *win = wm->windows.first; win; win = win->next) {
     bScreen *screen = WM_window_get_active_screen(win);
     for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -6804,6 +6815,15 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob)
         if (v3d != current_v3d) {
           need_tag |= !BKE_sculptsession_use_pbvh_draw(ob, v3d);
         }
+
+        /* Tag all 3D viewports for redraw now that we are done. Others
+         * viewports did not get a full redraw, and anti-aliasing for the
+         * current viewport was deactivated. */
+        for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+          if (ar->regiontype == RGN_TYPE_WINDOW) {
+            ED_region_tag_redraw(ar);
+          }
+        }
       }
     }
   }
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 10c61446d9d..283c361cc56 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -351,6 +351,7 @@ typedef struct View3D {
 #define RV3D_CLIPPING (1 << 2)
 #define RV3D_NAVIGATING (1 << 3)
 #define RV3D_GPULIGHT_UPDATE (1 << 4)
+#define RV3D_PAINTING (1 << 5)
 /*#define RV3D_IS_GAME_ENGINE       (1 << 5) */ /* UNUSED */
 /**
  * Disable zbuffer offset, skip calls to #ED_view3d_polygon_offset.



More information about the Bf-blender-cvs mailing list