[Bf-blender-cvs] [2d7ce3a] soc-2016-uv_tools: Added "Topological distance" option to Select Shortest Path operator
Phil Gosch
noreply at git.blender.org
Tue Jun 7 14:38:11 CEST 2016
Commit: 2d7ce3a69d7fa88899da7646b9a00cbc71101d29
Author: Phil Gosch
Date: Tue Jun 7 14:37:26 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rB2d7ce3a69d7fa88899da7646b9a00cbc71101d29
Added "Topological distance" option to Select Shortest Path operator
Similar to the editmesh operator: "Find the minimum number of steps, ignoring spatial distance"
===================================================================
M source/blender/editors/uvedit/uvedit_ops.c
M source/blender/editors/uvedit/uvedit_parametrizer.c
M source/blender/editors/uvedit/uvedit_unwrap_ops.c
===================================================================
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index a559fe2..5caeac8 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1490,6 +1490,7 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
BMElem *ele_src = NULL, *ele_dst = NULL, *ele;
MLoopUV *luv_src = NULL, *luv_dst = NULL;
int elem_sel = 0;
+ const bool topological_distance = RNA_boolean_get(op->ptr, "topological_distance");
if (ts->uv_flag & UV_SYNC_SELECTION) {
@@ -1587,7 +1588,7 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
/* -------- Now select shortest path between the 2 found elements ---------- */
- if (ED_uvedit_shortest_path_select(scene, obedit, bm)) {
+ if (ED_uvedit_shortest_path_select(scene, obedit, bm, topological_distance)) {
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT | ND_DATA, obedit->data);
@@ -1612,6 +1613,9 @@ static void UV_OT_select_shortest_path(wmOperatorType *ot)
/* api callbacks */
ot->exec = uv_shortest_path_exec;
ot->poll = ED_operator_uvedit;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "topological_distance", 0, "Topological Distance", "Find the minimum number of steps, ignoring spatial distance");
}
/* ******************** align operator **************** */
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 9236edf..0eaf483 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4747,7 +4747,7 @@ void param_scale_bounds(ParamHandle *handle)
}
}
-void p_verttag_add_adjacent(Heap *heap, PChart *chart, PVert *v_a, PVert **v_prev, float *cost)
+void p_verttag_add_adjacent(Heap *heap, PChart *chart, PVert *v_a, PVert **v_prev, float *cost, bool use_topology_distance)
{
const int v_a_index = v_a->u.id;
PEdge *e, *we, *lastwe = NULL;
@@ -4769,7 +4769,7 @@ void p_verttag_add_adjacent(Heap *heap, PChart *chart, PVert *v_a, PVert **v_pre
if (!(v_b->flag & PVERT_MARKED) && !(we->flag & PEDGE_DIAG )) {
/* v_b not visited yet, check it out! */
const int v_b_index = v_b->u.id;
- const float cost_cut = len_v2v2(v_a->uv, v_b->uv); /* params->use_topology_distance ? 1.0f : len_v2v2(v_a->uv, v_b->uv); */
+ const float cost_cut = use_topology_distance ? 1.0f : len_v2v2(v_a->uv, v_b->uv);
const float cost_new = cost[v_a_index] + cost_cut;
if (cost[v_b_index] > cost_new) {
@@ -4783,7 +4783,7 @@ void p_verttag_add_adjacent(Heap *heap, PChart *chart, PVert *v_a, PVert **v_pre
} while (we && (we != lastwe));
}
-LinkNode* p_calc_path_vert(PChart *chart, PVert *src, PVert *dst)
+LinkNode* p_calc_path_vert(PChart *chart, PVert *src, PVert *dst, bool topological_distance)
{
LinkNode *path = NULL;
Heap *heap;
@@ -4819,7 +4819,7 @@ LinkNode* p_calc_path_vert(PChart *chart, PVert *src, PVert *dst)
if (!(vert->flag & PVERT_MARKED)) {
vert->flag |= PVERT_MARKED;
- p_verttag_add_adjacent(heap, chart, vert, verts_prev, cost);
+ p_verttag_add_adjacent(heap, chart, vert, verts_prev, cost, topological_distance);
}
}
@@ -4859,7 +4859,7 @@ void p_vert_select_edges(PVert* v, bool recursive)
} while (we && (we != lastwe));
}
-void param_shortest_path(ParamHandle *handle, bool *p_found)
+void param_shortest_path(ParamHandle *handle, bool *p_found, bool topological_distance)
{
PHandle *phandle = (PHandle *)handle;
PChart *chart, *current_chart;
@@ -4899,7 +4899,7 @@ void param_shortest_path(ParamHandle *handle, bool *p_found)
LinkNode* path = NULL;
if (vert_src && vert_dst){
//printf("start path computation!\n");
- path = p_calc_path_vert(current_chart, vert_src, vert_dst);
+ path = p_calc_path_vert(current_chart, vert_src, vert_dst, topological_distance);
if (path) {
LinkNode *node = NULL;
node = path;
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 60339aa..656c95c 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -718,12 +718,12 @@ void UV_OT_minimize_stretch(wmOperatorType *ot)
}
/* ******************** Select Shortest Path operator **************** */
-bool ED_uvedit_shortest_path_select(Scene *scene, Object *ob, BMesh *bm)
+bool ED_uvedit_shortest_path_select(Scene *scene, Object *ob, BMesh *bm, bool topo_dist)
{
ParamHandle *handle;
bool path_found = false;
handle = construct_param_handle(scene, ob, bm, false, false, false, true);
- param_shortest_path(handle, &path_found);
+ param_shortest_path(handle, &path_found, topo_dist);
param_flush(handle);
param_delete(handle);
return path_found;
More information about the Bf-blender-cvs
mailing list