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:
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c9
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c18
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c261
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c450
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c70
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c213
6 files changed, 681 insertions, 340 deletions
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 16620436029..3983cce6769 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -69,8 +69,9 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im
zero_v2(center);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -100,8 +101,9 @@ static void uvedit_translate(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -203,8 +205,9 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
float center[2], delta[2];
int imx, imy;
- if (event != B_UVEDIT_VERTEX)
+ if (event != B_UVEDIT_VERTEX) {
return;
+ }
em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 5ff90097840..4fb2c6441a3 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -72,15 +72,19 @@ static int draw_uvs_face_check(const ToolSettings *ts)
{
/* checks if we are selecting only faces */
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode == SCE_SELECT_FACE)
+ if (ts->selectmode == SCE_SELECT_FACE) {
return 2;
- else if (ts->selectmode & SCE_SELECT_FACE)
+ }
+ else if (ts->selectmode & SCE_SELECT_FACE) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
- else
+ else {
return (ts->uv_selectmode == UV_SELECT_FACE);
+ }
}
/* ------------------------- */
@@ -461,8 +465,9 @@ static void draw_uv_shadows_get(
{
*show_shadow = *show_texpaint = false;
- if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT))
+ if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT)) {
return;
+ }
if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) {
struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -505,7 +510,8 @@ void ED_uvedit_draw_main(SpaceImage *sima,
draw_uvs_texpaint(scene, obact, depsgraph);
}
- if (show_uvedit && !(toolsettings->use_uv_sculpt))
+ if (show_uvedit && !(toolsettings->use_uv_sculpt)) {
ED_image_draw_cursor(ar, sima->cursor);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index ca527be7339..16a4b647cfe 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -114,11 +114,13 @@ bool ED_uvedit_test(Object *obedit)
BMEditMesh *em;
int ret;
- if (!obedit)
+ if (!obedit) {
return 0;
+ }
- if (obedit->type != OB_MESH)
+ if (obedit->type != OB_MESH) {
return 0;
+ }
em = BKE_editmesh_from_object(obedit);
ret = EDBM_uv_check(em);
@@ -142,8 +144,9 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
if (ob && ob->type == OB_MESH) {
Mesh *me = ob->data;
- if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL)
+ if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) {
return 1;
+ }
}
return 0;
@@ -172,8 +175,9 @@ bool ED_object_get_active_image(Object *ob,
bNode *node = (ntree) ? nodeGetActiveTexture(ntree) : NULL;
if (node && is_image_texture_node(node)) {
- if (r_ima)
+ if (r_ima) {
*r_ima = (Image *)node->id;
+ }
if (r_iuser) {
if (node->type == SH_NODE_TEX_IMAGE) {
*r_iuser = &((NodeTexImage *)node->storage)->iuser;
@@ -185,21 +189,27 @@ bool ED_object_get_active_image(Object *ob,
*r_iuser = NULL;
}
}
- if (r_node)
+ if (r_node) {
*r_node = node;
- if (r_ntree)
+ }
+ if (r_ntree) {
*r_ntree = ntree;
+ }
return true;
}
- if (r_ima)
+ if (r_ima) {
*r_ima = NULL;
- if (r_iuser)
+ }
+ if (r_iuser) {
*r_iuser = NULL;
- if (r_node)
+ }
+ if (r_node) {
*r_node = node;
- if (r_ntree)
+ }
+ if (r_ntree) {
*r_ntree = ntree;
+ }
return false;
}
@@ -263,10 +273,12 @@ static void uvedit_vertex_select_tagged(BMEditMesh *em,
bool uvedit_face_visible_nolocal_ex(const ToolSettings *ts, BMFace *efa)
{
- if (ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0);
- else
+ }
+ else {
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
+ }
}
bool uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
{
@@ -301,8 +313,9 @@ bool uvedit_face_select_test_ex(const ToolSettings *ts, BMFace *efa, const int c
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (!(luv->flag & MLOOPUV_VERTSEL))
+ if (!(luv->flag & MLOOPUV_VERTSEL)) {
return false;
+ }
}
return true;
@@ -432,10 +445,12 @@ void uvedit_edge_select_enable(
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, true);
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
BM_edge_select_set(em->bm, l->e, true);
+ }
else {
BM_vert_select_set(em->bm, l->e->v1, true);
BM_vert_select_set(em->bm, l->e->v2, true);
@@ -465,10 +480,12 @@ void uvedit_edge_select_disable(BMEditMesh *em,
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, false);
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
BM_edge_select_set(em->bm, l->e, false);
+ }
else {
BM_vert_select_set(em->bm, l->e->v1, false);
BM_vert_select_set(em->bm, l->e->v2, false);
@@ -488,10 +505,12 @@ void uvedit_edge_select_disable(BMEditMesh *em,
bool uvedit_uv_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_loop_uv_offset)
{
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
return BM_elem_flag_test_bool(l->f, BM_ELEM_SELECT);
- else
+ }
+ else {
return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT);
+ }
}
else {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -524,10 +543,12 @@ void uvedit_uv_select_enable(
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, true);
- else
+ }
+ else {
BM_vert_select_set(em->bm, l->v, true);
+ }
if (do_history) {
BM_select_history_remove(em->bm, (BMElem *)l->v);
@@ -544,10 +565,12 @@ void uvedit_uv_select_disable(BMEditMesh *em, Scene *scene, BMLoop *l, const int
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, false);
- else
+ }
+ else {
BM_vert_select_set(em->bm, l->v, false);
+ }
}
else {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -623,8 +646,9 @@ bool ED_uvedit_minmax_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -679,8 +703,9 @@ static bool ED_uvedit_median_multi(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1022,14 +1047,16 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first)
int count = 0;
for (iterv = first; iterv; iterv = iterv->next) {
- if (iterv->separate && iterv != first)
+ if (iterv->separate && iterv != first) {
break;
+ }
count++;
}
- if (count < 5)
+ if (count < 5) {
first->flag = 1;
+ }
}
static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa, BMLoop *l)
@@ -1038,10 +1065,12 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa
first = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
for (iterv = first; iterv; iterv = iterv->next) {
- if (iterv->separate)
+ if (iterv->separate) {
first = iterv;
- if (iterv->poly_index == BM_elem_index_get(efa))
+ }
+ if (iterv->poly_index == BM_elem_index_get(efa)) {
return first;
+ }
}
return NULL;
@@ -1058,18 +1087,21 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
/* count number of faces this edge has */
for (iterv1 = first1; iterv1; iterv1 = iterv1->next) {
- if (iterv1->separate && iterv1 != first1)
+ if (iterv1->separate && iterv1 != first1) {
break;
+ }
for (iterv2 = first2; iterv2; iterv2 = iterv2->next) {
- if (iterv2->separate && iterv2 != first2)
+ if (iterv2->separate && iterv2 != first2) {
break;
+ }
if (iterv1->poly_index == iterv2->poly_index) {
/* if face already tagged, don't do this edge */
efa = BM_face_at_index(em->bm, iterv1->poly_index);
- if (BM_elem_flag_test(efa, BM_ELEM_TAG))
+ if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
return false;
+ }
tot++;
break;
@@ -1077,19 +1109,23 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
}
}
- if (*totface == 0) /* start edge */
+ if (*totface == 0) { /* start edge */
*totface = tot;
- else if (tot != *totface) /* check for same number of faces as start edge */
+ }
+ else if (tot != *totface) { /* check for same number of faces as start edge */
return false;
+ }
/* tag the faces */
for (iterv1 = first1; iterv1; iterv1 = iterv1->next) {
- if (iterv1->separate && iterv1 != first1)
+ if (iterv1->separate && iterv1 != first1) {
break;
+ }
for (iterv2 = first2; iterv2; iterv2 = iterv2->next) {
- if (iterv2->separate && iterv2 != first2)
+ if (iterv2->separate && iterv2 != first2) {
break;
+ }
if (iterv1->poly_index == iterv2->poly_index) {
efa = BM_face_at_index(em->bm, iterv1->poly_index);
@@ -1156,10 +1192,12 @@ static int uv_select_edgeloop(Scene *scene,
uvedit_face_visible_test(scene, obedit, ima, efa)) {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
/* check face not hidden and not tagged */
- if (!(iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l)))
+ if (!(iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l))) {
continue;
- if (!(iterv_next = uv_select_edgeloop_vertex_map_get(vmap, efa, l->next)))
+ }
+ if (!(iterv_next = uv_select_edgeloop_vertex_map_get(vmap, efa, l->next))) {
continue;
+ }
/* check if vertex is tagged and has right valence */
if (iterv_curr->flag || iterv_next->flag) {
@@ -1253,8 +1291,9 @@ static void uv_select_linked_multi(Scene *scene,
* keeping island-select working as is. */
vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
- if (vmap == NULL)
+ if (vmap == NULL) {
return;
+ }
stack = MEM_mallocN(sizeof(*stack) * (em->bm->totface + 1), "UvLinkStack");
flag = MEM_callocN(sizeof(*flag) * em->bm->totface, "UvLinkFlag");
@@ -1312,15 +1351,18 @@ static void uv_select_linked_multi(Scene *scene,
startv = vlist;
for (iterv = vlist; iterv; iterv = iterv->next) {
- if (iterv->separate)
+ if (iterv->separate) {
startv = iterv;
- if (iterv->poly_index == a)
+ }
+ if (iterv->poly_index == a) {
break;
+ }
}
for (iterv = startv; iterv; iterv = iterv->next) {
- if ((startv != iterv) && (iterv->separate))
+ if ((startv != iterv) && (iterv->separate)) {
break;
+ }
else if (!flag[iterv->poly_index]) {
flag[iterv->poly_index] = 1;
stack[stacksize] = iterv->poly_index;
@@ -1407,8 +1449,9 @@ static float *uv_sel_co_from_eve(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_ELEM (l, &liter, eve, BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1620,8 +1663,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1653,8 +1697,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1672,8 +1717,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1698,8 +1744,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
/* tag verts with a selected UV */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
BM_ITER_ELEM (l, &liter, eve, BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
BM_elem_flag_enable(eve, BM_ELEM_TAG);
@@ -1775,23 +1822,28 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
eUVWeldAlign tool_local = tool;
if (tool_local == UV_STRAIGHTEN_X) {
- if (uv_start[1] == uv_end[1])
+ if (uv_start[1] == uv_end[1]) {
tool_local = UV_STRAIGHTEN;
- else
+ }
+ else {
a = (uv_end[0] - uv_start[0]) / (uv_end[1] - uv_start[1]);
+ }
}
else if (tool_local == UV_STRAIGHTEN_Y) {
- if (uv_start[0] == uv_end[0])
+ if (uv_start[0] == uv_end[0]) {
tool_local = UV_STRAIGHTEN;
- else
+ }
+ else {
a = (uv_end[1] - uv_start[1]) / (uv_end[0] - uv_start[0]);
+ }
}
/* go over all verts except for endpoints */
for (i = 0; i < BLI_array_len(eve_line); i++) {
BM_ITER_ELEM (l, &liter, eve_line[i], BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1799,12 +1851,15 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
* new_y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
* Maybe this should be a BLI func? Or is it already existing?
* Could use interp_v2_v2v2, but not sure it's worth it here...*/
- if (tool_local == UV_STRAIGHTEN_X)
+ if (tool_local == UV_STRAIGHTEN_X) {
luv->uv[0] = a * (luv->uv[1] - uv_start[1]) + uv_start[0];
- else if (tool_local == UV_STRAIGHTEN_Y)
+ }
+ else if (tool_local == UV_STRAIGHTEN_Y) {
luv->uv[1] = a * (luv->uv[0] - uv_start[0]) + uv_start[1];
- else
+ }
+ else {
closest_to_line_segment_v2(luv->uv, luv->uv, uv_start, uv_end);
+ }
changed = true;
}
}
@@ -2291,8 +2346,9 @@ static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, int
}
else {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2381,17 +2437,20 @@ static bool uv_sticky_select(
/* this function test if some vertex needs to selected
* in addition to the existing ones due to sticky select */
- if (sticky == SI_STICKY_DISABLE)
+ if (sticky == SI_STICKY_DISABLE) {
return false;
+ }
for (i = 0; i < hitlen; i++) {
if (hitv[i] == v) {
if (sticky == SI_STICKY_LOC) {
- if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1])
+ if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1]) {
return true;
+ }
}
- else if (sticky == SI_STICKY_VERTEX)
+ else if (sticky == SI_STICKY_VERTEX) {
return true;
+ }
}
}
@@ -2436,12 +2495,15 @@ static int uv_mouse_select_multi(
if (ts->uv_flag & UV_SYNC_SELECTION) {
sync = 1;
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
selectmode = UV_SELECT_FACE;
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
selectmode = UV_SELECT_EDGE;
- else
+ }
+ else {
selectmode = UV_SELECT_VERTEX;
+ }
sticky = SI_STICKY_DISABLE;
}
@@ -2585,14 +2647,16 @@ static int uv_mouse_select_multi(
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+ }
}
}
@@ -2621,17 +2685,20 @@ static int uv_mouse_select_multi(
/* select sticky uvs */
if (sticky != SI_STICKY_DISABLE) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (sticky == SI_STICKY_DISABLE)
+ if (sticky == SI_STICKY_DISABLE) {
continue;
+ }
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset);
+ }
flush = 1;
}
@@ -3127,11 +3194,13 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
vlist_iter = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
while (vlist_iter) {
- if (vlist_iter->separate)
+ if (vlist_iter->separate) {
start_vlist = vlist_iter;
+ }
- if (efa_index == vlist_iter->poly_index)
+ if (efa_index == vlist_iter->poly_index) {
break;
+ }
vlist_iter = vlist_iter->next;
}
@@ -3139,8 +3208,9 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
vlist_iter = start_vlist;
while (vlist_iter) {
- if (vlist_iter != start_vlist && vlist_iter->separate)
+ if (vlist_iter != start_vlist && vlist_iter->separate) {
break;
+ }
if (efa_index != vlist_iter->poly_index) {
BMLoop *l_other;
@@ -3415,8 +3485,9 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -3826,8 +3897,9 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
}
}
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, sima);
@@ -3875,8 +3947,9 @@ static bool uv_snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, cons
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -3902,8 +3975,9 @@ static bool uv_snap_uvs_offset(Scene *scene, Image *ima, Object *obedit, const f
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -3991,8 +4065,9 @@ static bool uv_snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit
h = (float)height;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -4329,8 +4404,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
}
}
}
- if (!swap)
+ if (!swap) {
uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset);
+ }
}
}
else if (em->selectmode == SCE_SELECT_FACE) {
@@ -4345,8 +4421,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (UV_SEL_TEST(luv, !swap)) {
BM_vert_select_set(em->bm, l->v, false);
- if (!swap)
+ if (!swap) {
luv->flag &= ~MLOOPUV_VERTSEL;
+ }
}
}
}
@@ -4354,8 +4431,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
}
/* flush vertex selection changes */
- if (em->selectmode != SCE_SELECT_FACE)
+ if (em->selectmode != SCE_SELECT_FACE) {
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX | SCE_SELECT_EDGE);
+ }
BM_select_history_validate(em->bm);
@@ -4539,8 +4617,9 @@ static int uv_set_2d_cursor_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima = CTX_wm_space_image(C);
- if (!sima)
+ if (!sima) {
return OPERATOR_CANCELLED;
+ }
RNA_float_get_array(op->ptr, "location", sima->cursor);
@@ -4650,20 +4729,23 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
UvMapVert *mv2cache = NULL, *mv2sep = NULL;
mvinit1 = vmap->vert[BM_elem_index_get(editedge->v1)];
- if (mark_seams)
+ if (mark_seams) {
BM_elem_flag_disable(editedge, BM_ELEM_SEAM);
+ }
for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) {
- if (mv1->separate && commonFaces)
+ if (mv1->separate && commonFaces) {
v1coincident = 0;
+ }
separated2 = 0;
efa1 = BM_face_at_index(bm, mv1->poly_index);
mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
- if (mv2->separate)
+ if (mv2->separate) {
mv2sep = mv2;
+ }
efa2 = BM_face_at_index(bm, mv2->poly_index);
if (efa1 == efa2) {
@@ -4674,11 +4756,13 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
/* flag seam unless proved to be coincident with previous hit */
separated2 = 1;
for (mviter = mv2cache; mviter; mviter = mviter->next) {
- if (mviter->separate && mviter != mv2cache)
+ if (mviter->separate && mviter != mv2cache) {
break;
+ }
/* coincident with previous hit, do not flag seam */
- if (mviter == mv2)
+ if (mviter == mv2) {
separated2 = 0;
+ }
}
}
/* First hit case, store the hit in the cache */
@@ -4687,8 +4771,9 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
commonFaces = 1;
}
}
- else
+ else {
separated1 = 1;
+ }
if (separated1 || separated2) {
faces_separated = 1;
@@ -4699,10 +4784,12 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
}
if (faces_separated) {
- if (mark_seams)
+ if (mark_seams) {
BM_elem_flag_enable(editedge, BM_ELEM_SEAM);
- if (mark_sharp)
+ }
+ if (mark_sharp) {
BM_elem_flag_disable(editedge, BM_ELEM_SMOOTH);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 913aacec4c8..10b2df48f2f 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -255,8 +255,9 @@ static PHash *phash_new(PHashLink **list, int sizehint)
ph->cursize_id = 0;
ph->list = list;
- while (PHashSizes[ph->cursize_id] < sizehint)
+ while (PHashSizes[ph->cursize_id] < sizehint) {
ph->cursize_id++;
+ }
ph->cursize = PHashSizes[ph->cursize_id];
ph->buckets = (PHashLink **)MEM_callocN(ph->cursize * sizeof(*ph->buckets), "PHashBuckets");
@@ -316,11 +317,14 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key)
PHashLink *link;
uintptr_t hash = PHASH_hash(ph, key);
- for (link = ph->buckets[hash]; link; link = link->next)
- if (link->key == key)
+ for (link = ph->buckets[hash]; link; link = link->next) {
+ if (link->key == key) {
return link;
- else if (PHASH_hash(ph, link->key) != hash)
+ }
+ else if (PHASH_hash(ph, link->key) != hash) {
return NULL;
+ }
+ }
return link;
}
@@ -329,11 +333,14 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link)
{
uintptr_t hash = PHASH_hash(ph, key);
- for (link = link->next; link; link = link->next)
- if (link->key == key)
+ for (link = link->next; link; link = link->next) {
+ if (link->key == key) {
return link;
- else if (PHASH_hash(ph, link->key) != hash)
+ }
+ else if (PHASH_hash(ph, link->key) != hash) {
return NULL;
+ }
+ }
return link;
}
@@ -362,12 +369,15 @@ static float p_vec_angle(float *v1, float *v2, float *v3)
{
float dot = p_vec_angle_cos(v1, v2, v3);
- if (dot <= -1.0f)
+ if (dot <= -1.0f) {
return (float)M_PI;
- else if (dot >= 1.0f)
+ }
+ else if (dot >= 1.0f) {
return 0.0f;
- else
+ }
+ else {
return acosf(dot);
+ }
}
static float p_vec2_angle(float *v1, float *v2, float *v3)
@@ -523,8 +533,9 @@ static PBool p_intersect_line_2d_dir(float *v1, float *dir1, float *v2, float *d
div = dir2[0] * dir1[1] - dir2[1] * dir1[0];
- if (div == 0.0f)
+ if (div == 0.0f) {
return P_FALSE;
+ }
lmbda = ((v1[1] - v2[1]) * dir1[0] - (v1[0] - v2[0]) * dir1[1]) / div;
isect[0] = v1[0] + lmbda * dir2[0];
@@ -645,8 +656,9 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
e = v->edge;
do {
if (e->orig_uv) {
- if (e->flag & PEDGE_SELECT)
+ if (e->flag & PEDGE_SELECT) {
v->flag |= PVERT_SELECT;
+ }
if (e->flag & PEDGE_PIN) {
pinuv[0] += e->orig_uv[0] * handle->aspx;
@@ -765,10 +777,12 @@ static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PE
{
PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
- if (v)
+ if (v) {
return v;
- else
+ }
+ else {
return p_vert_add(handle, key, co, e);
+ }
}
static PVert *p_vert_copy(PChart *chart, PVert *v)
@@ -791,10 +805,12 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key);
while (e) {
- if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1]))
+ if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1])) {
return e;
- else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0]))
+ }
+ else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) {
return e;
+ }
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
}
@@ -811,12 +827,14 @@ static int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2,
while (e) {
if ((e->vert->u.key == vkeys[i1]) && (e->next->vert->u.key == vkeys[i2])) {
- if (e->next->next->vert->u.key == vkeys[i3])
+ if (e->next->next->vert->u.key == vkeys[i3]) {
return P_TRUE;
+ }
}
else if ((e->vert->u.key == vkeys[i2]) && (e->next->vert->u.key == vkeys[i1])) {
- if (e->next->next->vert->u.key == vkeys[i3])
+ if (e->next->next->vert->u.key == vkeys[i3]) {
return P_TRUE;
+ }
}
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
@@ -881,8 +899,9 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
PHashKey key1 = e->vert->u.key;
PHashKey key2 = e->next->vert->u.key;
- if (e->flag & PEDGE_SEAM)
+ if (e->flag & PEDGE_SEAM) {
return P_FALSE;
+ }
key = PHASH_edge(key1, key2);
pe = (PEdge *)phash_lookup(handle->hash_edges, key);
@@ -925,8 +944,9 @@ static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PEdge ***stack, PBoo
PEdge *pair = NULL;
if (!e->pair && p_edge_has_pair(handle, e, &pair, impl)) {
- if (e->vert == pair->vert)
+ if (e->vert == pair->vert) {
p_face_flip(pair->face);
+ }
e->pair = pair;
pair->pair = e;
@@ -952,8 +972,9 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
/* connect pairs, count edges, set vertex-edge pointer to a pairless edge */
for (first = chart->faces; first; first = first->nextlink) {
- if (first->flag & PFACE_CONNECTED)
+ if (first->flag & PFACE_CONNECTED) {
continue;
+ }
*stack = first->edge;
stack++;
@@ -970,12 +991,15 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
/* assign verts to charts so we can sort them later */
f->u.chart = ncharts;
- if (!p_edge_connect_pair(handle, e, &stack, impl))
+ if (!p_edge_connect_pair(handle, e, &stack, impl)) {
e->vert->edge = e;
- if (!p_edge_connect_pair(handle, e1, &stack, impl))
+ }
+ if (!p_edge_connect_pair(handle, e1, &stack, impl)) {
e1->vert->edge = e1;
- if (!p_edge_connect_pair(handle, e2, &stack, impl))
+ }
+ if (!p_edge_connect_pair(handle, e2, &stack, impl)) {
e2->vert->edge = e2;
+ }
}
ncharts++;
@@ -996,18 +1020,21 @@ static void p_split_vert(PChart *chart, PEdge *e)
chart->flag |= PCHART_HAS_PINS;
}
- if (e->flag & PEDGE_VERTEX_SPLIT)
+ if (e->flag & PEDGE_VERTEX_SPLIT) {
return;
+ }
/* rewind to start */
lastwe = e;
- for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we))
+ for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we)) {
lastwe = we;
+ }
/* go over all edges in wheel */
for (we = lastwe; we; we = p_wheel_edge_next(we)) {
- if (we->flag & PEDGE_VERTEX_SPLIT)
+ if (we->flag & PEDGE_VERTEX_SPLIT) {
break;
+ }
we->flag |= PEDGE_VERTEX_SPLIT;
@@ -1046,8 +1073,9 @@ static PChart **p_split_charts(PHandle *handle, PChart *chart, int ncharts)
PFace *f, *nextf;
int i;
- for (i = 0; i < ncharts; i++)
+ for (i = 0; i < ncharts; i++) {
charts[i] = p_chart_new(handle);
+ }
f = chart->faces;
while (f) {
@@ -1133,21 +1161,27 @@ static PFace *p_face_add_construct(PHandle *handle,
e3->orig_uv = uv[i3];
if (pin) {
- if (pin[i1])
+ if (pin[i1]) {
e1->flag |= PEDGE_PIN;
- if (pin[i2])
+ }
+ if (pin[i2]) {
e2->flag |= PEDGE_PIN;
- if (pin[i3])
+ }
+ if (pin[i3]) {
e3->flag |= PEDGE_PIN;
+ }
}
if (select) {
- if (select[i1])
+ if (select[i1]) {
e1->flag |= PEDGE_SELECT;
- if (select[i2])
+ }
+ if (select[i2]) {
e2->flag |= PEDGE_SELECT;
- if (select[i3])
+ }
+ if (select[i3]) {
e3->flag |= PEDGE_SELECT;
+ }
}
/* insert into hash */
@@ -1205,12 +1239,14 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
* triangles, resulting in two identical triangles. for example in
* suzanne's nose. */
if (dir) {
- if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3))
+ if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3)) {
return !dir;
+ }
}
else {
- if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3))
+ if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3)) {
return !dir;
+ }
}
return dir;
@@ -1223,17 +1259,21 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
PEdge *e, *be;
float len, maxlen = -1.0;
- if (nboundaries)
+ if (nboundaries) {
*nboundaries = 0;
- if (outer)
+ }
+ if (outer) {
*outer = NULL;
+ }
for (e = chart->edges; e; e = e->nextlink) {
- if (e->pair || (e->flag & PEDGE_DONE))
+ if (e->pair || (e->flag & PEDGE_DONE)) {
continue;
+ }
- if (nboundaries)
+ if (nboundaries) {
(*nboundaries)++;
+ }
len = 0.0f;
@@ -1250,8 +1290,9 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
}
}
- for (e = chart->edges; e; e = e->nextlink)
+ for (e = chart->edges; e; e = e->nextlink) {
e->flag &= ~PEDGE_DONE;
+ }
}
static float p_edge_boundary_angle(PEdge *e)
@@ -1364,8 +1405,9 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
for (e = chart->edges; e; e = e->nextlink) {
/* enext = e->nextlink; - as yet unused */
- if (e->pair || (e->flag & PEDGE_FILLED))
+ if (e->pair || (e->flag & PEDGE_FILLED)) {
continue;
+ }
nedges = 0;
be = e;
@@ -1375,8 +1417,9 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
nedges++;
} while (be != e);
- if (e != outer)
+ if (e != outer) {
p_chart_fill_boundary(chart, e, nedges);
+ }
}
}
@@ -2350,8 +2393,9 @@ static void p_abf_setup_system(PAbfSystem *sys)
sys->bstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbstar");
sys->dstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFdstar");
- for (i = 0; i < sys->ninterior; i++)
+ for (i = 0; i < sys->ninterior; i++) {
sys->lambdaLength[i] = 1.0;
+ }
sys->minangle = 1.0 * M_PI / 180.0;
sys->maxangle = (float)M_PI - sys->minangle;
@@ -2404,16 +2448,18 @@ static float p_abf_compute_sin_product(PAbfSystem *sys, PVert *v, int aid)
sin1 *= sys->cosine[e1->u.id];
sin2 = 0.0;
}
- else
+ else {
sin1 *= sys->sine[e1->u.id];
+ }
if (aid == e2->u.id) {
/* see above */
sin1 = 0.0;
sin2 *= sys->cosine[e2->u.id];
}
- else
+ else {
sin2 *= sys->sine[e2->u.id];
+ }
e = e->next->next->pair;
} while (e && (e != v->edge));
@@ -2504,8 +2550,9 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
context = EIG_linear_solver_new(0, nvar, 1);
- for (i = 0; i < nvar; i++)
+ for (i = 0; i < nvar; i++) {
EIG_linear_solver_right_hand_side_add(context, 0, i, sys->bInterior[i]);
+ }
for (f = chart->faces; f; f = f->nextlink) {
float wi1, wi2, wi3, b, si, beta[3], j2[3][3], W[3][3];
@@ -2615,29 +2662,37 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
for (i = 0; i < 3; i++) {
int r = vid[i];
- if (r == -1)
+ if (r == -1) {
continue;
+ }
for (j = 0; j < 6; j++) {
int c = vid[j];
- if (c == -1)
+ if (c == -1) {
continue;
+ }
- if (i == 0)
+ if (i == 0) {
EIG_linear_solver_matrix_add(context, r, c, j2[0][i] * row1[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[0][i] * row1[j]);
+ }
- if (i == 1)
+ if (i == 1) {
EIG_linear_solver_matrix_add(context, r, c, j2[1][i] * row2[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[1][i] * row2[j]);
+ }
- if (i == 2)
+ if (i == 2) {
EIG_linear_solver_matrix_add(context, r, c, j2[2][i] * row3[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[2][i] * row3[j]);
+ }
}
}
}
@@ -2693,10 +2748,12 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
/* clamp */
e = f->edge;
do {
- if (sys->alpha[e->u.id] > (float)M_PI)
+ if (sys->alpha[e->u.id] > (float)M_PI) {
sys->alpha[e->u.id] = (float)M_PI;
- else if (sys->alpha[e->u.id] < 0.0f)
+ }
+ else if (sys->alpha[e->u.id] < 0.0f) {
sys->alpha[e->u.id] = 0.0f;
+ }
} while (e != f->edge);
}
@@ -2728,8 +2785,9 @@ static PBool p_chart_abf_solve(PChart *chart)
v->flag |= PVERT_INTERIOR;
v->u.id = sys.ninterior++;
}
- else
+ else {
v->flag &= ~PVERT_INTERIOR;
+ }
}
for (f = chart->faces; f; f = f->nextlink) {
@@ -2755,18 +2813,24 @@ static PBool p_chart_abf_solve(PChart *chart)
e3 = e2->next;
p_face_angles(f, &a1, &a2, &a3);
- if (a1 < sys.minangle)
+ if (a1 < sys.minangle) {
a1 = sys.minangle;
- else if (a1 > sys.maxangle)
+ }
+ else if (a1 > sys.maxangle) {
a1 = sys.maxangle;
- if (a2 < sys.minangle)
+ }
+ if (a2 < sys.minangle) {
a2 = sys.minangle;
- else if (a2 > sys.maxangle)
+ }
+ else if (a2 > sys.maxangle) {
a2 = sys.maxangle;
- if (a3 < sys.minangle)
+ }
+ if (a3 < sys.minangle) {
a3 = sys.minangle;
- else if (a3 > sys.maxangle)
+ }
+ else if (a3 > sys.maxangle) {
a3 = sys.maxangle;
+ }
sys.alpha[e1->u.id] = sys.beta[e1->u.id] = a1;
sys.alpha[e2->u.id] = sys.beta[e2->u.id] = a2;
@@ -2808,8 +2872,9 @@ static PBool p_chart_abf_solve(PChart *chart)
/* lastnorm = norm; */ /* UNUSED */
- if (norm < limit)
+ if (norm < limit) {
break;
+ }
if (!p_abf_matrix_invert(&sys, chart)) {
param_warning("ABF failed to invert matrix");
@@ -2906,12 +2971,14 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
if ((be->vert->flag & PVERT_SPLIT) ||
(lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) {
if (!cure) {
- if (be == outer)
+ if (be == outer) {
firste1 = be;
+ }
cure = be;
}
- else
+ else {
curlen += p_edge_length(lastbe);
+ }
}
else if (cure) {
if (curlen > maxlen) {
@@ -2944,8 +3011,9 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
}
}
- if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen))
+ if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen)) {
return P_FALSE;
+ }
/* find pin1 in the split vertices */
be1 = maxe1;
@@ -3054,12 +3122,14 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_PIN) {
npins++;
- if (v->flag & PVERT_SELECT)
+ if (v->flag & PVERT_SELECT) {
select = P_TRUE;
+ }
}
- if (!(v->flag & PVERT_SELECT))
+ if (!(v->flag & PVERT_SELECT)) {
deselect = P_TRUE;
+ }
}
if ((live && (!select || !deselect)) || (npins == 1)) {
@@ -3072,8 +3142,9 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
#endif
if (abf) {
- if (!p_chart_abf_solve(chart))
+ if (!p_chart_abf_solve(chart)) {
param_warning("ABF solving failed: falling back to LSCM.\n");
+ }
}
if (npins <= 1) {
@@ -3091,8 +3162,9 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
chart->u.lscm.pin2 = pin2;
}
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->u.id = id++;
+ }
chart->u.lscm.context = EIG_linear_least_squares_solver_new(
2 * chart->nfaces, 2 * chart->nverts, 1);
@@ -3113,9 +3185,11 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
/* TODO: make loading pins work for simplify/complexify. */
#endif
- for (v = chart->verts; v; v = v->nextlink)
- if (v->flag & PVERT_PIN)
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (v->flag & PVERT_PIN) {
p_vert_load_pin_select_uvs(handle, v); /* reload for live */
+ }
+ }
if (chart->u.lscm.pin1) {
EIG_linear_solver_variable_lock(context, 2 * pin1->u.id);
@@ -3152,10 +3226,12 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) {
float area = p_face_uv_area_signed(f);
- if (area > 0.0f)
+ if (area > 0.0f) {
area_pinned_up += area;
- else
+ }
+ else {
area_pinned_down -= area;
+ }
}
}
@@ -3176,8 +3252,9 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
a2 = *(alpha++);
a3 = *(alpha++);
}
- else
+ else {
p_face_angles(f, &a1, &a2, &a3);
+ }
if (flip_faces) {
SWAP(float, a2, a3);
@@ -3240,8 +3317,9 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
static void p_chart_lscm_end(PChart *chart)
{
- if (chart->u.lscm.context)
+ if (chart->u.lscm.context) {
EIG_linear_solver_delete(chart->u.lscm.context);
+ }
if (chart->u.lscm.abf_alpha) {
MEM_freeN(chart->u.lscm.abf_alpha);
@@ -3261,11 +3339,14 @@ static void p_stretch_pin_boundary(PChart *chart)
{
PVert *v;
- for (v = chart->verts; v; v = v->nextlink)
- if (v->edge->pair == NULL)
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (v->edge->pair == NULL) {
v->flag |= PVERT_PIN;
- else
+ }
+ else {
v->flag &= ~PVERT_PIN;
+ }
+ }
}
static float p_face_stretch(PFace *f)
@@ -3278,8 +3359,9 @@ static float p_face_stretch(PFace *f)
area = p_face_uv_area_signed(f);
- if (area <= 0.0f) /* flipped face -> infinite stretch */
+ if (area <= 0.0f) { /* flipped face -> infinite stretch */
return 1e10f;
+ }
w = 1.0f / (2.0f * area);
@@ -3315,8 +3397,9 @@ static float p_face_stretch(PFace *f)
c = dot_v3v3(Pt, Pt);
T = sqrtf(0.5f * (a + c));
- if (f->flag & PFACE_FILLED)
+ if (f->flag & PFACE_FILLED) {
T *= 0.2f;
+ }
return T;
}
@@ -3343,8 +3426,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
float orig_uv[2], dir[2], random_angle, trusted_radius;
for (v = chart->verts; v; v = v->nextlink) {
- if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT))
+ if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT)) {
continue;
+ }
orig_stretch = p_stretch_compute_vertex(v);
orig_uv[0] = v->uv[0];
@@ -3394,8 +3478,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
}
/* no luck, stretch has increased, reset to old values */
- if (stretch >= orig_stretch)
+ if (stretch >= orig_stretch) {
copy_v2_v2(v->uv, orig_uv);
+ }
}
}
@@ -3406,18 +3491,23 @@ static int p_compare_geometric_uv(const void *a, const void *b)
const PVert *v1 = *(const PVert *const *)a;
const PVert *v2 = *(const PVert *const *)b;
- if (v1->uv[0] < v2->uv[0])
+ if (v1->uv[0] < v2->uv[0]) {
return -1;
+ }
else if (v1->uv[0] == v2->uv[0]) {
- if (v1->uv[1] < v2->uv[1])
+ if (v1->uv[1] < v2->uv[1]) {
return -1;
- else if (v1->uv[1] == v2->uv[1])
+ }
+ else if (v1->uv[1] == v2->uv[1]) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
- else
+ else {
return 1;
+ }
}
static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int *right)
@@ -3431,8 +3521,9 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
p_chart_boundaries(chart, NULL, &be);
- if (!be)
+ if (!be) {
return P_FALSE;
+ }
e = be;
do {
@@ -3455,10 +3546,12 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
ulen = llen = 0;
for (p = points, i = 0; i < npoints; i++, p++) {
- while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0))
+ while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0)) {
ulen--;
- while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0))
+ }
+ while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0)) {
llen--;
+ }
U[ulen] = *p;
ulen++;
@@ -3467,12 +3560,14 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
}
npoints = 0;
- for (p = points, i = 0; i < ulen; i++, p++, npoints++)
+ for (p = points, i = 0; i < ulen; i++, p++, npoints++) {
*p = U[i];
+ }
/* the first and last point in L are left out, since they are also in U */
- for (i = llen - 2; i > 0; i--, p++, npoints++)
+ for (i = llen - 2; i > 0; i--, p++, npoints++) {
*p = L[i];
+ }
*verts = points;
*nverts = npoints;
@@ -3494,14 +3589,17 @@ static float p_rectangle_area(float *p1, float *dir, float *p2, float *p3, float
orthodir[0] = dir[1];
orthodir[1] = -dir[0];
- if (!p_intersect_line_2d_dir(p1, dir, p2, orthodir, corner1))
+ if (!p_intersect_line_2d_dir(p1, dir, p2, orthodir, corner1)) {
return 1e10;
+ }
- if (!p_intersect_line_2d_dir(p1, dir, p4, orthodir, corner2))
+ if (!p_intersect_line_2d_dir(p1, dir, p4, orthodir, corner2)) {
return 1e10;
+ }
- if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3))
+ if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3)) {
return 1e10;
+ }
return len_v2v2(corner1, corner2) * len_v2v2(corner2, corner3);
}
@@ -3517,8 +3615,9 @@ static float p_chart_minimum_area_angle(PChart *chart)
PVert **points, *p1, *p2, *p3, *p4, *p1n;
/* compute convex hull */
- if (!p_chart_convex_hull(chart, &points, &npoints, &right))
+ if (!p_chart_convex_hull(chart, &points, &npoints, &right)) {
return 0.0;
+ }
/* find left/top/right/bottom points, and compute angle for each point */
angles = MEM_mallocN(sizeof(float) * npoints, "PMinAreaAngles");
@@ -3577,11 +3676,12 @@ static float p_chart_minimum_area_angle(PChart *chart)
i_min = 0;
mina = 1e10;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
if (a[i] < mina) {
mina = a[i];
i_min = i;
}
+ }
rotated += mina;
nextidx = (idx[i_min] + 1) % npoints;
@@ -3618,8 +3718,9 @@ static float p_chart_minimum_area_angle(PChart *chart)
}
/* try keeping rotation as small as possible */
- if (minangle > (float)(M_PI / 4))
+ if (minangle > (float)(M_PI / 4)) {
minangle -= (float)(M_PI / 2.0);
+ }
MEM_freeN(angles);
MEM_freeN(points);
@@ -3712,8 +3813,9 @@ static SmoothNode *p_node_new(
node->tri = tri;
node->ntri = ntri;
- if (ntri <= 10 || depth >= 15)
+ if (ntri <= 10 || depth >= 15) {
return node;
+ }
t1 = MEM_mallocN(sizeof(*t1) * ntri, "PNodeTri1");
t2 = MEM_mallocN(sizeof(*t2) * ntri, "PNodeTri1");
@@ -3761,12 +3863,15 @@ static SmoothNode *p_node_new(
static void p_node_delete(SmoothNode *node)
{
- if (node->c1)
+ if (node->c1) {
p_node_delete(node->c1);
- if (node->c2)
+ }
+ if (node->c2) {
p_node_delete(node->c2);
- if (node->tri)
+ }
+ if (node->tri) {
MEM_freeN(node->tri);
+ }
}
static PBool p_node_intersect(SmoothNode *node, float co[2])
@@ -3774,17 +3879,21 @@ static PBool p_node_intersect(SmoothNode *node, float co[2])
int i;
if (node->tri) {
- for (i = 0; i < node->ntri; i++)
- if (p_triangle_inside(node->tri[i], co))
+ for (i = 0; i < node->ntri; i++) {
+ if (p_triangle_inside(node->tri[i], co)) {
return P_TRUE;
+ }
+ }
return P_FALSE;
}
else {
- if (co[node->axis] < node->split)
+ if (co[node->axis] < node->split) {
return p_node_intersect(node->c1, co);
- else
+ }
+ else {
return p_node_intersect(node->c2, co);
+ }
}
}
@@ -3795,12 +3904,15 @@ static int p_compare_float(const void *a_, const void *b_)
const float a = *(const float *)a_;
const float b = *(const float *)b_;
- if (a < b)
+ if (a < b) {
return -1;
- else if (a == b)
+ }
+ else if (a == b) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static float p_smooth_median_edge_length(PChart *chart)
@@ -3811,8 +3923,9 @@ static float p_smooth_median_edge_length(PChart *chart)
int i;
/* ok, so i'm lazy */
- for (i = 0, e = chart->edges; e; e = e->nextlink, i++)
+ for (i = 0, e = chart->edges; e; e = e->nextlink, i++) {
lengths[i] = p_edge_length(e);
+ }
qsort(lengths, i, sizeof(float), p_compare_float);
@@ -3845,14 +3958,16 @@ static void p_smooth(PChart *chart)
SmoothNode *root;
MemArena *arena;
- if (nedges == 0)
+ if (nedges == 0) {
return;
+ }
p_chart_uv_bbox(chart, minv, maxv);
median = p_smooth_median_edge_length(chart) * 0.10f;
- if (median == 0.0f)
+ if (median == 0.0f) {
return;
+ }
invmedian = 1.0f / median;
@@ -3905,8 +4020,9 @@ static void p_smooth(PChart *chart)
gridx = gridx * 2 + 1;
gridy = gridy * 2 + 1;
- if ((gridx <= 2) || (gridy <= 2))
+ if ((gridx <= 2) || (gridy <= 2)) {
return;
+ }
edgesx = gridx - 1;
edgesy = gridy - 1;
@@ -3922,20 +4038,27 @@ static void p_smooth(PChart *chart)
vedges = MEM_mallocN(sizeof(float) * esize, "PSmoothVEdges");
if (!nodes || !nodesx || !nodesy || !oldnodesx || !oldnodesy || !hedges || !vedges) {
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
- if (nodesx)
+ }
+ if (nodesx) {
MEM_freeN(nodesx);
- if (nodesy)
+ }
+ if (nodesy) {
MEM_freeN(nodesy);
- if (oldnodesx)
+ }
+ if (oldnodesx) {
MEM_freeN(oldnodesx);
- if (oldnodesy)
+ }
+ if (oldnodesy) {
MEM_freeN(oldnodesy);
- if (hedges)
+ }
+ if (hedges) {
MEM_freeN(hedges);
- if (vedges)
+ }
+ if (vedges) {
MEM_freeN(vedges);
+ }
// printf("Not enough memory for area smoothing grid");
return;
@@ -4062,12 +4185,14 @@ static void p_smooth(PChart *chart)
}
}
- if (d < dlimit)
+ if (d < dlimit) {
break;
+ }
}
- if (moved < climit)
+ if (moved < climit) {
break;
+ }
}
MEM_freeN(oldnodesx);
@@ -4084,10 +4209,12 @@ static void p_smooth(PChart *chart)
MEM_freeN(nodesx);
MEM_freeN(nodesy);
- if (triangles)
+ if (triangles) {
MEM_freeN(triangles);
- if (tri)
+ }
+ if (tri) {
MEM_freeN(tri);
+ }
// printf("Not enough memory for area smoothing grid");
return;
@@ -4149,9 +4276,11 @@ static void p_smooth(PChart *chart)
arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param smooth arena");
root = p_node_new(arena, tri, esize * 2, minv, maxv, 0);
- for (v = chart->verts; v; v = v->nextlink)
- if (!p_node_intersect(root, v->uv))
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (!p_node_intersect(root, v->uv)) {
param_warning("area smoothing error: couldn't find mapping triangle\n");
+ }
+ }
p_node_delete(root);
BLI_memarena_free(arena);
@@ -4197,11 +4326,13 @@ void param_delete(ParamHandle *handle)
param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) ||
(phandle->state == PHANDLE_STATE_CONSTRUCTED));
- for (i = 0; i < phandle->ncharts; i++)
+ for (i = 0; i < phandle->ncharts; i++) {
p_chart_delete(phandle->charts[i]);
+ }
- if (phandle->charts)
+ if (phandle->charts) {
MEM_freeN(phandle->charts);
+ }
if (phandle->construction_chart) {
p_chart_delete(phandle->construction_chart);
@@ -4323,8 +4454,9 @@ void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
e = p_edge_lookup(phandle, vkeys);
- if (e)
+ if (e) {
e->flag |= PEDGE_SEAM;
+ }
}
void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
@@ -4361,11 +4493,13 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
phandle->charts[j] = chart;
j++;
- if (fill && (nboundaries > 1))
+ if (fill && (nboundaries > 1)) {
p_chart_fill_boundaries(chart, outer);
+ }
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
p_vert_load_pin_select_uvs(handle, v);
+ }
}
phandle->ncharts = j;
@@ -4383,8 +4517,9 @@ void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
phandle->state = PHANDLE_STATE_LSCM;
for (i = 0; i < phandle->ncharts; i++) {
- for (f = phandle->charts[i]->faces; f; f = f->nextlink)
+ for (f = phandle->charts[i]->faces; f; f = f->nextlink) {
p_face_backup_uvs(f);
+ }
p_chart_lscm_begin(phandle->charts[i], (PBool)live, (PBool)abf);
}
}
@@ -4404,11 +4539,13 @@ void param_lscm_solve(ParamHandle *handle)
if (chart->u.lscm.context) {
result = p_chart_lscm_solve(phandle, chart);
- if (result && !(chart->flag & PCHART_HAS_PINS))
+ if (result && !(chart->flag & PCHART_HAS_PINS)) {
p_chart_rotate_minimum_area(chart);
+ }
- if (!result || (chart->u.lscm.pin1))
+ if (!result || (chart->u.lscm.pin1)) {
p_chart_lscm_end(chart);
+ }
}
}
}
@@ -4447,8 +4584,9 @@ void param_stretch_begin(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->flag &= ~PVERT_PIN; /* don't use user-defined pins */
+ }
p_stretch_pin_boundary(chart);
@@ -4503,8 +4641,9 @@ void param_smooth_area(ParamHandle *handle)
PChart *chart = phandle->charts[i];
PVert *v;
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->flag &= ~PVERT_PIN;
+ }
p_smooth(chart);
}
@@ -4557,16 +4696,18 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
PHandle *phandle = (PHandle *)handle;
- if (phandle->ncharts == 0)
+ if (phandle->ncharts == 0) {
return;
+ }
/* this could be its own function */
if (do_rotate) {
param_pack_rotate(handle, ignore_pinned);
}
- if (phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy) {
param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
+ }
/* we may not use all these boxes */
boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box");
@@ -4592,8 +4733,9 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_HAS_PINS boxes */
- if (margin > 0.0f)
+ if (margin > 0.0f) {
area += (double)sqrtf(box->w * box->h);
+ }
}
if (margin > 0.0f) {
@@ -4622,10 +4764,12 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
- if (tot_height > tot_width)
+ if (tot_height > tot_width) {
scale = 1.0f / tot_height;
- else
+ }
+ else {
scale = 1.0f / tot_width;
+ }
for (i = 0; i < phandle->ncharts - unpacked; i++) {
box = boxarray + i;
@@ -4638,8 +4782,9 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
}
MEM_freeN(boxarray);
- if (phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy) {
param_scale(handle, phandle->aspx, phandle->aspy);
+ }
}
void param_average(ParamHandle *handle, bool ignore_pinned)
@@ -4651,8 +4796,9 @@ void param_average(ParamHandle *handle, bool ignore_pinned)
float minv[2], maxv[2], trans[2];
PHandle *phandle = (PHandle *)handle;
- if (phandle->ncharts == 0)
+ if (phandle->ncharts == 0) {
return;
+ }
for (i = 0; i < phandle->ncharts; i++) {
PFace *f;
@@ -4729,13 +4875,16 @@ void param_flush(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context)
+ if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context) {
continue;
+ }
- if (phandle->blend == 0.0f)
+ if (phandle->blend == 0.0f) {
p_flush_uvs(phandle, chart);
- else
+ }
+ else {
p_flush_uvs_blend(phandle, chart, phandle->blend);
+ }
}
}
@@ -4749,7 +4898,8 @@ void param_flush_restore(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (f = chart->faces; f; f = f->nextlink)
+ for (f = chart->faces; f; f = f->nextlink) {
p_face_restore_uvs(f);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index fcb557473fd..b938f963d9a 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -466,11 +466,13 @@ static void stitch_calculate_island_snapping(StitchState *state,
float rotation_mat[2][2];
/* check to avoid divide by 0 */
- if (island_stitch_data[i].num_rot_elements > 1)
+ if (island_stitch_data[i].num_rot_elements > 1) {
island_stitch_data[i].rotation /= island_stitch_data[i].num_rot_elements;
+ }
- if (island_stitch_data[i].num_rot_elements_neg > 1)
+ if (island_stitch_data[i].num_rot_elements_neg > 1) {
island_stitch_data[i].rotation_neg /= island_stitch_data[i].num_rot_elements_neg;
+ }
if (island_stitch_data[i].numOfElements > 1) {
island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements;
@@ -609,8 +611,9 @@ static void stitch_island_calculate_vert_rotation(UvElement *element,
int rot_elem = 0, rot_elem_neg = 0;
BMLoop *l;
- if (element->island == ssc->static_island && !ssc->midpoints)
+ if (element->island == ssc->static_island && !ssc->midpoints) {
return;
+ }
l = element->l;
@@ -625,8 +628,9 @@ static void stitch_island_calculate_vert_rotation(UvElement *element,
float normal[2];
/* only calculate rotation against static island uv verts */
- if (!ssc->midpoints && element_iter->island != ssc->static_island)
+ if (!ssc->midpoints && element_iter->island != ssc->static_island) {
continue;
+ }
index_tmp1 = element_iter - state->element_map->buf;
index_tmp1 = state->map[index_tmp1];
@@ -717,8 +721,9 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
for (i = 0; i < state->total_separate_edges; i++) {
UvEdge *edge = edges + i;
- if (edge->first)
+ if (edge->first) {
continue;
+ }
/* only boundary edges can be stitched. Yes. Sorry about that :p */
if (edge->flag & STITCH_BOUNDARY) {
@@ -736,10 +741,12 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
UvElement *iter2 = NULL;
/* check to see if other vertex of edge belongs to same vertex as */
- if (BM_elem_index_get(iter1->l->next->v) == elemindex2)
+ if (BM_elem_index_get(iter1->l->next->v) == elemindex2) {
iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->next);
- else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2)
+ }
+ else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2) {
iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->prev);
+ }
if (iter2) {
int index1 = map[iter1 - first_element];
@@ -852,8 +859,9 @@ static void stitch_setup_face_preview_for_uv_group(UvElement *element,
StitchPreviewer *preview = state->stitch_preview;
/* static island does not change so returning immediately */
- if (ssc->snap_islands && !ssc->midpoints && ssc->static_island == element->island)
+ if (ssc->snap_islands && !ssc->midpoints && ssc->static_island == element->island) {
return;
+ }
if (ssc->snap_islands) {
island_stitch_data[element->island].addedForPreview = 1;
@@ -892,8 +900,9 @@ static void stitch_validate_uv_stitchability(UvElement *element,
for (; element_iter; element_iter = element_iter->next) {
if (element_iter->separate) {
- if (element_iter == element)
+ if (element_iter == element) {
continue;
+ }
if (stitch_check_uvs_state_stitchable(element, element_iter, ssc, state)) {
if ((element_iter->island == ssc->static_island) ||
(element->island == ssc->static_island)) {
@@ -930,8 +939,9 @@ static void stitch_validate_edge_stitchability(UvEdge *edge,
UvEdge *edge_iter = edge->first;
for (; edge_iter; edge_iter = edge_iter->next) {
- if (edge_iter == edge)
+ if (edge_iter == edge) {
continue;
+ }
if (stitch_check_edges_state_stitchable(edge, edge_iter, ssc, state)) {
if ((edge_iter->element->island == ssc->static_island) ||
(edge->element->island == ssc->static_island)) {
@@ -1029,8 +1039,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
/* cleanup previous preview */
stitch_preview_delete(state->stitch_preview);
preview = state->stitch_preview = stitch_preview_init();
- if (preview == NULL)
+ if (preview == NULL) {
return 0;
+ }
preview_position = MEM_mallocN(bm->totface * sizeof(*preview_position),
"stitch_face_preview_position");
@@ -1314,8 +1325,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
copy_v2_v2(final_position[i].uv, luv->uv);
final_position[i].count = 1;
- if (ssc->snap_islands && element->island == ssc->static_island && !stitch_midpoints)
+ if (ssc->snap_islands && element->island == ssc->static_island && !stitch_midpoints) {
continue;
+ }
element_iter = state->element_map->vert[BM_elem_index_get(l->v)];
@@ -1364,8 +1376,10 @@ static int stitch_process_data(StitchStateContainer *ssc,
state->uvs[edge->uv1]->flag |= STITCH_STITCHABLE;
state->uvs[edge->uv2]->flag |= STITCH_STITCHABLE;
- if (ssc->snap_islands && edge->element->island == ssc->static_island && !stitch_midpoints)
+ if (ssc->snap_islands && edge->element->island == ssc->static_island &&
+ !stitch_midpoints) {
continue;
+ }
for (edge_iter = edge->first; edge_iter; edge_iter = edge_iter->next) {
if (stitch_check_edges_state_stitchable(edge, edge_iter, ssc, state)) {
@@ -1587,8 +1601,9 @@ static void stitch_select_edge(UvEdge *edge, StitchState *state, int always_sele
for (eiter = edge->first; eiter; eiter = eiter->next) {
if (eiter->flag & STITCH_SELECTED) {
int i;
- if (always_select)
+ if (always_select) {
continue;
+ }
eiter->flag &= ~STITCH_SELECTED;
for (i = 0; i < state->selection_size; i++) {
@@ -1622,8 +1637,9 @@ static void stitch_select_uv(UvElement *element, StitchState *state, int always_
/* only separators go to selection */
if (element_iter->flag & STITCH_SELECTED) {
int i;
- if (always_select)
+ if (always_select) {
continue;
+ }
element_iter->flag &= ~STITCH_SELECTED;
for (i = 0; i < state->selection_size; i++) {
@@ -1660,8 +1676,9 @@ static void stitch_set_selection_mode(StitchState *state, const char from_stitch
UvElement *element1 = state->uvs[edge->uv1];
UvElement *element2 = state->uvs[edge->uv2];
- if ((element1->flag & STITCH_SELECTED) && (element2->flag & STITCH_SELECTED))
+ if ((element1->flag & STITCH_SELECTED) && (element2->flag & STITCH_SELECTED)) {
stitch_select_edge(edge, state, true);
+ }
}
/* unselect selected uvelements */
@@ -1770,8 +1787,9 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
/* Preview Polys */
if (stitch_preview->preview_polys) {
- for (int i = 0; i < stitch_preview->num_polys; i++)
+ for (int i = 0; i < stitch_preview->num_polys; i++) {
num_line += stitch_preview->uvs_per_polygon[i];
+ }
num_tri = num_line - 2 * stitch_preview->num_polys;
@@ -2237,8 +2255,9 @@ static bool goto_next_island(StitchStateContainer *ssc)
static int stitch_init_all(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
- if (!ar)
+ if (!ar) {
return 0;
+ }
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -2260,10 +2279,12 @@ static int stitch_init_all(bContext *C, wmOperator *op)
}
else {
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_VERTEX)
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
ssc->mode = STITCH_VERT;
- else
+ }
+ else {
ssc->mode = STITCH_EDGE;
+ }
}
else {
if (ts->uv_selectmode & UV_SELECT_VERTEX) {
@@ -2385,8 +2406,9 @@ static int stitch_init_all(bContext *C, wmOperator *op)
static int stitch_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (!stitch_init_all(C, op))
+ if (!stitch_init_all(C, op)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_modal_handler(C, op);
@@ -2469,8 +2491,9 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
MEM_freeN(objs_selection_count);
}
- if (sa)
+ if (sa) {
ED_workspace_status_text(C, NULL);
+ }
ED_region_draw_cb_exit(CTX_wm_region(C)->type, ssc->draw_handle);
@@ -2504,8 +2527,9 @@ static int stitch_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- if (!stitch_init_all(C, op))
+ if (!stitch_init_all(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (stitch_process_data_all((StitchStateContainer *)op->customdata, scene, 1)) {
stitch_exit(C, op, 1);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 92f7873d5c1..85393925802 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -84,10 +84,12 @@ static void modifier_unwrap_state(Object *obedit, Scene *scene, bool *r_use_subs
/* subsurf will take the modifier settings only if modifier is first or right after mirror */
if (subsurf) {
- if (md && md->type == eModifierType_Subsurf)
+ if (md && md->type == eModifierType_Subsurf) {
subsurf = true;
- else
+ }
+ else {
subsurf = false;
+ }
}
*r_use_subsurf = subsurf;
@@ -105,14 +107,17 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
SpaceImage *sima;
int cd_loop_uv_offset;
- if (ED_uvedit_test(obedit))
+ if (ED_uvedit_test(obedit)) {
return 1;
+ }
- if (em && em->bm->totface && !CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV))
+ if (em && em->bm->totface && !CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
ED_mesh_uv_texture_add(obedit->data, NULL, true, true);
+ }
- if (!ED_uvedit_test(obedit))
+ if (!ED_uvedit_test(obedit)) {
return 0;
+ }
cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
@@ -129,10 +134,12 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
ima = sima->image;
if (ima) {
- if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
+ if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
ima = NULL;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -176,19 +183,23 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, const UnwrapOpti
* so we can cancel the operator early */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
}
- else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
break;
+ }
}
- if (options->topology_from_uvs && !l)
+ if (options->topology_from_uvs && !l) {
continue;
+ }
return true;
}
@@ -286,8 +297,9 @@ static ParamHandle *construct_param_handle(Scene *scene,
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
- if (aspx != aspy)
+ if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
+ }
}
/* we need the vert indices */
@@ -432,8 +444,9 @@ static void texface_from_original_index(BMFace *efa,
*pin = 0;
*select = 1;
- if (index == ORIGINDEX_NONE)
+ if (index == ORIGINDEX_NONE) {
return;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (BM_elem_index_get(l->v) == index) {
@@ -495,8 +508,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
- if (aspx != aspy)
+ if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
+ }
}
/* number of subdivisions to perform */
@@ -531,8 +545,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_FACE);
/* map subsurfed faces to original editFaces */
- for (i = 0; i < numOfFaces; i++)
+ for (i = 0; i < numOfFaces; i++) {
faceMap[i] = BM_face_at_index(em->bm, origPolyIndices[i]);
+ }
edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map");
@@ -553,8 +568,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
BMFace *origFace = faceMap[i];
if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN)) {
continue;
+ }
}
else {
if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) ||
@@ -678,8 +694,9 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
ms->lasttime = PIL_check_seconds_timer();
param_stretch_begin(ms->handle);
- if (ms->blend != 0.0f)
+ if (ms->blend != 0.0f) {
param_stretch_blend(ms->handle, ms->blend);
+ }
op->customdata = ms;
@@ -738,13 +755,16 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
ED_area_status_text(sa, NULL);
ED_workspace_status_text(C, NULL);
- if (ms->timer)
+ if (ms->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ms->timer);
+ }
- if (cancel)
+ if (cancel) {
param_flush_restore(ms->handle);
- else
+ }
+ else {
param_flush(ms->handle);
+ }
param_stretch_end(ms->handle);
param_delete(ms->handle);
@@ -770,12 +790,14 @@ static int minimize_stretch_exec(bContext *C, wmOperator *op)
{
int i, iterations;
- if (!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
iterations = RNA_int_get(op->ptr, "iterations");
- for (i = 0; i < iterations; i++)
+ for (i = 0; i < iterations; i++) {
minimize_stretch_iteration(C, op, false);
+ }
minimize_stretch_exit(C, op, false);
return OPERATOR_FINISHED;
@@ -785,8 +807,9 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, const wmEvent *U
{
MinStretch *ms;
- if (!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
minimize_stretch_iteration(C, op, true);
@@ -964,10 +987,12 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (RNA_struct_property_is_set(op->ptr, "margin"))
+ if (RNA_struct_property_is_set(op->ptr, "margin")) {
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- else
+ }
+ else {
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+ }
uvedit_pack_islands_multi(scene, objects, objects_len, &options, rotate, ignore_pinned);
@@ -1081,10 +1106,12 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
.correct_aspect = (scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT) == 0,
};
- if (use_subsurf)
+ if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, &options);
- else
+ }
+ else {
handle = construct_param_handle(scene, obedit, em->bm, &options);
+ }
param_lscm_begin(handle, PARAM_TRUE, abf);
@@ -1119,8 +1146,9 @@ void ED_uvedit_live_unwrap_end(short cancel)
if (g_live_unwrap.handles) {
for (int i = 0; i < g_live_unwrap.len; i++) {
param_lscm_end(g_live_unwrap.handles[i]);
- if (cancel)
+ if (cancel) {
param_flush_restore(g_live_unwrap.handles[i]);
+ }
param_delete(g_live_unwrap.handles[i]);
}
MEM_freeN(g_live_unwrap.handles);
@@ -1232,10 +1260,12 @@ static void uv_map_rotation_matrix_ex(float result[4][4],
float sideangle = 0.0f, upangle = 0.0f;
/* get rotation of the current view matrix */
- if (rv3d)
+ if (rv3d) {
copy_m4_m4(viewmatrix, rv3d->viewmat);
- else
+ }
+ else {
unit_m4(viewmatrix);
+ }
/* but shifting */
copy_v4_fl(viewmatrix[3], 0.0f);
@@ -1300,17 +1330,21 @@ static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[4][4])
}
else {
upangledeg = 0.0f;
- if (align == POLAR_ZY)
+ if (align == POLAR_ZY) {
sideangledeg = 0.0f;
- else
+ }
+ else {
sideangledeg = 90.0f;
+ }
}
/* be compatible to the "old" sphere/cylinder mode */
- if (direction == ALIGN_TO_OBJECT)
+ if (direction == ALIGN_TO_OBJECT) {
unit_m4(rotmat);
- else
+ }
+ else {
uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius);
+ }
}
static void uv_transform_properties(wmOperatorType *ot, int radius)
@@ -1343,7 +1377,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
VIEW_ON_EQUATOR,
"Align",
"How to determine rotation around the pole");
- if (radius)
+ if (radius) {
RNA_def_float(ot->srna,
"radius",
1.0f,
@@ -1353,6 +1387,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
"Radius of the sphere or cylinder",
0.0001f,
100.0f);
+ }
}
static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
@@ -1367,15 +1402,17 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
- if (aspx == aspy)
+ if (aspx == aspy) {
return;
+ }
if (aspx > aspy) {
scale = aspy / aspx;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1387,8 +1424,9 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
scale = aspx / aspy;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1442,14 +1480,16 @@ static void uv_map_clip_correct_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
/* correct for image aspect ratio */
- if (correct_aspect)
+ if (correct_aspect) {
correct_uv_aspect(scene, ob, em);
+ }
if (scale_to_bounds) {
/* find uv limits */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1460,8 +1500,9 @@ static void uv_map_clip_correct_multi(Scene *scene,
else if (clip_to_bounds) {
/* clipping and wrapping */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1477,10 +1518,12 @@ static void uv_map_clip_correct_multi(Scene *scene,
dx = (max[0] - min[0]);
dy = (max[1] - min[1]);
- if (dx > 0.0f)
+ if (dx > 0.0f) {
dx = 1.0f / dx;
- if (dy > 0.0f)
+ }
+ if (dy > 0.0f) {
dy = 1.0f / dy;
+ }
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -1489,8 +1532,9 @@ static void uv_map_clip_correct_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1522,10 +1566,12 @@ static void uvedit_unwrap(Scene *scene, Object *obedit, const UnwrapOptions *opt
modifier_unwrap_state(obedit, scene, &use_subsurf);
ParamHandle *handle;
- if (use_subsurf)
+ if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, options);
- else
+ }
+ else {
handle = construct_param_handle(scene, obedit, em->bm, options);
+ }
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
@@ -1655,31 +1701,41 @@ static int unwrap_exec(bContext *C, wmOperator *op)
}
/* remember last method for live unwrap */
- if (RNA_struct_property_is_set(op->ptr, "method"))
+ if (RNA_struct_property_is_set(op->ptr, "method")) {
scene->toolsettings->unwrapper = method;
- else
+ }
+ else {
RNA_enum_set(op->ptr, "method", scene->toolsettings->unwrapper);
+ }
/* remember packing margin */
- if (RNA_struct_property_is_set(op->ptr, "margin"))
+ if (RNA_struct_property_is_set(op->ptr, "margin")) {
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- else
+ }
+ else {
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+ }
- if (options.fill_holes)
+ if (options.fill_holes) {
scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag &= ~UVCALC_FILLHOLES;
+ }
- if (options.correct_aspect)
+ if (options.correct_aspect) {
scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag |= UVCALC_NO_ASPECT_CORRECT;
+ }
- if (use_subsurf)
+ if (use_subsurf) {
scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag &= ~UVCALC_USESUBSURF;
+ }
/* execute unwrap */
uvedit_unwrap_multi(scene, objects, objects_len, &options);
@@ -1748,11 +1804,13 @@ static int uv_from_view_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "camera_bounds");
- if (!RNA_property_is_set(op->ptr, prop))
+ if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (camera != NULL));
+ }
prop = RNA_struct_find_property(op->ptr, "correct_aspect");
- if (!RNA_property_is_set(op->ptr, prop))
+ if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (camera == NULL));
+ }
return uv_from_view_exec(C, op);
}
@@ -1808,8 +1866,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
uv_map_rotation_matrix_ex(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f, objects_pos_offset);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1828,8 +1887,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
if (uci) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1845,8 +1905,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
copy_m4_m4(rotmat, obedit->obmat);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1886,8 +1947,9 @@ static bool uv_from_view_poll(bContext *C)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- if (!ED_operator_uvmap(C))
+ if (!ED_operator_uvmap(C)) {
return 0;
+ }
return (rv3d != NULL);
}
@@ -1980,8 +2042,9 @@ static void uv_sphere_project(float target[2],
map_to_sphere(&target[0], &target[1], pv[0], pv[1], pv[2]);
/* split line is always zero */
- if (target[0] >= 1.0f)
+ if (target[0] >= 1.0f) {
target[0] -= 1.0f;
+ }
}
static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
@@ -2001,15 +2064,18 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
}
mi = 0;
- for (i = 1; i < efa->len; i++)
- if (uvs[i][0] > uvs[mi][0])
+ for (i = 1; i < efa->len; i++) {
+ if (uvs[i][0] > uvs[mi][0]) {
mi = i;
+ }
+ }
for (i = 0; i < efa->len; i++) {
if (i != mi) {
dx = uvs[mi][0] - uvs[i][0];
- if (dx > 0.5f)
+ if (dx > 0.5f) {
uvs[i][0] += 1.0f;
+ }
}
}
}
@@ -2047,8 +2113,9 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
uv_map_transform_center(scene, v3d, obedit, em, center, NULL);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2102,8 +2169,9 @@ static void uv_cylinder_project(float target[2],
map_to_tube(&target[0], &target[1], pv[0], pv[1], pv[2]);
/* split line is always zero */
- if (target[0] >= 1.0f)
+ if (target[0] >= 1.0f) {
target[0] -= 1.0f;
+ }
}
static int cylinder_project_exec(bContext *C, wmOperator *op)
@@ -2139,8 +2207,9 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
uv_map_transform_center(scene, v3d, obedit, em, center, NULL);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2209,8 +2278,9 @@ static void uvedit_unwrap_cube_project(BMesh *bm,
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
- if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
axis_dominant_v3(&cox, &coy, efa->no);
@@ -2340,6 +2410,7 @@ void ED_uvedit_add_simple_uvs(Main *bmain, Scene *scene, Object *ob)
BM_mesh_bm_to_me(bmain, bm, me, (&(struct BMeshToMeshParams){0}));
BM_mesh_free(bm);
- if (sync_selection)
+ if (sync_selection) {
scene->toolsettings->uv_flag |= UV_SYNC_SELECTION;
+ }
}