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:
parent
fb7510087f
commit
ec00d218c9
Notes:
blender-bot
2023-02-14 04:46:12 +01:00
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93 Referenced by issue #90477, Cursor vertex snapping not working in UV editor
|
@ -78,7 +78,10 @@ static void initSnapSpatial(TransInfo *t, float r_snap[3]);
|
|||
|
||||
bool transdata_check_local_islands(TransInfo *t, short around)
|
||||
{
|
||||
return ((around == V3D_AROUND_LOCAL_ORIGINS) && ((ELEM(t->obedit_type, OB_MESH, OB_GPENCIL))));
|
||||
if (t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) {
|
||||
return false;
|
||||
}
|
||||
return ((around == V3D_AROUND_LOCAL_ORIGINS) && (ELEM(t->obedit_type, OB_MESH, OB_GPENCIL)));
|
||||
}
|
||||
|
||||
/* ************************** SPACE DEPENDENT CODE **************************** */
|
||||
|
|
|
@ -577,7 +577,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. */
|
||||
|
|
|
@ -1066,7 +1066,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 {
|
||||
|
@ -1366,7 +1367,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:
|
||||
|
@ -1389,7 +1389,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:
|
||||
|
@ -1399,9 +1398,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:
|
||||
|
@ -1420,11 +1416,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:
|
||||
|
@ -1468,12 +1462,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:
|
||||
|
@ -1487,8 +1479,6 @@ void createTransData(bContext *C, TransInfo *t)
|
|||
countAndCleanTransDataContainer(t);
|
||||
|
||||
init_proportional_edit(t);
|
||||
|
||||
BLI_assert((!(t->flag & T_EDIT)) == (!(t->obedit_type != -1)));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -540,7 +540,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;
|
||||
|
||||
|
@ -571,15 +571,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. */
|
||||
|
||||
|
@ -598,17 +605,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 */
|
||||
|
|
Loading…
Reference in New Issue