diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-08-06 17:44:15 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-08-06 17:44:26 +0300 |
commit | 3fab16fe8eb4a99607e00d5716ba88bf24020354 (patch) | |
tree | a14e541cbda24671ec882b2a90db32427a978bb8 /source/blender | |
parent | 4f64fa4f8628aa514ec1f14d798b2f406a3bf6ef (diff) |
Fix T90477: Cursor vertex snapping not working in UV editor
`t->obedit_type` is read to indicate if we are in uv edit mode.
Also fixes a crash introduced in {rBdd14ea18190ff27082009f73a556569a43377a71}.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_convert.c | 14 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 29 |
5 files changed, 20 insertions, 31 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 96b84bd2a35..4069a72a8fc 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -78,6 +78,9 @@ static void initSnapSpatial(TransInfo *t, float r_snap[2]); bool transdata_check_local_islands(TransInfo *t, short around) { + if (t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) { + return false; + } return ((around == V3D_AROUND_LOCAL_ORIGINS) && (ELEM(t->obedit_type, OB_MESH, OB_GPENCIL))); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 1a61a594f37..1fa123e8507 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -582,7 +582,7 @@ typedef struct TransInfo { short around; /** space-type where transforming is. */ char spacetype; - /** Avoid looking inside #TransDataContainer.obedit. */ + /** Type of active object being edited. */ short obedit_type; /** translation, to show for widget. */ diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index e77fedfe143..3f730956dd0 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -1072,7 +1072,8 @@ static void init_proportional_edit(TransInfo *t) else if (convert_type == TC_MESH_UV && t->flag & T_PROP_CONNECTED) { /* Already calculated by uv_set_connectivity_distance. */ } - else if (convert_type == TC_CURVE_VERTS && t->obedit_type == OB_CURVE) { + else if (convert_type == TC_CURVE_VERTS) { + BLI_assert(t->obedit_type == OB_CURVE); set_prop_dist(t, false); } else { @@ -1371,7 +1372,6 @@ void createTransData(bContext *C, TransInfo *t) switch (t->data_type) { case TC_ACTION_DATA: - t->obedit_type = -1; createTransActionData(C, t); break; case TC_POSE: @@ -1394,7 +1394,6 @@ void createTransData(bContext *C, TransInfo *t) createTransCurveVerts(t); break; case TC_GRAPH_EDIT_DATA: - t->obedit_type = -1; createTransGraphEditData(C, t); break; case TC_GPENCIL: @@ -1404,9 +1403,6 @@ void createTransData(bContext *C, TransInfo *t) createTransLatticeVerts(t); break; case TC_MASKING_DATA: - if (t->spacetype == SPACE_CLIP) { - t->obedit_type = -1; - } createTransMaskingData(C, t); break; case TC_MBALL_VERTS: @@ -1425,11 +1421,9 @@ void createTransData(bContext *C, TransInfo *t) createTransUVs(C, t); break; case TC_NLA_DATA: - t->obedit_type = -1; createTransNlaData(C, t); break; case TC_NODE_DATA: - t->obedit_type = -1; createTransNodeData(t); break; case TC_OBJECT: @@ -1473,12 +1467,10 @@ void createTransData(bContext *C, TransInfo *t) createTransSculpt(C, t); break; case TC_SEQ_DATA: - t->obedit_type = -1; t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point transform. */ createTransSeqData(t); break; case TC_TRACKING_DATA: - t->obedit_type = -1; createTransTrackingData(C, t); break; case TC_NONE: @@ -1492,8 +1484,6 @@ void createTransData(bContext *C, TransInfo *t) countAndCleanTransDataContainer(t); init_proportional_edit(t); - - BLI_assert((!(t->flag & T_EDIT)) == (!(t->obedit_type != -1))); } /** \} */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e89ab6729d2..be8e551a1e8 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -152,8 +152,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->flag = 0; - if (obact && !(t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) && - ELEM(object_mode, OB_MODE_EDIT, OB_MODE_EDIT_GPENCIL)) { + if (obact && 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 2619fdf3403..656a1e5d9c7 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -575,7 +575,7 @@ static void initSnappingMode(TransInfo *t) { ToolSettings *ts = t->settings; /* All obedit types will match. */ - const int obedit_type = t->data_container->obedit ? t->data_container->obedit->type : -1; + const int obedit_type = t->obedit_type; ViewLayer *view_layer = t->view_layer; Base *base_act = view_layer->basact; @@ -609,15 +609,22 @@ static void initSnappingMode(TransInfo *t) } } - if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && - (t->options & CTX_CAMERA) == 0) { + if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE) && !(t->options & CTX_CAMERA)) { /* Only 3D view or UV. */ /* Not with camera selected in camera view. */ setSnappingCallback(t); - if ((obedit_type != -1) && - ELEM(obedit_type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) { + if (t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR | CTX_OBMODE_XFORM_OBDATA)) { + /* In "Edit Strokes" mode, + * snap tool can perform snap to selected or active objects (see T49632) + * TODO: perform self snap in gpencil_strokes. + * + * When we're moving the origins, allow snapping onto our own geometry (see T69132). */ + t->tsnap.modeSelect = SNAP_ALL; + } + else if ((obedit_type != -1) && + ELEM(obedit_type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) { /* Edit mode */ /* Temporary limited to edit mode meshes, armature, curves, metaballs. */ @@ -636,17 +643,7 @@ static void initSnappingMode(TransInfo *t) } else if (obedit_type == -1) { /* Object mode */ - if (t->options & (CTX_GPENCIL_STROKES | CTX_CURSOR | CTX_OBMODE_XFORM_OBDATA)) { - /* In "Edit Strokes" mode, - * snap tool can perform snap to selected or active objects (see T49632) - * TODO: perform self snap in gpencil_strokes. - * - * When we're moving the origins, allow snapping onto our own geometry (see T69132). */ - t->tsnap.modeSelect = SNAP_ALL; - } - else { - t->tsnap.modeSelect = SNAP_NOT_SELECTED; - } + t->tsnap.modeSelect = SNAP_NOT_SELECTED; } else { /* Increment if snap is not possible */ |