diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-06-30 14:58:34 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-06-30 14:58:47 +0300 |
commit | 602cfdeac7f2a6a7ec2c6af3b397f8782ea597ee (patch) | |
tree | 0c4dd61f6f60a7ad477a2c20c114ad736bee728b | |
parent | 84901f2edaf1b00e242ca5d5c24c452ca9c5b922 (diff) |
Transform: Add constraint intersection support
Snap to faces and edges is now enhanced in the Edge Slide.
It works in the same way that it already works in the Vert Slide.
Basically it now snaps to the intersection of the slid edge with the
face plane or the edge line.
-rw-r--r-- | source/blender/editors/transform/transform_mode_edge_slide.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c index 76b45d7fd36..af803489d78 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_slide.c @@ -50,6 +50,7 @@ #include "BLT_translation.h" #include "transform.h" +#include "transform_constraints.h" #include "transform_convert.h" #include "transform_mode.h" #include "transform_snap.h" @@ -1291,6 +1292,7 @@ static void edge_slide_snap_apply(TransInfo *t, float *value) float perc = *value; int side_index; + float t_mid; if (slp->use_even == false) { const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); if (is_clamp) { @@ -1299,19 +1301,34 @@ static void edge_slide_snap_apply(TransInfo *t, float *value) else { side_index = sld_active->curr_side_unclamp; } - perc = line_point_factor_v3(snap_point, co_orig, co_dest[side_index]); - if (side_index) { - perc *= -1; - } } else { /* Could be pre-calculated. */ - float t_mid = line_point_factor_v3( - (float[3]){0.0f, 0.0f, 0.0f}, sv->dir_side[0], sv->dir_side[1]); + t_mid = line_point_factor_v3((float[3]){0.0f, 0.0f, 0.0f}, sv->dir_side[0], sv->dir_side[1]); float t_snap = line_point_factor_v3(snap_point, co_dest[0], co_dest[1]); side_index = t_snap >= t_mid; - perc = line_point_factor_v3(snap_point, co_orig, co_dest[side_index]); + } + + if (t->tsnap.snapElem & (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE)) { + float co_dir[3]; + sub_v3_v3v3(co_dir, co_dest[side_index], co_orig); + if (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) { + transform_constraint_snap_axis_to_edge(t, co_dir, dvec); + } + else { + transform_constraint_snap_axis_to_face(t, co_dir, dvec); + } + add_v3_v3v3(snap_point, co_orig, dvec); + } + + perc = line_point_factor_v3(snap_point, co_orig, co_dest[side_index]); + if (slp->use_even == false) { + if (side_index) { + perc *= -1; + } + } + else { if (!side_index) { perc = (1.0f - perc) * t_mid; } |