[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60192] branches/ soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c : code rewrite: using the replace_layer_info in copying the customdata

Walid Shouman eng.walidshouman at gmail.com
Tue Sep 17 12:02:55 CEST 2013


Revision: 60192
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60192
Author:   walid
Date:     2013-09-17 10:02:54 +0000 (Tue, 17 Sep 2013)
Log Message:
-----------
code rewrite: using the replace_layer_info in copying the customdata

Modified Paths:
--------------
    branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.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-09-17 09:17:10 UTC (rev 60191)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c	2013-09-17 10:02:54 UTC (rev 60192)
@@ -244,10 +244,15 @@
 
 static void BM_mesh_cd_transfer_array(CustomData *cd_src, BMElem **array_src, int array_src_count,
                                       CustomData *cd_dst, BMElem **array_dst, int array_dst_count,
-                                      const int layer_type, const struct ReplaceLayerInfo *UNUSED(replace_info))
+                                      const int layer_type, const struct ReplaceLayerInfo *replace_info)
 {
 	//... copy between arrays aligned arrays ...
+	int dst_lay_start = replace_info->dst_lay_start;
+	int dst_lay_end = replace_info->dst_lay_end;
+	int src_lay_start = replace_info->src_lay_start;
+	int src_n, dst_n;
 
+
 	if ((array_dst && array_src) && (array_src_count == array_dst_count)) {
 		int i;
 
@@ -257,19 +262,32 @@
 			BMElem *ele_src = array_src[i];
 			BMElem *ele_dst = array_dst[i];
 
-			ptr = CustomData_bmesh_get(cd_src, ele_src->head.data, layer_type);
-			CustomData_bmesh_set(cd_dst, ele_dst->head.data, layer_type, ptr);
+			if (layer_type == CD_MDEFORMVERT) {
+				ptr = CustomData_bmesh_get(cd_src, ele_src->head.data, layer_type);
+				CustomData_bmesh_set(cd_dst, ele_dst->head.data, layer_type, ptr);
+			}
 
+			else {
+				for (dst_n = dst_lay_start, src_n = src_lay_start; dst_n <= dst_lay_end; dst_n++, src_n++) {
+					ptr = CustomData_bmesh_get_n(cd_src, ele_src->head.data, layer_type, src_n);
+					CustomData_bmesh_set_n(cd_dst, ele_dst->head.data, layer_type, dst_n, ptr);
+				}
+			}
+
 		}
 	}
 }
 
 void BM_mesh_cd_transfer_mapped(CustomData *cd_src, BMElem **array_src, int array_src_count,
                                       CustomData *cd_dst, BMElem **array_dst, int array_dst_count,
-                                      const int layer_type, const struct ReplaceLayerInfo *UNUSED(replace_info),
+                                      const int layer_type, const struct ReplaceLayerInfo *replace_info,
                                       int *index_mapping)
 {
 	//... copy between arrays with a mapping! ...
+	int dst_lay_start = replace_info->dst_lay_start;
+	int dst_lay_end = replace_info->dst_lay_end;
+	int src_lay_start = replace_info->src_lay_start;
+	int src_n, dst_n;
 
 	if ((array_dst && array_src) && (array_src_count == array_dst_count)) {
 		int i;
@@ -288,9 +306,17 @@
 			ele_src = array_src[index_mapping[i]];
 			ele_dst = array_dst[i];
 
-			ptr = CustomData_bmesh_get(cd_src, ele_src->head.data, layer_type);
-			CustomData_bmesh_set(cd_dst, ele_dst->head.data, layer_type, ptr);
+			if (layer_type == CD_MDEFORMVERT) {
+				ptr = CustomData_bmesh_get(cd_src, ele_src->head.data, layer_type);
+				CustomData_bmesh_set(cd_dst, ele_dst->head.data, layer_type, ptr);
 
+			}
+			else {
+				for (dst_n = dst_lay_start, src_n = src_lay_start; dst_n <= dst_lay_end; dst_n++, src_n++) {
+					ptr = CustomData_bmesh_get_n(cd_src, ele_src->head.data, layer_type, src_n);
+					CustomData_bmesh_set_n(cd_dst, ele_dst->head.data, layer_type, dst_n, ptr);
+				}
+			}
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list