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
This commit is contained in:
Germano Cavalcante 2022-03-28 13:54:59 -03:00
parent 854af0cd09
commit df4d6c22cf
3 changed files with 7 additions and 24 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}