[Bf-blender-cvs] [1471cfd] gsoc2016-improved_extrusion: Curves: Keymaps
João Araújo
noreply at git.blender.org
Fri Aug 19 01:04:31 CEST 2016
Commit: 1471cfdba8ff25273f15db61b97fcf2a5ca50673
Author: João Araújo
Date: Thu Aug 18 19:08:48 2016 +0100
Branches: gsoc2016-improved_extrusion
https://developer.blender.org/rB1471cfdba8ff25273f15db61b97fcf2a5ca50673
Curves: Keymaps
Added keymaps for extend, batch extend, trim, offset, fillet and chamfer tools.
===================================================================
M source/blender/editors/curve/curve_ops.c
M source/blender/editors/curve/editcurve.c
===================================================================
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 4de74f5..87399b1 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -270,6 +270,13 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CURVE_OT_make_segment", FKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CURVE_OT_cyclic_toggle", CKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_extend_curve", EKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_batch_extend", EKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_trim_curve", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_offset_curve", OKEY, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_curve_chamfer", CKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_curve_fillet", FKEY, KM_PRESS, KM_CTRL, 0);
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_delete", DELKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index c183409..db64c56 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -8146,6 +8146,7 @@ static int curve_chamfer_exec(bContext *C, wmOperator *op)
Nurb *nu;
float distance = RNA_float_get(op->ptr, "distance");
float angle = RNA_float_get(op->ptr, "angle");
+ float v1[3], v2[3];
/* get selected spline */
int spline_id = get_selected_spline_id(nubase);
@@ -8163,6 +8164,17 @@ static int curve_chamfer_exec(bContext *C, wmOperator *op)
if (BEZT_ISSEL_ANY(bezt) && bezt->h1 == 2 && bezt->h2 == 2) {
bezt1 = MEM_callocN(sizeof(BezTriple), "curve_chamfer1");
bezt2 = MEM_callocN(sizeof(BezTriple), "curve_chamfer2");
+ sub_v3_v3v3(v1, bezt->vec[1], bezt->vec[0]);
+ normalize_v3(v1);
+ sub_v3_v3v3(v2, bezt->vec[1], bezt->vec[2]);
+ normalize_v3(v2);
+ float test_angle = DEG2RAD(90) - angle_normalized_v3v3(v1, v2) / 2;
+ if (test_angle < 1.0e-4) {
+ MEM_freeN(bezt1);
+ MEM_freeN(bezt2);
+ BKE_report(op->reports, RPT_ERROR, "Lines cannot be chamfered");
+ return OPERATOR_CANCELLED;
+ }
chamfer_handle(bezt, bezt1, bezt2, angle, distance);
selected_point = i;
BKE_nurb_bezierPoints_add(nu, 1);
@@ -8461,7 +8473,7 @@ static int curve_chamfer_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
{
CD *cd = MEM_callocN(sizeof(CD), "curve_chamfer_invoke1");
cd->data = MEM_callocN(sizeof(OffsetData), "curve_chamfer_invoke2");
- float center_3d[3];
+ float center_3d[3], v1[3], v2[3];
calculateTransformCenter(C, V3D_AROUND_CENTER_MEAN, center_3d, cd->data->mcenter);
Object *obedit = CTX_data_edit_object(C);
@@ -8481,6 +8493,14 @@ static int curve_chamfer_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
for (int i = 0; i < nu->pntsu; i++) {
bezt = &nu->bezt[i];
if (BEZT_ISSEL_ANY(bezt)) {
+ sub_v3_v3v3(v1, bezt->vec[1], bezt->vec[0]);
+ normalize_v3(v1);
+ sub_v3_v3v3(v2, bezt->vec[1], bezt->vec[2]);
+ normalize_v3(v2);
+ float test_angle = DEG2RAD(90) - angle_normalized_v3v3(v1, v2) / 2;
+ if (test_angle < 1.0e-4) {
+ continue;
+ }
selected += 1;
cd->selected_points = MEM_reallocN(cd->selected_points, selected * sizeof(BezTriple));
memcpy(&cd->selected_points[selected - 1], bezt, sizeof(BezTriple));
More information about the Bf-blender-cvs
mailing list