[Bf-blender-cvs] [86e63507470] soc-2017-normal-tools: Fixed issues with Copy Normals

Rohan Rathi noreply at git.blender.org
Tue Jul 25 19:49:12 CEST 2017


Commit: 86e63507470b05cfe290adcbd925879fa8445b48
Author: Rohan Rathi
Date:   Tue Jul 25 23:18:41 2017 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rB86e63507470b05cfe290adcbd925879fa8445b48

Fixed issues with Copy Normals

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

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/editors/mesh/editmesh_tools.c
M	source/tools

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

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 92f4a9d9f81..59495b4b590 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 92f4a9d9f81d6de6f2b8d1d8531c298e8cc455f2
+Subproject commit 59495b4b59077aa1cc68fffbdae1463af980f08e
diff --git a/release/scripts/addons b/release/scripts/addons
index 371960484a3..27970761a18 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 371960484a38fc64e0a2635170a41a0d8ab2f6bd
+Subproject commit 27970761a18926abe1b0020aa350305e3109a537
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index a8515cfdfe9..6a4f93c9b8f 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit a8515cfdfe9a98127b592f36fcbe51b7e23b969a
+Subproject commit 6a4f93c9b8f36b19bd02087abf3d7f5983df035a
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 26800d51811..a9accacfcea 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -6611,14 +6611,15 @@ static int edbm_copy_paste_normal_exec(bContext *C, wmOperator *op)
 	BMEditMesh *em = BKE_editmesh_from_object(obedit);
 	BMesh *bm = em->bm;
 
-	const bool copy = RNA_boolean_get(op->ptr, "copy");
+	const bool copy = RNA_boolean_get(op->ptr, "copy"),
+		  absolute = RNA_boolean_get(op->ptr, "absolute");
 
 	BM_lnorspace_update(bm);
 	LoopNormalData *ld = BM_loop_normal_init(bm);
 	TransDataLoopNormal *tld = ld->normal;
 	int i = 0;
 
-	if (copy) {
+	if (copy && (op->flag & OP_IS_INVOKE)) {
 		bool join =  ld->totloop > 0 ? true : false;
 		for (; i < ld->totloop; i++, tld++) {
 			if (!compare_v3v3(ld->normal->nloc, tld->nloc, 1e-4f))
@@ -6640,24 +6641,39 @@ static int edbm_copy_paste_normal_exec(bContext *C, wmOperator *op)
 			BKE_report(op->reports, RPT_ERROR, "Invalid Selection");
 			return OPERATOR_CANCELLED;
 		}
+		op->flag &= ~OP_IS_INVOKE;			//required to make target editable from ui
 	}
-	else {
+	else if (!copy){
 		float normal_val[3];
 		RNA_float_get_array(op->ptr, "normal_vector", normal_val);
-		if (is_zero_v3(normal_val)) {
-			BKE_reportf(op->reports, RPT_ERROR, "Buffer is empty");
-			return OPERATOR_CANCELLED;
-		}
 
 		for (i = 0; i < ld->totloop; i++, tld++) {
-			BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index], normal_val, tld->clnors_data);
+			if (absolute) {
+				float abs_normal[3];
+				copy_v3_v3(abs_normal, tld->loc);
+				negate_v3(abs_normal);
+				add_v3_v3(abs_normal, normal_val);
+				normalize_v3(abs_normal);
+
+				BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index], abs_normal, tld->clnors_data);
+			}
+			else {
+				BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[tld->loop_index], normal_val, tld->clnors_data);
+			}
 		}
 	}
 
+	MEM_freeN(ld->normal);
+	MEM_freeN(ld);
 	EDBM_update_generic(em, true, false);
 	return OPERATOR_FINISHED;
 }
 
+static int edbm_copy_paste_normal_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+	return edbm_copy_paste_normal_exec(C, op);
+}
+
 void MESH_OT_copy_normal(struct wmOperatorType *ot)
 {
 	/* identifiers */
@@ -6667,6 +6683,7 @@ void MESH_OT_copy_normal(struct wmOperatorType *ot)
 
 	/* api callbacks */
 	ot->exec = edbm_copy_paste_normal_exec;
+	ot->invoke = edbm_copy_paste_normal_invoke;
 	ot->poll = ED_operator_editmesh_auto_smooth;
 
 	/* flags */
@@ -6675,7 +6692,9 @@ void MESH_OT_copy_normal(struct wmOperatorType *ot)
 	ot->prop = RNA_def_boolean(ot->srna, "copy", 1, "Copy Normal", "Copy normal of mesh");
 	RNA_def_property_flag(ot->prop, PROP_HIDDEN);
 
-	PropertyRNA *prop = RNA_def_property(ot->srna, "normal_vector", PROP_FLOAT, PROP_XYZ);
+	PropertyRNA *prop = RNA_def_boolean(ot->srna, "absolute", 0, "Absolute", "Absolute value to copy");
+
+	prop = RNA_def_property(ot->srna, "normal_vector", PROP_FLOAT, PROP_XYZ);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Copied Normal", "Normal vector of copied face or loop");
 }
\ No newline at end of file
diff --git a/source/tools b/source/tools
index b11375e8906..88a1758d2d2 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit b11375e89061303401376f7aeae42ac2fd64692a
+Subproject commit 88a1758d2d2e862cc69c08b5b40a4e75f71592d3




More information about the Bf-blender-cvs mailing list