[Bf-blender-cvs] [df4d6c22cfa] master: Transform: avoid excessive recalculation with 'TREDRAW_SOFT'

Germano Cavalcante noreply at git.blender.org
Mon Mar 28 19:23:31 CEST 2022


Commit: df4d6c22cfa266d52d178b79e6145a871761846d
Author: Germano Cavalcante
Date:   Mon Mar 28 13:54:59 2022 -0300
Branches: master
https://developer.blender.org/rBdf4d6c22cfa266d52d178b79e6145a871761846d

Transform: avoid excessive recalculation with 'TREDRAW_SOFT'

Contrary to the initial intention (in rB9916e0193c36), `TREDRAW_SOFT`
flag, when isolated, is not cleared in `transformApply` and therefore is
used in the `drawTransformApply` callback which basically recalculates
the `transformation` which finally clears the flag.

So remove the `drawTransformApply` callback so `transformApply` is not
called when unnecessary.

Differential Revision: https://developer.blender.org/D14430

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

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_generics.c

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 975f4370425..ec15b748c40 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -59,8 +59,6 @@
  * and being able to set it to zero is handy. */
 /* #define USE_NUM_NO_ZERO */
 
-static void drawTransformApply(const struct bContext *C, ARegion *region, void *arg);
-
 static void initSnapSpatial(TransInfo *t, float r_snap[2]);
 
 bool transdata_check_local_islands(TransInfo *t, short around)
@@ -1733,8 +1731,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
   initTransInfo(C, t, op, event);
 
   if (t->spacetype == SPACE_VIEW3D) {
-    t->draw_handle_apply = ED_region_draw_cb_activate(
-        t->region->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);
     t->draw_handle_view = ED_region_draw_cb_activate(
         t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
     t->draw_handle_pixel = ED_region_draw_cb_activate(
@@ -1925,18 +1921,19 @@ void transformApply(bContext *C, TransInfo *t)
 {
   t->context = C;
 
-  if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) {
+  if (t->redraw == TREDRAW_HARD) {
     selectConstraint(t);
     if (t->transform) {
       t->transform(t, t->mval); /* calls recalcData() */
-      viewRedrawForce(C, t);
     }
-    t->redraw = TREDRAW_NOTHING;
   }
-  else if (t->redraw & TREDRAW_SOFT) {
+
+  if (t->redraw & TREDRAW_SOFT) {
     viewRedrawForce(C, t);
   }
 
+  t->redraw = TREDRAW_NOTHING;
+
   /* If auto confirm is on, break after one pass */
   if (t->options & CTX_AUTOCONFIRM) {
     t->state = TRANS_CONFIRM;
@@ -1945,16 +1942,6 @@ void transformApply(bContext *C, TransInfo *t)
   t->context = NULL;
 }
 
-static void drawTransformApply(const bContext *C, ARegion *UNUSED(region), void *arg)
-{
-  TransInfo *t = arg;
-
-  if (t->redraw & TREDRAW_SOFT) {
-    t->redraw |= TREDRAW_HARD;
-    transformApply((bContext *)C, t);
-  }
-}
-
 int transformEnd(bContext *C, TransInfo *t)
 {
   int exit_code = OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 713cf487ac7..37478dfc187 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -188,8 +188,8 @@ typedef enum {
 /** #TransInfo.redraw */
 typedef enum {
   TREDRAW_NOTHING = 0,
-  TREDRAW_HARD = 1,
-  TREDRAW_SOFT = 2,
+  TREDRAW_SOFT = (1 << 0),
+  TREDRAW_HARD = (1 << 1) | TREDRAW_SOFT,
 } eRedrawFlag;
 
 /** #TransInfo.helpline */
@@ -663,7 +663,6 @@ typedef struct TransInfo {
   int mval[2];
   /** use for 3d view. */
   float zfac;
-  void *draw_handle_apply;
   void *draw_handle_view;
   void *draw_handle_pixel;
   void *draw_handle_cursor;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 3b9e2a982dc..975dbc2e986 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -718,9 +718,6 @@ void postTrans(bContext *C, TransInfo *t)
   if (t->draw_handle_view) {
     ED_region_draw_cb_exit(t->region->type, t->draw_handle_view);
   }
-  if (t->draw_handle_apply) {
-    ED_region_draw_cb_exit(t->region->type, t->draw_handle_apply);
-  }
   if (t->draw_handle_pixel) {
     ED_region_draw_cb_exit(t->region->type, t->draw_handle_pixel);
   }



More information about the Bf-blender-cvs mailing list