[Bf-blender-cvs] [a9bf839] soc-2016-uv_tools: Clean-Up commit
Phil Gosch
noreply at git.blender.org
Sat Jun 11 00:31:16 CEST 2016
Commit: a9bf839f22caafb0b4cb7cc0d6031ba25678d9db
Author: Phil Gosch
Date: Sat Jun 11 00:30:35 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rBa9bf839f22caafb0b4cb7cc0d6031ba25678d9db
Clean-Up commit
* Remove debug prints
* Remove Warnings
* Correct code style (whitespace, formating, line length, etc.) according to check_style_c.py
===================================================================
M source/blender/editors/uvedit/uvedit_ops.c
M source/blender/editors/uvedit/uvedit_parametrizer.c
M source/blender/editors/uvedit/uvedit_parametrizer.h
===================================================================
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 7b526e6..a8c052c 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -1478,7 +1478,6 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Image *ima = CTX_data_edit_image(C);
- SpaceImage *sima = CTX_wm_space_image(C);
ToolSettings *ts = scene->toolsettings;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
@@ -1486,9 +1485,8 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
BMEdge *e;
BMIter iter, liter;
BMLoop *l;
- BMEditSelection *ese_src, *ese_dst;
- BMElem *ele_src = NULL, *ele_dst = NULL, *ele;
MLoopUV *luv_src = NULL, *luv_dst = NULL;
+ BMElem *elem_src = NULL, *elem_dst = NULL;
int elem_sel = 0;
const bool topological_distance = RNA_boolean_get(op->ptr, "topological_distance");
@@ -1501,7 +1499,7 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
/* -------- Check for 2 selected elements of same type on the same UV island ---------- */
-
+ /* Note: Only vertex path computation implemented for now, but Edge/Face checks already there*/
if (ts->uv_selectmode & UV_SELECT_FACE) {
/* clear tags */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
@@ -1515,11 +1513,11 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
if (uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
elem_sel++;
- if (luv_src == NULL) {
- luv_src = efa;
+ if (elem_src == NULL) {
+ elem_src = efa;
}
- else if ((luv_dst == NULL)) {
- luv_dst = efa;
+ else if ((elem_dst == NULL)) {
+ elem_dst = efa;
}
}
}
@@ -1536,11 +1534,11 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
elem_sel++;
- if (luv_src == NULL) {
- luv_src = e;
+ if (elem_src == NULL) {
+ elem_src = e;
}
- else if ((luv_dst == NULL)) {
- luv_dst = e;
+ else if ((elem_dst == NULL)) {
+ elem_dst = e;
}
}
}
@@ -1571,7 +1569,8 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
luv_dst = luv;
elem_sel++;
}
- else if ((!compare_v2v2(luv->uv, luv_src->uv, 0.000003f)) && (!compare_v2v2(luv->uv, luv_dst->uv, 0.000003f))) {
+ else if ((!compare_v2v2(luv->uv, luv_src->uv, 0.000003f)) &&
+ (!compare_v2v2(luv->uv, luv_dst->uv, 0.000003f))) {
elem_sel++;
}
}
@@ -1580,9 +1579,10 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
}
}
- if (elem_sel != 2) {
+ if (elem_sel != 2 || !(ts->uv_selectmode & UV_SELECT_VERTEX)) {
/* Not exactly 2 elements of same typ selected */
- BKE_report(op->reports, RPT_WARNING, "Path selection requires exactly two matching elements of the same island to be selected");
+ BKE_report(op->reports, RPT_WARNING,
+ "Path selection requires exactly two vertices of the same island to be selected");
return OPERATOR_CANCELLED;
}
@@ -1597,7 +1597,8 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
}
else {
/* No path found because the selected elements aren't part of the same uv island */
- BKE_report(op->reports, RPT_WARNING, "Path selection requires exactly two matching elements of the same island to be selected");
+ BKE_report(op->reports, RPT_WARNING,
+ "Path selection requires exactly two vertices of the same island to be selected");
return OPERATOR_CANCELLED;
}
}
@@ -1605,7 +1606,7 @@ static int uv_shortest_path_exec(bContext *C, wmOperator *op)
static void UV_OT_select_shortest_path(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Select Shortest Path";
+ ot->name = "Select Shortest Vertex Path";
ot->description = "Select the shortest path between the current selected vertices";
ot->idname = "UV_OT_select_shortest_path";
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1615,7 +1616,8 @@ static void UV_OT_select_shortest_path(wmOperatorType *ot)
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");
+ RNA_def_boolean(ot->srna, "topological_distance", 0, "Topological Distance",
+ "Find the minimum number of steps, ignoring spatial distance");
}
/* ******************** scale to bounds operator **************** */
@@ -1630,7 +1632,6 @@ static int uv_scale_to_bounds_exec(bContext *C, wmOperator *op)
BMFace *efa;
BMLoop *l;
BMIter iter, liter;
- MLoopUV *luv;
MTexPoly *tf;
float dx, dy, min[2], max[2];
@@ -1640,7 +1641,7 @@ static int uv_scale_to_bounds_exec(bContext *C, wmOperator *op)
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
- if (individual){
+ if (individual) {
ED_uvedit_scale_to_bounds(scene, obedit, bm);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 0eaf483..5e19f84 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -1155,8 +1155,7 @@ static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkey
phash_insert(handle->hash_edges, (PHashLink *)e2);
phash_insert(handle->hash_edges, (PHashLink *)e3);
- if (diag_edge != -1)
- {
+ if (diag_edge != -1) {
switch (diag_edge) {
case 0:
{
@@ -4747,15 +4746,13 @@ void param_scale_bounds(ParamHandle *handle)
}
}
-void p_verttag_add_adjacent(Heap *heap, PChart *chart, PVert *v_a, PVert **v_prev, float *cost, bool use_topology_distance)
+void p_verttag_add_adjacent(Heap *heap, 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;
e = v_a->edge;
- //printf("add_adjacent for v_a: %i\n", v_a->u.id);
- //printf("v_a->edge->next->vert: %i\n", v_a->edge->next->vert->u.id);
-
/* rewind to start */
lastwe = e;
for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we)) {
@@ -4765,7 +4762,6 @@ void p_verttag_add_adjacent(Heap *heap, PChart *chart, PVert *v_a, PVert **v_pre
we = lastwe;
do {
PVert *v_b = we->next->vert;
- //printf("----add_adjacent considering v_b: %i\n", v_b->u.id);
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;
@@ -4783,7 +4779,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, bool topological_distance)
+LinkNode *p_calc_path_vert(PChart *chart, PVert *src, PVert *dst, bool topological_distance)
{
LinkNode *path = NULL;
Heap *heap;
@@ -4792,7 +4788,7 @@ LinkNode* p_calc_path_vert(PChart *chart, PVert *src, PVert *dst, bool topologic
float *cost;
int totvert, index;
- /* Clear flags */
+ /* Clear flags, assign index */
for (vert = chart->verts, index = 0; vert; vert = vert->nextlink, index++) {
vert->flag &= ~PVERT_MARKED;
vert->u.id = index; /* Re-use lscm id field */
@@ -4819,7 +4815,7 @@ LinkNode* p_calc_path_vert(PChart *chart, PVert *src, PVert *dst, bool topologic
if (!(vert->flag & PVERT_MARKED)) {
vert->flag |= PVERT_MARKED;
- p_verttag_add_adjacent(heap, chart, vert, verts_prev, cost, topological_distance);
+ p_verttag_add_adjacent(heap, vert, verts_prev, cost, topological_distance);
}
}
@@ -4836,10 +4832,8 @@ LinkNode* p_calc_path_vert(PChart *chart, PVert *src, PVert *dst, bool topologic
return path;
}
-void p_vert_select_edges(PVert* v, bool recursive)
+void p_vert_select_edges(PVert *v)
{
- //printf("reached p_vert_select_edges() for %i --\n", v->u.id);
-
v->flag |= PVERT_SELECT;
PEdge *e = v->edge;
e->flag |= PEDGE_SELECT;
@@ -4852,19 +4846,21 @@ void p_vert_select_edges(PVert* v, bool recursive)
we = lastwe;
do {
+
we->flag |= PEDGE_SELECT;
PVert *v_e = we->vert;
v_e->flag |= PVERT_SELECT;
we = p_wheel_edge_next(we);
+
} while (we && (we != lastwe));
}
void param_shortest_path(ParamHandle *handle, bool *p_found, bool topological_distance)
{
PHandle *phandle = (PHandle *)handle;
- PChart *chart, *current_chart;
+ PChart *chart, *current_chart = 0;
PVert *v, *vert_src = NULL, *vert_dst = NULL;
- int i, j;
+ int i;
bool success = false;
if (phandle->ncharts == 0) {
@@ -4883,31 +4879,29 @@ void param_shortest_path(ParamHandle *handle, bool *p_found, bool topological_di
if (vert_src == NULL) {
vert_src = v;
current_chart = chart;
- //printf("--- DEBUG (SaphireS): vert_src found\n");
}
else if (vert_dst == NULL) {
- //if (current_chart == chart) {
+ if (current_chart == chart) {
vert_dst = v;
- //printf("--- DEBUG (SaphireS): vet_dsc found\n");
- //}
+ }
}
}
}
}
/* Connect src and dst */
- LinkNode* path = NULL;
- if (vert_src && vert_dst){
- //printf("start path computation!\n");
+ LinkNode *path = NULL;
+ if (vert_src && vert_dst) {
+
path = p_calc_path_vert(current_chart, vert_src, vert_dst, topological_distance);
+
if (path) {
LinkNode *node = NULL;
node = path;
do {
PVert *v = node->link;
- p_vert_select_edges(v, false);
-
+ p_vert_select_edges(v);
} while (node = node->next);
success = true;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index 4894614..9b81dab 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -64,7 +64,7 @@ void param_face_add(ParamHandle *handle,
ParamBool *pin,
ParamBool *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list