diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-12-16 19:45:27 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-12-16 19:45:35 +0300 |
commit | 9765ddf4eb1ea0092b96624ee78b8852b5ebe1d1 (patch) | |
tree | 9361226ca473cc9c6f6e2e147fd635b6cd182cef /source/blender | |
parent | 0624fad0f3ffa1167c8d807d991aa5788236925b (diff) |
Fix T94109: 3d cursor crash when using shortcut
Operator was erroneously starting edge_slide operation.
Revert part of the changes in rB3fab16fe8eb4 as obedit_type was being
confused with object_mode.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 17 |
2 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index c2ff095904d..43d894d60f2 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -214,7 +214,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->flag = 0; - if (obact && ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) { + if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) && + ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) { t->obedit_type = obact->type; } else { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index a09078a8222..9cdec357afd 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -499,7 +499,9 @@ void applySnapping(TransInfo *t, float *vec) /* Time base quirky code to go around find-nearest slowness. */ /* TODO: add exception for object mode, no need to slow it down then. */ if (current - t->tsnap.last >= 0.01) { - t->tsnap.calcSnap(t, vec); + if (t->tsnap.calcSnap) { + t->tsnap.calcSnap(t, vec); + } if (t->tsnap.targetSnap) { t->tsnap.targetSnap(t); } @@ -783,8 +785,15 @@ static void setSnappingCallback(TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { t->tsnap.calcSnap = snap_calc_view3d_fn; } - else if (t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH) { - t->tsnap.calcSnap = snap_calc_uv_fn; + else if (t->spacetype == SPACE_IMAGE) { + SpaceImage *sima = t->area->spacedata.first; + Object *obact = t->view_layer->basact ? t->view_layer->basact->object : NULL; + + const bool is_uv_editor = sima->mode == SI_MODE_UV; + const bool has_edit_object = obact && BKE_object_is_in_editmode(obact); + if (is_uv_editor && has_edit_object) { + t->tsnap.calcSnap = snap_calc_uv_fn; + } } else if (t->spacetype == SPACE_NODE) { t->tsnap.calcSnap = snap_calc_node_fn; @@ -959,7 +968,7 @@ static void snap_calc_view3d_fn(TransInfo *t, float *UNUSED(vec)) static void snap_calc_uv_fn(TransInfo *t, float *UNUSED(vec)) { - BLI_assert(t->spacetype == SPACE_IMAGE && t->obedit_type == OB_MESH); + BLI_assert(t->spacetype == SPACE_IMAGE); if (t->tsnap.mode & SCE_SNAP_MODE_VERTEX) { float co[2]; |