[Bf-blender-cvs] [1b92a80703b] soc-2017-normal-tools: Made UI changes. Removed binary weighting in average. Changed weight calculation.

Rohan Rathi noreply at git.blender.org
Sun Aug 20 18:14:04 CEST 2017


Commit: 1b92a80703b6531ff7caa1421cc44f4d23b8527c
Author: Rohan Rathi
Date:   Sun Aug 20 21:41:40 2017 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rB1b92a80703b6531ff7caa1421cc44f4d23b8527c

Made UI changes. Removed binary weighting in average. Changed weight calculation.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/makesrna/intern/rna_modifier.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index a86585a0ece..4111dd7c343 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -432,19 +432,19 @@ class VIEW3D_PT_tools_shading(View3DPanel, Panel):
         col.label(text="Normals:")
         col.operator("mesh.normals_make_consistent", text="Recalculate")
         col.operator("mesh.flip_normals", text="Flip Direction")
-        col.operator("mesh.set_normals_from_faces", text="Set From Faces")
 
 
 class VIEW3D_PT_tools_normal(View3DPanel, Panel):
 	bl_category = "Shading / UVs"
 	bl_context = "mesh_edit"
-	bl_label = "Normal Tools"
+	bl_label = "Custom Normal Tools"
 
 	def draw(self, context):
 		layout = self.layout
 		toolsettings = context.tool_settings
 
 		col = layout.column(align=True)
+		col.operator("mesh.set_normals_from_faces", text="Set From Faces")
 		col.operator("transform.rotate_normal", text = "Rotate Normal")
 		col.operator("mesh.point_normals")
 
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 9ef463db893..19c59738a8c 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -6564,17 +6564,29 @@ static int edbm_average_loop_normals_exec(bContext *C, wmOperator *op)
 	const int average_type = RNA_enum_get(op->ptr, "average_type");
 	int cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
 	float absweight = (float) RNA_int_get(op->ptr, "weight"), threshold = RNA_float_get(op->ptr, "threshold");
-	const bool binary_weights = RNA_boolean_get(op->ptr, "binary_weights");
-	float weight = absweight / 10.0f;
+	float weight = absweight / 50.0f;
 
-	if (absweight == 20) {
+	if (average_type == LOOP_AVERAGE) {
+		PropertyRNA *prop = RNA_struct_find_property(op->ptr, "weight");
+		RNA_def_property_flag(prop, PROP_HIDDEN);
+		prop = RNA_struct_find_property(op->ptr, "threshold");
+		RNA_def_property_flag(prop, PROP_HIDDEN);
+	}
+	else {
+		PropertyRNA *prop = RNA_struct_find_property(op->ptr, "weight");
+		RNA_def_property_clear_flag(prop, PROP_HIDDEN);
+		prop = RNA_struct_find_property(op->ptr, "threshold");
+		RNA_def_property_clear_flag(prop, PROP_HIDDEN);
+	}
+
+	if (absweight == 100) {
 		weight = (float)SHRT_MAX;
 	}
 	else if (absweight == 1) {
 		weight = 1 / (float)SHRT_MAX;
 	}
-	else if (weight > 1) {
-		weight = (weight - 1) * 10;
+	else if ((weight - 1) * 25 > 1) {
+		weight = (weight - 1) * 25;
 	}
 	BM_ITER_MESH(e, &eiter, bm, BM_EDGES_OF_MESH) {
 		BMLoop *l_a, *l_b;
@@ -6638,9 +6650,6 @@ static int edbm_average_loop_normals_exec(bContext *C, wmOperator *op)
 						else if (average_type == ANGLE_AVERAGE) {
 							val = 1.0f / BM_loop_calc_face_angle(lfan_pivot);
 						}
-						if (binary_weights && BM_elem_flag_test(lfan_pivot->f, BM_ELEM_SMOOTH)) {
-							val = (float)INT_MAX;
-						}
 
 						BLI_heap_insert(loop_weight, val, lfan_pivot);
 
@@ -6712,11 +6721,9 @@ void MESH_OT_average_loop_normals(struct wmOperatorType *ot)
 	ot->prop = RNA_def_enum(ot->srna, "average_type", average_method_items, LOOP_AVERAGE, "Type", "Averaging method");
 	RNA_def_property_flag(ot->prop, PROP_HIDDEN);
 
-	ot->prop = RNA_def_int(ot->srna, "weight", 10, 1, 20, "Weight", "Weight applied per face", 1, 20);
+	ot->prop = RNA_def_int(ot->srna, "weight", 50, 1, 100, "Weight", "Weight applied per face", 1, 100);
 
-	ot->prop = RNA_def_float(ot->srna, "threshold", 0.01f, 0, 5, "Threshold", "Threshold value for different weights to be considered equal", 0, 5);
-	
-	ot->prop = RNA_def_boolean(ot->srna, "binary_weights", 0, "Binary Weights", "Sets weight of smooth faces to 0. Weight of flat faces remains unchanged");
+	ot->prop = RNA_def_float(ot->srna, "threshold", 0.01f, 0, 10, "Threshold", "Threshold value for different weights to be considered equal", 0, 5);
 }
 
 /********************** Custom Normal Interface Tools **********************/
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 52595084159..6a06379bad9 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4775,8 +4775,8 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
 	RNA_def_struct_ui_icon(srna, ICON_MOD_NORMALEDIT);
 
 	prop = RNA_def_property(srna, "weight", PROP_INT, PROP_NONE);
-	RNA_def_property_range(prop, 1, 20);
-	RNA_def_property_ui_range(prop, 1, 20, 1, -1);
+	RNA_def_property_range(prop, 1, 100);
+	RNA_def_property_ui_range(prop, 1, 100, 1, -1);
 	RNA_def_property_ui_text(prop, "Weight", "Weights given to Face Normal for each mode");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
@@ -4786,8 +4786,8 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
 	prop = RNA_def_property(srna, "thresh", PROP_FLOAT, PROP_NONE);
-	RNA_def_property_range(prop, 0, 5);
-	RNA_def_property_ui_range(prop, 0, 5, 1, 2);
+	RNA_def_property_range(prop, 0, 10);
+	RNA_def_property_ui_range(prop, 0, 10, 1, 2);
 	RNA_def_property_ui_text(prop, "Thresh", "Threshold value for different weights to be considered equal");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");



More information about the Bf-blender-cvs mailing list