[Bf-blender-cvs] [602cfdeac7f] master: Transform: Add constraint intersection support

Germano Cavalcante noreply at git.blender.org
Tue Jun 30 14:00:37 CEST 2020


Commit: 602cfdeac7f2a6a7ec2c6af3b397f8782ea597ee
Author: Germano Cavalcante
Date:   Tue Jun 30 08:58:34 2020 -0300
Branches: master
https://developer.blender.org/rB602cfdeac7f2a6a7ec2c6af3b397f8782ea597ee

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.

===================================================================

M	source/blender/editors/transform/transform_mode_edge_slide.c

===================================================================

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;
     }



More information about the Bf-blender-cvs mailing list