[Bf-blender-cvs] [bed5cd5] temp_custom_loop_normals: More cleanup, simplied set_clnor funcs, reworked mix feature of setsplinor modifier

Bastien Montagne noreply at git.blender.org
Thu Jan 22 21:34:57 CET 2015


Commit: bed5cd5f24e6083081bae4dd3cfc24d838cef9e5
Author: Bastien Montagne
Date:   Thu Jan 22 21:31:42 2015 +0100
Branches: temp_custom_loop_normals
https://developer.blender.org/rBbed5cd5f24e6083081bae4dd3cfc24d838cef9e5

More cleanup, simplied set_clnor funcs, reworked mix feature of setsplinor modifier

Now, `BKE_mesh_normals_loop_custom_set()` & co do not take a factor value anymore.
It could make perfomances slightly better, but it was adding some complexity and fuzzyness
in an area that do not need that. So now, caller code is expected to handle
mixing itself, if needed.

And SetSplitNormal modifier now has a real mixing handling, quite similar to
the one of txdata.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/intern/data_transfer.c
M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_mesh_api.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_setsplitnormal.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index ef62243..b8b81f8 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1355,31 +1355,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         sub = col.row()
         sub.active = needs_object_bbox_center
         sub.prop(md, "use_bbox_center")
-        col.prop(md, "use_current_custom_split_normals")
 
         col = split.column()
         row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        sub = row.row(align=True)
-        sub.active = has_vgroup
-        sub.prop(md, "use_invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
-        row = col.row(align=True)
         row.active = (md.mode == 'TRACKTO')
         row.prop(md, "use_trackto_parallel")
-
-    def COPY_SPLIT_NORMAL(self, layout, ob, md):
-        has_vgroup = bool(md.vertex_group)
-
-        row = layout.row()
-        row.prop(md, "mode", expand=True)
+        col.prop(md, "use_current_normals")
 
         split = layout.split()
+        split.active = md.use_current_normals
 
-        col = split.column()
-        col.prop(md, "target", text="")
-        col.prop(md, "use_current_custom_split_normals")
+        col = split.column(align=True)
+        col.label("Mix Mode:")
+        col.prop(md, "mix_mode", text="")
 
-        col = split.column()
+        col = split.column(align=True)
+        col.prop(md, "mix_factor")
         row = col.row(align=True)
         row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
         sub = row.row(align=True)
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 09ccd3b..3eb3eb5 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -218,14 +218,14 @@ void BKE_mesh_normals_loop_split(struct MVert *mverts, const int numVerts, struc
 
 void BKE_mesh_normals_loop_custom_set(
         struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
-        struct MLoop *mloops, float (*custom_loopnors)[3], const float *custom_loopnors_facs, const int numLoops,
+        struct MLoop *mloops, float (*custom_loopnors)[3], const int numLoops,
         struct MPoly *mpolys, const float (*polynors)[3], const int numPolys,
-        short (*r_clnors_data)[2], const bool use_clnors_data);
+        short (*r_clnors_data)[2]);
 void BKE_mesh_normals_loop_custom_from_vertices_set(
-        struct MVert *mverts, float (*custom_vertnors)[3], const float *custom_vertnors_facs, const int numVerts,
+        struct MVert *mverts, float (*custom_vertnors)[3], const int numVerts,
         struct MEdge *medges, const int numEdges, struct MLoop *mloops, const int numLoops,
         struct MPoly *mpolys, const float (*polynors)[3], const int numPolys,
-        short (*r_clnors_data)[2], const bool use_clnors_data);
+        short (*r_clnors_data)[2]);
 
 void BKE_mesh_calc_poly_normal(
         struct MPoly *mpoly, struct MLoop *loopstart,
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index e59a1c4..e1c8a23 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -346,9 +346,9 @@ static void data_transfer_dtdata_type_postprocess(
 
 		/* Note loop_nors_dst contains our custom normals as transferred from source... */
 		BKE_mesh_normals_loop_custom_set(verts_dst, num_verts_dst, edges_dst, num_edges_dst,
-		                                 loops_dst, loop_nors_dst, NULL, num_loops_dst,
+		                                 loops_dst, loop_nors_dst, num_loops_dst,
 		                                 polys_dst, poly_nors_dst, num_polys_dst,
-		                                 custom_nors_dst, false);
+		                                 custom_nors_dst);
 	}
 }
 
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index d8d29ee..7ba16d4 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -491,8 +491,6 @@ void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, const float
 	}
 }
 
-#undef LNOR_SPACE_TRIGO_THRESHOLD
-
 #define LOOP_SPLIT_TASK_BLOCK_SIZE 1024
 
 typedef struct LoopSplitTaskData {
@@ -1241,16 +1239,13 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int numVerts, MEdge *medge
  * Compute internal representation of given custom normals (as an array of float[2]).
  * It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed to get a
  * same custom lnor for all loops sharing a same smooth fan.
- * If use_vertices if true, custom_loopnors and custom_loopnors_facs are assumed to be per-vertex, not per-loop
+ * If use_vertices if true, custom_loopnors is assumed to be per-vertex, not per-loop
  * (this allows to set whole vert's normals at once, useful in some cases).
- * If use_clnors_data is true, auto lnors will be computed using data available in given r_clnors_data. Useful to edit
- * custom normals instead of simply overwriting them!
  */
 static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdge *medges, const int numEdges,
-                                         MLoop *mloops, float (*custom_loopnors)[3],
-                                         const float *custom_loopnors_facs, const int numLoops,
+                                         MLoop *mloops, float (*custom_loopnors)[3], const int numLoops,
                                          MPoly *mpolys, const float (*polynors)[3], const int numPolys,
-                                         short (*r_clnors_data)[2], const bool use_clnors_data, const bool use_vertices)
+                                         short (*r_clnors_data)[2], const bool use_vertices)
 {
 	/* We *may* make that poor BKE_mesh_normals_loop_split() even more complex by making it handling that
 	 * feature too, would probably be more efficient in absolute.
@@ -1272,7 +1267,7 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 	/* Compute current lnor spaces. */
 	BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
 	                            mpolys, polynors, numPolys, use_split_normals, split_angle,
-	                            &lnors_spaces, use_clnors_data ? r_clnors_data : NULL, loop_to_poly);
+	                            &lnors_spaces, NULL, loop_to_poly);
 
 	/* Now, check each current smooth fan (one lnor space per smooth fan!), and if all its matching custom lnors
 	 * are not (enough) equal, add sharp edges as needed.
@@ -1306,21 +1301,17 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 				LinkNode *loops = lnors_spaces.lspaces[i]->loops;
 				MLoop *prev_ml = NULL;
 				const float *org_nor = NULL;
-				float org_fac = 0.0f;
 
 				while (loops) {
 					const int lidx = GET_INT_FROM_POINTER(loops->link);
 					MLoop *ml = &mloops[lidx];
 					const int nidx = use_vertices ? (int)ml->v : lidx;
 					float *nor = custom_loopnors[nidx];
-					const float fac = custom_loopnors_facs ? custom_loopnors_facs[nidx] : 0.0f;
 
 					if (!org_nor) {
 						org_nor = nor;
-						org_fac = fac;
 					}
-					else if (dot_v3v3(org_nor, nor) < 1.0f - 1e-6f ||
-					         (custom_loopnors_facs && fabsf(org_fac - fac) > 1e-6f))
+					else if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD)
 					{
 						/* Current normal differs too much from org one, we have to tag the edge between
 						 * previous loop's face and current's one as sharp.
@@ -1332,7 +1323,6 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 						medges[(prev_ml->e == mlp->e) ? prev_ml->e : ml->e].flag |= ME_SHARP;
 
 						org_nor = nor;
-						org_fac = fac;
 					}
 
 					prev_ml = ml;
@@ -1347,7 +1337,7 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 		BKE_lnor_spaces_free(&lnors_spaces);
 		BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
 		                            mpolys, polynors, numPolys, use_split_normals, split_angle,
-		                            &lnors_spaces, use_clnors_data ? r_clnors_data : NULL, loop_to_poly);
+		                            &lnors_spaces, NULL, loop_to_poly);
 	}
 	else {
 		BLI_BITMAP_SET_ALL(done_loops, true, (size_t)numLoops);
@@ -1370,7 +1360,6 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 			if (loops) {
 				int nbr_nors = 0;
 				float avg_nor[3];
-				float avg_fac = 0.0f;
 				short clnor_data_tmp[2], *clnor_data;
 
 				zero_v3(avg_nor);
@@ -1381,9 +1370,6 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 
 					nbr_nors++;
 					add_v3_v3(avg_nor, nor);
-					if (custom_loopnors_facs) {
-						avg_fac += custom_loopnors_facs[nidx];
-					}
 					BLI_SMALLSTACK_PUSH(clnors_data, (short *)r_clnors_data[lidx]);
 
 					loops = loops->next;
@@ -1391,13 +1377,6 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 				}
 
 				mul_v3_fl(avg_nor, 1.0f / (float)nbr_nors);
-				if (custom_loopnors_facs) {
-					avg_fac /= (float)nbr_nors;
-					if (avg_fac < 1.0f - 1e-6f) {
-						/* Slerp with final computed lnors, which may include custom lnors if required! */
-						interp_v3_v3v3_slerp_safe(avg_nor, lnors[i], avg_nor, avg_fac);
-					}
-				}
 				BKE_lnor_space_custom_normal_to_data(lnors_spaces.lspaces[i], avg_nor, clnor_data_tmp);
 
 				while ((clnor_data = BLI_SMALLSTACK_POP(clnors_data))) {
@@ -1410,16 +1389,6 @@ static void mesh_normals_loop_custom_set(MVert *mverts, const int numVerts, MEdg
 				float *nor = custom_loopnors[nidx];
 				float tnor[3];
 
-				if (custom_loopnors_facs) {
-					const float fac = custom_loopnors_facs[nidx];
-
-					if (fac < 1.0f - 1e-6f) {
-						/* Slerp with final computed lnors, which may include custom lno

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list