Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-02-12 22:13:28 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-02-22 03:47:24 +0300
commit459d9c1e3d88361c26479c88b75b83451e4d4794 (patch)
tree0e27bcff418d8eb3c4e8cada8752205b5d532142 /source/blender/editors
parentec5bbebf3ee165869eba5e980d22f261d4d06f68 (diff)
Fix (unreported): Issues with 'SNAP_NOT_SELECTED' for pose and edit modes
This is a regression partially introduced in rB0a6f428be7f0. Bones being transformed into edit mode were snapping to themselves. And the bones of the pose mode weren't even snapping. (Curious that this was not reported).
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/transform/transform_snap.c5
-rw-r--r--source/blender/editors/transform/transform_snap_object.c41
2 files changed, 34 insertions, 12 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 40be8e6e641..dd18e8d4656 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -644,13 +644,16 @@ static short snap_select_type_get(TransInfo *t)
else if (!t->tsnap.snap_self) {
r_snap_select = SNAP_NOT_ACTIVE;
}
+ else {
+ r_snap_select = SNAP_NOT_SELECTED;
+ }
}
else if ((obedit_type == -1) && base_act && base_act->object &&
(base_act->object->mode & OB_MODE_PARTICLE_EDIT)) {
/* Particles edit mode. */
}
else if (obedit_type == -1) {
- /* Object mode */
+ /* Object or pose mode. */
r_snap_select = SNAP_NOT_SELECTED;
}
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 9dc8b6cf69d..dc9315b6d5a 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -491,7 +491,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;
}
}
@@ -1832,6 +1835,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 */
@@ -1852,9 +1856,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],
@@ -1873,10 +1878,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) {
@@ -1886,7 +1892,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;
@@ -1930,10 +1936,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;
@@ -2699,7 +2711,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;
@@ -2735,8 +2747,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(