[Bf-blender-cvs] [b9d58887282] blender2.8: Multi-Objects: CURVE_OT_duplicate

Dalai Felinto noreply at git.blender.org
Tue Oct 30 22:33:38 CET 2018


Commit: b9d58887282470244b906bf5a582390169129f3d
Author: Dalai Felinto
Date:   Tue Oct 30 18:31:27 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBb9d58887282470244b906bf5a582390169129f3d

Multi-Objects: CURVE_OT_duplicate

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

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

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

diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index bda0d67b2a4..e7478b3253d 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5375,22 +5375,39 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
 
 static int duplicate_exec(bContext *C, wmOperator *op)
 {
-	Object *obedit = CTX_data_edit_object(C);
+	ViewLayer * view_layer = CTX_data_view_layer(C);
 	View3D *v3d = CTX_wm_view3d(C);
-	ListBase newnurb = {NULL, NULL};
+	int ok = -1;
 
-	adduplicateflagNurb(obedit, v3d, &newnurb, SELECT, false);
+	uint objects_len = 0;
+	Object * *objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+	for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+		Object * obedit = objects[ob_index];
+		Curve * cu = obedit->data;
 
-	if (BLI_listbase_is_empty(&newnurb) == false) {
+		if (!ED_curve_select_check(v3d, cu->editnurb)) {
+			ok = MAX2(ok, 0);
+			continue;
+		}
+
+		ListBase newnurb = {NULL, NULL};
+		adduplicateflagNurb(obedit, v3d, &newnurb, SELECT, false);
+
+		if (BLI_listbase_is_empty(&newnurb)) {
+			continue;
+		}
+
+		ok = 1;
 		BLI_movelisttolist(object_editcurve_get(obedit), &newnurb);
 		DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
 		WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
 	}
-	else {
+	MEM_freeN(objects);
+
+	if (ok == 0) {
 		BKE_report(op->reports, RPT_ERROR, "Cannot duplicate current selection");
 		return OPERATOR_CANCELLED;
 	}
-
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list