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>2021-11-13 03:57:44 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-11-13 03:57:44 +0300
commitdc378bf1a452563be4fdf89f91859c8c141e01d0 (patch)
treec06eea89c0ab34aa23e533e816f2d3f46c7f9584
parent60b8eb30bbb5bc0e0893a4dc5953fa01cc0c41c4 (diff)
parent0a6f428be7f0a8868306ef4771daf129671d3661 (diff)
Merge branch 'blender-v3.0-release'
-rw-r--r--source/blender/editors/transform/transform_snap_object.c153
1 files changed, 88 insertions, 65 deletions
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index f3b8ef98101..4a2ac806b2c 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -471,7 +471,7 @@ static void iter_snap_objects(SnapObjectContext *sctx,
continue;
}
- if (base->flag_legacy & BA_TRANSFORM_LOCKED_IN_PLACE) {
+ if ((snap_select == SNAP_ALL) || (base->flag_legacy & BA_TRANSFORM_LOCKED_IN_PLACE)) {
/* pass */
}
else if (base->flag_legacy & BA_SNAP_FIX_DEPS_FIASCO) {
@@ -479,13 +479,13 @@ static void iter_snap_objects(SnapObjectContext *sctx,
}
const bool is_object_active = (base == base_act);
- if (snap_select == SNAP_NOT_SELECTED) {
- if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) {
+ if (snap_select == SNAP_NOT_ACTIVE) {
+ if (is_object_active) {
continue;
}
}
- else if (snap_select == SNAP_NOT_ACTIVE) {
- if (is_object_active) {
+ else if (snap_select == SNAP_NOT_SELECTED) {
+ if ((base->flag & BASE_SELECTED) || (base->flag_legacy & BA_WAS_SEL)) {
continue;
}
}
@@ -1849,74 +1849,38 @@ static short snapArmature(SnapObjectContext *sctx,
mul_v4_m4v4(clip_planes_local[i], tobmat, sctx->runtime.clip_plane[i]);
}
+ const eSnapSelect snap_select = sctx->runtime.params->snap_select;
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) {
- /* skip hidden or moving (selected) bones */
- if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
- bool has_vert_snap = false;
-
- if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) {
- has_vert_snap = test_projected_vert_dist(&neasrest_precalc,
- clip_planes_local,
- sctx->runtime.clip_plane_len,
- is_persp,
- eBone->head,
- &dist_px_sq,
- r_loc);
- has_vert_snap |= test_projected_vert_dist(&neasrest_precalc,
- clip_planes_local,
- sctx->runtime.clip_plane_len,
- is_persp,
- eBone->tail,
- &dist_px_sq,
- r_loc);
-
- if (has_vert_snap) {
- retval = SCE_SNAP_MODE_VERTEX;
- }
- }
- if (!has_vert_snap && sctx->runtime.snap_to_flag & SCE_SNAP_MODE_EDGE) {
- if (test_projected_edge_dist(&neasrest_precalc,
- clip_planes_local,
- sctx->runtime.clip_plane_len,
- is_persp,
- eBone->head,
- eBone->tail,
- &dist_px_sq,
- r_loc)) {
- retval = SCE_SNAP_MODE_EDGE;
- }
- }
+ if (eBone->flag & BONE_HIDDEN_A) {
+ /* Skip hidden bones. */
+ continue;
+ }
+
+ const bool is_selected = (eBone->flag & (BONE_ROOTSEL | BONE_TIPSEL)) != 0;
+ if (is_selected && snap_select == SNAP_NOT_SELECTED) {
+ continue;
}
- }
- }
- }
- 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))) {
bool has_vert_snap = false;
- const float *head_vec = pchan->pose_head;
- const float *tail_vec = pchan->pose_tail;
if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) {
has_vert_snap = test_projected_vert_dist(&neasrest_precalc,
clip_planes_local,
sctx->runtime.clip_plane_len,
is_persp,
- head_vec,
+ eBone->head,
&dist_px_sq,
r_loc);
has_vert_snap |= test_projected_vert_dist(&neasrest_precalc,
clip_planes_local,
sctx->runtime.clip_plane_len,
is_persp,
- tail_vec,
+ eBone->tail,
+
&dist_px_sq,
r_loc);
@@ -1929,8 +1893,8 @@ static short snapArmature(SnapObjectContext *sctx,
clip_planes_local,
sctx->runtime.clip_plane_len,
is_persp,
- head_vec,
- tail_vec,
+ eBone->head,
+ eBone->tail,
&dist_px_sq,
r_loc)) {
retval = SCE_SNAP_MODE_EDGE;
@@ -1939,6 +1903,51 @@ 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))) {
+ continue;
+ }
+ bool has_vert_snap = false;
+ const float *head_vec = pchan->pose_head;
+ const float *tail_vec = pchan->pose_tail;
+
+ if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) {
+ has_vert_snap = test_projected_vert_dist(&neasrest_precalc,
+ clip_planes_local,
+ sctx->runtime.clip_plane_len,
+ is_persp,
+ head_vec,
+ &dist_px_sq,
+ r_loc);
+ has_vert_snap |= test_projected_vert_dist(&neasrest_precalc,
+ clip_planes_local,
+ sctx->runtime.clip_plane_len,
+ is_persp,
+ tail_vec,
+ &dist_px_sq,
+ r_loc);
+
+ if (has_vert_snap) {
+ retval = SCE_SNAP_MODE_VERTEX;
+ }
+ }
+ if (!has_vert_snap && sctx->runtime.snap_to_flag & SCE_SNAP_MODE_EDGE) {
+ if (test_projected_edge_dist(&neasrest_precalc,
+ clip_planes_local,
+ sctx->runtime.clip_plane_len,
+ is_persp,
+ head_vec,
+ tail_vec,
+ &dist_px_sq,
+ r_loc)) {
+ retval = SCE_SNAP_MODE_EDGE;
+ }
+ }
+ }
+ }
if (retval) {
*dist_px = sqrtf(dist_px_sq);
@@ -1980,8 +1989,7 @@ static short snapCurve(SnapObjectContext *sctx,
dist_squared_to_projected_aabb_precalc(
&neasrest_precalc, lpmat, sctx->runtime.win_size, sctx->runtime.mval);
- const bool use_obedit = (sctx->runtime.params->edit_mode_type == SNAP_GEOM_EDIT) &&
- BKE_object_is_in_editmode(ob_eval);
+ const bool use_obedit = BKE_object_is_in_editmode(ob_eval);
if (use_obedit == false) {
/* Test BoundBox */
@@ -2014,14 +2022,20 @@ static short snapCurve(SnapObjectContext *sctx,
}
bool is_persp = sctx->runtime.view_proj == VIEW_PROJ_PERSP;
+ bool skip_selected = sctx->runtime.params->snap_select == SNAP_NOT_SELECTED;
for (Nurb *nu = (use_obedit ? cu->editnurb->nurbs.first : cu->nurb.first); nu; nu = nu->next) {
for (int u = 0; u < nu->pntsu; u++) {
if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) {
if (use_obedit) {
if (nu->bezt) {
- /* don't snap to selected (moving) or hidden */
- if (nu->bezt[u].f2 & SELECT || nu->bezt[u].hide != 0) {
+ if (nu->bezt[u].hide) {
+ /* Skip hidden. */
+ continue;
+ }
+
+ bool is_selected = (nu->bezt[u].f2 & SELECT) != 0;
+ if (is_selected && skip_selected) {
continue;
}
has_snap |= test_projected_vert_dist(&neasrest_precalc,
@@ -2033,8 +2047,9 @@ static short snapCurve(SnapObjectContext *sctx,
r_loc);
/* Don't snap if handle is selected (moving),
* or if it is aligning to a moving handle. */
- if (!(nu->bezt[u].f1 & SELECT) &&
- !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) {
+ is_selected = (!(nu->bezt[u].f1 & SELECT) &&
+ !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) != 0;
+ if (!(is_selected && skip_selected)) {
has_snap |= test_projected_vert_dist(&neasrest_precalc,
clip_planes_local,
clip_plane_len,
@@ -2043,8 +2058,10 @@ static short snapCurve(SnapObjectContext *sctx,
&dist_px_sq,
r_loc);
}
- if (!(nu->bezt[u].f3 & SELECT) &&
- !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) {
+
+ is_selected = (!(nu->bezt[u].f3 & SELECT) &&
+ !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) != 0;
+ if (!(is_selected && skip_selected)) {
has_snap |= test_projected_vert_dist(&neasrest_precalc,
clip_planes_local,
clip_plane_len,
@@ -2055,10 +2072,16 @@ static short snapCurve(SnapObjectContext *sctx,
}
}
else {
- /* don't snap to selected (moving) or hidden */
- if (nu->bp[u].f1 & SELECT || nu->bp[u].hide != 0) {
+ if (nu->bp[u].hide) {
+ /* Skip hidden. */
+ continue;
+ }
+
+ bool is_selected = (nu->bp[u].f1 & SELECT) != 0;
+ if (is_selected && skip_selected) {
continue;
}
+
has_snap |= test_projected_vert_dist(&neasrest_precalc,
clip_planes_local,
clip_plane_len,