diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2022-03-28 19:54:59 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-03-28 20:18:56 +0300 |
commit | df4d6c22cfa266d52d178b79e6145a871761846d (patch) | |
tree | 1e4180a7af3fd5792abdd439a62d166a9c7600d1 | |
parent | 854af0cd09f194fadb688e899916cdc91e931623 (diff) |
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
-rw-r--r-- | source/blender/editors/transform/transform.c | 23 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 3 |
3 files changed, 7 insertions, 24 deletions
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); } |