Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-04 05:23:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-04 05:23:51 +0400
commit48fd740096c283243498d6271b6bff5da275cb36 (patch)
tree2a871557ced1ed6e4e02334fd3249db30e461b4d /source/blender/bmesh/operators/bmo_utils.c
parentb537bc011be07a860d2acd1b61f5660195935327 (diff)
edit-mesh improvements to select shortest path
- Ctrl+RMB only worked for edges & faces - Menu item 'Select Shortest Path' only worked for vertices. Now Ctrl+RMB works for vertices and the menu item works for verts/edges/faces (depending on the current selection).
Diffstat (limited to 'source/blender/bmesh/operators/bmo_utils.c')
-rw-r--r--source/blender/bmesh/operators/bmo_utils.c108
1 files changed, 0 insertions, 108 deletions
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index 14870dc918a..5e61b8ea7ea 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -673,111 +673,3 @@ void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op)
}
}
}
-
-
-/*************************************************************************** *
- * shortest vertex path select
- *************************************************************************** */
-
-typedef struct ElemNode {
- BMVert *v; /* vertex */
- BMVert *parent; /* node parent id */
- float weight; /* node weight */
- HeapNode *hn; /* heap node */
-} ElemNode;
-
-#define VERT_MARK 1
-
-void bmo_shortest_path_exec(BMesh *bm, BMOperator *op)
-{
- BMIter v_iter; /* mesh verts iterator */
- BMVert *sv, *ev; /* starting vertex, ending vertex */
- BMVert *v; /* mesh vertex */
- Heap *h = NULL;
-
- ElemNode *vert_list = NULL;
-
- int num_total = 0 /*, num_sels = 0 */, i = 0;
- const int type = BMO_slot_int_get(op->slots_in, "type");
-
- sv = BMO_slot_buffer_get_single(BMO_slot_get(op->slots_in, "vert_start"));
- ev = BMO_slot_buffer_get_single(BMO_slot_get(op->slots_in, "vert_end"));
-
- num_total = BM_mesh_elem_count(bm, BM_VERT);
-
- /* allocate memory for the nodes */
- vert_list = (ElemNode *)MEM_mallocN(sizeof(ElemNode) * num_total, "vertex nodes");
-
- /* iterate through all the mesh vertices */
- /* loop through all the vertices and fill the vertices/indices structure */
- i = 0;
- BM_ITER_MESH (v, &v_iter, bm, BM_VERTS_OF_MESH) {
- vert_list[i].v = v;
- vert_list[i].parent = NULL;
- vert_list[i].weight = FLT_MAX;
- BM_elem_index_set(v, i); /* set_inline */
- i++;
- }
- bm->elem_index_dirty &= ~BM_VERT;
-
- /*
- * we now have everything we need, start Dijkstra path finding algorithm
- */
-
- /* set the distance/weight of the start vertex to 0 */
- vert_list[BM_elem_index_get(sv)].weight = 0.0f;
-
- h = BLI_heap_new();
-
- for (i = 0; i < num_total; i++) {
- vert_list[i].hn = BLI_heap_insert(h, vert_list[i].weight, vert_list[i].v);
- }
-
- while (!BLI_heap_is_empty(h)) {
- BMEdge *e;
- BMIter e_i;
- float v_weight;
-
- /* take the vertex with the lowest weight out of the heap */
- BMVert *v = (BMVert *)BLI_heap_popmin(h);
-
- if (vert_list[BM_elem_index_get(v)].weight == FLT_MAX) /* this means that there is no path */
- break;
-
- v_weight = vert_list[BM_elem_index_get(v)].weight;
-
- BM_ITER_ELEM (e, &e_i, v, BM_EDGES_OF_VERT) {
- BMVert *u;
- float e_weight = v_weight;
-
- if (type == VPATH_SELECT_EDGE_LENGTH)
- e_weight += len_v3v3(e->v1->co, e->v2->co);
- else e_weight += 1.0f;
-
- u = (e->v1 == v) ? e->v2 : e->v1;
-
- if (e_weight < vert_list[BM_elem_index_get(u)].weight) { /* is this path shorter ? */
- /* add it if so */
- vert_list[BM_elem_index_get(u)].parent = v;
- vert_list[BM_elem_index_get(u)].weight = e_weight;
-
- /* we should do a heap update node function!!! :-/ */
- BLI_heap_remove(h, vert_list[BM_elem_index_get(u)].hn);
- BLI_heap_insert(h, e_weight, u);
- }
- }
- }
-
- /* now we trace the path (if it exists) */
- v = ev;
-
- while (vert_list[BM_elem_index_get(v)].parent != NULL) {
- BMO_elem_flag_enable(bm, v, VERT_MARK);
- v = vert_list[BM_elem_index_get(v)].parent;
- }
-
- BLI_heap_free(h, NULL);
- MEM_freeN(vert_list);
-
- BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "verts.out", BM_VERT, VERT_MARK);
-}