[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58968] branches/ soc-2013-meshdata_transfer/source/blender: All transfer through projection: supporting either to transfer relative to the target (the space) or relative to the objects' centers

Walid Shouman eng.walidshouman at gmail.com
Tue Aug 6 16:50:40 CEST 2013


Revision: 58968
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58968
Author:   walid
Date:     2013-08-06 14:50:39 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
All transfer through projection: supporting either to transfer relative to the target (the space) or relative to the objects' centers

Modified Paths:
--------------
    branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
    branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
    branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c
    branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_shapekey.c
    branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c

Modified: branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
===================================================================
--- branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c	2013-08-06 13:41:05 UTC (rev 58967)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c	2013-08-06 14:50:39 UTC (rev 58968)
@@ -1093,7 +1093,8 @@
 }
 
 
-bool BM_mesh_shapekey_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, float tmp_mat[4][4])
+bool BM_mesh_shapekey_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, bool relative_to_target,
+                            float tmp_mat[4][4])
 {
 	//-----algorithm definitions start
 	struct BMBVHTree *bmtree_src = NULL;
@@ -1154,10 +1155,17 @@
 
 		//the way we do it is by looping over each vertex!!
 		for (v = BM_iter_new(&iter, bm_dst, BM_VERTS_OF_MESH, NULL); v; v = BM_iter_step(&iter)) {
+			if (relative_to_target == true) {
+				zero_v3(tmp_co);
 
-			// Transform into target space.
-			mul_v3_m4v3(tmp_co, tmp_mat, v->co);
+				// Transform into target space.
+				mul_v3_m4v3(tmp_co, tmp_mat, v->co);
+			}
 
+			else {
+				copy_v3_v3(tmp_co, v->co);
+			}
+
 			// Node tree accelerated search for closest face.
 			f = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);
 
@@ -1287,7 +1295,8 @@
 	return true;
 }
 
-bool BM_mesh_uv_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, float tmp_mat[4][4])
+bool BM_mesh_uv_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, bool relative_to_target,
+                      float tmp_mat[4][4])
 {
 	//-----uv dependent variables
 	BMLoop *l, *l2;						//used for iterating the destination's loops
@@ -1587,12 +1596,20 @@
 			zero_v3(f_mid_dst);
 			mid_poly_v3(f_mid_dst, v_co_list_dst, v_dst_count);
 
-			// Transform into target space.
-			mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
+			if (relative_to_target == true) {
+				// Transform into target space.
+				mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
 
-			// Node tree accelerated search for closest face.
-			f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
-																				//have faces within the radius range!!
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
+
+			else {
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, f_mid_dst, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
 			///fork from here to map each vertex into the projection
 
 			if (fl_table[f_src->head.index].f == NULL) {	//if the face source reperesnts a new entry
@@ -1642,14 +1659,19 @@
 
 				fl_table[f_src->head.index].l[b + (fl_table[f_src->head.index].count - f_dst->len)] = l;
 
-				zero_v3(tmp_co);
-				// Transform into target space.
-				mul_v3_m4v3(tmp_co, tmp_mat, l->v->co);
+				if (relative_to_target == true) {
+					zero_v3(tmp_co);
+					// Transform into target space.
+					mul_v3_m4v3(tmp_co, tmp_mat, l->v->co);
 
-				// Project each vertex onto face.
-				project_v3_plane(tmp_co, f_src->no, f_mid_src);
-				//project_v3_plane(tmp_co, f->no, f->l_first->v->co);//not sure, do we really have to use an actual vertex ?
+					// Project each vertex onto face.
+					project_v3_plane(tmp_co, f_src->no, f_mid_src);
+				}
 
+				else {
+					copy_v3_v3(tmp_co, f_mid_src);
+				}
+
 				// Interpolate weights over face.
 
 				//spatially finding the weights from the face's vertices
@@ -1837,7 +1859,7 @@
 	int count;	//used to keep track of the coordinate to be filled
 } coord_pool;
 
-bool BM_mesh_shapekey_copy3(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info,
+bool BM_mesh_shapekey_copy3(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, bool relative_to_target,
                             float tmp_mat[4][4])
 {
 	//-----algorithm definitions start
@@ -1937,12 +1959,21 @@
 			zero_v3(f_mid_dst);
 			mid_poly_v3(f_mid_dst, v_co_list_dst, v_dst_count);
 
-			// Transform into target space.
-			mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
+			if (relative_to_target == true) {
+				// Transform into target space.
+				mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
 
-			// Node tree accelerated search for closest face.
-			f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
-																				//have faces within the radius range!!
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
+
+			else {
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, f_mid_dst, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
+
 			//deprecated comment
 			///fork from here to map each vertex into the projection
 
@@ -1968,10 +1999,17 @@
 			mid_poly_v3(f_mid_src, v_co_list_src, v_src_count);	//get the mid point of the source face
 
 			BM_ITER_ELEM (v, &fiter, f_dst, BM_VERTS_OF_FACE) {
-				zero_v3(tmp_co);
-				// Transform into target space.
-				mul_v3_m4v3(tmp_co, tmp_mat, v->co);
+				if (relative_to_target == true) {
+					zero_v3(tmp_co);
 
+					// Transform into target space.
+					mul_v3_m4v3(tmp_co, tmp_mat, v->co);
+				}
+
+				else {
+					copy_v3_v3(tmp_co, v->co);
+				}
+
 				// Project each vertex onto face.
 				project_v3_plane(tmp_co, f_src->no, f_mid_src);
 				//project_v3_plane(tmp_co, f->no, f->l_first->v->co);//not sure, do we really have to use an actual vertex ?
@@ -2149,6 +2187,7 @@
 			// Node tree accelerated search for closest face.
 			f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
 																				//have faces within the radius range!!
+
 			//deprecated comment
 			///fork from here to map each vertex into the projection
 
@@ -2175,6 +2214,7 @@
 
 			BM_ITER_ELEM (v, &fiter, f_dst, BM_VERTS_OF_FACE) {
 				zero_v3(tmp_co);
+
 				// Transform into target space.
 				mul_v3_m4v3(tmp_co, tmp_mat, v->co);
 
@@ -2224,7 +2264,7 @@
 	return true;
 }
 
-bool BM_mesh_vertex_color_copy(BMesh *bm_src, BMesh* bm_dst, const struct ReplaceLayerInfo replace_info,
+bool BM_mesh_vertex_color_copy(BMesh *bm_src, BMesh* bm_dst, const struct ReplaceLayerInfo replace_info, bool relative_to_target,
                                float tmp_mat[4][4])
 {
 	//-----uv dependent variables
@@ -2310,12 +2350,20 @@
 			zero_v3(f_mid_dst);
 			mid_poly_v3(f_mid_dst, v_co_list_dst, v_dst_count);
 
-			// Transform into target space.
-			mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
+			if (relative_to_target == true) {
+				// Transform into target space.
+				mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
 
-			// Node tree accelerated search for closest face.
-			f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
-																				//have faces within the radius range!!
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
+
+			else {
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, f_mid_dst, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
 			///fork from here to map each vertex into the projection
 
 
@@ -2344,10 +2392,17 @@
 				MLoopCol *lcol = BM_ELEM_CD_GET_VOID_P(l, CD_dst);
 				MLoopCol *lcol_out = MEM_mallocN(sizeof(*lcol_out), "lcol_out bmesh_data_transfer.c");
 
-				zero_v3(tmp_co);
-				// Transform into target space.
-				mul_v3_m4v3(tmp_co, tmp_mat, l->v->co);
+				if (relative_to_target == true) {
+					zero_v3(tmp_co);
 
+					// Transform into target space.
+					mul_v3_m4v3(tmp_co, tmp_mat, l->v->co);
+				}
+
+				else {
+					copy_v3_v3(tmp_co, l->v->co);
+				}
+
 				// Project each vertex onto face.
 				project_v3_plane(tmp_co, f_src->no, f_mid_src);
 
@@ -2396,7 +2451,8 @@
 }
 
 
-bool BM_mesh_vertex_group_copy2(BMesh *bm_src, BMesh* bm_dst, const struct ReplaceLayerInfo replace_info,float tmp_mat[4][4])
+bool BM_mesh_vertex_group_copy2(BMesh *bm_src, BMesh* bm_dst, const struct ReplaceLayerInfo replace_info, bool relative_to_target,
+                                float tmp_mat[4][4])
 {
 	//-----algorithm definitions start
 	struct BMBVHTree *bmtree_src = NULL;
@@ -2494,12 +2550,21 @@
 			zero_v3(f_mid_dst);
 			mid_poly_v3(f_mid_dst, v_co_list_dst, v_dst_count);
 
-			// Transform into target space.
-			mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
+			if (relative_to_target == true) {
+				// Transform into target space.
+				mul_v3_m4v3(tmp_co, tmp_mat, f_mid_dst);	//to start searching for a match
 
-			// Node tree accelerated search for closest face.
-			f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
-																				//have faces within the radius range!!
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, tmp_co, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
+
+			else {
+				// Node tree accelerated search for closest face.
+				f_src = BKE_bmbvh_find_face_closest(bmtree_src, f_mid_dst, FLT_MAX);	//would return null if the source didn't
+																					//have faces within the radius range!!
+			}
+
 			//deprecated comment
 			///fork from here to map each vertex into the projection
 
@@ -2525,13 +2590,18 @@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list