[Bf-blender-cvs] [e040aea7bfa] blender-v3.3-release: Transform: Use more general approach to node view update

Germano Cavalcante noreply at git.blender.org
Fri Aug 26 20:34:58 CEST 2022


Commit: e040aea7bfa4c17905c27b5f8d9ffac54055cfc2
Author: Germano Cavalcante
Date:   Fri Aug 26 15:20:08 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBe040aea7bfa4c17905c27b5f8d9ffac54055cfc2

Transform: Use more general approach to node view update

With rBe6a557952ead, concerns were reported about missing updates when
the view is moved other than through the Edge Pan system.

Although the transform operator blocks navigation in general, it is
good to avoid these cases.

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

M	source/blender/editors/transform/transform_convert_node.c

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

diff --git a/source/blender/editors/transform/transform_convert_node.c b/source/blender/editors/transform/transform_convert_node.c
index 0712fd8f719..ed19789fdd8 100644
--- a/source/blender/editors/transform/transform_convert_node.c
+++ b/source/blender/editors/transform/transform_convert_node.c
@@ -27,6 +27,13 @@
 #include "transform_convert.h"
 #include "transform_snap.h"
 
+struct TransCustomDataNode {
+  View2DEdgePanData edgepan_data;
+
+  /* Compare if the view has changed so we can update with `transformViewUpdate`. */
+  rctf viewrect_prev;
+};
+
 /* -------------------------------------------------------------------- */
 /** \name Node Transform Creation
  * \{ */
@@ -95,15 +102,17 @@ static void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
   SpaceNode *snode = t->area->spacedata.first;
 
   /* Custom data to enable edge panning during the node transform */
-  View2DEdgePanData *customdata = MEM_callocN(sizeof(*customdata), __func__);
+  struct TransCustomDataNode *customdata = MEM_callocN(sizeof(*customdata), __func__);
   UI_view2d_edge_pan_init(t->context,
-                          customdata,
+                          &customdata->edgepan_data,
                           NODE_EDGE_PAN_INSIDE_PAD,
                           NODE_EDGE_PAN_OUTSIDE_PAD,
                           NODE_EDGE_PAN_SPEED_RAMP,
                           NODE_EDGE_PAN_MAX_SPEED,
                           NODE_EDGE_PAN_DELAY,
                           NODE_EDGE_PAN_ZOOM_INFLUENCE);
+  customdata->viewrect_prev = customdata->edgepan_data.initial_rect;
+
   t->custom.type.data = customdata;
   t->custom.type.use_free = true;
 
@@ -153,13 +162,12 @@ static void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
 static void flushTransNodes(TransInfo *t)
 {
   const float dpi_fac = UI_DPI_FAC;
-  float offset[2] = {0.0f, 0.0f};
 
-  View2DEdgePanData *customdata = (View2DEdgePanData *)t->custom.type.data;
+  struct TransCustomDataNode *customdata = (struct TransCustomDataNode *)t->custom.type.data;
 
   if (t->options & CTX_VIEW2D_EDGE_PAN) {
     if (t->state == TRANS_CANCEL) {
-      UI_view2d_edge_pan_cancel(t->context, customdata);
+      UI_view2d_edge_pan_cancel(t->context, &customdata->edgepan_data);
     }
     else {
       /* Edge panning functions expect window coordinates, mval is relative to region */
@@ -167,13 +175,17 @@ static void flushTransNodes(TransInfo *t)
           t->region->winrct.xmin + t->mval[0],
           t->region->winrct.ymin + t->mval[1],
       };
-      const rctf rect = t->region->v2d.cur;
-      UI_view2d_edge_pan_apply(t->context, customdata, xy);
-      if (!BLI_rctf_compare(&rect, &t->region->v2d.cur, FLT_EPSILON)) {
-        /* Additional offset due to change in view2D rect. */
-        BLI_rctf_transform_pt_v(&t->region->v2d.cur, &rect, offset, offset);
-        tranformViewUpdate(t);
-      }
+      UI_view2d_edge_pan_apply(t->context, &customdata->edgepan_data, xy);
+    }
+  }
+
+  float offset[2] = {0.0f, 0.0f};
+  if (t->state != TRANS_CANCEL) {
+    if (!BLI_rctf_compare(&customdata->viewrect_prev, &t->region->v2d.cur, FLT_EPSILON)) {
+      /* Additional offset due to change in view2D rect. */
+      BLI_rctf_transform_pt_v(&t->region->v2d.cur, &customdata->viewrect_prev, offset, offset);
+      tranformViewUpdate(t);
+      customdata->viewrect_prev = t->region->v2d.cur;
     }
   }



More information about the Bf-blender-cvs mailing list