Transform: Remove current 'Snap Base' in 'Set Snap Base' mode

The current `Snap Base` was available and displayed to allow snapping
to `Edge Perpendicular`.

However, the usefulness of perpendicular snapping in `Set Snap Base`
mode is questionable and can sometimes cause inconvenience.

Also, removing the current `Snap Base` indicator (the `X` drawing)
makes the intention of the operation more apparent.

Therefore, this commit removes both the indicator and the effect of the
current `Snap Base` in `Set Snap Base` mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/108776
This commit is contained in:
Germano Cavalcante
2023-06-09 14:12:15 +02:00
committed by Germano Cavalcante
parent 6ceb6fa27a
commit 5621154185
5 changed files with 22 additions and 27 deletions

View File

@@ -581,7 +581,7 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
return false;
}
if (value == TFM_MODAL_ADD_SNAP) {
if (!validSnap(t)) {
if (!(t->tsnap.status & SNAP_TARGET_FOUND)) {
return false;
}
}

View File

@@ -143,6 +143,8 @@ typedef enum {
/** Do not display Xform gizmo even though it is available. */
T_NO_GIZMO = 1 << 24,
T_DRAW_SNAP_SOURCE = 1 << 25,
} eTFlag;
ENUM_OPERATORS(eTFlag, T_NO_GIZMO);

View File

@@ -61,12 +61,9 @@ static void snapsource_end(TransInfo *t)
t->mouse.post = customdata->mouse_prev.post;
t->mouse.use_virtual_mval = customdata->mouse_prev.use_virtual_mval;
transform_gizmo_3d_model_from_constraint_and_mode_set(t);
MEM_freeN(customdata);
t->tsnap.snap_source_fn = NULL;
transform_gizmo_3d_model_from_constraint_and_mode_set(t);
tranform_snap_source_restore_context(t);
}
@@ -74,6 +71,9 @@ static void snapsource_confirm(TransInfo *t)
{
BLI_assert(t->modifiers & MOD_EDIT_SNAP_SOURCE);
getSnapPoint(t, t->tsnap.snap_source);
t->tsnap.snap_source_fn = NULL;
t->tsnap.status |= SNAP_SOURCE_FOUND;
t->flag |= T_DRAW_SNAP_SOURCE;
int mval[2];
#ifndef RESET_TRANSFORMATION
@@ -180,23 +180,12 @@ void transform_mode_snap_source_init(TransInfo *t, wmOperator *UNUSED(op))
t->mode_info = &TransMode_snapsource;
t->tsnap.target_operation = SCE_SNAP_TARGET_ALL;
if ((t->tsnap.status & SNAP_SOURCE_FOUND) == 0) {
if (t->tsnap.snap_source_fn) {
/* Calculate the current snap source for perpendicular snap. */
t->tsnap.snap_source_fn(t);
}
if ((t->tsnap.status & SNAP_SOURCE_FOUND) == 0) {
/* Fallback. */
copy_v3_v3(t->tsnap.snap_source, t->center_global);
t->tsnap.status |= SNAP_SOURCE_FOUND;
}
}
t->tsnap.status &= ~SNAP_SOURCE_FOUND;
if ((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) == 0) {
/* Initialize snap modes for geometry. */
t->tsnap.mode &= ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID);
t->tsnap.mode |= SCE_SNAP_MODE_GEOM & ~SCE_SNAP_MODE_FACE_NEAREST;
t->tsnap.mode |= SCE_SNAP_MODE_GEOM;
}
if (t->data_type == &TransConvertType_Mesh) {

View File

@@ -174,12 +174,10 @@ void drawSnapping(const bContext *C, TransInfo *t)
return;
}
const bool draw_source = (t->spacetype == SPACE_VIEW3D) &&
(t->tsnap.status & SNAP_SOURCE_FOUND) &&
((t->tsnap.mode & SCE_SNAP_MODE_EDGE_PERPENDICULAR) ||
t->tsnap.snap_source_fn == nullptr);
const bool draw_source = (t->tsnap.status & SNAP_SOURCE_FOUND) && (t->flag & T_DRAW_SNAP_SOURCE);
const bool draw_target = (t->tsnap.status & (SNAP_TARGET_FOUND | SNAP_MULTI_POINTS));
if (!(draw_source || validSnap(t))) {
if (!(draw_source || draw_target)) {
return;
}
@@ -767,6 +765,10 @@ static void initSnappingMode(TransInfo *t)
t->tsnap.mode &= ~(SCE_SNAP_MODE_FACE_RAYCAST | SCE_SNAP_MODE_FACE_NEAREST);
}
if (t->tsnap.mode & SCE_SNAP_MODE_EDGE_PERPENDICULAR) {
t->flag |= T_DRAW_SNAP_SOURCE;
}
setSnappingCallback(t);
if (t->spacetype == SPACE_VIEW3D) {
@@ -1388,7 +1390,7 @@ eSnapMode snapObjectsTransform(
snap_object_params.use_occlusion_test = true;
snap_object_params.use_backface_culling = (t->tsnap.flag & SCE_SNAP_BACKFACE_CULLING) != 0;
float *target = (t->tsnap.status & SNAP_SOURCE_FOUND) ? t->tsnap.snap_source : t->center_global;
float *prev_co = (t->tsnap.status & SNAP_SOURCE_FOUND) ? t->tsnap.snap_source : nullptr;
return ED_transform_snap_object_project_view3d(t->tsnap.object_context,
t->depsgraph,
t->region,
@@ -1397,7 +1399,7 @@ eSnapMode snapObjectsTransform(
&snap_object_params,
nullptr,
mval,
target,
prev_co,
dist_px,
r_loc,
r_no);

View File

@@ -3294,8 +3294,10 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
}
}
if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && ELEM(nullptr, prev_co, init_co)) {
/* No location to work with #SCE_SNAP_MODE_FACE_NEAREST. */
if (prev_co == nullptr) {
snap_to_flag &= ~(SCE_SNAP_MODE_EDGE_PERPENDICULAR | SCE_SNAP_MODE_FACE_NEAREST);
}
else if (init_co == nullptr) {
snap_to_flag &= ~SCE_SNAP_MODE_FACE_NEAREST;
}