[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58965] branches/ soc-2013-meshdata_transfer/source/blender: Applying fixes for the layer management of all the transfer functions, fix for UV transfer -mistake of swapping CD_dst with CD_src which didn' t show up in small layer numbers-

Walid Shouman eng.walidshouman at gmail.com
Tue Aug 6 12:52:44 CEST 2013


Revision: 58965
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58965
Author:   walid
Date:     2013-08-06 10:52:43 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
Applying fixes for the layer management of all the transfer functions, fix for UV transfer -mistake of swapping CD_dst with CD_src which didn't show up in small layer numbers-

Modified Paths:
--------------
    branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
    branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.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 09:27:20 UTC (rev 58964)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c	2013-08-06 10:52:43 UTC (rev 58965)
@@ -1682,7 +1682,7 @@
 
 					f_n = (fa->head.index == f_src->head.index) ? fb: fa;
 					//if any of them was found in our src tables
-					if ((fl_table[f_n->head.index].f != NULL) && (BM_edge_has_consistant_loops(e, CD_dst))) {
+					if ((fl_table[f_n->head.index].f != NULL) && (BM_edge_has_consistant_loops(e, CD_src))) {
 
 						//search within the mapped -to the src face- loops in fl_table
 						//for the loops that share the same vertex between f_src and f_n

Modified: branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c
===================================================================
--- branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c	2013-08-06 09:27:20 UTC (rev 58964)
+++ branches/soc-2013-meshdata_transfer/source/blender/editors/mesh/mesh_data.c	2013-08-06 10:52:43 UTC (rev 58965)
@@ -614,8 +614,8 @@
 	else if (replace_mode == REPLACE_ACTIVE_GROUP) {
 
 		//find the source active layer
-		active_src = CustomData_get_active_layer_index(&me_src->ldata, CD_MLOOPUV);
-		active_dst = CustomData_get_active_layer_index(&me_dst->ldata, CD_MLOOPUV);
+		active_src = CustomData_get_active_layer_index(&me_src->ldata, CD_MLOOPUV) - me_src->ldata.typemap[CD_MLOOPUV];
+		active_dst = CustomData_get_active_layer_index(&me_dst->ldata, CD_MLOOPUV) - me_src->ldata.typemap[CD_MLOOPUV];
 
 		CD_src = CustomData_get_layer_index(&me_src->pdata, CD_MTEXPOLY);
 
@@ -639,9 +639,9 @@
 			CustomData_set_layer_name(&me_dst->pdata, CD_MTEXPOLY, active_dst, src_name);
 		}
 
-		replace_info.src_lay_start = active_src - 1;
+		replace_info.src_lay_start = active_src;
 		replace_info.src_lay_end = replace_info.src_lay_start;
-		replace_info.dst_lay_start = active_dst - 1;	//fixing the indices
+		replace_info.dst_lay_start = active_dst;	//fixing the indices
 		replace_info.dst_lay_end = replace_info.dst_lay_start;
 	}
 
@@ -817,7 +817,7 @@
 		//add layers as needed
 		i = num_src_lay - num_dst_lay;
 		while (i > 0) {
-			ED_mesh_uv_texture_add(me_dst, NULL, true);
+			ED_mesh_color_add(me_dst, NULL, true);
 			i--;
 		}
 		CD_src = CustomData_get_layer_index(&me_src->ldata, CD_MLOOPCOL);
@@ -842,7 +842,7 @@
 
 			src_name = me_src->ldata.layers[CD_src + i].name;
 			//append uv layer with the src names
-			ED_mesh_uv_texture_add(me_dst, src_name, true);
+			ED_mesh_color_add(me_dst, src_name, true);
 		}
 
 		replace_info.src_lay_start = 0;
@@ -856,14 +856,14 @@
 		i = num_dst_lay;
 		while (i > 0) {
 			i--;
-			ED_mesh_uv_texture_remove_index(me_dst, i);
+			ED_mesh_color_remove_index(me_dst, i);
 		}
 
 		CD_src = CustomData_get_layer_index(&me_src->ldata, CD_MLOOPCOL);
 		for (i = 0; i < num_src_lay; ++i) {
 			src_name = me_src->ldata.layers[CD_src + i].name;
 			//add uv layer with the src name
-			ED_mesh_uv_texture_add(me_dst, src_name, true);
+			ED_mesh_color_add(me_dst, src_name, true);
 		}
 
 		replace_info.src_lay_start = 0;
@@ -875,20 +875,21 @@
 	else if (replace_mode == REPLACE_ACTIVE_GROUP) {
 
 		//find the source active layer
-		active_src = CustomData_get_active_layer_index(&me_src->ldata, CD_MLOOPCOL);
-		active_dst = CustomData_get_active_layer_index(&me_dst->ldata, CD_MLOOPCOL);
+		active_src = CustomData_get_active_layer_index(&me_src->ldata, CD_MLOOPCOL) - me_src->ldata.typemap[CD_MLOOPCOL];
+		active_dst = CustomData_get_active_layer_index(&me_dst->ldata, CD_MLOOPCOL) - me_dst->ldata.typemap[CD_MLOOPCOL];
 
 		CD_src = CustomData_get_layer_index(&me_src->ldata, CD_MLOOPCOL);
 
-		if (num_src_lay == 0) {	//empty destination
+		if (num_dst_lay == 0) {	//empty destination
 			src_name = me_src->ldata.layers[CD_src + active_src].name;
 
 			//add uv layer with the src name
-			ED_mesh_uv_texture_add(me_dst, src_name, true);
+			ED_mesh_color_add(me_dst, src_name, true);
 
 			//make the added layer the active one
 			///what about the MTEXPOLY
-			CustomData_set_layer_active(&me_dst->ldata, CD_MLOOPCOL, 0);
+			active_dst = 0;
+			CustomData_set_layer_active(&me_dst->ldata, CD_MLOOPCOL, active_dst);
 		}
 
 		else {	//destination has layers (accordingly there's a selected layer)
@@ -898,9 +899,9 @@
 			CustomData_set_layer_name(&me_dst->ldata, CD_MLOOPCOL, active_dst, src_name);
 		}
 
-		replace_info.src_lay_start = active_src - 1;
+		replace_info.src_lay_start = active_src;
 		replace_info.src_lay_end = replace_info.src_lay_start;
-		replace_info.dst_lay_start = active_dst - 1;	//fixing the indices
+		replace_info.dst_lay_start = active_dst;	//fixing the indices
 		replace_info.dst_lay_end = replace_info.dst_lay_start;
 	}
 

Modified: branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c
===================================================================
--- branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c	2013-08-06 09:27:20 UTC (rev 58964)
+++ branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c	2013-08-06 10:52:43 UTC (rev 58965)
@@ -310,14 +310,16 @@
 	else if (replace_mode == APPEND_GROUPS)
 	{
 		dg_src = ob_src->defbase.first;
+		dg_dst = ob_dst->defbase.last;
 
 		for (i = 0; i < num_src_lay; ++i) {
-
 			src_name = dg_src->name;
 			//append vertex group with the src names
 			ED_vgroup_add_name(ob_dst, src_name);
 
-			dg_dst = dg_dst->next;
+			//we could eliminate that check if layers are ordered according to the last (ie: instead of by name)
+			dg_dst = (dg_dst == NULL) ? ob_dst->defbase.last : dg_dst->next;
+			dg_src = dg_src->next;
 		}
 
 		replace_info.src_lay_start = 0;
@@ -332,6 +334,9 @@
 			ED_vgroup_delete(ob_dst, dg_dst);
 		}
 
+		//after removing all the layers we'll need to re-add the CD_MDEFORMVERT
+		CustomData_add_layer(&me_dst->vdata, CD_MDEFORMVERT, 1, NULL, me_dst->totvert);
+
 		dg_src = ob_src->defbase.first;
 
 		for (i = 0; i < num_src_lay; ++i) {
@@ -353,13 +358,15 @@
 		active_src = ob_src->actdef;
 		active_dst = ob_dst->actdef;
 
-		dg_src = BLI_findlink(&ob_src->defbase, active_src);
-		dg_dst = BLI_findlink(&ob_dst->defbase, active_dst);
+		dg_src = BLI_findlink(&ob_src->defbase, active_src - 1);
+		dg_dst = BLI_findlink(&ob_dst->defbase, active_dst - 1);
 
-		if (num_src_lay == 0) {	//empty destination
+		if (num_dst_lay == 0) {	//empty destination
 			src_name = dg_src->name;
 			ED_vgroup_add_name(ob_dst, src_name);
 
+			active_dst++;
+			dg_dst = BLI_findlink(&ob_dst->defbase, active_dst - 1);
 		}
 
 		else {	//destination has layers (accordingly there's a selected layer)




More information about the Bf-blender-cvs mailing list