Revision: 58963 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58963 Author: walid Date: 2013-08-06 09:19:44 +0000 (Tue, 06 Aug 2013) Log Message: ----------- Shapekey, UV and Vertex Color transfer: removing the layer identification completely outside of the copy functions
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 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 07:10:18 UTC (rev 58962) +++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c 2013-08-06 09:19:44 UTC (rev 58963) @@ -664,7 +664,7 @@ */ bool BM_mesh_shapekey_copy(BMesh *bm_src, BMesh *bm_dst, float tolerance, float radius_interp, int dist_pow, int no_pow, - bool USE_NORMALS, ST_ShapekeyGroupMode replace_mode, int *act_shapekey_lay, bool auto_tol, + bool USE_NORMALS, const struct ReplaceLayerInfo replace_info, bool auto_tol, float auto_tol_percentage) { int CD_offset_src, CD_offset_dst; @@ -674,7 +674,6 @@ BMVert *v; //iter => vertex iterator BMIter iter; - int tot_layer_src,tot_layer_dst; int src_lay_iter, dst_lay_iter; //tree variables @@ -690,7 +689,7 @@ //replace mode variables int src_lay_start, src_lay_end; - int dst_lay_start, dst_lay_end; //dst_lay_end currently isn't being used + int dst_lay_start; int i, j, k, m; @@ -721,9 +720,6 @@ //if it was false ... data other than //em->bm won't be copied - tot_layer_src = CustomData_number_of_layers(&bm_src->vdata, CD_SHAPEKEY);//to change the last one - tot_layer_dst = CustomData_number_of_layers(&bm_dst->vdata, CD_SHAPEKEY); //get the number of Shapekey layers - //within the target vertexCos_src_basis = MEM_mallocN(sizeof(*vertexCos_src_basis), "vertexCos_src_basis bmesh_data_transfer.c"); vertexCos_src_offset = MEM_mallocN(sizeof(*vertexCos_src_offset), "vertexCos_src_offset bmesh_data_transfer.c"); @@ -732,30 +728,10 @@ CD_basis_src = CustomData_get_n_offset(&bm_src->vdata, CD_SHAPEKEY, 0); //get the offset of the basis CD_basis_dst = CustomData_get_n_offset(&bm_dst->vdata, CD_SHAPEKEY, 0); - if (replace_mode == ST_APPEND_SHAPEKEY_GROUPS) { - //add 1 to skip the basis - src_lay_start = 1; - src_lay_end = tot_layer_src; - dst_lay_start = tot_layer_dst - tot_layer_src + 1; - dst_lay_end = tot_layer_dst; - } + src_lay_start = replace_info.src_lay_start; + src_lay_end = replace_info.src_lay_end; + dst_lay_start = replace_info.dst_lay_start; - else if ((replace_mode == ST_REPLACE_ENOUGH_SHAPEKEY_GROUPS) || (replace_mode == ST_REPLACE_ALL_SHAPEKEY_GROUPS)) { - src_lay_start = 1; - src_lay_end = tot_layer_src; - dst_lay_start = 1; - dst_lay_end = tot_layer_src; - } - - else if (replace_mode == ST_REPLACE_ACTIVE_SHAPEKEY_GROUP) { - //passed shapekey reperesents the # of shapekeys (starts from one), however lay_start uses it as an index - src_lay_start = act_shapekey_lay[0] - 1; - src_lay_end = act_shapekey_lay[0]; - dst_lay_start = act_shapekey_lay[1] - 1; - dst_lay_end = act_shapekey_lay[1]; - } - - //for a higher speed we allocate the pointers by the maximum size they may need (mesh_vert_num) in previous //to avoid nested reallocations if (src_lay_end >= src_lay_start) { @@ -831,7 +807,7 @@ } //start transfering for each layer - for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; src_lay_iter < src_lay_end; + for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; src_lay_iter <= src_lay_end; src_lay_iter++, dst_lay_iter++) { //fix the layer index of the source & dest @@ -1116,12 +1092,8 @@ } } -/*bool BM_mesh_shapekey_copy2(BMesh *bm_src, BMesh *bm_dst, float tolerance, float radius_interp, int dist_pow, int no_pow, - bool USE_NORMALS, ST_ShapekeyGroupMode replace_mode, int *act_shapekey_lay, - float tmp_mat[4])*/ -bool BM_mesh_shapekey_copy2(BMesh *bm_src, BMesh *bm_dst, float UNUSED(tolerance), float UNUSED(radius_interp), - int UNUSED(dist_pow), int UNUSED(no_pow), bool UNUSED(USE_NORMALS), - ST_ShapekeyGroupMode replace_mode, int *act_shapekey_lay, float tmp_mat[4][4]) + +bool BM_mesh_shapekey_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, float tmp_mat[4][4]) { //-----algorithm definitions start struct BMBVHTree *bmtree_src = NULL; @@ -1145,7 +1117,6 @@ BMVert *v; //iter => vertex iterator BMIter iter; - int tot_layer_src,tot_layer_dst; int src_lay_iter, dst_lay_iter; //tree variables @@ -1153,7 +1124,7 @@ //replace mode variables int src_lay_start, src_lay_end; - int dst_lay_start, dst_lay_end; //dst_lay_end currently isn't being used + int dst_lay_start; float v_co[3]; @@ -1164,39 +1135,17 @@ //if it was false ... data other than //em->bm won't be copied - tot_layer_src = CustomData_number_of_layers(&bm_src->vdata, CD_SHAPEKEY);//to change the last one - tot_layer_dst = CustomData_number_of_layers(&bm_dst->vdata, CD_SHAPEKEY); //get the number of Shapekey layers - //within the target CD_basis_src = CustomData_get_n_offset(&bm_src->vdata, CD_SHAPEKEY, 0); //get the offset of the basis CD_basis_dst = CustomData_get_n_offset(&bm_dst->vdata, CD_SHAPEKEY, 0); //get the faces tree bmtree_src = BKE_bmbvh_new(em_src, 0, NULL, false); - if (replace_mode == ST_APPEND_SHAPEKEY_GROUPS) { - //add 1 to skip the basis - src_lay_start = 1; - src_lay_end = tot_layer_src; - dst_lay_start = tot_layer_dst - tot_layer_src + 1; - dst_lay_end = tot_layer_dst; - } + src_lay_start = replace_info.src_lay_start; + src_lay_end = replace_info.src_lay_end; + dst_lay_start = replace_info.dst_lay_start; - else if ((replace_mode == ST_REPLACE_ENOUGH_SHAPEKEY_GROUPS) || (replace_mode == ST_REPLACE_ALL_SHAPEKEY_GROUPS)) { - src_lay_start = 1; - src_lay_end = tot_layer_src; - dst_lay_start = 1; - dst_lay_end = tot_layer_src; - } - - else if (replace_mode == ST_REPLACE_ACTIVE_SHAPEKEY_GROUP) { - //passed shapekey reperesents the # of shapekeys (starts from one), however lay_start uses it as an index - src_lay_start = act_shapekey_lay[0] - 1; - src_lay_end = act_shapekey_lay[0]; - dst_lay_start = act_shapekey_lay[1] - 1; - dst_lay_end = act_shapekey_lay[1]; - } - - for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; src_lay_iter < src_lay_end; + for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; src_lay_iter <= src_lay_end; src_lay_iter++, dst_lay_iter++) { //fix the layer index of the source & dest @@ -1338,9 +1287,7 @@ return true; } -bool BM_mesh_uv_copy2(BMesh *bm_src, BMesh *bm_dst, float UNUSED(tolerance), float UNUSED(radius_interp), - int UNUSED(dist_pow), int UNUSED(no_pow), bool UNUSED(USE_NORMALS), - ReplaceGroupMode replace_mode, int *UNUSED(act_shapekey_lay), float tmp_mat[4][4]) +bool BM_mesh_uv_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, float tmp_mat[4][4]) { //-----uv dependent variables BMLoop *l, *l2; //used for iterating the destination's loops @@ -1392,7 +1339,7 @@ //replace mode variables int src_lay_start, src_lay_end; - int dst_lay_start, dst_lay_end; //dst_lay_end currently isn't being used + int dst_lay_start; //------loops connecting definitions //we connect the loops (faces) after we map them to avoid the expensive //computation for an island based algorithm @@ -1607,28 +1554,12 @@ } tmp_weight = MEM_mallocN(sizeof(*tmp_weight) * exp_vert_per_face, "tmp_weight bmesh_data_transfer.c"); - if (replace_mode == APPEND_GROUPS) { - src_lay_start = 0; - src_lay_end = tot_layer_src; - dst_lay_start = tot_layer_dst - tot_layer_src; - dst_lay_end = tot_layer_dst; - } - else if ((replace_mode == REPLACE_ENOUGH_GROUPS) || (replace_mode == REPLACE_ALL_GROUPS)) { - src_lay_start = 0; - src_lay_end = tot_layer_src; - dst_lay_start = 0; - dst_lay_end = tot_layer_src; - } + src_lay_start = replace_info.src_lay_start; + src_lay_end = replace_info.src_lay_end; + dst_lay_start = replace_info.dst_lay_start; - else if (replace_mode == REPLACE_ACTIVE_GROUP) { - src_lay_start = CustomData_get_active_layer_index(&bm_src->ldata, CD_MLOOPUV); - src_lay_end = src_lay_start + 1; //stopping condition - dst_lay_start = CustomData_get_active_layer_index(&bm_dst->ldata, CD_MLOOPUV); - dst_lay_end = dst_lay_start + 1; - } - - for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; src_lay_iter < src_lay_end; + for (src_lay_iter = src_lay_start, dst_lay_iter = dst_lay_start; src_lay_iter <= src_lay_end; src_lay_iter++, dst_lay_iter++) { //fix the layer index of the source & dest @@ -1906,9 +1837,8 @@ 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, float UNUSED(tolerance), float UNUSED(radius_interp), - int UNUSED(dist_pow), int UNUSED(no_pow), bool UNUSED(USE_NORMALS), - ST_ShapekeyGroupMode replace_mode, int *act_shapekey_lay, float tmp_mat[4][4]) +bool BM_mesh_shapekey_copy3(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo replace_info, + float tmp_mat[4][4]) { //-----algorithm definitions start struct BMBVHTree *bmtree_src = NULL; @@ -1938,7 +1868,6 @@ BMVert *v; //iter => vertex iterator BMIter iter; - int tot_layer_src,tot_layer_dst; int src_lay_iter, dst_lay_iter; //tree variables @@ -1946,7 +1875,7 @@ //replace mode variables int src_lay_start, src_lay_end; - int dst_lay_start, dst_lay_end; //dst_lay_end currently isn't being used + int dst_lay_start; // float v_co[3]; @@ -1957,9 +1886,6 @@ //if it was false ... data other than //em->bm won't be copied - tot_layer_src = CustomData_number_of_layers(&bm_src->vdata, CD_SHAPEKEY);//to change the last one - tot_layer_dst = CustomData_number_of_layers(&bm_dst->vdata, CD_SHAPEKEY); //get the number of Shapekey layers - //within the target CD_basis_src = CustomData_get_n_offset(&bm_src->vdata, CD_SHAPEKEY, 0); //get the offset of the basis CD_basis_dst = CustomData_get_n_offset(&bm_dst->vdata, CD_SHAPEKEY, 0); @@ -1980,30 +1906,12 @@ } tmp_weight = MEM_mallocN(sizeof(*tmp_weight) * exp_vert_per_face, "tmp_weight bmesh_data_transfer.c"); - if (replace_mode == ST_APPEND_SHAPEKEY_GROUPS) { @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs