[Bf-blender-cvs] [3a98227b97b] soc-2021-curves: Fix move segment behavior for selected splines

Dilith Jayakody noreply at git.blender.org
Sun Apr 3 17:34:20 CEST 2022


Commit: 3a98227b97b19fb4ff28a9707e11e77f95a851fb
Author: Dilith Jayakody
Date:   Sat Mar 26 00:46:06 2022 +0530
Branches: soc-2021-curves
https://developer.blender.org/rB3a98227b97b19fb4ff28a9707e11e77f95a851fb

Fix move segment behavior for selected splines

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

M	source/blender/editors/curve/editcurve_pen.c

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

diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c
index f102f5ff8db..c7b28bb54c2 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -1117,12 +1117,22 @@ static bool is_spline_nearby(ViewContext *vc,
 }
 
 /* Move segment to mouse pointer. */
-static void move_segment(ViewContext *vc, MoveSegmentData *seg_data, const wmEvent *event)
+static void move_segment(ViewContext *vc,
+                         MoveSegmentData *seg_data,
+                         const wmEvent *event,
+                         const bool free_toggle)
 {
   Nurb *nu = seg_data->nu;
   BezTriple *bezt1 = nu->bezt + seg_data->bezt_index;
   BezTriple *bezt2 = BKE_nurb_bezt_get_next(nu, bezt1);
 
+  if (free_toggle) {
+    bezt1->h1 = bezt1->h2 = bezt2->h1 = bezt2->h2 = HD_FREE;
+  }
+  else {
+    bezt1->h1 = bezt1->h2 = bezt2->h1 = bezt2->h2 = HD_ALIGN;
+  }
+
   const float t = max_ff(min_ff(seg_data->t, 0.9f), 0.1f);
 
   const float t_sq = t * t;
@@ -1511,23 +1521,27 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
   if (event->type == EVT_MODAL_MAP) {
     if (event->val == PEN_MODAL_FREE_ALIGN_TOGGLE) {
-      toggle_bezt_free_align_handles(nurbs);
       cpd->free_toggle = !cpd->free_toggle;
     }
-    else if (event->val == PEN_MODAL_LINK_HANDLES) {
-      cpd->link_handles = !cpd->link_handles;
-      if (cpd->link_handles) {
-        move_all_selected_points(&vc, event, cpd, nurbs, false);
+    if (cpd->msd == NULL) {
+      if (event->val == PEN_MODAL_FREE_ALIGN_TOGGLE) {
+        toggle_bezt_free_align_handles(nurbs);
+      }
+      else if (event->val == PEN_MODAL_LINK_HANDLES) {
+        cpd->link_handles = !cpd->link_handles;
+        if (cpd->link_handles) {
+          move_all_selected_points(&vc, event, cpd, nurbs, false);
+        }
+      }
+      else if (event->val == PEN_MODAL_MOVE_ENTIRE) {
+        cpd->move_entire = !cpd->move_entire;
+      }
+      else if (event->val == PEN_MODAL_MOVE_ADJACENT) {
+        cpd->move_adjacent = !cpd->move_adjacent;
+      }
+      else if (event->val == PEN_MODAL_LOCK_ANGLE) {
+        cpd->lock_angle = !cpd->lock_angle;
       }
-    }
-    else if (event->val == PEN_MODAL_MOVE_ENTIRE) {
-      cpd->move_entire = !cpd->move_entire;
-    }
-    else if (event->val == PEN_MODAL_MOVE_ADJACENT) {
-      cpd->move_adjacent = !cpd->move_adjacent;
-    }
-    else if (event->val == PEN_MODAL_LOCK_ANGLE) {
-      cpd->lock_angle = !cpd->lock_angle;
     }
   }
 
@@ -1544,7 +1558,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
     if (cpd->dragging) {
       if (cpd->spline_nearby && move_seg && cpd->msd != NULL) {
         MoveSegmentData *seg_data = cpd->msd;
-        move_segment(&vc, seg_data, event);
+        move_segment(&vc, seg_data, event, cpd->free_toggle);
         cpd->acted = true;
         if (seg_data->nu && seg_data->nu->type == CU_BEZIER) {
           BKE_nurb_handles_calc(seg_data->nu);



More information about the Bf-blender-cvs mailing list