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}.
This commit is contained in:
Germano Cavalcante 2021-08-06 11:44:15 -03:00
parent 4f64fa4f86
commit 3fab16fe8e
Notes: blender-bot 2023-10-12 12:49:04 +02:00
Referenced by commit 9765ddf4eb, Fix T94109: 3d cursor crash when using shortcut
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #94109, 3d cursor crash when using shortcut
Referenced by issue #90477, Cursor vertex snapping not working in UV editor
5 changed files with 20 additions and 31 deletions

View File

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

View File

@ -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. */

View File

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

View File

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

View File

@ -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 */