Revision: 58976
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58976
Author:   walid
Date:     2013-08-06 22:58:40 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
Code cleaning: removing deprecated function vertex BM_mesh_vertex_group_copy 
and replacing it with BM_mesh_vertex_group_copy2

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/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 21:52:05 UTC (rev 58975)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c
        2013-08-06 22:58:40 UTC (rev 58976)
@@ -2066,204 +2066,6 @@
        int count;
 } float_pool;
 
-bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* bm_dst, ReplaceGroupMode 
replace_mode, float tmp_mat[4][4])
-{
-       //-----algorithm definitions start
-       struct BMBVHTree *bmtree_src = NULL;
-       float *tmp_weight = NULL;
-       float tmp_co[3];
-       BMIter fiter, fiter2;
-       BMVert *v2;
-
-       int a;
-
-       BMIter viter;
-       BMFace *f_dst, *f_src;
-       int v_dst_count, v_src_count;
-       float (*v_co_list_dst)[3], (*v_co_list_src)[3];
-       float f_mid_dst[3], f_mid_src[3];
-       float_pool *weights_grp;                                //stores all 
the gathered offsets/vert to be averaged at the end of interpolation
-
-       float weight_accu;
-       int i;
-       const int exp_vert_per_face = 10;
-       int v_src_max_count, v_dst_max_count;
-       //====algorithm definitions end
-
-       int CD_src, CD_dst;
-
-       //used for iterating the destination's verts
-       BMVert *v;
-       //iter => vertex iterator
-       BMIter iter;
-       int tot_layer_src,tot_layer_dst;
-       int src_lay_iter, dst_lay_iter;
-
-       //tree variables
-       BMEditMesh *em_src;
-
-       //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
-
-       //Is that good to support edit mesh mode at the cost of receiving 
me_src too ?
-       //if (me_src->edit_btmesh != NULL) em_src = me_src->edit_btmesh;        
//edit mesh mode
-       //else
-       em_src = BKE_editmesh_create(bm_src, true);     //create editmesh data 
from bm WITH tess.
-                                                                               
                        //if it was false ... data other than
-                                                                               
                        //em->bm won't be copied
-
-       tot_layer_src = CustomData_number_of_layers(&bm_src->vdata, 
CD_MDEFORMVERT);//to change the last one
-       tot_layer_dst = CustomData_number_of_layers(&bm_dst->vdata, 
CD_MDEFORMVERT);    //get the number of Shapekey layers
-                                                                               
                                                                                
//within the target
-
-       //get the faces tree
-       bmtree_src = BKE_bmbvh_new(em_src, 0, NULL, false);
-
-       v_co_list_dst = MEM_mallocN(sizeof(*v_co_list_dst) * exp_vert_per_face, 
"v_co_list_dst bmesh_data_transfer.c");
-       v_co_list_src = MEM_mallocN(sizeof(*v_co_list_src) * exp_vert_per_face, 
"v_co_list_src bmesh_data_transfer.c");
-
-       weights_grp = MEM_mallocN(sizeof(*weights_grp) * bm_dst->totvert, 
"weights_grp bmesh_data_transfer.c");
-       BM_ITER_MESH (v, &iter, bm_dst, BM_VERTS_OF_MESH) {
-
-               BM_ITER_ELEM_INDEX (f_dst, &viter, v, BM_FACES_OF_VERT, a) {}
-               weights_grp[v->head.index].fl = 
MEM_mallocN(sizeof(*(weights_grp[v->head.index].fl)) * a,
-                       "weights_grp[v->head.index].fl  bmesh_data_transfer.c");
-
-               weights_grp[v->head.index].count = 0;   //if that wasn't fast 
enf we may use calloc for the offsets_grp
-       }
-
-       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;
-       }
-
-       else if (replace_mode == REPLACE_ACTIVE_GROUP) {
-               src_lay_start = 
CustomData_get_active_layer_index(&bm_src->ldata, CD_MDEFORMVERT);
-               src_lay_end = src_lay_start + 1;        //stopping condition
-               dst_lay_start = 
CustomData_get_active_layer_index(&bm_dst->ldata, CD_MDEFORMVERT);
-               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;
-               src_lay_iter++, dst_lay_iter++) {
-
-               //fix the layer index of the source & dest
-               CD_src = CustomData_get_n_offset(&bm_src->vdata, 
CD_MDEFORMVERT, src_lay_iter); //get the offset of the
-               CD_dst = CustomData_get_n_offset(&bm_dst->vdata, 
CD_MDEFORMVERT, dst_lay_iter); //lay_iter(th)CD_SHAPEKEY layer
-
-               //the way we do it is by looping over each face!!
-               BM_ITER_MESH (f_dst, &iter, bm_dst, BM_FACES_OF_MESH) {
-
-                       //get a coordinate list of the f_dst verts
-                       //used to get the the f_mid_dst for mid_poly_v3
-                       BM_ITER_ELEM_INDEX (v, &fiter, f_dst, BM_VERTS_OF_FACE, 
v_dst_count) {
-                               if (v_dst_count > exp_vert_per_face) {
-                                       if (v_dst_count > v_dst_max_count) {
-                                               v_co_list_dst = 
MEM_reallocN(v_co_list_dst, sizeof(*v_co_list_dst) * (v_dst_count + 1));
-                                               v_dst_max_count = v_dst_count;
-                                       }
-                               }
-
-                               copy_v3_v3(v_co_list_dst[v_dst_count], v->co);
-                       }
-
-                       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
-
-                       // 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
-
-                       //get a coordinate list of the f verts
-                       BM_ITER_ELEM_INDEX (v2, &fiter, f_src, 
BM_VERTS_OF_FACE, v_src_count) {
-                               //reallocate if the verts/faces were more than 
expected
-                               if (v_src_count > exp_vert_per_face) {
-                                       //and according to the previous records 
only allocate if that more than max already allocated
-                                       if (v_src_count > v_src_max_count) {
-                                               v_co_list_src = 
MEM_reallocN(v_co_list_src, sizeof(*v_co_list_src) * (v_src_count + 1));
-
-                                               // Prepare memory for later 
interpolation
-                                               tmp_weight = 
MEM_reallocN(tmp_weight, sizeof(*tmp_weight) * v_src_count);
-
-                                               v_src_max_count = v_src_count;
-                                       }
-                               }
-
-                               copy_v3_v3(v_co_list_src[v_src_count], v2->co);
-                       }
-
-                       zero_v3(f_mid_src);
-                       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);
-
-                               // Project each vertex onto face.
-                               project_v3_plane(tmp_co, f_src->no, f_mid_src);
-
-                               // Interpolate weights over face.
-
-                               //spatially finding the weights from the face's 
vertices
-                               interp_weights_poly_v3(tmp_weight, 
v_co_list_src, v_src_count, tmp_co);
-
-                               // Interpolating according to the spatially 
found weights
-                               // Get weights from face.
-                               weight_accu = 0;
-                               BM_ITER_ELEM_INDEX (v2, &fiter2, f_src, 
BM_VERTS_OF_FACE, a) {
-                                       weight_accu = BM_ELEM_CD_GET_FLOAT(v2, 
CD_src) * tmp_weight[a];
-                               }
-
-                               
weights_grp[v->head.index].fl[weights_grp[v->head.index].count] = weight_accu;
-                               (weights_grp[v->head.index].count)++;
-
-                               //shall we verify the indices!?
-                               //we interpolate vertix weights instead
-                       }
-
-               }
-
-               BM_ITER_MESH (v, &iter, bm_dst, BM_VERTS_OF_MESH) {
-                       weight_accu = 0;
-
-                       for (i = 0; i < weights_grp[v->head.index].count; i++) {
-                               weight_accu += 
(weights_grp[v->head.index].fl[i]) / (float)(weights_grp[v->head.index].count);
-                       }
-
-                       ((float*)BM_ELEM_CD_GET_VOID_P(v, CD_dst))[0] = 
weight_accu;
-                       weights_grp[v->head.index].count = 0;
-               }
-
-       }
-
-       BKE_bmbvh_free(bmtree_src);
-
-       MEM_freeN(v_co_list_dst);
-       MEM_freeN(v_co_list_src);
-       MEM_freeN(tmp_weight);
-
-       return true;
-}
-
 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])
 {
@@ -2451,7 +2253,7 @@
 }
 
 
-bool BM_mesh_vertex_group_copy2(BMesh *bm_src, BMesh* bm_dst, const struct 
ReplaceLayerInfo replace_info, bool relative_to_target,
+bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* bm_dst, const struct 
ReplaceLayerInfo replace_info, bool relative_to_target,
                                 float tmp_mat[4][4])
 {
        //-----algorithm definitions start

Modified: 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
===================================================================
--- 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
        2013-08-06 21:52:05 UTC (rev 58975)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.h
        2013-08-06 22:58:40 UTC (rev 58976)
@@ -70,10 +70,9 @@
 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]);
 void BM_mesh_shapekey_copy_index(BMesh *bm_src, BMesh *bm_dst);
-bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* bm_dst, ReplaceGroupMode 
replace_mode, float tmp_mat[4][4]);
 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]);
-bool BM_mesh_vertex_group_copy2(BMesh *bm_src, BMesh* bm_dst, const struct 
ReplaceLayerInfo replace_info, bool relative_to_target,
+bool BM_mesh_vertex_group_copy(BMesh *bm_src, BMesh* bm_dst, const struct 
ReplaceLayerInfo replace_info, bool relative_to_target,
                                 float tmp_mat[4][4]);
 
 #endif /* __BMESH_DATA_TRANSFER_H__ */

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 21:52:05 UTC (rev 58975)
+++ 
branches/soc-2013-meshdata_transfer/source/blender/editors/object/object_vgroup.c
   2013-08-06 22:58:40 UTC (rev 58976)
@@ -390,7 +390,7 @@
        BM_mesh_bm_from_me(bm_dst, me_dst, TRUE, true, 0);
 
        if (transfer_mode == PROJECTION_TRANSFER) {
-               if (!BM_mesh_vertex_group_copy2(bm_src, bm_dst, replace_info, 
relative_to_target, tmp_mat)) {
+               if (!BM_mesh_vertex_group_copy(bm_src, bm_dst, replace_info, 
relative_to_target, tmp_mat)) {
                        return false;
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to