[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59910] branches/ soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c : code rewrite: code-cleanup removing BM_mesh_multi_layer_copy2()
Walid Shouman
eng.walidshouman at gmail.com
Sat Sep 7 08:11:32 CEST 2013
Revision: 59910
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59910
Author: walid
Date: 2013-09-07 06:11:32 +0000 (Sat, 07 Sep 2013)
Log Message:
-----------
code rewrite: code-cleanup removing BM_mesh_multi_layer_copy2()
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-07 05:59:05 UTC (rev 59909)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c 2013-09-07 06:11:32 UTC (rev 59910)
@@ -103,8 +103,6 @@
static void BM_mesh_aligned_transfer(BMesh *bm_src, BMesh *bm_dst, const char htype, const int layer_type,
const struct ReplaceLayerInfo *replace_info);
-bool BM_mesh_multi_layer_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo *replace_info,
- TransferMode transfer_mode, int type, void *match_table);
bool BM_mesh_data_copy2(BMesh *bm_src, BMesh* bm_dst, const struct ReplaceLayerInfo *replace_info, int type)
{
@@ -198,184 +196,6 @@
return true;
}
-bool BM_mesh_multi_layer_copy2(BMesh *bm_src, BMesh *bm_dst, const struct ReplaceLayerInfo *replace_info,
- TransferMode transfer_mode, int type, void *match_table)
-{
-
- BMIter liter, fiter, iter;
- BMFace *UNUSED(f_src), *f_dst, *f;
- BMVert *v_src, *v_dst, *v;
- BMLoop *UNUSED(l_src), *UNUSED(l_dst), *l;
- int a, b;
-
- //layer management
- int src_lay_iter, dst_lay_iter;
- int src_lay_start = replace_info->src_lay_start;
- int src_lay_end = replace_info->src_lay_end;
- int dst_lay_start = replace_info->dst_lay_start;
-
-//+-------------+
-//| |
-//| Block 1 | //Switch over the copy method ... either by index or interpolate
-//| |
-//+-------------+
-
-
- //transfer by indices (1.0)
- // |
- // |
- // V
-
- if(transfer_mode == TRANSFER_BY_INDEX) {
-
- if ((bm_dst->totface != bm_src->totface) || (bm_dst->totvert != bm_src->totvert))
- return false;
-
- 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++) {
-
- //+-----------------+
- //| sub_Block 1.0.a | //paste into each loop's/vert's value
- //+-----------------+
-
- switch (type) {
- case CD_MLOOPCOL:
- {
- BMFace_match *f_match_table = (BMFace_match*) match_table;
-
- //fix the layers
- int CD_src = CustomData_get_n_offset(&bm_src->ldata, CD_MLOOPCOL, src_lay_iter);
- int CD_dst = CustomData_get_n_offset(&bm_dst->ldata, CD_MLOOPCOL, dst_lay_iter);
-
- //as we can see here, storing l_src_dst may seem a redundant step ... however its made
- //as a matter of consistency and being over cautious
- BM_ITER_MESH_INDEX (f, &fiter, bm_dst, BM_FACES_OF_MESH, a) {
- BMLoop **l_src_grp = f_match_table[a].l_src;
- BMLoop **l_dst_grp = f_match_table[a].l_dst;
-
- f_dst = f_match_table[a].f_dst;
- BM_ITER_ELEM_INDEX (l, &liter, f_dst, BM_LOOPS_OF_FACE, b) {
- MLoopCol *lcol_src = BM_ELEM_CD_GET_VOID_P(l_src_grp[b], CD_src);
- MLoopCol *lcol_dst = BM_ELEM_CD_GET_VOID_P(l_dst_grp[b], CD_dst);
- CustomData_data_copy_value(CD_MLOOPCOL, lcol_src, lcol_dst);
- }
-
- }
-
- break;
- }
- case CD_MLOOPUV:
- {
- BMFace_match *f_match_table = (BMFace_match*) match_table;
-
- //fix the layers
- int CD_src = CustomData_get_n_offset(&bm_src->ldata, CD_MLOOPUV, src_lay_iter);
- int CD_dst = CustomData_get_n_offset(&bm_dst->ldata, CD_MLOOPUV, dst_lay_iter);
-
- //as we can see here, storing l_src_dst may seem a redundant step ... however its made
- //as a matter of consistency and being over cautious
- BM_ITER_MESH_INDEX (f, &fiter, bm_dst, BM_FACES_OF_MESH, a) {
- BMLoop **l_src_grp = f_match_table[a].l_src;
- BMLoop **l_dst_grp = f_match_table[a].l_dst;
-
- f_dst = f_match_table[a].f_dst;
- BM_ITER_ELEM_INDEX (l, &liter, f_dst, BM_LOOPS_OF_FACE, b) {
- MLoopUV *lcol_src = BM_ELEM_CD_GET_VOID_P(l_src_grp[b], CD_src);
- MLoopUV *lcol_dst = BM_ELEM_CD_GET_VOID_P(l_dst_grp[b], CD_dst);
- CustomData_data_copy_value(CD_MLOOPUV, lcol_src, lcol_dst);
- }
-
- }
-
- break;
- }
- case CD_SHAPEKEY:
- {
- BMVert_match *v_match_table = (BMVert_match*) match_table;
-
- //fix the layers
- int CD_basis_src = CustomData_get_n_offset(&bm_src->vdata, CD_SHAPEKEY, 0); //get the offset of the basis
- int CD_basis_dst = CustomData_get_n_offset(&bm_dst->vdata, CD_SHAPEKEY, 0);
- int CD_offset_src = CustomData_get_n_offset(&bm_src->vdata, CD_SHAPEKEY,src_lay_iter); //get the offset of the
- int CD_offset_dst = CustomData_get_n_offset(&bm_dst->vdata, CD_SHAPEKEY,dst_lay_iter); //lay_iter(th)CD_SHAPEKEY layer
-
- BM_ITER_MESH_INDEX (v, &iter, bm_dst, BM_VERTS_OF_MESH, a) {
- float *lcol_src = BM_ELEM_CD_GET_VOID_P(v_src, CD_offset_dst);
- float *lcol_dst = BM_ELEM_CD_GET_VOID_P(v_dst, CD_offset_src);
-
- float *lcol_src_basis = BM_ELEM_CD_GET_VOID_P(v_src, CD_basis_src);
- float *lcol_dst_basis = BM_ELEM_CD_GET_VOID_P(v_dst, CD_basis_dst);
-
- float offset[3];
-
- v_src = v_match_table[a].v_src;
- v_dst = v_match_table[a].v_dst;
-
- sub_v3_v3v3(offset, lcol_src, lcol_src_basis);
- add_v3_v3v3(lcol_dst, offset, lcol_dst_basis);
- }
-
- break;
- }
- case CD_MDEFORMVERT:
- {
- BMVert_match *v_match_table = (BMVert_match*) match_table;
-
- //fix the layers
- const int cd_dvert_dst_offset = CustomData_get_offset(&bm_dst->vdata, CD_MDEFORMVERT);
- const int cd_dvert_src_offset = CustomData_get_offset(&bm_src->vdata, CD_MDEFORMVERT);
-
- const int src_grp_ind = src_lay_start + src_lay_iter;
- const int dst_grp_ind = dst_lay_start + dst_lay_iter;
-
- BM_ITER_MESH_INDEX (v, &iter, bm_dst, BM_VERTS_OF_MESH, a) {
- MDeformVert *dv_dst, *dv_src;
- MDeformWeight *dw_dst, *dw_src;
-
- v_src = v_match_table[a].v_src;
- v_dst = v_match_table[a].v_dst;
-
- dv_src = BM_ELEM_CD_GET_VOID_P(v_src, cd_dvert_src_offset);
- dw_src = defvert_verify_index(dv_src, src_grp_ind);
-
- dv_dst = BM_ELEM_CD_GET_VOID_P(v_dst, cd_dvert_dst_offset);
- dw_dst = defvert_verify_index(dv_dst, dst_grp_ind);
-
- if (dw_src == NULL)
- dw_dst = NULL;
-
- else
- dw_src->weight = dw_dst->weight;
- }
-
- break;
- }
- }
- }
- }
-
- else {
- //transfer by interpolation (1.1)
- // |
- // |
- // V
-
- //+-----------------+
- //| sub_Block 1.1.a | //loop over each destination face
- //+-----------------+
-
- //+---------------------+
- //| sub_Block 1.1.a.1 | //paste the (weights * source data) into the destination
- //+---------------------+
-
- //+---------------------+
- //| sub_Block 1.1.a.2 | //make any needed post processing that is data type dependent
- //+---------------------+ //ie: average for the vert values in the shapekeys .. connect faces in the UV transfer
- }
- return true;
-}
-
-
static void BM_mesh_cd_array_transfer(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))
More information about the Bf-blender-cvs
mailing list