Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606>2020-03-12 19:51:39 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-04-02 19:00:51 +0300
commitb8d9b5e3315232bb157de43713ec2a54433cf9a6 (patch)
tree8f14c626a0742b1e4539966348d847c8ba314dda /source/blender/draw/intern/draw_manager_data.c
parent34465a7fb091664b07611353d99dcaa0862d4a4c (diff)
Sculpt: Delay Viewport Updates
In Blender 2.81 we update and draw all nodes inside the view planes. When navigating with a pen tablet after an operation that tags the whole mesh to update (like undo or inverting the mask), this introduces some lag as nodes are updating when they enter the view. The viewport is not fully responsive again until all nodes have entered the view after the operation. This commit delays nodes updates until the view navigation stops, so the viewport navigation is always fully responsive. This introduces some artifacts while navigating, so it can be disabled if you don't want to see them. I'm storing the update planes in the PBVH. This way I can add support for some tools to update in real-time only the nodes inside this plane while running the operator, like the mesh filter. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D6269
Diffstat (limited to 'source/blender/draw/intern/draw_manager_data.c')
-rw-r--r--source/blender/draw/intern/draw_manager_data.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 94a3e9e8343..1d1ca575b02 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -884,7 +884,11 @@ static float sculpt_debug_colors[9][4] = {
static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers)
{
+ if (!buffers) {
+ return;
+ }
+ /* Meh... use_mask is a bit misleading here. */
if (scd->use_mask && !GPU_pbvh_buffers_has_overlays(buffers)) {
return;
}
@@ -958,24 +962,52 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
const DRWContextState *drwctx = DRW_context_state_get();
RegionView3D *rv3d = drwctx->rv3d;
+ const bool navigating = rv3d && (rv3d->rflag & RV3D_NAVIGATING);
+
+ Paint *p = NULL;
+ if (drwctx->evil_C != NULL) {
+ p = BKE_paint_get_active_from_context(drwctx->evil_C);
+ }
/* Frustum planes to show only visible PBVH nodes. */
- float planes[6][4];
- drw_sculpt_get_frustum_planes(scd->ob, planes);
- PBVHFrustumPlanes frustum = {.planes = planes, .num_planes = 6};
+ float update_planes[6][4];
+ float draw_planes[6][4];
+ PBVHFrustumPlanes update_frustum;
+ PBVHFrustumPlanes draw_frustum;
+
+ if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) {
+ update_frustum.planes = update_planes;
+ update_frustum.num_planes = 6;
+ BKE_pbvh_get_frustum_planes(pbvh, &update_frustum);
+ if (!navigating) {
+ drw_sculpt_get_frustum_planes(scd->ob, update_planes);
+ update_frustum.planes = update_planes;
+ update_frustum.num_planes = 6;
+ BKE_pbvh_set_frustum_planes(pbvh, &update_frustum);
+ }
+ }
+ else {
+ drw_sculpt_get_frustum_planes(scd->ob, update_planes);
+ update_frustum.planes = update_planes;
+ update_frustum.num_planes = 6;
+ }
+
+ drw_sculpt_get_frustum_planes(scd->ob, draw_planes);
+ draw_frustum.planes = draw_planes;
+ draw_frustum.num_planes = 6;
/* Fast mode to show low poly multires while navigating. */
scd->fast_mode = false;
- if (drwctx->evil_C != NULL) {
- Paint *p = BKE_paint_get_active_from_context(drwctx->evil_C);
- if (p && (p->flags & PAINT_FAST_NAVIGATE)) {
- scd->fast_mode = rv3d && (rv3d->rflag & RV3D_NAVIGATING);
- }
+ if (p && (p->flags & PAINT_FAST_NAVIGATE)) {
+ scd->fast_mode = rv3d && (rv3d->rflag & RV3D_NAVIGATING);
}
/* Update draw buffers only for visible nodes while painting.
* But do update them otherwise so navigating stays smooth. */
- const bool update_only_visible = rv3d && (rv3d->rflag & RV3D_PAINTING);
+ bool update_only_visible = rv3d && !(rv3d->rflag & RV3D_PAINTING);
+ if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) {
+ update_only_visible = true;
+ }
Mesh *mesh = scd->ob->data;
BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg);
@@ -983,7 +1015,8 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol)
BKE_pbvh_draw_cb(pbvh,
use_vcol,
update_only_visible,
- &frustum,
+ &update_frustum,
+ &draw_frustum,
(void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb,
scd);