[Bf-blender-cvs] [c3a6ec1b08d] soc-2021-curves: Fixed link handles snapping bug
Dilith Jayakody
noreply at git.blender.org
Sat Jan 29 16:22:17 CET 2022
Commit: c3a6ec1b08d02284ecb3fb69732961747b75e3bf
Author: Dilith Jayakody
Date: Tue Jan 25 21:57:55 2022 +0530
Branches: soc-2021-curves
https://developer.blender.org/rBc3a6ec1b08d02284ecb3fb69732961747b75e3bf
Fixed link handles snapping bug
===================================================================
M release/scripts/addons
M source/blender/editors/curve/editcurve_pen.c
===================================================================
diff --git a/release/scripts/addons b/release/scripts/addons
index 5a24fe5c17c..7f5d0ab6beb 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 5a24fe5c17c60e065acab25987730c9f2c737bdf
+Subproject commit 7f5d0ab6beb397051c55c737f601d33bbdbc239d
diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c
index b1b9a1450dc..8cee1e1b71a 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -238,6 +238,7 @@ static void get_displacement_to_avg_selected_bezt(const ListBase *nurbs,
/* Move the handle of the newly added #BezTriple to mouse. */
static void move_new_bezt_handles_to_mouse(const wmEvent *event,
const ViewContext *vc,
+ const bool link_handles,
ListBase *nurbs)
{
float change[2];
@@ -265,16 +266,26 @@ static void move_new_bezt_handles_to_mouse(const wmEvent *event,
copy_v3_v3(bezt->vec[2], location);
if (bezt->h2 != HD_FREE) {
- negate_v3(location);
- madd_v3_v3v3fl(bezt->vec[0], location, bezt->vec[1], 2.0f);
+ float handle_vec[3];
+ sub_v3_v3v3(handle_vec, bezt->vec[1], location);
+ if (!link_handles) {
+ float handle_len = len_v3v3(bezt->vec[0], bezt->vec[1]);
+ normalize_v3_length(handle_vec, handle_len);
+ }
+ add_v3_v3v3(bezt->vec[0], bezt->vec[1], handle_vec);
}
}
else {
copy_v3_v3(bezt->vec[0], location);
if (bezt->h1 != HD_FREE) {
- negate_v3(location);
- madd_v3_v3v3fl(bezt->vec[2], location, bezt->vec[1], 2.0f);
+ float handle_vec[3];
+ sub_v3_v3v3(handle_vec, bezt->vec[1], location);
+ if (!link_handles) {
+ float handle_len = len_v3v3(bezt->vec[2], bezt->vec[1]);
+ normalize_v3_length(handle_vec, handle_len);
+ }
+ add_v3_v3v3(bezt->vec[2], bezt->vec[1], handle_vec);
}
}
FOREACH_SELECTED_BEZT_END
@@ -1641,8 +1652,14 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
cpd->free_toggle_pressed = is_extra_key_pressed(event, free_toggle);
if (!cpd->link_handles_pressed && is_extra_key_pressed(event, link_handles)) {
- move_all_selected_points(nurbs, false, cpd, event, &vc);
cpd->link_handles = !cpd->link_handles;
+ if (cpd->link_handles) {
+ move_all_selected_points(nurbs, false, cpd, event, &vc);
+ }
+ else {
+ // Recalculate offset after link handles is turned off
+ cpd->offset_calc = false;
+ }
}
cpd->link_handles_pressed = is_extra_key_pressed(event, link_handles);
const bool move_entire_pressed = is_extra_key_pressed(event, move_entire);
@@ -1670,7 +1687,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
move_all_selected_points(nurbs, move_entire_pressed, cpd, event, &vc);
}
else {
- move_new_bezt_handles_to_mouse(event, &vc, nurbs);
+ move_new_bezt_handles_to_mouse(event, &vc, cpd->link_handles, nurbs);
}
cpd->acted = true;
}
@@ -1728,22 +1745,19 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
"new_point" to true so that the new point's handles can be controlled. */
if (insert_point && !move_seg) {
insert_point_to_segment(event, vc.obedit->data, &nu, sel_dist_mul, &vc);
- cpd->new_point = true;
- cpd->acted = true;
+ cpd->new_point = cpd->acted = cpd->link_handles = true;
}
}
else if (new_spline) {
ED_curve_deselect_all(((Curve *)(vc.obedit->data))->editnurb);
extrude_points_from_selected_vertices(
&vc, obedit, event, extrude_center, extrude_handle);
- cpd->new_point = true;
- cpd->acted = true;
+ cpd->new_point = cpd->acted = cpd->link_handles = true;
}
else if (extrude_point) {
extrude_points_from_selected_vertices(
&vc, obedit, event, extrude_center, extrude_handle);
- cpd->new_point = true;
- cpd->acted = true;
+ cpd->new_point = cpd->acted = cpd->link_handles = true;
}
}
}
More information about the Bf-blender-cvs
mailing list