diff options
Diffstat (limited to 'source/blender/editors/transform/transform_snap_object.c')
-rw-r--r-- | source/blender/editors/transform/transform_snap_object.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 6ad5962226a..ca6940040b2 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -477,7 +477,10 @@ static void iter_snap_objects(SnapObjectContext *sctx, } } else if (snap_select == SNAP_NOT_SELECTED) { - if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) { + if (is_object_active && !(base->object->mode & OB_MODE_OBJECT)) { + /* Pass. Consider the selection of elements being edited. */ + } + else if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) { continue; } } @@ -1818,6 +1821,7 @@ static short snapArmature(SnapObjectContext *sctx, const struct SnapObjectParams *params, Object *ob_eval, const float obmat[4][4], + bool is_object_active, /* read/write args */ float *dist_px, /* return args */ @@ -1838,9 +1842,10 @@ static short snapArmature(SnapObjectContext *sctx, dist_squared_to_projected_aabb_precalc( &neasrest_precalc, lpmat, sctx->runtime.win_size, sctx->runtime.mval); - bool use_obedit = ((bArmature *)ob_eval->data)->edbo != NULL; + bArmature *arm = ob_eval->data; + const bool is_editmode = arm->edbo != NULL; - if (use_obedit == false) { + if (is_editmode == false) { /* Test BoundBox */ BoundBox *bb = BKE_armature_boundbox_get(ob_eval); if (bb && !snap_bound_box_check_dist(bb->vec[0], @@ -1859,10 +1864,11 @@ static short snapArmature(SnapObjectContext *sctx, mul_v4_m4v4(clip_planes_local[i], tobmat, sctx->runtime.clip_plane[i]); } - const eSnapSelect snap_select = params->snap_select; - bool is_persp = sctx->runtime.view_proj == VIEW_PROJ_PERSP; + const bool is_posemode = is_object_active && (ob_eval->mode & OB_MODE_POSE); + const bool skip_selected = (is_editmode || is_posemode) && + (params->snap_select == SNAP_NOT_SELECTED); + const bool is_persp = sctx->runtime.view_proj == VIEW_PROJ_PERSP; - bArmature *arm = ob_eval->data; if (arm->edbo) { LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) { if (eBone->layer & arm->layer) { @@ -1872,7 +1878,7 @@ static short snapArmature(SnapObjectContext *sctx, } const bool is_selected = (eBone->flag & (BONE_ROOTSEL | BONE_TIPSEL)) != 0; - if (is_selected && snap_select == SNAP_NOT_SELECTED) { + if (is_selected && skip_selected) { continue; } bool has_vert_snap = false; @@ -1916,10 +1922,16 @@ static short snapArmature(SnapObjectContext *sctx, else if (ob_eval->pose && ob_eval->pose->chanbase.first) { LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_eval->pose->chanbase) { Bone *bone = pchan->bone; - /* skip hidden bones */ if (!bone || (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) { + /* Skip hidden bones. */ continue; } + + const bool is_selected = (bone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) != 0; + if (is_selected && skip_selected) { + continue; + } + bool has_vert_snap = false; const float *head_vec = pchan->pose_head; const float *tail_vec = pchan->pose_tail; @@ -2685,7 +2697,7 @@ static void snap_obj_fn(SnapObjectContext *sctx, const struct SnapObjectParams *params, Object *ob_eval, float obmat[4][4], - bool UNUSED(is_object_active), + bool is_object_active, void *data) { struct SnapObjUserData *dt = data; @@ -2721,8 +2733,15 @@ static void snap_obj_fn(SnapObjectContext *sctx, break; } case OB_ARMATURE: - retval = snapArmature( - sctx, params, ob_eval, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index); + retval = snapArmature(sctx, + params, + ob_eval, + obmat, + is_object_active, + dt->dist_px, + dt->r_loc, + dt->r_no, + dt->r_index); break; case OB_CURVE: retval = snapCurve( |