[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60583] branches/ soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c : Code rewrite: clean up and moving unused code pieces to #if 0
Walid Shouman
eng.walidshouman at gmail.com
Mon Oct 7 10:25:30 CEST 2013
Revision: 60583
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60583
Author: walid
Date: 2013-10-07 08:25:30 +0000 (Mon, 07 Oct 2013)
Log Message:
-----------
Code rewrite: clean up and moving unused code pieces to #if 0
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-10-07 08:06:19 UTC (rev 60582)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c 2013-10-07 08:25:30 UTC (rev 60583)
@@ -21,7 +21,8 @@
#include "BKE_bvhutils.h" //using the bvhutils.h
#include "BKE_deform.h"
-//stub!! shall be rewired to the main function after the rewrite
+//----------------stub-----------------------------------
+///shall be rewired to the main function after the rewrite
bool BM_mesh_data_copy(BMesh *UNUSED(bm_src), BMesh* UNUSED(bm_dst), int UNUSED(type), const struct ReplaceLayerInfo *UNUSED(replace_info), bool UNUSED(relative_to_target),
float UNUSED(tmp_mat[4][4]), bool UNUSED(use_tolerance), float UNUSED(tolerance))
{
@@ -35,73 +36,7 @@
//---------------------------*
//----------------------*
//******************
-BMLoop* BM_vert_find_best_tan_match_loop(BMVert *v_src, BMLoop *l_dst);
-BMLoop* BM_vert_find_best_tan_match_loop(BMVert *v_src, BMLoop *l_dst) {
-
- BMLoop *l, *l_src;
- BMIter liter;
- float l_dst_tan[3], l_src_tan[3];
-
- float dot_product, prev_dot_product;
-
- if (BM_vert_edge_count(v_src) == 0) {
- return NULL;
- }
-
- dot_product = -1;
- prev_dot_product = -2;
-
- BM_loop_calc_face_tangent(l_dst, l_dst_tan);
-
- BM_ITER_ELEM (l_src, &liter, v_src, BM_LOOPS_OF_VERT) {
- BM_loop_calc_face_tangent(l_src, l_src_tan);
-
- dot_product = dot_v3v3(l_src_tan, l_dst_tan);
-
- if (dot_product > prev_dot_product) {
- l = l_src;
- prev_dot_product = dot_product;
- }
-
- }
-
- return l;
-}
-
-BMLoop* BM_face_find_best_tan_match_loop(BMFace *f_src, BMLoop *l_dst);
-
-BMLoop* BM_face_find_best_tan_match_loop(BMFace *f_src, BMLoop *l_dst) {
-
- BMLoop *l, *l_src;
- BMIter liter;
- float l_dst_tan[3], l_src_tan[3];
-
- float dot_product, prev_dot_product;
-
- if (f_src->len == 0)
- return NULL;
-
- dot_product = -1;
- prev_dot_product = -2;
-
- BM_loop_calc_face_tangent(l_dst, l_dst_tan);
-
- BM_ITER_ELEM (l_src, &liter, f_src, BM_LOOPS_OF_FACE) {
- BM_loop_calc_face_tangent(l_src, l_src_tan);
-
- dot_product = dot_v3v3(l_src_tan, l_dst_tan);
-
- if (dot_product > prev_dot_product) {
- l = l_src;
- prev_dot_product = dot_product;
- }
-
- }
-
- return l;
-}
-
typedef struct BMFace_match {
BMFace *f_src;
BMFace *f_dst;
@@ -114,12 +49,19 @@
BMVert *v_dst;
} BMVert_match;
-//---------------helping functions-----------------------
+//---------------Declarations------------------------------
+
+//---------------helping functions declarations -----------
+BMLoop* BM_vert_find_best_tan_match_loop(BMVert *v_src, BMLoop *l_dst);
+#if 0
+BMLoop* BM_face_find_best_tan_match_loop(BMFace *f_src, BMLoop *l_dst);
+#endif
+
int* BM_transform_index_mapping(BMesh *bm_src, BMElem **array_dst, int array_dst_count, int *index_mapping_in,
- int UNUSED_htype_from, int UNUSED_htype_to);
+ int htype_from, int htype_to);
void *BM_mesh_mapping(BMesh *bm_src, BMesh *bm_dst, const char htype);
-//--------------index based transfer functions ----------
+//--------------index transfer declarations ----------
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 *replace_info);
@@ -127,7 +69,7 @@
static void BM_mesh_transfer_aligned(BMesh *bm_src, BMesh *bm_dst, const char htype, const int layer_type,
const struct ReplaceLayerInfo *replace_info);
-//--------------topology based transfer functions ------
+//--------------topology transfer declarations ------
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 *replace_info,
@@ -138,6 +80,8 @@
void set_loop_indices(BMesh *bm);
+//---------------Definitions---------------------------
+
bool BM_mesh_data_copy2(BMesh *bm_src, BMesh* bm_dst, const struct ReplaceLayerInfo *replace_info, int type,
TransferMode transfer_mode)
{
@@ -246,6 +190,8 @@
return true;
}
+//--------------index transfer definitions---------
+
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 *replace_info)
@@ -283,50 +229,6 @@
}
}
-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 *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;
-
- void *ptr;
-
- for (i = 0; i < array_dst_count; i++) {
-
- BMElem *ele_src;
- BMElem *ele_dst;
-
- if (index_mapping[i] == -1) { //shall never be reached!!
- continue;
- }
-
- ele_src = array_src[index_mapping[i]];
- ele_dst = array_dst[i];
-
- if (layer_type == CD_MDEFORMVERT) {
- //all vertex groups will be copied as they are found in a single CD_layer
- 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);
- }
- }
- }
- }
-}
-
static void BM_mesh_transfer_aligned(BMesh *bm_src, BMesh *bm_dst, const char htype, const int layer_type,
const struct ReplaceLayerInfo *replace_info)
{
@@ -382,11 +284,12 @@
cd_dst = &bm_dst->vdata;
break;
+#if 0
case BM_EDGE:
cd_src = &bm_src->edata;
cd_dst = &bm_dst->edata;
break;
-
+#endif
case BM_LOOP:
cd_src = &bm_src->ldata;
cd_dst = &bm_dst->ldata;
@@ -398,6 +301,52 @@
BM_mesh_cd_transfer_array(cd_src, array_src, array_src_len, cd_dst, array_dst, array_dst_len, layer_type, replace_info);
}
+//--------------topology transfer definitions---------
+
+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 *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;
+
+ void *ptr;
+
+ for (i = 0; i < array_dst_count; i++) {
+
+ BMElem *ele_src;
+ BMElem *ele_dst;
+
+ if (index_mapping[i] == -1) { //shall never be reached!!
+ continue;
+ }
+
+ ele_src = array_src[index_mapping[i]];
+ ele_dst = array_dst[i];
+
+ if (layer_type == CD_MDEFORMVERT) {
+ //all vertex groups will be copied as they are found in a single CD_layer
+ 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);
+ }
+ }
+ }
+ }
+}
+
static void BM_mesh_transfer_mapped(BMesh *bm_src, BMesh *bm_dst, const char htype, const int layer_type,
const struct ReplaceLayerInfo *replace_info)
{
@@ -458,17 +407,21 @@
cd_src = &bm_src->vdata;
cd_dst = &bm_dst->vdata;
break;
-
+#if 0
case BM_EDGE:
cd_src = &bm_src->edata;
cd_dst = &bm_dst->edata;
break;
+#endif
case BM_LOOP:
cd_src = &bm_src->ldata;
cd_dst = &bm_dst->ldata;
break;
+ default:
+ break;
+
///should the pdata be associated to the FACES_OF_MESH?
}
@@ -480,16 +433,22 @@
MEM_freeN(index_mapping);
}
+//---------------helping functions definitions-----------
+
void *BM_mesh_mapping(BMesh *bm_src, BMesh *bm_dst, const char htype)
{
BMVert *v_src, *v_dst;
+ BMIter iter;
+#if 0
BMFace *f_src, *f_dst;
BMLoop *l_dst, *l_src;
- BMIter iter, fiter, liter;
+ BMIter fiter, liter;
+ float f_mid_dst[3];
+#endif
+
int a;
int *index_mapping;
- float f_mid_dst[3];
//does the bm_src get affected when we do_tesselation ?
BMBVHTree *bmtree_src;
@@ -514,6 +473,7 @@
}
break;
+#if 0
case BM_LOOP:
index_mapping = MEM_mallocN(bm_dst->totloop * sizeof(*index_mapping), "index_mapping bmesh_data_transfer.c");
@@ -539,6 +499,14 @@
}
break;
+
+ case BM_EDGE:
+ break;
+
+ case BM_FACE:
+ break;
+#endif
+
default:
BKE_bmbvh_free(bmtree_src);
MEM_freeN(em_src);
@@ -571,7 +539,7 @@
}
int* BM_transform_index_mapping(BMesh *bm_src,BMElem **array_dst, int array_dst_count, int *index_mapping_in,
- int UNUSED(htype_from), int UNUSED(htype_to))
+ int htype_from, int htype_to)
{
int i;
BMElem *ele_dst;
@@ -581,32 +549,103 @@
int *index_mapping_out = MEM_mallocN(array_dst_count * sizeof(*index_mapping_out),
"index_mapping_out bmesh_data_transfer.c");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list