From 0335df9384eeca26716eb488b38ec68ef8602170 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Tue, 16 Nov 2021 10:54:50 -0300 Subject: Transform: better contextualize the status bar `Remove Last Snap Point` should only be displayed when there is a Snap Point to be removed. --- source/blender/editors/transform/transform.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f212c7f5747..ae4c3f02c46 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -601,8 +601,15 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) if ((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) == 0) { return false; } - if (!validSnap(t)) { - return false; + if (value == TFM_MODAL_ADD_SNAP) { + if (!validSnap(t)) { + return false; + } + } + else { + if (!t->tsnap.selectedPoint) { + return false; + } } break; } -- cgit v1.2.3 From bd3755385017ef2fbe37d456982830d49e7b712f Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Tue, 16 Nov 2021 13:09:02 -0300 Subject: Cleanup: better delimit member initialization The initialization of `t->around` and `t->view` was scattered and with duplicate code --- .../blender/editors/transform/transform_generics.c | 102 +++++++++++---------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 7ff95ebeeae..2fab22594e8 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -138,6 +138,49 @@ void resetTransRestrictions(TransInfo *t) t->flag &= ~T_ALL_RESTRICTIONS; } +static void *t_view_get(TransInfo *t) +{ + if (t->spacetype == SPACE_VIEW3D) { + View3D *v3d = t->area->spacedata.first; + return (void *)v3d; + } + else if (t->region) { + return (void *)&t->region->v2d; + } + return NULL; +} + +static int t_around_get(TransInfo *t) +{ + ScrArea *area = t->area; + if (t->spacetype == SPACE_VIEW3D) { + /* Bend always uses the cursor. */ + if (t->mode == TFM_BEND) { + return V3D_AROUND_CURSOR; + } + else { + return t->settings->transform_pivot_point; + } + } + else if (t->spacetype == SPACE_IMAGE) { + SpaceImage *sima = area->spacedata.first; + return sima->around; + } + else if (t->spacetype == SPACE_GRAPH) { + SpaceGraph *sipo = area->spacedata.first; + return sipo->around; + } + else if (t->spacetype == SPACE_CLIP) { + SpaceClip *sclip = area->spacedata.first; + return sclip->around; + } + else if (t->spacetype == SPACE_SEQ && t->region->regiontype == RGN_TYPE_PREVIEW) { + return SEQ_tool_settings_pivot_point_get(t->scene); + } + + return V3D_AROUND_CENTER_BOUNDS; +} + /** * Setup internal data, mouse, vectors * @@ -261,32 +304,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } if (t->spacetype == SPACE_VIEW3D) { - View3D *v3d = area->spacedata.first; bScreen *animscreen = ED_screen_animation_playing(CTX_wm_manager(C)); - t->view = v3d; t->animtimer = (animscreen) ? animscreen->animtimer : NULL; if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) { t->flag |= T_V3D_ALIGN; } - t->around = t->scene->toolsettings->transform_pivot_point; - - /* bend always uses the cursor */ - if (t->mode == TFM_BEND) { - t->around = V3D_AROUND_CURSOR; - } - - /* exceptional case */ - if (t->around == V3D_AROUND_LOCAL_ORIGINS) { - if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { - const bool use_island = transdata_check_local_islands(t, t->around); - - if ((t->obedit_type != -1) && !use_island) { - t->options |= CTX_NO_PET; - } - } - } if (object_mode & OB_MODE_ALL_PAINT) { Paint *p = BKE_paint_get_active_from_context(C); @@ -313,10 +337,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } else if (t->spacetype == SPACE_IMAGE) { SpaceImage *sima = area->spacedata.first; - /* XXX for now, get View2D from the active region. */ - t->view = ®ion->v2d; - t->around = sima->around; - if (ED_space_image_show_uvedit(sima, OBACT(t->view_layer))) { /* UV transform */ } @@ -331,21 +351,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } /* image not in uv edit, nor in mask mode, can happen for some tools */ } - else if (t->spacetype == SPACE_NODE) { - /* XXX for now, get View2D from the active region. */ - t->view = ®ion->v2d; - t->around = V3D_AROUND_CENTER_BOUNDS; - } - else if (t->spacetype == SPACE_GRAPH) { - SpaceGraph *sipo = area->spacedata.first; - t->view = ®ion->v2d; - t->around = sipo->around; - } else if (t->spacetype == SPACE_CLIP) { SpaceClip *sclip = area->spacedata.first; - t->view = ®ion->v2d; - t->around = sclip->around; - if (ED_space_clip_check_show_trackedit(sclip)) { t->options |= CTX_MOVIECLIP; } @@ -354,20 +361,21 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } else if (t->spacetype == SPACE_SEQ && region->regiontype == RGN_TYPE_PREVIEW) { - t->view = ®ion->v2d; - t->around = SEQ_tool_settings_pivot_point_get(t->scene); t->options |= CTX_SEQUENCER_IMAGE; } - else { - if (region) { - /* XXX: For now, get View2D from the active region. */ - t->view = ®ion->v2d; - /* XXX: For now, the center point is the midpoint of the data. */ - } - else { - t->view = NULL; + + t->view = t_view_get(t); + t->around = t_around_get(t); + + /* Exceptional case. */ + if (t->around == V3D_AROUND_LOCAL_ORIGINS) { + if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { + const bool use_island = transdata_check_local_islands(t, t->around); + + if ((t->obedit_type != -1) && !use_island) { + t->options |= CTX_NO_PET; + } } - t->around = V3D_AROUND_CENTER_BOUNDS; } bool t_values_set_is_array = false; -- cgit v1.2.3 From 1572c4d3d3317209bb846ca2d05cafeed06d1ead Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Tue, 16 Nov 2021 13:50:05 -0300 Subject: Fix T93011: Individual origins being used when pivot point is override There should be a special `t->around` for this case, but for now let's just avoid having the individual origins overlap. --- .../blender/editors/transform/transform_generics.c | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 2fab22594e8..4194fb2a0ad 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -152,6 +152,11 @@ static void *t_view_get(TransInfo *t) static int t_around_get(TransInfo *t) { + if (t->flag & T_OVERRIDE_CENTER) { + /* Avoid initialization of individual origins (#V3D_AROUND_LOCAL_ORIGINS). */ + return V3D_AROUND_CENTER_BOUNDS; + } + ScrArea *area = t->area; if (t->spacetype == SPACE_VIEW3D) { /* Bend always uses the cursor. */ @@ -364,6 +369,15 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->options |= CTX_SEQUENCER_IMAGE; } + setTransformViewAspect(t, t->aspect); + + if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && + RNA_property_is_set(op->ptr, prop)) { + RNA_property_float_get_array(op->ptr, prop, t->center_global); + mul_v3_v3(t->center_global, t->aspect); + t->flag |= T_OVERRIDE_CENTER; + } + t->view = t_view_get(t); t->around = t_around_get(t); @@ -664,15 +678,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->flag |= T_NO_CURSOR_WRAP; } - setTransformViewAspect(t, t->aspect); - - if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && - RNA_property_is_set(op->ptr, prop)) { - RNA_property_float_get_array(op->ptr, prop, t->center_global); - mul_v3_v3(t->center_global, t->aspect); - t->flag |= T_OVERRIDE_CENTER; - } - setTransformViewMatrices(t); initNumInput(&t->num); } -- cgit v1.2.3