[Bf-blender-cvs] [fd3960a4eb8] soc-2017-normal-tools: Fixed vgroups editing all loop data in modifier

Rohan Rathi noreply at git.blender.org
Fri Aug 4 18:44:47 CEST 2017


Commit: fd3960a4eb8060c5b86f57778431ee1f0dca4e18
Author: Rohan Rathi
Date:   Fri Aug 4 17:39:56 2017 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rBfd3960a4eb8060c5b86f57778431ee1f0dca4e18

Fixed vgroups editing all loop data in modifier

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

M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_weighted_normal.c

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

diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index fd61b162659..ec8e9347be8 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, 0, 20);
-	RNA_def_property_ui_range(prop, 0, 20, 1, -1);
+	RNA_def_property_range(prop, 1, 20);
+	RNA_def_property_ui_range(prop, 1, 20, 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");
 
@@ -4809,7 +4809,7 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
 
 	prop = RNA_def_property(srna, "boolean_weights", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_BOOL_WEIGHTS);
-	RNA_def_property_ui_text(prop, "Boolean Weights", "Use Smooth/Sharp flags as boolean weights");
+	RNA_def_property_ui_text(prop, "Boolean Weights", "Sets weight of smooth faces to 0. Weight of flat faces remains unchanged.");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 15933a8038c..28bdffbca11 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -143,6 +143,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, Object
 		BLI_bitmap *sharp_verts = BLI_BITMAP_NEW(numVerts, "__func__");
 		int *loops_per_vert = MEM_callocN(sizeof(*loops_per_vert) * numVerts, "__func__");
 
+		BKE_mesh_normals_loop_split(mvert, numVerts, medge, numEdges, mloop, loop_normal, numLoops, mpoly, polynors,
+			numPoly, true, (float)M_PI, NULL, clnors, loops_to_poly);
+
 		for (int mp_index = 0; mp_index < numPoly; mp_index++) {
 			int ml_index = mpoly[mp_index].loopstart;
 			const int ml_index_end = ml_index + mpoly[mp_index].totloop;
@@ -154,7 +157,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, Object
 				}
 				loops_per_vert[mloop[i].v]++;
 				loops_to_poly[i] = mp_index;
-				copy_v3_v3(loop_normal[i], custom_normal[mloop[i].v]);
+				if (!is_zero_v3(custom_normal[mloop[i].v])) {
+					copy_v3_v3(loop_normal[i], custom_normal[mloop[i].v]);
+				}
 			}
 		}
 
@@ -212,7 +217,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, Object
 				for (int k = 0; k < totloop; k++) {
 					MPoly mp = mpoly[loops_to_poly[*loops]];
 					MLoop *prev_loop = (*loops - 1 >= mp.loopstart ? &mloop[*loops - 1] : &mloop[mp.loopstart + mp.totloop - 1]),
-						*next_loop = (*loops + 1 <= mp.loopstart + mp.totloop ? &mloop[*loops + 1] : &mloop[mp.loopstart]),
+						*next_loop = (*loops + 1 < mp.loopstart + mp.totloop ? &mloop[*loops + 1] : &mloop[mp.loopstart]),
 						*vert_loop;
 
 					int other_v1 = BKE_mesh_edge_other_vert(&medge[prev_loop->e], prev_loop->v),




More information about the Bf-blender-cvs mailing list