[Bf-blender-cvs] [5f0be48] temp_custom_loop_normals: When converting custom normals to CD data, interpret NULL vectors as NOP ones.

Bastien Montagne noreply at git.blender.org
Wed Aug 6 21:36:39 CEST 2014


Commit: 5f0be484a782f8e0d48f5af08459eb09f7b6c2ba
Author: Bastien Montagne
Date:   Tue Jul 15 16:58:29 2014 +0200
Branches: temp_custom_loop_normals
https://developer.blender.org/rB5f0be484a782f8e0d48f5af08459eb09f7b6c2ba

When converting custom normals to CD data, interpret NULL vectors as NOP ones.

i.e. if you give a (0, 0, 0) vector, you will always get auto-computed normal...

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

M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/makesrna/intern/rna_mesh_api.c

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

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index c86badc..e85e137 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -441,7 +441,8 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, const float
 	print_v3("auto lnor", lnor_space->vec_lnor);
 	print_v3("custom lnor", custom_lnor);
 
-	if (equals_v3v3(lnor_space->vec_lnor, custom_lnor)) {
+	/* We use null vector as NOP custom normal (can be simpler than giving autocomputed lnor...). */
+	if (is_zero_v3(custom_lnor) || equals_v3v3(lnor_space->vec_lnor, custom_lnor)) {
 		zero_v2(r_clnor_data);
 		printf("same nors\n");
 		return;
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index 1c8581a..d0e6ba6 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -254,14 +254,14 @@ void RNA_api_mesh(StructRNA *srna)
 	RNA_def_property_flag(parm, PROP_OUTPUT);
 
 	func = RNA_def_function(srna, "define_normals_split_custom", "rna_Mesh_define_normals_split_custom");
-	RNA_def_function_ui_description(func, "Define custom split normals of this mesh");
+	RNA_def_function_ui_description(func,
+	                                "Define custom split normals of this mesh (use NULL vectors to keep auto ones)");
 	RNA_def_function_flag(func, FUNC_USE_REPORTS);
 	/* TODO, see how array size of 0 works, this shouldnt be used */
 	parm = RNA_def_float_array(func, "normals", 1, NULL, -1.0f, 1.0f, "", "Normals", 0.0f, 0.0f);
 	RNA_def_property_multi_array(parm, 2, normals_array_dim);
 	RNA_def_property_flag(parm, PROP_DYNAMIC | PROP_REQUIRED);
 
-
 	func = RNA_def_function(srna, "update", "ED_mesh_update");
 	RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges");
 	RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces");




More information about the Bf-blender-cvs mailing list