[Bf-blender-cvs] [2d9bf95] temp_custom_loop_normals: Various cleanup...

Bastien Montagne noreply at git.blender.org
Sat Jan 24 16:32:44 CET 2015


Commit: 2d9bf95335538e1a75c085c4600b437c91b7ef5a
Author: Bastien Montagne
Date:   Sat Jan 24 15:00:33 2015 +0100
Branches: temp_custom_loop_normals
https://developer.blender.org/rB2d9bf95335538e1a75c085c4600b437c91b7ef5a

Various cleanup...

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

M	intern/cycles/blender/blender_mesh.cpp
M	source/blender/blenkernel/intern/cdderivedmesh.c
M	source/blender/blenkernel/intern/customdata.c
M	source/blender/blenkernel/intern/data_transfer.c
M	source/blender/blenkernel/intern/editderivedmesh.c
M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/bmesh/intern/bmesh_mesh.h
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/makesrna/intern/rna_mesh.c
M	source/blender/makesrna/intern/rna_mesh_api.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/render/intern/source/convertblender.c

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

diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index d1758e0..8805443 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -265,7 +265,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
 	int numverts = b_mesh.vertices.length();
 	int numfaces = b_mesh.tessfaces.length();
 	int numtris = 0;
-	bool use_loop_normals = b_mesh.use_auto_smooth() || b_mesh.has_custom_normals();
+	bool use_loop_normals = b_mesh.use_auto_smooth();
 
 	BL::Mesh::vertices_iterator v;
 	BL::Mesh::tessfaces_iterator f;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index e82b40c..0bc7b47 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -2162,7 +2162,7 @@ void CDDM_calc_loop_normals(DerivedMesh *dm, const bool use_split_normals, const
 	CDDM_calc_loop_normals_spaceset(dm, use_split_normals, split_angle, NULL);
 }
 
-//#define DEBUG_CLNORS
+// #define DEBUG_CLNORS
 
 void CDDM_calc_loop_normals_spaceset(
         DerivedMesh *dm, const bool use_split_normals, const float split_angle, MLoopNorSpaceset *r_lnors_spaceset)
@@ -2175,6 +2175,7 @@ void CDDM_calc_loop_normals_spaceset(
 	CustomData *ldata, *pdata;
 
 	float (*lnors)[3];
+	short (*clnor_data)[2];
 	float (*pnors)[3];
 
 	const int numVerts = dm->getNumVerts(dm);
@@ -2202,41 +2203,40 @@ void CDDM_calc_loop_normals_spaceset(
 
 	dm->dirty &= ~DM_DIRTY_NORMALS;
 
-	{
-		short (*clnor_data)[2] = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
+	clnor_data = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
 
-		BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
-		                            mpolys, (const float (*)[3])pnors, numPolys,
-		                            use_split_normals, split_angle,
-		                            r_lnors_spaceset, clnor_data, NULL);
+	BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
+	                            mpolys, (const float (*)[3])pnors, numPolys,
+	                            use_split_normals, split_angle,
+	                            r_lnors_spaceset, clnor_data, NULL);
 #ifdef DEBUG_CLNORS
-		if (r_lnors_spaceset) {
-			int i;
-			for (i = 0; i < numLoops; i++) {
-				if (r_lnors_spaceset->lspaceset[i]->ref_alpha != 0.0f) {
-					LinkNode *loops = r_lnors_spaceset->lspaceset[i]->loops;
-					printf("Loop %d uses lnor space %p:\n", i, r_lnors_spaceset->lspaceset[i]);
-					print_v3("\tfinal lnor", lnors[i]);
-					print_v3("\tauto lnor", r_lnors_spaceset->lspaceset[i]->vec_lnor);
-					print_v3("\tref_vec", r_lnors_spaceset->lspaceset[i]->vec_ref);
-					printf("\talpha: %f\n\tbeta: %f\n\tloops: %p\n", r_lnors_spaceset->lspaceset[i]->ref_alpha,
-					       r_lnors_spaceset->lspaceset[i]->ref_beta, r_lnors_spaceset->lspaceset[i]->loops);
-					printf("\t\t(shared with loops");
-					while(loops) {
-						printf(" %d", GET_INT_FROM_POINTER(loops->link));
-						loops = loops->next;
-					}
-					printf(")\n");
-				}
-				else {
-					printf("Loop %d has no lnor space\n", i);
+	if (r_lnors_spaceset) {
+		int i;
+		for (i = 0; i < numLoops; i++) {
+			if (r_lnors_spaceset->lspaceset[i]->ref_alpha != 0.0f) {
+				LinkNode *loops = r_lnors_spaceset->lspaceset[i]->loops;
+				printf("Loop %d uses lnor space %p:\n", i, r_lnors_spaceset->lspaceset[i]);
+				print_v3("\tfinal lnor", lnors[i]);
+				print_v3("\tauto lnor", r_lnors_spaceset->lspaceset[i]->vec_lnor);
+				print_v3("\tref_vec", r_lnors_spaceset->lspaceset[i]->vec_ref);
+				printf("\talpha: %f\n\tbeta: %f\n\tloops: %p\n", r_lnors_spaceset->lspaceset[i]->ref_alpha,
+				       r_lnors_spaceset->lspaceset[i]->ref_beta, r_lnors_spaceset->lspaceset[i]->loops);
+				printf("\t\t(shared with loops");
+				while(loops) {
+					printf(" %d", GET_INT_FROM_POINTER(loops->link));
+					loops = loops->next;
 				}
+				printf(")\n");
+			}
+			else {
+				printf("Loop %d has no lnor space\n", i);
 			}
 		}
-#endif
 	}
+#endif
 }
 
+
 void CDDM_calc_normals_tessface(DerivedMesh *dm)
 {
 	CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index abeab61..b443d2d 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1209,7 +1209,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
 	/* 8: CD_NORMAL */
 	/* 3 floats per normal vector */
 	{sizeof(float) * 3, "vec3f", 1, NULL, NULL, NULL, layerInterp_normal, NULL, NULL,
-     NULL, NULL, NULL, NULL, NULL, layerCopyValue_normal},
+	 NULL, NULL, NULL, NULL, NULL, layerCopyValue_normal},
 	/* 9: CD_POLYINDEX (deprecated) */
 	{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
 	/* 10: CD_PROP_FLT */
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index e1c8a23..5ce2573 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -256,11 +256,8 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type)
 
 static void data_transfer_dtdata_type_preprocess(
         Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst,
-        const int dtdata_type, const bool dirty_nors_dst, const bool use_split_nors_src, const float split_angle_src,
-        void **r_prepost_data)
+        const int dtdata_type, const bool dirty_nors_dst, const bool use_split_nors_src, const float split_angle_src)
 {
-	*r_prepost_data = NULL;
-
 	if (dtdata_type == DT_TYPE_LNOR) {
 		/* Compute custom normals into regular loop normals, which will be used for the transfer. */
 		MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert;
@@ -315,7 +312,7 @@ static void data_transfer_dtdata_type_preprocess(
 
 static void data_transfer_dtdata_type_postprocess(
         Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *UNUSED(dm_src), DerivedMesh *dm_dst, Mesh *me_dst,
-        const int dtdata_type, const bool changed, void *UNUSED(prepost_data))
+        const int dtdata_type, const bool changed)
 {
 	if (dtdata_type == DT_TYPE_LNOR) {
 		/* Bake edited destination loop normals into custom normals again. */
@@ -1131,7 +1128,6 @@ bool BKE_object_data_transfer_dm(
 	/* Check all possible data types.
 	 * Note item mappings and dest mix weights are cached. */
 	for (i = 0; i < DT_TYPE_MAX; i++) {
-		void *prepost_data;
 		const int dtdata_type = 1 << i;
 		int cddata_type;
 		int fromlayers, tolayers, fromto_idx;
@@ -1142,8 +1138,7 @@ bool BKE_object_data_transfer_dm(
 
 		data_transfer_dtdata_type_preprocess(ob_src, ob_dst, dm_src, dm_dst, me_dst,
 		                                     dtdata_type, dirty_nors_dst,
-		                                     (me_src->flag & ME_AUTOSMOOTH) != 0, me_src->smoothresh,
-		                                     &prepost_data);
+		                                     (me_src->flag & ME_AUTOSMOOTH) != 0, me_src->smoothresh);
 
 		cddata_type = BKE_object_data_transfer_dttype_to_cdtype(dtdata_type);
 
@@ -1340,8 +1335,7 @@ bool BKE_object_data_transfer_dm(
 			}
 		}
 
-		data_transfer_dtdata_type_postprocess(ob_src, ob_dst, dm_src, dm_dst, me_dst,
-		                                      dtdata_type, changed, prepost_data);
+		data_transfer_dtdata_type_postprocess(ob_src, ob_dst, dm_src, dm_dst, me_dst, dtdata_type, changed);
 	}
 
 	for (i = 0; i < DATAMAX; i++) {
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index cb41d2d..2258046 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -186,6 +186,8 @@ static void emDM_calcLoopNormalsSpaceset(
 	BMesh *bm = bmdm->em->bm;
 	const float (*vertexCos)[3], (*vertexNos)[3], (*polyNos)[3];
 	float (*loopNos)[3];
+	short (*clnors_data)[2];
+	int cd_loop_clnors_offset;
 
 	/* calculate loop normals from poly and vertex normals */
 	emDM_ensureVertNormals(bmdm);
@@ -202,39 +204,37 @@ static void emDM_calcLoopNormalsSpaceset(
 		loopNos = dm->getLoopDataArray(dm, CD_NORMAL);
 	}
 
-	{
-		/* We can have both, give priority to dm's data, and fallback to bm's ones. */
-		short (*clnors_data)[2] = dm->getLoopDataArray(dm, CD_CUSTOMLOOPNORMAL);
-		const int cd_loop_clnors_offset = clnors_data ? -1 : CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
+	/* We can have both, give priority to dm's data, and fallback to bm's ones. */
+	clnors_data = dm->getLoopDataArray(dm, CD_CUSTOMLOOPNORMAL);
+	cd_loop_clnors_offset = clnors_data ? -1 : CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
 
-		BM_loops_calc_normal_vcos(bm, vertexCos, vertexNos, polyNos, use_split_normals, split_angle, loopNos,
-		                          r_lnors_spaceset, clnors_data, cd_loop_clnors_offset);
+	BM_loops_calc_normal_vcos(bm, vertexCos, vertexNos, polyNos, use_split_normals, split_angle, loopNos,
+	                          r_lnors_spaceset, clnors_data, cd_loop_clnors_offset);
 #ifdef DEBUG_CLNORS
-		if (r_lnors_spaceset) {
-			int i;
-			for (i = 0; i < numLoops; i++) {
-				if (r_lnors_spaceset->lspaceset[i]->ref_alpha != 0.0f) {
-					LinkNode *loops = r_lnors_spaceset->lspaceset[i]->loops;
-					printf("Loop %d uses lnor space %p:\n", i, r_lnors_spaceset->lspaceset[i]);
-					print_v3("\tfinal lnor:", loopNos[i]);
-					print_v3("\tauto lnor:", r_lnors_spaceset->lspaceset[i]->vec_lnor);
-					print_v3("\tref_vec:", r_lnors_spaceset->lspaceset[i]->vec_ref);
-					printf("\talpha: %f\n\tbeta: %f\n\tloops: %p\n", r_lnors_spaceset->lspaceset[i]->ref_alpha,
-					       r_lnors_spaceset->lspaceset[i]->ref_beta, r_lnors_spaceset->lspaceset[i]->loops);
-					printf("\t\t(shared with loops");
-					while(loops) {
-						printf(" %d", GET_INT_FROM_POINTER(loops->link));
-						loops = loops->next;
-					}
-					printf(")\n");
-				}
-				else {
-					printf("Loop %d has no lnor space\n", i);
+	if (r_lnors_space

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list