[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59501] branches/ soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c : code rewrite: removing the old code ...
Walid Shouman
eng.walidshouman at gmail.com
Sun Aug 25 20:52:53 CEST 2013
Revision: 59501
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59501
Author: walid
Date: 2013-08-25 18:52:52 +0000 (Sun, 25 Aug 2013)
Log Message:
-----------
code rewrite: removing the old code ... leaving only a stub for BM_mesh_data_copy()
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-08-25 18:45:04 UTC (rev 59500)
+++ branches/soc-2013-meshdata_transfer/source/blender/bmesh/tools/bmesh_data_transfer.c 2013-08-25 18:52:52 UTC (rev 59501)
@@ -21,3400 +21,13 @@
#include "BKE_bvhutils.h" //using the bvhutils.h
#include "BKE_deform.h"
-//should be replaced by the min_float and its inverse
-#ifndef MY_MIN_FLOAT
-#define MY_MIN_FLOAT .001
-#endif
-
-#ifndef MY_MAX_FLOAT
-#define MY_MAX_FLOAT 1000
-#endif
-
-#define SHAPEKEY_VALUES_BY_VERT (1 << 1)
-#define SHAPEKEY_VALUES_BY_LAYER (1 << 2)
-#define SHAPEKEY_OFFSETS_BY_VERT (1 << 3)
-#define SHAPEKEY_OFFSETS_BY_LAYER (1 << 4)
-
-/* vert to vert mapping */
-typedef struct BM_vert_mapping{
- struct BMesh bm;
- bool *mapped;
-}BM_vert_mapping;
-
-bool print_shapekeys_info(BMesh *bm, int type, bool type_info, bool layer_info, int mode);
-
-//to support checking for different faces around the loop, we'll need to have the l_other sent from
-//BM_mesh_calc_face_groups
-static bool UNUSED_FUNCTION(BM_face_in_island) (BMEdge *e, void *user_data)
+//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))
{
- BMVert *v1, *v2;
- BM_vert_mapping *vert_table = (BM_vert_mapping*) user_data;
- bool v1_fnd = false, v2_fnd = false;
-
- //get the 2 verts
- v1 = e->v1;
- v2 = e->v2;
-
- if(user_data == NULL) {
- return false;
- }
-
- //check whether both v1 or v2 are UV_mapped or not
- v1_fnd = vert_table->mapped[v1->head.index];
- v2_fnd = vert_table->mapped[v2->head.index];
-
-/*
- //this should be used if the mapping got changed to a vertex to vertex ie:
- typedef struct BM_vert_mapping{
- struct BMVert v1_list, v2_list;
- int count;
- } BM_vert_mapping;
-
- for (i = 0; i < vert_table->count; i++) {
- if (vert_table->v1_list[i]->head,index == BM_elem_index_get(v1)) {
- v1_fnd = true;
- }
- if (vert_table->v1_list[i]->head,index == BM_elem_index_get(v1)) {
- v2_fnd = true;
- }
- }
-*/
- //the edge leads to passing over to another island
- if (v1_fnd && v2_fnd) {
- return false;
- }
-
- //it's ok to pass to the next face
- else {
- return true;
- }
-}
-
-BMLoop** get_match_loops_per_vert(BMVert *v_src, BMVert *v_dst, BMLoop **loop_match);
-
-/**
- * @brief get_match_loops_per_vert: gets best match src loop for each of the v_dst's loops
- * @param v_src
- * @param v_dst
- * @param loop_match a pointer to be filled with source matching pointer per each v_dst
- * @return NULL upon failure, the matching pointers upon success
- */
-BMLoop** get_match_loops_per_vert(BMVert *v_src, BMVert *v_dst, BMLoop **loop_match)
-{
- int loop_count;
- BMIter liter_src, liter_dst;
- BMLoop *l_src, *l_dst;
- BMLoop *l_src_match;
-
- float f_src_cent[3], f_dst_cent[3];
- float e_src_cent[3], e_dst_cent[3];
- float src_vec[3], dst_vec[3];
-
- float best_align, curr_align;
-
- loop_count = 0;
- loop_match = MEM_mallocN(sizeof(*loop_match), "loop_match bmesh_data_transfer.c");
-
- BM_ITER_ELEM (l_dst, &liter_dst, v_dst, BM_LOOPS_OF_VERT) {
- best_align = -2; //-1 is the least value of the dot product, however we use -2 to detect if no loops
- //were found within the source vertex!!
- loop_count++;
- loop_match = MEM_reallocN(loop_match, sizeof(*loop_match) * loop_count);
- //loop_match[loop_count - 1] = NULL; //this should be a redundant assignment as we return false
- //if errors were found (ie: best_align == -2)
-
- BM_face_calc_center_mean(l_dst->f, f_dst_cent);
-
- //calc loop's edge center
- interp_v3_v3v3(e_dst_cent, l_dst->e->v1->co, l_dst->e->v2->co, 0.5);
-
- sub_v3_v3v3(dst_vec, f_dst_cent, e_dst_cent);
-
- BM_ITER_ELEM (l_src, &liter_src, v_src, BM_LOOPS_OF_VERT) {
- BM_face_calc_center_mean(l_src->f, f_src_cent);
-
- //calc loop's edge center
- interp_v3_v3v3(e_src_cent, l_src->e->v1->co, l_src->e->v2->co, 0.5);
-
- sub_v3_v3v3(src_vec, f_src_cent, e_src_cent);
-
- curr_align = dot_v3v3(dst_vec,src_vec);
-
- if (best_align < curr_align) {
- best_align = curr_align;
- l_src_match = l_src;
- }
- }
-
- if (best_align == -2) {
- //Error (supposingly the source vertex has no loops around it!)
- return NULL;
- }
-
- loop_match[loop_count - 1] = l_src_match;
- }
- return loop_match;
-}
-
-bool flag_islands(BMesh *bm, int *UNUSED_count, bool mark_seams, bool mark_sharp, bool mark_tag);
-//take the bmesh, get the islands, with their count
-bool flag_islands(BMesh *bm, int *UNUSED(count), bool mark_seams, bool mark_sharp, bool mark_tag)
-{
- UvVertMap *vmap;
- BMEditMesh *em;
- BMEdge *editedge;
- float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
-
- BMIter iter;
-
- em = BKE_editmesh_create(bm, true);
-
- //is that needed!?
- if (!(em && em->bm->totface && CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY) &&
- CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV))) {
- return false;
- }
-
- /* This code sets editvert->tmp.l to the index. This will be useful later on. */
- EDBM_index_arrays_ensure(em, BM_FACE);
- vmap = EDBM_uv_vert_map_create(em, 0, limit);
-
- BM_ITER_MESH (editedge, &iter, bm, BM_EDGES_OF_MESH) {
- /* flags to determine if we uv is separated from first editface match */
- char separated1 = 0, separated2;
- /* set to denote edge must be flagged as seam */
- char faces_separated = 0;
- /* flag to keep track if uv1 is disconnected from first editface match */
- char v1coincident = 1;
- /* For use with v1coincident. v1coincident will change only if we've had commonFaces */
- int commonFaces = 0;
-
- BMFace *efa1, *efa2;
-
- UvMapVert *mv1, *mvinit1, *mv2, *mvinit2, *mviter;
- /* mv2cache stores the first of the list of coincident uv's for later comparison
- * mv2sep holds the last separator and is copied to mv2cache when a hit is first found */
- UvMapVert *mv2cache = NULL, *mv2sep = NULL;
-
- mvinit1 = vmap->vert[BM_elem_index_get(editedge->v1)];
- if (mark_seams)
- BM_elem_flag_disable(editedge, BM_ELEM_SEAM);
- if (mark_tag)
- BM_elem_flag_disable(editedge, BM_ELEM_TAG);
-
- //start looping from the first vertex, as long as the iterator (mv1) exists and there are no
- //separated faces execute the for loop then move mv1 a step forward
- for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) {
- if (mv1->separate && commonFaces)
- v1coincident = 0;
-
- separated2 = 0;
- efa1 = EDBM_face_at_index(em, mv1->f);
- mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
-
- for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
- if (mv2->separate)
- mv2sep = mv2;
-
- efa2 = EDBM_face_at_index(em, mv2->f);
- if (efa1 == efa2) {
- /* if v1 is not coincident no point in comparing */
- if (v1coincident) {
- /* have we found previously anything? */
- if (mv2cache) {
- /* flag seam unless proved to be coincident with previous hit */
- separated2 = 1;
- for (mviter = mv2cache; mviter; mviter = mviter->next) {
- if (mviter->separate && mviter != mv2cache)
- break;
- /* coincident with previous hit, do not flag seam */
- if (mviter == mv2)
- separated2 = 0;
- }
- }
- /* First hit case, store the hit in the cache */
- else {
- mv2cache = mv2sep;
- commonFaces = 1;
- }
- }
- else
- separated1 = 1;
-
- if (separated1 || separated2) {
- faces_separated = 1;
- break;
- }
- }
- }
- }
-
- if (faces_separated) {
- if (mark_seams)
- BM_elem_flag_enable(editedge, BM_ELEM_SEAM);
- if (mark_sharp)
- BM_elem_flag_disable(editedge, BM_ELEM_SMOOTH);
- if (mark_tag)
- BM_elem_flag_enable(editedge, BM_ELEM_TAG);
-
- }
- }
-
- EDBM_uv_vert_map_free(vmap);
-
- return true;
-}
-
-bool BM_edge_in_paths(LinkNode **e_lists, BMEdge *e, int count);
-
-bool BM_edge_in_paths(LinkNode **e_lists, BMEdge *e, int count)
-{
- LinkNode *link_iter;
- int i;
-
- //looping over the paths
- for (i = 0; i < count; i++) {
- link_iter = e_lists[i];
-
- //check if the list is empty!
- if (link_iter == NULL) {
- continue;
- }
- do {
- if (e == (BMEdge*) link_iter->link) {
- return true;
- }
-
- link_iter = link_iter->next;
- } while (link_iter != NULL);
- }
-
- //end of search
return false;
-
}
-bool BM_test_and_set_visited_vert_cb(BMVert *v, bool *visited_verts);
-bool BM_test_and_set_visited_vert_cb(BMVert *v, bool *visited_verts)
-{
- if (visited_verts[BM_elem_index_get(v)] == true) {
- return false;
- }
- else {
- visited_verts[BM_elem_index_get(v)] = true;
- return true;
- }
-}
-
-/**
- * @brief BM_test_unvisited_vert_cb: callback for find vert path
- * @param v: vert under test
- * @param visited_verts: table of marked vertices (true for visited)
- * @return "false" if the vertex was visited
- */
-
-bool BM_test_unvisited_vert_cb(BMVert *v, bool *visited_verts);
-bool BM_test_unvisited_vert_cb(BMVert *v, bool *visited_verts)
-{
- return (!(visited_verts[BM_elem_index_get(v)] == true));
-}
-
-
-LinkNode *BM_get_vert_path_relative_to_edge(BMesh *bm_dst, BMBVHTree *bm_dst_tree, BMEdge *e, float rad_search, bool *visited_verts_dst);
-
-/**
- * @brief BM_get_vert_path_relative_to_edge: get the corresponding vertex path to a single edge
- * @param bm_dst: the bmesh
- * @param bm_dst_tree: the bmesh tree where the vertices exist //we shall make it ourselves!!
- * @param e: the source edge
- * @param rad_search: the maximum distance we should search within
- * @param visited_verts_dst: used to avoid passing by a visited vertex from a previous search
- * @return the vert path within the bm_dst
- */
-
-LinkNode *BM_get_vert_path_relative_to_edge(BMesh *bm_dst, BMBVHTree *bm_dst_tree, BMEdge *e, float rad_search,
- bool *visited_verts_dst)
-{
- BMVert *v_start, *v_end;
-
- v_start = BKE_bmbvh_find_vert_closest(bm_dst_tree, e->v1->co, rad_search);
- v_end = BKE_bmbvh_find_vert_closest(bm_dst_tree, e->v2->co, rad_search);
-
- if ((v_start != NULL) && (v_end != NULL) && (v_start->head.index != v_end->head.index)) {
- return BM_mesh_calc_path_vert(bm_dst, v_start, v_end, true, visited_verts_dst,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list