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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-24 10:38:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-24 10:38:07 +0400
commitab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch)
tree81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/uvedit
parent5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff)
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c12
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c124
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c502
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c36
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c341
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c180
6 files changed, 610 insertions, 585 deletions
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index a45a3555b51..ff673fa0eab 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -81,7 +81,7 @@ static int uvedit_center(Scene *scene, BMEditMesh *em, Image *UNUSED(ima), float
}
}
- if(tot > 0) {
+ if (tot > 0) {
center[0] /= tot;
center[1] /= tot;
}
@@ -124,15 +124,15 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
em = BMEdit_FromObject(obedit);
- if(uvedit_center(scene, em, ima, center)) {
+ if (uvedit_center(scene, em, ima, center)) {
copy_v2_v2(uvedit_old_center, center);
- if(!(sima->flag & SI_COORDFLOATS)) {
+ if (!(sima->flag & SI_COORDFLOATS)) {
uvedit_old_center[0] *= imx;
uvedit_old_center[1] *= imy;
}
- if(sima->flag & SI_COORDFLOATS) {
+ if (sima->flag & SI_COORDFLOATS) {
step= 1;
digits= 3;
}
@@ -158,7 +158,7 @@ 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 = BMEdit_FromObject(obedit);
@@ -166,7 +166,7 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
ED_space_image_size(sima, &imx, &imy);
uvedit_center(scene, em, ima, center);
- if(sima->flag & SI_COORDFLOATS) {
+ if (sima->flag & SI_COORDFLOATS) {
delta[0]= uvedit_old_center[0] - center[0];
delta[1]= uvedit_old_center[1] - center[1];
}
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 66ba28e70a6..6767d543c5e 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -112,10 +112,10 @@ static int draw_uvs_face_check(Scene *scene)
ToolSettings *ts= scene->toolsettings;
/* checks if we are selecting only faces */
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode == SCE_SELECT_FACE)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ 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
return 0;
@@ -152,7 +152,7 @@ static int draw_uvs_dm_shadow(DerivedMesh *dm)
{
/* draw shadow mesh - this is the mesh with the modifier applied */
- if(dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
+ if (dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
glColor3ub(112, 112, 112);
dm->drawUVEdges(dm);
return 1;
@@ -204,22 +204,22 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
//totuvarea += tf_area(tf, efa->v4!=0);
totuvarea += poly_uv_area(tf_uv, efa->len);
- if(uvedit_face_visible(scene, ima, efa, tf)) {
+ if (uvedit_face_visible(scene, ima, efa, tf)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
}
else {
- if(tf == activetf)
+ if (tf == activetf)
activetf= NULL;
BM_elem_flag_disable(efa, BM_ELEM_TAG);
}
}
- if(totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) {
+ if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) {
col[0] = 1.0;
col[1] = col[2] = 0.0;
glColor3fv(col);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_elem_flag_test(efa, BM_ELEM_TAG)) {
+ if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
glBegin(GL_POLYGON);
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -231,7 +231,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
}
else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_elem_flag_test(efa, BM_ELEM_TAG)) {
+ if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
area = BM_face_area_calc(em->bm, efa) / totarea;
BLI_array_empty(tf_uv);
@@ -253,9 +253,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
//uvarea = tf_area(tf, efa->v4!=0) / totuvarea;
uvarea = poly_uv_area(tf_uv, efa->len) / totuvarea;
- if(area < FLT_EPSILON || uvarea < FLT_EPSILON)
+ if (area < FLT_EPSILON || uvarea < FLT_EPSILON)
areadiff = 1.0f;
- else if(area>uvarea)
+ else if (area>uvarea)
areadiff = 1.0f-(uvarea/area);
else
areadiff = 1.0f-(area/uvarea);
@@ -286,13 +286,13 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
glShadeModel(GL_SMOOTH);
- for(efa= em->faces.first; efa; efa= efa->next) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
tf= CustomData_em_get(&em->fdata, efa->head.data, CD_MTFACE);
- if(uvedit_face_visible(scene, ima, efa, tf)) {
+ if (uvedit_face_visible(scene, ima, efa, tf)) {
efa->tmp.p = tf;
uv_copy_aspect(tf->uv, tf_uv, aspx, aspy);
- if(efa->v4) {
+ if (efa->v4) {
#if 0 /* Simple but slow, better reuse normalized vectors */
uvang1 = RAD2DEG(angle_v2v2v2(tf_uv[3], tf_uv[0], tf_uv[1]));
@@ -410,7 +410,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
glEnd();
}
else {
- if(tf == activetf)
+ if (tf == activetf)
activetf= NULL;
efa->tmp.p = NULL;
}
@@ -430,24 +430,24 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage)
glColor3ub(96, 96, 96);
- for(base=scene->base.first; base; base=base->next) {
+ for (base=scene->base.first; base; base=base->next) {
Object *ob= base->object;
- if(!(base->flag & SELECT)) continue;
- if(!(base->lay & scene->lay)) continue;
- if(ob->restrictflag & OB_RESTRICT_VIEW) continue;
+ if (!(base->flag & SELECT)) continue;
+ if (!(base->lay & scene->lay)) continue;
+ if (ob->restrictflag & OB_RESTRICT_VIEW) continue;
- if((ob->type==OB_MESH) && (ob!=obedit)) {
+ if ((ob->type==OB_MESH) && (ob!=obedit)) {
Mesh *me= ob->data;
- if(me->mtface) {
+ if (me->mtface) {
MPoly *mface= me->mpoly;
MTexPoly *tface= me->mtpoly;
MLoopUV *mloopuv;
int a, b;
- for(a=me->totpoly; a>0; a--, tface++, mface++) {
- if(tface->tpage == curimage) {
+ for (a=me->totpoly; a>0; a--, tface++, mface++) {
+ if (tface->tpage == curimage) {
glBegin(GL_LINE_LOOP);
mloopuv = me->mloopuv + mface->loopstart;
@@ -467,19 +467,19 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob)
Mesh *me= ob->data;
Image *curimage = ED_space_image(sima);
- if(sima->flag & SI_DRAW_OTHER)
+ if (sima->flag & SI_DRAW_OTHER)
draw_uvs_other(scene, ob, curimage);
glColor3ub(112, 112, 112);
- if(me->mtface) {
+ if (me->mtface) {
MPoly *mface= me->mpoly;
MTexPoly *tface= me->mtpoly;
MLoopUV *mloopuv;
int a, b;
- for(a=me->totpoly; a>0; a--, tface++, mface++) {
- if(tface->tpage == curimage) {
+ for (a=me->totpoly; a>0; a--, tface++, mface++) {
+ if (tface->tpage == curimage) {
glBegin(GL_LINE_LOOP);
mloopuv = me->mloopuv + mface->loopstart;
@@ -517,13 +517,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
ts= scene->toolsettings;
drawfaces= draw_uvs_face_check(scene);
- if(ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION)
interpedges= (ts->selectmode & SCE_SELECT_VERTEX);
else
interpedges= (ts->uv_selectmode == UV_SELECT_VERTEX);
/* draw other uvs */
- if(sima->flag & SI_DRAW_OTHER) {
+ if (sima->flag & SI_DRAW_OTHER) {
Image *curimage= (activetf)? activetf->tpage: NULL;
draw_uvs_other(scene, obedit, curimage);
@@ -531,29 +531,29 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* 1. draw shadow mesh */
- if(sima->flag & SI_DRAWSHADOW) {
+ if (sima->flag & SI_DRAWSHADOW) {
/* first try existing derivedmesh */
- if(!draw_uvs_dm_shadow(em->derivedFinal)) {
+ if (!draw_uvs_dm_shadow(em->derivedFinal)) {
/* create one if it does not exist */
cagedm = editbmesh_get_derived_cage_and_final(scene, obedit, me->edit_btmesh, &finaldm, CD_MASK_BAREMESH|CD_MASK_MTFACE);
/* when sync selection is enabled, all faces are drawn (except for hidden)
* so if cage is the same as the final, theres no point in drawing this */
- if(!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm)))
+ if (!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm)))
draw_uvs_dm_shadow(finaldm);
/* release derivedmesh again */
- if(cagedm != finaldm) cagedm->release(cagedm);
+ if (cagedm != finaldm) cagedm->release(cagedm);
finaldm->release(finaldm);
}
}
/* 2. draw colored faces */
- if(sima->flag & SI_DRAW_STRETCH) {
+ if (sima->flag & SI_DRAW_STRETCH) {
draw_uvs_stretch(sima, scene, em, activetf);
}
- else if(!(sima->flag & SI_NO_DRAWFACES)) {
+ else if (!(sima->flag & SI_NO_DRAWFACES)) {
/* draw transparent faces */
UI_GetThemeColor4ubv(TH_FACE, col1);
UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
@@ -563,11 +563,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(uvedit_face_visible(scene, ima, efa, tf)) {
+ if (uvedit_face_visible(scene, ima, efa, tf)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
- if(tf==activetf) continue; /* important the temp boolean is set above */
+ if (tf==activetf) continue; /* important the temp boolean is set above */
- if(uvedit_face_selected(scene, em, efa))
+ if (uvedit_face_selected(scene, em, efa))
glColor4ubv((GLubyte *)col2);
else
glColor4ubv((GLubyte *)col1);
@@ -580,7 +580,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
glEnd();
}
else {
- if(tf == activetf)
+ if (tf == activetf)
activetf= NULL;
BM_elem_flag_disable(efa, BM_ELEM_TAG);
}
@@ -593,11 +593,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(uvedit_face_visible(scene, ima, efa, tf)) {
+ if (uvedit_face_visible(scene, ima, efa, tf)) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
}
else {
- if(tf == activetf)
+ if (tf == activetf)
activetf= NULL;
BM_elem_flag_disable(efa, BM_ELEM_TAG);
}
@@ -607,7 +607,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* 3. draw active face stippled */
- if(activef) {
+ if (activef) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UI_ThemeColor4(TH_EDITMESH_ACTIVE);
@@ -628,7 +628,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* 4. draw edges */
- if(sima->flag & SI_SMOOTH_UV) {
+ if (sima->flag & SI_SMOOTH_UV) {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -641,7 +641,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
continue;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(tf) {
+ if (tf) {
cpack(0x111111);
glBegin(GL_LINE_LOOP);
@@ -676,7 +676,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
break;
case SI_UVDT_BLACK: /* black/white */
case SI_UVDT_WHITE:
- if(sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f);
+ if (sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f);
else glColor3f(0.0f, 0.0f, 0.0f);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -711,11 +711,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
col2[0] = col2[1] = col2[2] = 192; col2[3] = 255;
glColor4ubv((unsigned char *)col2);
- if(me->drawflag & ME_DRAWEDGES) {
+ if (me->drawflag & ME_DRAWEDGES) {
int sel, lastsel = -1;
UI_GetThemeColor4ubv(TH_VERTEX_SELECT, col1);
- if(interpedges) {
+ if (interpedges) {
glShadeModel(GL_SMOOTH);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -743,7 +743,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
glBegin(GL_LINES);
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
sel = (uvedit_edge_selected(em, scene, l)? 1 : 0);
- if(sel != lastsel){
+ if (sel != lastsel) {
glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2);
lastsel = sel;
}
@@ -774,14 +774,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
break;
}
- if(sima->flag & SI_SMOOTH_UV) {
+ if (sima->flag & SI_SMOOTH_UV) {
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
/* 5. draw face centers */
- if(drawfaces) {
+ if (drawfaces) {
float cent[2];
pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
@@ -795,7 +795,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- if(!uvedit_face_selected(scene, em, efa)) {
+ if (!uvedit_face_selected(scene, em, efa)) {
poly_uv_center(em, efa, cent);
bglVertex2fv(cent);
}
@@ -810,7 +810,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
continue;
- if(uvedit_face_selected(scene, em, efa)) {
+ if (uvedit_face_selected(scene, em, efa)) {
poly_uv_center(em, efa, cent);
bglVertex2fv(cent);
}
@@ -820,7 +820,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* 6. draw uv vertices */
- if(drawfaces != 2) { /* 2 means Mesh Face Mode */
+ if (drawfaces != 2) { /* 2 means Mesh Face Mode */
/* unselected uvs */
UI_ThemeColor(TH_VERTEX);
pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
@@ -833,7 +833,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(!uvedit_uv_selected(em, scene, l))
+ if (!uvedit_uv_selected(em, scene, l))
bglVertex2fv(luv->uv);
}
}
@@ -852,7 +852,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(luv->flag & MLOOPUV_PINNED)
+ if (luv->flag & MLOOPUV_PINNED)
bglVertex2fv(luv->uv);
}
}
@@ -870,7 +870,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(uvedit_uv_selected(em, scene, l))
+ if (uvedit_uv_selected(em, scene, l))
bglVertex2fv(luv->uv);
}
}
@@ -878,7 +878,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
}
/* finally draw stitch preview */
- if(stitch_preview) {
+ if (stitch_preview) {
int i, index = 0;
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -891,7 +891,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_static_tris*3);
glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_polys);
- for(i = 0; i < stitch_preview->num_polys; i++){
+ for (i = 0; i < stitch_preview->num_polys; i++) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
UI_ThemeColor4(TH_STITCH_PREVIEW_FACE);
glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]);
@@ -934,15 +934,15 @@ void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedi
show_uvedit= ED_space_image_show_uvedit(sima, obedit);
show_uvshadow= ED_space_image_show_uvshadow(sima, obedit);
- if(show_uvedit || show_uvshadow || show_texpaint_uvshadow) {
- if(show_uvshadow)
+ if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) {
+ if (show_uvshadow)
draw_uvs_shadow(obedit);
- else if(show_uvedit)
+ else if (show_uvedit)
draw_uvs(sima, scene, obedit);
else
draw_uvs_texpaint(sima, scene, obact);
- if(show_uvedit && !(toolsettings->use_uv_sculpt))
+ if (show_uvedit && !(toolsettings->use_uv_sculpt))
drawcursor_sima(sima, ar);
}
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 6c050355a3e..1c5fc18e99f 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -94,7 +94,7 @@ int ED_uvedit_test(Object *obedit)
if (!obedit)
return 0;
- if(obedit->type != OB_MESH)
+ if (obedit->type != OB_MESH)
return 0;
em = BMEdit_FromObject(obedit);
@@ -116,10 +116,10 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
{
Object *ob= CTX_data_active_object(C);
- if(ob && ob->type==OB_MESH) {
+ 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;
}
@@ -137,16 +137,16 @@ int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser **
Material *ma= give_current_material(ob, mat_nr);
bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL;
- if(node && is_image_texture_node(node)) {
- if(ima) *ima= (Image*)node->id;
- if(iuser) *iuser= NULL;
- if(node_r) *node_r= node;
+ if (node && is_image_texture_node(node)) {
+ if (ima) *ima= (Image*)node->id;
+ if (iuser) *iuser= NULL;
+ if (node_r) *node_r= node;
return TRUE;
}
- if(ima) *ima= NULL;
- if(iuser) *iuser= NULL;
- if(node_r) *node_r= node;
+ if (ima) *ima= NULL;
+ if (iuser) *iuser= NULL;
+ if (node_r) *node_r= node;
return FALSE;
}
@@ -156,7 +156,7 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i
Material *ma= give_current_material(ob, mat_nr);
bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL;
- if(node && is_image_texture_node(node)) {
+ if (node && is_image_texture_node(node)) {
node->id= &ima->id;
ED_node_generic_update(bmain, ma->nodetree, node);
}
@@ -173,31 +173,31 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im
int update= 0;
/* skip assigning these procedural images... */
- if(ima && (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE))
+ if (ima && (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE))
return;
/* verify we have a mesh we can work with */
- if(!obedit || (obedit->type != OB_MESH))
+ if (!obedit || (obedit->type != OB_MESH))
return;
em = BMEdit_FromObject(obedit);
- if(!em || !em->bm->totface) {
+ if (!em || !em->bm->totface) {
return;
}
- if(scene_use_new_shading_nodes(scene)) {
+ if (scene_use_new_shading_nodes(scene)) {
/* new shading system, assign image in material */
int sloppy= 1;
BMFace *efa= BM_active_face_get(em->bm, sloppy);
- if(efa)
+ if (efa)
ED_object_assign_active_image(bmain, obedit, efa->mat_nr, ima);
}
else {
/* old shading system, assign image to selected faces */
/* ensure we have a uv map */
- if(!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) {
+ if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY);
BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV);
update= 1;
@@ -207,11 +207,11 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(uvedit_face_visible(scene, previma, efa, tf)) {
- if(ima) {
+ if (uvedit_face_visible(scene, previma, efa, tf)) {
+ if (ima) {
tf->tpage= ima;
- if(ima->id.us==0) id_us_plus(&ima->id);
+ if (ima->id.us==0) id_us_plus(&ima->id);
else id_lib_extern(&ima->id);
}
else {
@@ -223,7 +223,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im
}
/* and update depdency graph */
- if(update)
+ if (update)
DAG_id_tag_update(obedit->data, 0);
}
@@ -239,14 +239,14 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile)
MTexPoly *tf;
/* verify if we have something to do */
- if(!ima || !ED_uvedit_test(obedit))
+ if (!ima || !ED_uvedit_test(obedit))
return 0;
- if((ima->tpageflag & IMA_TILES) == 0)
+ if ((ima->tpageflag & IMA_TILES) == 0)
return 0;
/* skip assigning these procedural images... */
- if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
+ if (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
return 0;
em = BMEdit_FromObject(obedit);
@@ -254,7 +254,7 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT))
tf->tile= curtile; /* set tile index */
}
@@ -269,7 +269,7 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist
{
int width, height;
- if(sima) {
+ if (sima) {
ED_space_image_size(sima, &width, &height);
}
else {
@@ -287,7 +287,7 @@ int uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
{
ToolSettings *ts= scene->toolsettings;
- 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
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)==0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
@@ -297,7 +297,7 @@ int uvedit_face_visible(Scene *scene, Image *ima, BMFace *efa, MTexPoly *tf)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SHOW_SAME_IMAGE)
+ if (ts->uv_flag & UV_SHOW_SAME_IMAGE)
return (tf->tpage==ima)? uvedit_face_visible_nolocal(scene, efa): 0;
else
return uvedit_face_visible_nolocal(scene, efa);
@@ -307,7 +307,7 @@ int uvedit_face_selected(Scene *scene, BMEditMesh *em, BMFace *efa)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION)
return (BM_elem_flag_test(efa, BM_ELEM_SELECT));
else {
BMLoop *l;
@@ -328,7 +328,7 @@ int uvedit_face_select(Scene *scene, BMEditMesh *em, BMFace *efa)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION)
BM_elem_select_set(em->bm, efa, TRUE);
else {
BMLoop *l;
@@ -350,7 +350,7 @@ int uvedit_face_deselect(Scene *scene, BMEditMesh *em, BMFace *efa)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
BM_elem_select_set(em->bm, efa, FALSE);
}
else {
@@ -373,7 +373,7 @@ int uvedit_edge_selected(BMEditMesh *em, Scene *scene, BMLoop *l)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
if (ts->selectmode & SCE_SELECT_FACE) {
return BM_elem_flag_test(l->f, BM_ELEM_SELECT);
}
@@ -400,10 +400,10 @@ void uvedit_edge_select(BMEditMesh *em, Scene *scene, BMLoop *l)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode & SCE_SELECT_FACE)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode & SCE_SELECT_FACE)
BM_elem_select_set(em->bm, l->f, TRUE);
- else if(ts->selectmode & SCE_SELECT_EDGE)
+ else if (ts->selectmode & SCE_SELECT_EDGE)
BM_elem_select_set(em->bm, l->e, TRUE);
else {
BM_elem_select_set(em->bm, l->e->v1, TRUE);
@@ -426,10 +426,10 @@ void uvedit_edge_deselect(BMEditMesh *em, Scene *scene, BMLoop *l)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode & SCE_SELECT_FACE)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode & SCE_SELECT_FACE)
BM_elem_select_set(em->bm, l->f, FALSE);
- else if(ts->selectmode & SCE_SELECT_EDGE)
+ else if (ts->selectmode & SCE_SELECT_EDGE)
BM_elem_select_set(em->bm, l->e, FALSE);
else {
BM_elem_select_set(em->bm, l->e->v1, FALSE);
@@ -451,8 +451,8 @@ int uvedit_uv_selected(BMEditMesh *em, Scene *scene, BMLoop *l)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode & SCE_SELECT_FACE)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode & SCE_SELECT_FACE)
return BM_elem_flag_test(l->f, BM_ELEM_SELECT);
else
return BM_elem_flag_test(l->v, BM_ELEM_SELECT);
@@ -468,8 +468,8 @@ void uvedit_uv_select(BMEditMesh *em, Scene *scene, BMLoop *l)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode & SCE_SELECT_FACE)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode & SCE_SELECT_FACE)
BM_elem_select_set(em->bm, l->f, TRUE);
else
BM_elem_select_set(em->bm, l->v, TRUE);
@@ -485,8 +485,8 @@ void uvedit_uv_deselect(BMEditMesh *em, Scene *scene, BMLoop *l)
{
ToolSettings *ts= scene->toolsettings;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode & SCE_SELECT_FACE)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode & SCE_SELECT_FACE)
BM_elem_select_set(em->bm, l->f, FALSE);
else
BM_elem_select_set(em->bm, l->v, FALSE);
@@ -502,7 +502,7 @@ void uvedit_uv_deselect(BMEditMesh *em, Scene *scene, BMLoop *l)
void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit)
{
- if(sima && (sima->flag & SI_LIVE_UNWRAP)) {
+ if (sima && (sima->flag & SI_LIVE_UNWRAP)) {
ED_uvedit_live_unwrap_begin(scene, obedit);
ED_uvedit_live_unwrap_re_solve();
ED_uvedit_live_unwrap_end(0);
@@ -529,7 +529,7 @@ void poly_uv_center(BMEditMesh *em, BMFace *f, float cent[2])
void uv_center(float uv[][2], float cent[2], int quad)
{
- if(quad) {
+ if (quad) {
cent[0] = (uv[0][0] + uv[1][0] + uv[2][0] + uv[3][0]) / 4.0f;
cent[1] = (uv[0][1] + uv[1][1] + uv[2][1] + uv[3][1]) / 4.0f;
}
@@ -541,7 +541,7 @@ void uv_center(float uv[][2], float cent[2], int quad)
float uv_area(float uv[][2], int quad)
{
- if(quad)
+ if (quad)
return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]);
else
return area_tri_v2(uv[0], uv[1], uv[2]);
@@ -552,7 +552,7 @@ float poly_uv_area(float uv[][2], int len)
//BMESH_TODO: make this not suck
//maybe use scanfill? I dunno.
- if(len >= 4)
+ if (len >= 4)
return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]);
else
return area_tri_v2(uv[0], uv[1], uv[2]);
@@ -599,7 +599,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float
sel= 0;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -627,7 +627,7 @@ static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3
zero_v3(co);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -649,8 +649,8 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent,
float min[2], max[2];
int change= 0;
- if(mode==V3D_CENTER) { /* bounding box */
- if(ED_uvedit_minmax(scene, ima, obedit, min, max)) {
+ if (mode==V3D_CENTER) { /* bounding box */
+ if (ED_uvedit_minmax(scene, ima, obedit, min, max)) {
change = 1;
cent[0]= (min[0]+max[0])/2.0f;
@@ -658,13 +658,13 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent,
}
}
else {
- if(ED_uvedit_median(scene, ima, obedit, cent)) {
+ if (ED_uvedit_median(scene, ima, obedit, cent)) {
change = 1;
}
}
- if(change) {
+ if (change) {
return 1;
}
@@ -690,7 +690,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, float co[2],
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
i = 0;
@@ -700,7 +700,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, float co[2],
dist= dist_to_line_segment_v2(co, luv->uv, nextluv->uv);
- if(dist < mindist) {
+ if (dist < mindist) {
hit->tf= tf;
hit->efa= efa;
@@ -739,7 +739,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, float
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
cent[0]= cent[1]= 0.0f;
@@ -753,7 +753,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, float
cent[1] /= efa->len;
dist= fabs(co[0]- cent[0]) + fabs(co[1]- cent[1]);
- if(dist < mindist) {
+ if (dist < mindist) {
hit->tf= tf;
hit->efa= efa;
mindist= dist;
@@ -797,7 +797,7 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i
c1= v1[0]*m[1] - v1[1]*m[0];
c2= v1[0]*v2[1] - v1[1]*v2[0];
- if(c1*c2 < 0.0f)
+ if (c1*c2 < 0.0f)
return 0;
/* m and v1 on same side of v-v2? */
@@ -830,21 +830,21 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em,
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(penalty && uvedit_uv_selected(em, scene, l))
+ if (penalty && uvedit_uv_selected(em, scene, l))
dist= fabs(co[0]-luv->uv[0])+penalty[0] + fabs(co[1]-luv->uv[1])+penalty[1];
else
dist= fabs(co[0]-luv->uv[0]) + fabs(co[1]-luv->uv[1]);
- if(dist<=mindist) {
- if(dist==mindist)
- if(!nearest_uv_between(em, efa, efa->len, i, co, luv->uv)) {
+ if (dist<=mindist) {
+ if (dist==mindist)
+ if (!nearest_uv_between(em, efa, efa->len, i, co, luv->uv)) {
i++;
continue;
}
@@ -883,14 +883,14 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, float co[2],
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
dist= fabs(co[0]-luv->uv[0]) + fabs(co[1]-luv->uv[1]);
- if(dist<=mindist) {
+ if (dist<=mindist) {
mindist= dist;
uv[0]= luv->uv[0];
@@ -910,14 +910,14 @@ static void uv_vertex_loop_flag(UvMapVert *first)
UvMapVert *iterv;
int count= 0;
- for(iterv=first; iterv; iterv=iterv->next) {
- if(iterv->separate && iterv!=first)
+ for (iterv=first; iterv; iterv=iterv->next) {
+ if (iterv->separate && iterv!=first)
break;
count++;
}
- if(count < 5)
+ if (count < 5)
first->flag= 1;
}
@@ -929,10 +929,10 @@ static UvMapVert *uv_vertex_map_get(UvVertMap *vmap, BMFace *efa, int a)
l = BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, a);
first= EDBM_get_uv_map_vert(vmap, BM_elem_index_get(l->v));
- for(iterv=first; iterv; iterv=iterv->next) {
- if(iterv->separate)
+ for (iterv=first; iterv; iterv=iterv->next) {
+ if (iterv->separate)
first= iterv;
- if(iterv->f == BM_elem_index_get(efa))
+ if (iterv->f == BM_elem_index_get(efa))
return first;
}
@@ -945,8 +945,8 @@ UvElement *ED_get_uv_element(UvElementMap *map, BMFace *efa, BMLoop *l)
element = map->vert[BM_elem_index_get(l->v)];
- for(; element; element = element->next)
- if(element->face == efa)
+ for (; element; element = element->next)
+ if (element->face == efa)
return element;
return NULL;
@@ -959,18 +959,18 @@ static int uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, UvMapVert *first
int tot = 0;
/* count number of faces this edge has */
- for(iterv1=first1; iterv1; iterv1=iterv1->next) {
- if(iterv1->separate && iterv1 != first1)
+ for (iterv1=first1; iterv1; iterv1=iterv1->next) {
+ if (iterv1->separate && iterv1 != first1)
break;
- for(iterv2=first2; iterv2; iterv2=iterv2->next) {
- if(iterv2->separate && iterv2 != first2)
+ for (iterv2=first2; iterv2; iterv2=iterv2->next) {
+ if (iterv2->separate && iterv2 != first2)
break;
- if(iterv1->f == iterv2->f) {
+ if (iterv1->f == iterv2->f) {
/* if face already tagged, don't do this edge */
efa= EDBM_get_face_for_index(em, iterv1->f);
- if(BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG))
+ if (BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG))
return 0;
tot++;
@@ -979,21 +979,21 @@ static int uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, UvMapVert *first
}
}
- 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 0;
/* tag the faces */
- for(iterv1=first1; iterv1; iterv1=iterv1->next) {
- if(iterv1->separate && iterv1 != first1)
+ for (iterv1=first1; iterv1; iterv1=iterv1->next) {
+ if (iterv1->separate && iterv1 != first1)
break;
- for(iterv2=first2; iterv2; iterv2=iterv2->next) {
- if(iterv2->separate && iterv2 != first2)
+ for (iterv2=first2; iterv2; iterv2=iterv2->next) {
+ if (iterv2->separate && iterv2 != first2)
break;
- if(iterv1->f == iterv2->f) {
+ if (iterv1->f == iterv2->f) {
efa= EDBM_get_face_for_index(em, iterv1->f);
BMO_elem_flag_enable(em->bm, efa, EFA_F1_FLAG);
break;
@@ -1022,7 +1022,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
count = 0;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(!extend) {
+ if (!extend) {
uvedit_face_deselect(scene, em, efa);
}
@@ -1045,7 +1045,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
uv_edge_tag_faces(em, iterv1, iterv2, &starttotf);
/* sorry, first edge isn't even ok */
- if(iterv1->flag==0 && iterv2->flag==0) looking= 0;
+ if (iterv1->flag==0 && iterv2->flag==0) looking= 0;
else looking= 1;
/* iterate */
@@ -1057,9 +1057,9 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG) && uvedit_face_visible(scene, ima, efa, tf)) {
+ if (!BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG) && uvedit_face_visible(scene, ima, efa, tf)) {
nverts= efa->len;
- for(a=0; a<nverts; a++) {
+ for (a=0; a<nverts; a++) {
/* check face not hidden and not tagged */
iterv1= uv_vertex_map_get(vmap, efa, a);
iterv2= uv_vertex_map_get(vmap, efa, (a+1)%nverts);
@@ -1068,8 +1068,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
continue;
/* check if vertex is tagged and has right valence */
- if(iterv1->flag || iterv2->flag) {
- if(uv_edge_tag_faces(em, iterv1, iterv2, &starttotf)) {
+ if (iterv1->flag || iterv2->flag) {
+ if (uv_edge_tag_faces(em, iterv1, iterv2, &starttotf)) {
looking= 1;
BMO_elem_flag_enable(em->bm, efa, EFA_F1_FLAG);
@@ -1090,8 +1090,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
iterv1->flag= 1;
iterv2->flag= 1;
- if(extend) {
- if(uvedit_uv_selected(em, scene, hit->l))
+ if (extend) {
+ if (uvedit_uv_selected(em, scene, hit->l))
select= 0;
else
select= 1;
@@ -1104,8 +1104,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
iterv1= uv_vertex_map_get(vmap, efa, a);
- if(iterv1->flag) {
- if(select) uvedit_uv_select(em, scene, l);
+ if (iterv1->flag) {
+ if (select) uvedit_uv_select(em, scene, l);
else uvedit_uv_deselect(em, scene, l);
}
@@ -1138,17 +1138,17 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
EDBM_init_index_arrays(em, 0, 0, 1); /* we can use this too */
vmap= EDBM_make_uv_vert_map(em, 1, 1, limit);
- 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");
- if(!hit) {
+ if (!hit) {
BM_ITER_INDEX(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL, a) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(uvedit_face_visible(scene, ima, efa, tf)) {
+ if (uvedit_face_visible(scene, ima, efa, tf)) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -1166,7 +1166,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
else {
a = 0;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(efa == hit->efa) {
+ if (efa == hit->efa) {
stack[stacksize]= a;
stacksize++;
flag[a]= 1;
@@ -1185,7 +1185,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
j = 0;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(j==a)
+ if (j==a)
break;
j++;
@@ -1199,17 +1199,17 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
startv= vlist;
- for(iterv=vlist; iterv; iterv=iterv->next) {
- if(iterv->separate)
+ for (iterv=vlist; iterv; iterv=iterv->next) {
+ if (iterv->separate)
startv= iterv;
- if(iterv->f == a)
+ if (iterv->f == a)
break;
}
- for(iterv=startv; iterv; iterv=iterv->next) {
- if((startv != iterv) && (iterv->separate))
+ for (iterv=startv; iterv; iterv=iterv->next) {
+ if ((startv != iterv) && (iterv->separate))
break;
- else if(!flag[iterv->f]) {
+ else if (!flag[iterv->f]) {
flag[iterv->f]= 1;
stack[stacksize]= iterv->f;
stacksize++;
@@ -1220,7 +1220,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
}
}
- if(!extend) {
+ if (!extend) {
a = 0;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -1255,7 +1255,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[
a++;
}
- if(efa) {
+ if (efa) {
a = 0;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!flag[a]) {
@@ -1341,14 +1341,14 @@ static void weld_align_uv(bContext *C, int tool)
INIT_MINMAX2(min, max);
- if(tool == 'a') {
+ if (tool == 'a') {
BMFace *efa;
BMLoop *l;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -1364,13 +1364,13 @@ static void weld_align_uv(bContext *C, int tool)
uvedit_center(scene, ima, obedit, cent, 0);
- if(tool == 'x' || tool == 'w') {
+ if (tool == 'x' || tool == 'w') {
BMFace *efa;
BMLoop *l;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -1383,13 +1383,13 @@ static void weld_align_uv(bContext *C, int tool)
}
}
- if(tool == 'y' || tool == 'w') {
+ if (tool == 'y' || tool == 'w') {
BMFace *efa;
BMLoop *l;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -1402,7 +1402,7 @@ static void weld_align_uv(bContext *C, int tool)
}
}
- if(tool == 's' || tool == 't' || tool == 'u') {
+ if (tool == 's' || tool == 't' || tool == 'u') {
BMEdge *eed;
BMLoop *l;
BMVert *eve;
@@ -1606,7 +1606,7 @@ static void select_all_perform(bContext *C, int action)
em = BMEdit_FromObject(obedit);
ima = CTX_data_edit_image(C);
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
switch (action) {
case SEL_TOGGLE:
@@ -1629,7 +1629,7 @@ static void select_all_perform(bContext *C, int action)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -1647,7 +1647,7 @@ static void select_all_perform(bContext *C, int action)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -1704,16 +1704,16 @@ static int sticky_select(float *limit, int hitv[4], int v, float *hituv[4], floa
/* 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 0;
- 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])
+ 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])
return 1;
}
- else if(sticky == SI_STICKY_VERTEX)
+ else if (sticky == SI_STICKY_VERTEX)
return 1;
}
}
@@ -1752,12 +1752,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
uvedit_pixel_to_float(sima, penalty, 5.0f / sima->zoom);
/* retrieve operation mode */
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ 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
selectmode= UV_SELECT_VERTEX;
@@ -1771,10 +1771,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
}
/* find nearest element */
- if(loop) {
+ if (loop) {
/* find edge */
uv_find_nearest_edge(scene, ima, em, co, &hit);
- if(hit.efa == NULL) {
+ if (hit.efa == NULL) {
BLI_array_free(hitv);
BLI_array_free(hituv);
return OPERATOR_CANCELLED;
@@ -1782,10 +1782,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
hitlen = 0;
}
- else if(selectmode == UV_SELECT_VERTEX) {
+ else if (selectmode == UV_SELECT_VERTEX) {
/* find vertex */
uv_find_nearest_vert(scene, ima, em, co, penalty, &hit);
- if(hit.efa == NULL) {
+ if (hit.efa == NULL) {
BLI_array_free(hitv);
BLI_array_free(hituv);
return OPERATOR_CANCELLED;
@@ -1794,7 +1794,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
/* mark 1 vertex as being hit */
BLI_array_growitems(hitv, hit.efa->len);
BLI_array_growitems(hituv, hit.efa->len);
- for(i=0; i<hit.efa->len; i++) {
+ for (i=0; i<hit.efa->len; i++) {
hitv[i]= 0xFFFFFFFF;
}
@@ -1803,10 +1803,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
hitlen = hit.efa->len;
}
- else if(selectmode == UV_SELECT_EDGE) {
+ else if (selectmode == UV_SELECT_EDGE) {
/* find edge */
uv_find_nearest_edge(scene, ima, em, co, &hit);
- if(hit.efa == NULL) {
+ if (hit.efa == NULL) {
BLI_array_free(hitv);
BLI_array_free(hituv);
return OPERATOR_CANCELLED;
@@ -1828,10 +1828,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
hitlen = hit.efa->len;
}
- else if(selectmode == UV_SELECT_FACE) {
+ else if (selectmode == UV_SELECT_FACE) {
/* find face */
find_nearest_uv_face(scene, ima, em, co, &hit);
- if(hit.efa == NULL) {
+ if (hit.efa == NULL) {
BLI_array_free(hitv);
BLI_array_free(hituv);
return OPERATOR_CANCELLED;
@@ -1854,10 +1854,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
hitlen = hit.efa->len;
}
- else if(selectmode == UV_SELECT_ISLAND) {
+ else if (selectmode == UV_SELECT_ISLAND) {
uv_find_nearest_vert(scene, ima, em, co, NULL, &hit);
- if(hit.efa==NULL) {
+ if (hit.efa==NULL) {
BLI_array_free(hitv);
BLI_array_free(hituv);
return OPERATOR_CANCELLED;
@@ -1873,16 +1873,16 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
}
/* do selection */
- if(loop) {
+ if (loop) {
flush= select_edgeloop(scene, ima, em, &hit, limit, extend);
}
- else if(selectmode == UV_SELECT_ISLAND) {
+ else if (selectmode == UV_SELECT_ISLAND) {
select_linked(scene, ima, em, limit, &hit, extend);
}
- else if(extend) {
- if(selectmode == UV_SELECT_VERTEX) {
+ else if (extend) {
+ if (selectmode == UV_SELECT_VERTEX) {
/* (de)select uv vertex */
- if(uvedit_uv_selected(em, scene, hit.l)) {
+ if (uvedit_uv_selected(em, scene, hit.l)) {
uvedit_uv_deselect(em, scene, hit.l);
select= 0;
}
@@ -1892,9 +1892,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
}
flush = 1;
}
- else if(selectmode == UV_SELECT_EDGE) {
+ else if (selectmode == UV_SELECT_EDGE) {
/* (de)select edge */
- if(uvedit_edge_selected(em, scene, hit.l)) {
+ if (uvedit_edge_selected(em, scene, hit.l)) {
uvedit_edge_deselect(em, scene, hit.l);
select= 0;
}
@@ -1904,9 +1904,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
}
flush = 1;
}
- else if(selectmode == UV_SELECT_FACE) {
+ else if (selectmode == UV_SELECT_FACE) {
/* (de)select face */
- if(uvedit_face_selected(scene, em, hit.efa)) {
+ if (uvedit_face_selected(scene, em, hit.efa)) {
uvedit_face_deselect(scene, em, hit.efa);
select= 0;
}
@@ -1918,20 +1918,20 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
}
/* (de)select sticky uv nodes */
- if(sticky != SI_STICKY_DISABLE) {
+ if (sticky != SI_STICKY_DISABLE) {
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
/* deselect */
- if(select==0) {
+ if (select==0) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
uvedit_uv_deselect(em, scene, l);
}
}
@@ -1941,12 +1941,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
uvedit_uv_select(em, scene, l);
}
}
@@ -1961,33 +1961,33 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
uvedit_face_deselect(scene, em, efa);
}
- if(selectmode == UV_SELECT_VERTEX) {
+ if (selectmode == UV_SELECT_VERTEX) {
/* select vertex */
uvedit_uv_select(em, scene, hit.l);
flush= 1;
}
- else if(selectmode == UV_SELECT_EDGE) {
+ else if (selectmode == UV_SELECT_EDGE) {
/* select edge */
uvedit_edge_select(em, scene, hit.l);
flush= 1;
}
- else if(selectmode == UV_SELECT_FACE) {
+ else if (selectmode == UV_SELECT_FACE) {
/* select face */
uvedit_face_select(scene, em, hit.efa);
}
/* select sticky uvs */
- if(sticky != SI_STICKY_DISABLE) {
+ if (sticky != SI_STICKY_DISABLE) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- if(sticky == SI_STICKY_DISABLE) continue;
+ if (sticky == SI_STICKY_DISABLE) continue;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
uvedit_uv_select(em, scene, l);
flush= 1;
@@ -1998,11 +1998,11 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
#if 0 /* BM_elem_select_set API handles all of this? */
- if(sync) {
+ if (sync) {
/* flush for mesh selection */
- if(ts->selectmode != SCE_SELECT_FACE) {
- if(flush==1) EDBM_select_flush(em);
- else if(flush==-1) EDBM_deselect_flush(em);
+ if (ts->selectmode != SCE_SELECT_FACE) {
+ if (flush==1) EDBM_select_flush(em);
+ else if (flush==-1) EDBM_deselect_flush(em);
}
}
#else
@@ -2122,7 +2122,7 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i
NearestHit hit, *hit_p= NULL;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled");
return OPERATOR_CANCELLED;
}
@@ -2130,10 +2130,10 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i
extend= RNA_boolean_get(op->ptr, "extend");
uvedit_pixel_to_float(sima, limit, 0.05f);
- if(pick) {
+ if (pick) {
float co[2];
- if(event) {
+ if (event) {
/* invoke */
ARegion *ar= CTX_wm_region(C);
@@ -2225,7 +2225,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op)
MTexPoly *tf;
MLoopUV *luv;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
BKE_report(op->reports, RPT_ERROR, "Can't unlink selection when sync selection is enabled");
return OPERATOR_CANCELLED;
}
@@ -2234,7 +2234,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op)
int desel = 0;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -2297,7 +2297,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
BMIter iter, liter;
/* MTexPoly *tf; */
- if((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_VERTEX) {
+ if ((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_VERTEX) {
/* Tag all verts as untouched, then touch the ones that have a face center
* in the loop and select all MLoopUV's that use a touched vert. */
BMVert *eve;
@@ -2328,7 +2328,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
}
}
}
- else if((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_LOC) {
+ else if ((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_LOC) {
BMFace *efa_vlist;
/* MTexPoly *tf_vlist; */ /* UNUSED */
UvMapVert *start_vlist=NULL, *vlist_iter;
@@ -2346,10 +2346,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
/* verts are numbered above in make_uv_vert_map_EM, make sure this stays true! */
/* BMESH_TODO - why keep this commented? - campbell */
#if 0
- for(a=0, eve= em->verts.first; eve; a++, eve= eve->next)
+ for (a=0, eve= em->verts.first; eve; a++, eve= eve->next)
eve->tmp.l = a;
#endif
- if(vmap == NULL) {
+ if (vmap == NULL) {
return;
}
@@ -2359,7 +2359,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- if(select)
+ if (select)
uvedit_uv_select(em, scene, l);
else
uvedit_uv_deselect(em, scene, l);
@@ -2367,10 +2367,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
vlist_iter= EDBM_get_uv_map_vert(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->f)
+ if (efa_index == vlist_iter->f)
break;
vlist_iter = vlist_iter->next;
@@ -2379,14 +2379,14 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
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->f) {
+ if (efa_index != vlist_iter->f) {
efa_vlist = EDBM_get_face_for_index(em, vlist_iter->f);
/* tf_vlist = CustomData_bmesh_get(&em->bm->pdata, efa_vlist->head.data, CD_MTEXPOLY); */ /* UNUSED */
- if(select)
+ if (select)
uvedit_uv_select(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex));
else
uvedit_uv_deselect(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex));
@@ -2403,7 +2403,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
- if(select)
+ if (select)
uvedit_face_select(scene, em, efa);
else
uvedit_face_deselect(scene, em, efa);
@@ -2444,16 +2444,16 @@ static int border_select_exec(bContext *C, wmOperator *op)
pinned= RNA_boolean_get(op->ptr, "pinned");
extend= RNA_boolean_get(op->ptr, "extend");
- if(!extend)
+ if (!extend)
select_all_perform(C, SEL_DESELECT);
- if(ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION)
faces= (ts->selectmode == SCE_SELECT_FACE);
else
faces= (ts->uv_selectmode == UV_SELECT_FACE);
/* do actual selection */
- if(faces && !pinned) {
+ if (faces && !pinned) {
/* handle face selection mode */
float cent[2];
@@ -2464,9 +2464,9 @@ static int border_select_exec(bContext *C, wmOperator *op)
BM_elem_flag_disable(efa, BM_ELEM_TAG);
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(uvedit_face_visible(scene, ima, efa, tf)) {
+ if (uvedit_face_visible(scene, ima, efa, tf)) {
poly_uv_center(em, efa, cent);
- if(BLI_in_rctf(&rectf, cent[0], cent[1])) {
+ if (BLI_in_rctf(&rectf, cent[0], cent[1])) {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
change = 1;
}
@@ -2474,7 +2474,7 @@ static int border_select_exec(bContext *C, wmOperator *op)
}
/* (de)selects all tagged faces and deals with sticky modes */
- if(change)
+ if (change)
uv_faces_do_sticky(C, sima, scene, obedit, select);
}
else {
@@ -2483,22 +2483,23 @@ static int border_select_exec(bContext *C, wmOperator *op)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tf))
+ if (!uvedit_face_visible(scene, ima, efa, tf))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) {
+ if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) {
/* UV_SYNC_SELECTION - can't do pinned selection */
- if(BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) {
- if(select) uvedit_uv_select(em, scene, l);
+ if (BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) {
+ if (select) uvedit_uv_select(em, scene, l);
else uvedit_uv_deselect(em, scene, l);
}
- } else if(pinned) {
+ }
+ else if (pinned) {
if ((luv->flag & MLOOPUV_PINNED) &&
BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) {
- if(select) uvedit_uv_select(em, scene, l);
+ if (select) uvedit_uv_select(em, scene, l);
else uvedit_uv_deselect(em, scene, l);
}
}
@@ -2506,12 +2507,12 @@ static int border_select_exec(bContext *C, wmOperator *op)
}
}
- if(change) {
+ if (change) {
/* make sure newly selected vert selection is updated*/
#if 0 /* BM_elem_select_set API handles all of this? */
- if(ts->uv_flag & UV_SYNC_SELECTION) {
- if(ts->selectmode != SCE_SELECT_FACE) {
- if(select) EDBM_select_flush(em);
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->selectmode != SCE_SELECT_FACE) {
+ if (select) EDBM_select_flush(em);
else EDBM_deselect_flush(em);
}
}
@@ -2563,8 +2564,8 @@ static void select_uv_inside_ellipse(BMEditMesh *em, SpaceImage *UNUSED(sima), S
y= (uv[1] - offset[1])*ell[1];
r2 = x*x + y*y;
- if(r2 < 1.0f) {
- if(select) uvedit_uv_select(em, scene, l);
+ if (r2 < 1.0f) {
+ if (select) uvedit_uv_select(em, scene, l);
else uvedit_uv_deselect(em, scene, l);
}
}
@@ -2609,7 +2610,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
}
#if 0 //I think the BM_elem_select_set api stuff handles all this as necessary?
- if(select) EM_select_flush(em);
+ if (select) EM_select_flush(em);
else EM_deselect_flush(em);
#endif
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
@@ -2680,7 +2681,7 @@ static int snap_cursor_exec(bContext *C, wmOperator *op)
break;
}
- if(!change)
+ if (!change)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, sima);
@@ -2723,11 +2724,11 @@ static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, SpaceIma
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface))
+ if (!uvedit_face_visible(scene, ima, efa, tface))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- if(uvedit_uv_selected(em, scene, l)) {
+ if (uvedit_uv_selected(em, scene, l)) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
copy_v2_v2(luv->uv, sima->cursor);
change= 1;
@@ -2765,10 +2766,11 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
* get unique indices and to count how much to malloc */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface)) {
+ if (!uvedit_face_visible(scene, ima, efa, tface)) {
BM_elem_flag_disable(efa, BM_ELEM_TAG);
continue;
- } else {
+ }
+ else {
BM_elem_flag_enable(efa, BM_ELEM_TAG);
}
@@ -2791,7 +2793,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
continue;
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface))
+ if (!uvedit_face_visible(scene, ima, efa, tface))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -2805,7 +2807,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
}
/* no other verts selected, bail out */
- if(!change) {
+ if (!change) {
MEM_freeN(coords);
MEM_freeN(usercount);
return change;
@@ -2817,7 +2819,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
continue;
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface))
+ if (!uvedit_face_visible(scene, ima, efa, tface))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -2854,7 +2856,7 @@ static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface))
+ if (!uvedit_face_visible(scene, ima, efa, tface))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -2890,7 +2892,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op)
break;
}
- if(!change)
+ if (!change)
return OPERATOR_CANCELLED;
uvedit_live_unwrap_update(sima, scene, obedit);
@@ -2939,16 +2941,17 @@ static int pin_exec(bContext *C, wmOperator *op)
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface))
+ if (!uvedit_face_visible(scene, ima, efa, tface))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(!clear) {
+ if (!clear) {
if (uvedit_uv_selected(em, scene, l))
luv->flag |= MLOOPUV_PINNED;
- } else {
+ }
+ else {
if (uvedit_uv_selected(em, scene, l))
luv->flag &= ~MLOOPUV_PINNED;
}
@@ -2992,7 +2995,7 @@ static int select_pinned_exec(bContext *C, wmOperator *UNUSED(op))
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- if(!uvedit_face_visible(scene, ima, efa, tface))
+ if (!uvedit_face_visible(scene, ima, efa, tface))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -3037,7 +3040,7 @@ static int hide_exec(bContext *C, wmOperator *op)
int swap = RNA_boolean_get(op->ptr, "unselected");
int facemode= sima ? sima->flag & SI_SELACTFACE : 0;
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
EDBM_hide_mesh(em, swap);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
@@ -3073,7 +3076,8 @@ static int hide_exec(bContext *C, wmOperator *op)
BM_elem_select_set(em->bm, efa, FALSE);
uvedit_face_deselect(scene, em, efa);
}
- } else if(em->selectmode == SCE_SELECT_FACE) {
+ }
+ else if (em->selectmode == SCE_SELECT_FACE) {
/*check if a UV is selected*/
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -3082,7 +3086,8 @@ static int hide_exec(bContext *C, wmOperator *op)
}
luv->flag &= ~MLOOPUV_VERTSEL;
}
- } else {
+ }
+ else {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
if (luv->flag & MLOOPUV_VERTSEL) {
@@ -3134,14 +3139,14 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
int stickymode= sima ? (sima->sticky != SI_STICKY_DISABLE) : 1;
/* call the mesh function if we are in mesh sync sel */
- if(ts->uv_flag & UV_SYNC_SELECTION) {
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
EDBM_reveal_mesh(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
- if(facemode) {
- if(em->selectmode == SCE_SELECT_FACE) {
+ if (facemode) {
+ if (em->selectmode == SCE_SELECT_FACE) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_elem_select_set(em->bm, efa, TRUE);
@@ -3154,7 +3159,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
/* enable adjacent faces to have disconnected UV selections if sticky is disabled */
- if(!stickymode) {
+ if (!stickymode) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
int totsel=0;
@@ -3172,7 +3177,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
- } else {
+ }
+ else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -3187,7 +3193,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
- } else if(em->selectmode == SCE_SELECT_FACE) {
+ }
+ else if (em->selectmode == SCE_SELECT_FACE) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -3198,7 +3205,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op))
BM_elem_select_set(em->bm, efa, TRUE);
}
}
- } else {
+ }
+ else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -3238,7 +3246,7 @@ static int set_2d_cursor_exec(bContext *C, wmOperator *op)
SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
- if(!sima)
+ if (!sima)
return OPERATOR_CANCELLED;
RNA_float_get_array(op->ptr, "location", location);
@@ -3290,7 +3298,7 @@ static int set_tile_exec(bContext *C, wmOperator *op)
RNA_int_get_array(op->ptr, "tile", tile);
- if(uvedit_set_tile(obedit, ima, tile[0] + ima->xrep*tile[1])) {
+ if (uvedit_set_tile(obedit, ima, tile[0] + ima->xrep*tile[1])) {
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL);
@@ -3308,12 +3316,12 @@ static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event)
float fx, fy;
int tile[2];
- if(!ima || !(ima->tpageflag & IMA_TILES))
+ if (!ima || !(ima->tpageflag & IMA_TILES))
return OPERATOR_CANCELLED;
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
- if(fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
+ if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
fx= fx*ima->xrep;
fy= fy*ima->yrep;
@@ -3364,7 +3372,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op)
em = me->edit_btmesh;
bm = em->bm;
- if(!EDBM_texFaceCheck(em)) {
+ if (!EDBM_texFaceCheck(em)) {
return OPERATOR_CANCELLED;
}
@@ -3390,34 +3398,34 @@ static int 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)
+ for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) {
+ if (mv1->separate && commonFaces)
v1coincident = 0;
separated2 = 0;
efa1 = EDBM_get_face_for_index(em, mv1->f);
mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
- for(mv2 = mvinit2; mv2; mv2 = mv2->next) {
- if(mv2->separate)
+ for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
+ if (mv2->separate)
mv2sep = mv2;
efa2 = EDBM_get_face_for_index(em, mv2->f);
- if(efa1 == efa2) {
+ if (efa1 == efa2) {
/* if v1 is not coincident no point in comparing */
- if(v1coincident) {
+ if (v1coincident) {
/* have we found previously anything? */
- if(mv2cache) {
+ if (mv2cache) {
/* flag seam unless proved to be coincident with previous hit */
separated2 = 1;
- for(mviter = mv2cache; mviter; mviter = mviter->next) {
- if(mviter->separate && mviter != mv2cache)
+ for (mviter = mv2cache; mviter; mviter = mviter->next) {
+ if (mviter->separate && mviter != mv2cache)
break;
/* coincident with previous hit, do not flag seam */
- if(mviter == mv2)
+ if (mviter == mv2)
separated2 = 0;
}
}
@@ -3430,7 +3438,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op)
else
separated1 = 1;
- if(separated1 || separated2) {
+ if (separated1 || separated2) {
faces_separated = 1;
break;
}
@@ -3438,10 +3446,10 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op)
}
}
- if(faces_separated) {
- if(mark_seams)
+ if (faces_separated) {
+ 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);
}
}
@@ -3490,7 +3498,7 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op))
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
BM_ITER(loop, &liter, bm, BM_LOOPS_OF_FACE, efa) {
- if(uvedit_edge_selected(em, scene, loop)) {
+ if (uvedit_edge_selected(em, scene, loop)) {
BM_elem_flag_enable(loop, BM_ELEM_SEAM);
}
}
@@ -3498,7 +3506,7 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op))
me->drawflag |= ME_DRAWSEAMS;
- if(scene->toolsettings->edge_mode_live_unwrap)
+ if (scene->toolsettings->edge_mode_live_unwrap)
ED_unwrap_lscm(scene, ob, FALSE);
DAG_id_tag_update(&me->id, 0);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index d6035b08fd6..7d388e6206c 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -800,12 +800,12 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep)
uvp2 = ep->orig_uv;
}
- if((fabsf(uv1[0]-uvp1[0]) > limit[0]) || (fabsf(uv1[1]-uvp1[1]) > limit[1])) {
+ if ((fabsf(uv1[0]-uvp1[0]) > limit[0]) || (fabsf(uv1[1]-uvp1[1]) > limit[1])) {
e->flag |= PEDGE_SEAM;
ep->flag |= PEDGE_SEAM;
return P_TRUE;
}
- if((fabsf(uv2[0]-uvp2[0]) > limit[0]) || (fabsf(uv2[1]-uvp2[1]) > limit[1])) {
+ if ((fabsf(uv2[0]-uvp2[0]) > limit[0]) || (fabsf(uv2[1]-uvp2[1]) > limit[1])) {
e->flag |= PEDGE_SEAM;
ep->flag |= PEDGE_SEAM;
return P_TRUE;
@@ -866,7 +866,7 @@ 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->pair && p_edge_has_pair(handle, e, &pair, impl)) {
if (e->vert == pair->vert)
p_face_flip(pair->face);
@@ -1162,7 +1162,7 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
be->flag |= PEDGE_DONE;
len += p_edge_length(be);
be = be->next->vert->edge;
- } while(be != e);
+ } while (be != e);
if (outer && (len > maxlen)) {
*outer = e;
@@ -1213,7 +1213,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges)
e->u.heaplink = BLI_heap_insert(heap, angle, e);
e = p_boundary_edge_next(e);
- } while(e != be);
+ } while (e != be);
if (nedges == 2) {
/* no real boundary, but an isolated seam */
@@ -1297,7 +1297,7 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
be->flag |= PEDGE_FILLED;
be = be->next->vert->edge;
nedges++;
- } while(be != e);
+ } while (be != e);
if (e != outer)
p_chart_fill_boundary(chart, e, nedges);
@@ -2847,7 +2847,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
lastbe = be;
be = nextbe;
- } while(be != outer);
+ } while (be != outer);
/* make sure we also count a series of splits over the starting point */
if (cure && (cure != outer)) {
@@ -3180,7 +3180,7 @@ static void p_stretch_pin_boundary(PChart *chart)
{
PVert *v;
- for(v=chart->verts; v; v=v->nextlink)
+ for (v=chart->verts; v; v=v->nextlink)
if (v->edge->pair == NULL)
v->flag |= PVERT_PIN;
else
@@ -3261,8 +3261,8 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
float orig_stretch, low, stretch_low, high, stretch_high, mid, stretch;
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))
+ for (v=chart->verts; v; v=v->nextlink) {
+ if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT))
continue;
orig_stretch = p_stretch_compute_vertex(v);
@@ -3313,7 +3313,7 @@ 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);
}
}
@@ -3357,7 +3357,7 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
do {
npoints++;
e = p_boundary_edge_next(e);
- } while(e != be);
+ } while (e != be);
p = points = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints*2, "PCHullpoints");
U = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints, "PCHullU");
@@ -3368,7 +3368,7 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
*p = e->vert;
p++;
e = p_boundary_edge_next(e);
- } while(e != be);
+ } while (e != be);
qsort(points, npoints, sizeof(PVert*), p_compare_geometric_uv);
@@ -3792,7 +3792,7 @@ static void p_smooth(PChart *chart)
nwheel++;
e = e->next->next->pair;
- } while(e && (e != v->edge));
+ } while (e && (e != v->edge));
v->u.distortion /= nwheel;
}
@@ -4344,7 +4344,7 @@ void param_pack(ParamHandle *handle, float margin)
if (phandle->ncharts == 0)
return;
- 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 */
@@ -4372,11 +4372,11 @@ void param_pack(ParamHandle *handle, float margin)
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_NOPACK boxes */
- if(margin>0.0f)
+ if (margin>0.0f)
area += sqrt(box->w*box->h);
}
- if(margin>0.0f) {
+ if (margin>0.0f) {
/* multiply the margin by the area to give predictable results not dependent on UV scale,
* ...Without using the area running pack multiple times also gives a bad feedback loop.
* multiply by 0.1 so the margin value from the UI can be from 0.0 to 1.0 but not give a massive margin */
@@ -4417,7 +4417,7 @@ void param_pack(ParamHandle *handle, float margin)
}
MEM_freeN(boxarray);
- if(phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy)
param_scale(handle, phandle->aspx, phandle->aspy);
}
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index ad96142ae86..af87f4d4b07 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -185,24 +185,24 @@ static StitchPreviewer * stitch_preview_init(void)
/* destructor...yeah this should be C++ :) */
static void stitch_preview_delete(void)
{
- if(_stitch_preview) {
- if(_stitch_preview->preview_polys){
+ if (_stitch_preview) {
+ if (_stitch_preview->preview_polys) {
MEM_freeN(_stitch_preview->preview_polys);
_stitch_preview->preview_polys = NULL;
}
- if(_stitch_preview->uvs_per_polygon){
+ if (_stitch_preview->uvs_per_polygon) {
MEM_freeN(_stitch_preview->uvs_per_polygon);
_stitch_preview->uvs_per_polygon = NULL;
}
- if(_stitch_preview->preview_stitchable){
+ if (_stitch_preview->preview_stitchable) {
MEM_freeN(_stitch_preview->preview_stitchable);
_stitch_preview->preview_stitchable = NULL;
}
- if(_stitch_preview->preview_unstitchable){
+ if (_stitch_preview->preview_unstitchable) {
MEM_freeN(_stitch_preview->preview_unstitchable);
_stitch_preview->preview_unstitchable = NULL;
}
- if(_stitch_preview->static_tris){
+ if (_stitch_preview->static_tris) {
MEM_freeN(_stitch_preview->static_tris);
_stitch_preview->static_tris = NULL;
}
@@ -229,7 +229,7 @@ static void stitch_update_header(StitchState *stitch_state, bContext *C)
char msg[HEADER_LENGTH];
ScrArea *sa= CTX_wm_area(C);
- if(sa) {
+ if (sa) {
BLI_snprintf(msg, HEADER_LENGTH, str,
stitch_state->snap_islands? "On" : "Off",
stitch_state->midpoints? "On": "Off",
@@ -242,9 +242,10 @@ static void stitch_update_header(StitchState *stitch_state, bContext *C)
static int getNumOfIslandUvs(UvElementMap *elementMap, int island)
{
- if(island == elementMap->totalIslands-1){
+ if (island == elementMap->totalIslands-1) {
return elementMap->totalUVs - elementMap->islandIndices[island];
- }else{
+ }
+ else {
return elementMap->islandIndices[island+1] - elementMap->islandIndices[island];
}
}
@@ -268,14 +269,14 @@ static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_it
float limit;
int do_limit;
- if(element_iter == element){
+ if (element_iter == element) {
return 0;
}
limit = state->limit_dist;
do_limit = state->use_limit;
- if(do_limit){
+ if (do_limit) {
MLoopUV *luv_orig, *luv_iter;
BMLoop *l_orig, *l_iter;
@@ -285,19 +286,23 @@ static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_it
l_iter = element_iter->l;
luv_iter = CustomData_bmesh_get(&state->em->bm->ldata, l_iter->head.data, CD_MLOOPUV);
- if(fabs(luv_orig->uv[0] - luv_iter->uv[0]) < limit
- && fabs(luv_orig->uv[1] - luv_iter->uv[1]) < limit){
+ if (fabs(luv_orig->uv[0] - luv_iter->uv[0]) < limit
+ && fabs(luv_orig->uv[1] - luv_iter->uv[1]) < limit) {
return 1;
- }else
+ }
+ else {
return 0;
- }else
+ }
+ }
+ else {
return 1;
+ }
}
static int stitch_check_uvs_state_stitchable(UvElement *element, UvElement *element_iter, StitchState *state)
{
- if((state->snap_islands && element->island == element_iter->island) ||
+ if ((state->snap_islands && element->island == element_iter->island) ||
(!state->midpoints && element->island == element_iter->island))
return 0;
@@ -311,12 +316,12 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition
int i;
UvElement *element;
- for(i = 0; i < state->element_map->totalIslands; i++){
- if(island_stitch_data[i].addedForPreview){
+ for (i = 0; i < state->element_map->totalIslands; i++) {
+ if (island_stitch_data[i].addedForPreview) {
int numOfIslandUVs = 0, j;
/* check to avoid divide by 0 */
- if(island_stitch_data[i].num_rot_elements>0){
+ if (island_stitch_data[i].num_rot_elements>0) {
island_stitch_data[i].rotation /= island_stitch_data[i].num_rot_elements;
island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements;
island_stitch_data[i].medianPoint[1] /= island_stitch_data[i].numOfElements;
@@ -325,16 +330,16 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition
island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements;
numOfIslandUVs = getNumOfIslandUvs(state->element_map, i);
element = &state->element_map->buf[state->element_map->islandIndices[i]];
- for(j = 0; j < numOfIslandUVs; j++, element++){
+ for (j = 0; j < numOfIslandUVs; j++, element++) {
/* stitchable uvs have already been processed, don't process */
- if(!(element->flag & STITCH_PROCESSED)){
+ if (!(element->flag & STITCH_PROCESSED)) {
MLoopUV *luv;
BMLoop *l;
l = element->l;
luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(final){
+ if (final) {
stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, luv->uv);
@@ -410,7 +415,7 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat
float rotation = 0;
BMLoop *l;
- if(element->island == state->static_island && !state->midpoints)
+ if (element->island == state->static_island && !state->midpoints)
return;
l = element->l;
@@ -419,8 +424,8 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat
element_iter = state->element_map->vert[index];
- for(; element_iter; element_iter = element_iter->next){
- if(element_iter->separate && stitch_check_uvs_state_stitchable(element, element_iter, state)){
+ for (; element_iter; element_iter = element_iter->next) {
+ if (element_iter->separate && stitch_check_uvs_state_stitchable(element, element_iter, state)) {
int index_tmp1, index_tmp2;
float normal[2];
/* easily possible*/
@@ -437,7 +442,7 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat
}
}
- if(state->midpoints)
+ if (state->midpoints)
rotation /= 2.0;
island_stitch_data[element->island].num_rot_elements++;
island_stitch_data[element->island].rotation += rotation;
@@ -446,26 +451,26 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat
static void stitch_state_delete(StitchState *stitch_state)
{
- if(stitch_state){
- if(stitch_state->element_map){
+ if (stitch_state) {
+ if (stitch_state->element_map) {
EDBM_free_uv_element_map(stitch_state->element_map);
}
- if(stitch_state->uvs){
+ if (stitch_state->uvs) {
MEM_freeN(stitch_state->uvs);
}
- if(stitch_state->selection_stack){
+ if (stitch_state->selection_stack) {
MEM_freeN(stitch_state->selection_stack);
}
- if(stitch_state->tris_per_island){
+ if (stitch_state->tris_per_island) {
MEM_freeN(stitch_state->tris_per_island);
}
- if(stitch_state->map){
+ if (stitch_state->map) {
MEM_freeN(stitch_state->map);
}
- if(stitch_state->normals){
+ if (stitch_state->normals) {
MEM_freeN(stitch_state->normals);
}
- if(stitch_state->edges){
+ if (stitch_state->edges) {
MEM_freeN(stitch_state->edges);
}
MEM_freeN(stitch_state);
@@ -486,12 +491,12 @@ static void determine_uv_stitchability(UvElement *element, StitchState *state, I
vert_index = BM_elem_index_get(l->v);
element_iter = state->element_map->vert[vert_index];
- for(; element_iter; element_iter = element_iter->next){
- if(element_iter->separate){
- if(element_iter == element){
+ for (; element_iter; element_iter = element_iter->next) {
+ if (element_iter->separate) {
+ if (element_iter == element) {
continue;
}
- if(stitch_check_uvs_stitchable(element, element_iter, state)){
+ if (stitch_check_uvs_stitchable(element, element_iter, state)) {
island_stitch_data[element_iter->island].stitchableCandidate = 1;
island_stitch_data[element->island].stitchableCandidate = 1;
element->flag |= STITCH_STITCHABLE_CANDIDATE;
@@ -506,7 +511,7 @@ static void stitch_set_face_preview_buffer_position(BMFace *efa, StitchPreviewer
{
int index = BM_elem_index_get(efa);
- if(preview_position[index].data_position == STITCH_NO_PREVIEW) {
+ if (preview_position[index].data_position == STITCH_NO_PREVIEW) {
preview_position[index].data_position = preview->preview_uvs*2;
preview_position[index].polycount_position = preview->num_polys++;
preview->preview_uvs += efa->len;
@@ -516,27 +521,27 @@ static void stitch_set_face_preview_buffer_position(BMFace *efa, StitchPreviewer
/* setup face preview for all coincident uvs and their faces */
static void stitch_setup_face_preview_for_uv_group(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data,
- PreviewPosition *preview_position){
+ PreviewPosition *preview_position) {
StitchPreviewer *preview = uv_get_stitch_previewer();
/* static island does not change so returning immediately */
- if(state->snap_islands && !state->midpoints && state->static_island == element->island)
+ if (state->snap_islands && !state->midpoints && state->static_island == element->island)
return;
- if(state->snap_islands){
+ if (state->snap_islands) {
island_stitch_data[element->island].addedForPreview = 1;
}
do {
stitch_set_face_preview_buffer_position(element->face, preview, preview_position);
element = element->next;
- } while(element && !element->separate);
+ } while (element && !element->separate);
}
/* checks if uvs are indeed stitchable and registers so that they can be shown in preview */
static void stitch_validate_stichability (UvElement *element, StitchState *state, IslandStitchData *island_stitch_data,
- PreviewPosition *preview_position){
+ PreviewPosition *preview_position) {
UvElement *element_iter;
StitchPreviewer *preview;
int vert_index;
@@ -549,12 +554,12 @@ static void stitch_validate_stichability (UvElement *element, StitchState *state
preview = uv_get_stitch_previewer();
element_iter = state->element_map->vert[vert_index];
- for(; element_iter; element_iter = element_iter->next){
- if(element_iter->separate){
- if(element_iter == element)
+ for (; element_iter; element_iter = element_iter->next) {
+ if (element_iter->separate) {
+ if (element_iter == element)
continue;
- if(stitch_check_uvs_state_stitchable(element, element_iter, state)){
- if((element_iter->island == state->static_island) || (element->island == state->static_island)){
+ if (stitch_check_uvs_state_stitchable(element, element_iter, state)) {
+ if ((element_iter->island == state->static_island) || (element->island == state->static_island)) {
element->flag |= STITCH_STITCHABLE;
preview->num_stitchable++;
stitch_setup_face_preview_for_uv_group(element, state, island_stitch_data, preview_position);
@@ -565,7 +570,7 @@ static void stitch_validate_stichability (UvElement *element, StitchState *state
}
/* this can happen if the uvs to be stitched are not on a stitchable island */
- if(!(element->flag & STITCH_STITCHABLE)){
+ if (!(element->flag & STITCH_STITCHABLE)) {
preview->num_unstitchable++;
}
}
@@ -589,17 +594,17 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
/* cleanup previous preview */
stitch_preview_delete();
preview = stitch_preview_init();
- if(preview == NULL)
+ if (preview == NULL)
return 0;
preview_position = MEM_mallocN(state->em->bm->totface*sizeof(*preview_position), "stitch_face_preview_position");
/* each face holds its position in the preview buffer in tmp. -1 is uninitialized */
- for(i = 0; i < state->em->bm->totface; i++){
+ for (i = 0; i < state->em->bm->totface; i++) {
preview_position[i].data_position = STITCH_NO_PREVIEW;
}
island_stitch_data = MEM_callocN(sizeof(*island_stitch_data)*state->element_map->totalIslands, "stitch_island_data");
- if(!island_stitch_data){
+ if (!island_stitch_data) {
return 0;
}
@@ -610,27 +615,28 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
* First determine stitchability of uvs *
*****************************************/
- for(i = 0; i < state->selection_size; i++){
+ for (i = 0; i < state->selection_size; i++) {
UvElement *element = state->selection_stack[i];
determine_uv_stitchability(element, state, island_stitch_data);
}
/* set static island to one that is added for preview */
state->static_island %= state->element_map->totalIslands;
- while(!(island_stitch_data[state->static_island].stitchableCandidate)){
+ while (!(island_stitch_data[state->static_island].stitchableCandidate)) {
state->static_island++;
state->static_island %= state->element_map->totalIslands;
/* this is entirely possible if for example limit stitching with no stitchable verts or no selection */
- if(state->static_island == previous_island)
+ if (state->static_island == previous_island)
break;
}
- for(i = 0; i < state->selection_size; i++){
+ for (i = 0; i < state->selection_size; i++) {
UvElement *element = state->selection_stack[i];
- if(element->flag & STITCH_STITCHABLE_CANDIDATE){
+ if (element->flag & STITCH_STITCHABLE_CANDIDATE) {
element->flag &= ~STITCH_STITCHABLE_CANDIDATE;
stitch_validate_stichability(element, state, island_stitch_data, preview_position);
- }else{
+ }
+ else {
/* add to preview for unstitchable */
preview->num_unstitchable++;
}
@@ -639,14 +645,14 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
/*****************************************
* Setup preview for stitchable islands *
*****************************************/
- if(state->snap_islands){
- for(i = 0; i < state->element_map->totalIslands; i++){
- if(island_stitch_data[i].addedForPreview){
+ if (state->snap_islands) {
+ for (i = 0; i < state->element_map->totalIslands; i++) {
+ if (island_stitch_data[i].addedForPreview) {
int numOfIslandUVs = 0, j;
UvElement *element;
numOfIslandUVs = getNumOfIslandUvs(state->element_map, i);
element = &state->element_map->buf[state->element_map->islandIndices[i]];
- for(j = 0; j < numOfIslandUVs; j++, element++){
+ for (j = 0; j < numOfIslandUVs; j++, element++) {
stitch_set_face_preview_buffer_position(element->face, preview, preview_position);
}
}
@@ -656,7 +662,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
/*********************************************************************
* Setup the preview buffers and fill them with the appropriate data *
*********************************************************************/
- if(!final){
+ if (!final) {
BMIter liter;
BMLoop *l;
MLoopUV *luv;
@@ -672,7 +678,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
preview->num_static_tris = state->tris_per_island[state->static_island];
/* will cause cancel and freeing of all data structures so OK */
- if(!preview->preview_polys || !preview->preview_stitchable || !preview->preview_unstitchable){
+ if (!preview->preview_polys || !preview->preview_stitchable || !preview->preview_unstitchable) {
return 0;
}
@@ -681,11 +687,11 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
/* just to test if face was added for processing. uvs of inselected vertices will return NULL */
UvElement *element = ED_get_uv_element(state->element_map, efa, BM_FACE_FIRST_LOOP(efa));
- if(element){
+ if (element) {
int numoftris = efa->len - 2;
int index = BM_elem_index_get(efa);
int face_preview_pos = preview_position[index].data_position;
- if(face_preview_pos != STITCH_NO_PREVIEW){
+ if (face_preview_pos != STITCH_NO_PREVIEW) {
preview->uvs_per_polygon[preview_position[index].polycount_position] = efa->len;
BM_ITER_INDEX(l, &liter, state->em->bm, BM_LOOPS_OF_FACE, efa, i) {
luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -693,12 +699,12 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
}
}
- if(element->island == state->static_island){
+ if (element->island == state->static_island) {
BMLoop *fl = BM_FACE_FIRST_LOOP(efa);
MLoopUV *fuv = CustomData_bmesh_get(&state->em->bm->ldata, fl->head.data, CD_MLOOPUV);
BM_ITER_INDEX(l, &liter, state->em->bm, BM_LOOPS_OF_FACE, efa, i) {
- if(i < numoftris){
+ if (i < numoftris) {
/* using next since the first uv is already accounted for */
BMLoop *lnext = l->next;
MLoopUV *luvnext = CustomData_bmesh_get(&state->em->bm->ldata, lnext->next->head.data, CD_MLOOPUV);
@@ -708,16 +714,19 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
memcpy(preview->static_tris + buffer_index + 2, luv->uv, 2*sizeof(float));
memcpy(preview->static_tris + buffer_index + 4, luvnext->uv, 2*sizeof(float));
buffer_index += 6;
- }else break;
+ }
+ else {
+ break;
+ }
}
}
}
}
/* fill the appropriate preview buffers */
- for(i = 0; i < state->total_separate_uvs; i++){
+ for (i = 0; i < state->total_separate_uvs; i++) {
UvElement *element = (UvElement *)state->uvs[i];
- if(element->flag & STITCH_STITCHABLE){
+ if (element->flag & STITCH_STITCHABLE) {
l = element->l;
luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -725,7 +734,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
stitchBufferIndex++;
}
- else if(element->flag & STITCH_SELECTED){
+ else if (element->flag & STITCH_SELECTED) {
l = element->l;
luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -743,9 +752,9 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
uvfinal_map = MEM_mallocN(state->element_map->totalUVs*sizeof(*uvfinal_map), "stitch_uv_final_map");
/* first pass, calculate final position for stitchable uvs of the static island */
- for(i = 0; i < state->selection_size; i++){
+ for (i = 0; i < state->selection_size; i++) {
UvElement *element = state->selection_stack[i];
- if(element->flag & STITCH_STITCHABLE){
+ if (element->flag & STITCH_STITCHABLE) {
BMLoop *l;
MLoopUV *luv;
UvElement *element_iter;
@@ -759,20 +768,21 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
copy_v2_v2(final_position[i].uv, luv->uv);
final_position[i].count = 1;
- if(state->snap_islands && element->island == state->static_island && !stitch_midpoints)
+ if (state->snap_islands && element->island == state->static_island && !stitch_midpoints)
continue;
element_iter = state->element_map->vert[BM_elem_index_get(l->v)];
- for(;element_iter; element_iter = element_iter->next){
- if(element_iter->separate){
- if(stitch_check_uvs_state_stitchable(element, element_iter, state)){
+ for (;element_iter; element_iter = element_iter->next) {
+ if (element_iter->separate) {
+ if (stitch_check_uvs_state_stitchable(element, element_iter, state)) {
l = element_iter->l;
luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV);
- if(stitch_midpoints){
+ if (stitch_midpoints) {
add_v2_v2(final_position[i].uv, luv->uv);
final_position[i].count++;
- }else if(element_iter->island == state->static_island){
+ }
+ else if (element_iter->island == state->static_island) {
/* if multiple uvs on the static island exist,
* last checked remains. to disambiguate we need to limit or use
* edge stitch */
@@ -782,17 +792,17 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
}
}
}
- if(stitch_midpoints){
+ if (stitch_midpoints) {
final_position[i].uv[0] /= final_position[i].count;
final_position[i].uv[1] /= final_position[i].count;
}
}
/* second pass, calculate island rotation and translation before modifying any uvs */
- if(state->snap_islands){
- for(i = 0; i < state->selection_size; i++){
+ if (state->snap_islands) {
+ for (i = 0; i < state->selection_size; i++) {
UvElement *element = state->selection_stack[i];
- if(element->flag & STITCH_STITCHABLE){
+ if (element->flag & STITCH_STITCHABLE) {
BMLoop *l;
MLoopUV *luv;
@@ -810,18 +820,18 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
}
/* only calculate rotation when an edge has been fully selected */
- for(i = 0; i < state->total_boundary_edges; i++){
+ for (i = 0; i < state->total_boundary_edges; i++) {
UvEdge *edge = state->edges+i;
- if((state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)){
+ if ((state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)) {
stitch_island_calculate_edge_rotation(edge, state, final_position, uvfinal_map, island_stitch_data);
island_stitch_data[state->uvs[edge->uv1]->island].use_edge_rotation = 1;
}
}
- for(i = 0; i < state->selection_size; i++){
+ for (i = 0; i < state->selection_size; i++) {
UvElement *element = state->selection_stack[i];
- if(!island_stitch_data[element->island].use_edge_rotation){
- if(element->flag & STITCH_STITCHABLE){
+ if (!island_stitch_data[element->island].use_edge_rotation) {
+ if (element->flag & STITCH_STITCHABLE) {
stitch_island_calculate_vert_rotation(element, state, island_stitch_data);
}
}
@@ -830,9 +840,9 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
}
/* third pass, propagate changes to coincident uvs */
- for(i = 0; i < state->selection_size; i++){
+ for (i = 0; i < state->selection_size; i++) {
UvElement *element = state->selection_stack[i];
- if(element->flag & STITCH_STITCHABLE){
+ if (element->flag & STITCH_STITCHABLE) {
UvElement *element_iter = element;
/* propagate to coincident uvs */
do {
@@ -844,30 +854,31 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final)
element_iter->flag |= STITCH_PROCESSED;
/* either flush to preview or to the MTFace, if final */
- if(final){
+ if (final) {
copy_v2_v2(luv->uv, final_position[i].uv);
uvedit_uv_select(state->em, scene, l);
- }else {
+ }
+ else {
int face_preview_pos = preview_position[BM_elem_index_get(element_iter->face)].data_position;
- if(face_preview_pos != STITCH_NO_PREVIEW){
+ if (face_preview_pos != STITCH_NO_PREVIEW) {
copy_v2_v2(preview->preview_polys + face_preview_pos + 2*element_iter->tfindex,
final_position[i].uv);
}
}
/* end of calculations, keep only the selection flag */
- if( (!state->snap_islands) || ((!stitch_midpoints) && (element_iter->island == state->static_island))) {
+ if ( (!state->snap_islands) || ((!stitch_midpoints) && (element_iter->island == state->static_island))) {
element_iter->flag &= STITCH_SELECTED;
}
element_iter = element_iter->next;
- } while(element_iter && !element_iter->separate);
+ } while (element_iter && !element_iter->separate);
}
}
/* final pass, calculate Island translation/rotation if needed */
- if(state->snap_islands){
+ if (state->snap_islands) {
stitch_calculate_island_snapping(state, preview_position, preview, island_stitch_data, final);
}
@@ -893,7 +904,7 @@ static int uv_edge_compare(const void *a, const void *b)
UvEdge *edge1 = (UvEdge *)a;
UvEdge *edge2 = (UvEdge *)b;
- if((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)){
+ if ((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)) {
return 0;
}
return 1;
@@ -911,23 +922,24 @@ static void stitch_select_uv(UvElement *element, StitchState *state, int always_
element_iter = state->element_map->vert[BM_elem_index_get(l->v)];
/* first deselect all common uvs */
- for(; element_iter; element_iter = element_iter->next){
- if(element_iter->separate){
+ for (; element_iter; element_iter = element_iter->next) {
+ if (element_iter->separate) {
/* only separators go to selection */
- if(element_iter->flag & STITCH_SELECTED){
+ 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++){
- if(selection_stack[i] == element_iter){
+ for (i = 0; i < state->selection_size; i++) {
+ if (selection_stack[i] == element_iter) {
(state->selection_size)--;
selection_stack[i] = selection_stack[state->selection_size];
break;
}
}
- }else{
+ }
+ else {
element_iter->flag |= STITCH_SELECTED;
selection_stack[state->selection_size++] = element_iter;
}
@@ -977,7 +989,7 @@ static int stitch_init(bContext *C, wmOperator *op)
op->customdata = state;
- if(!state)
+ if (!state)
return 0;
/* initialize state */
@@ -988,12 +1000,13 @@ static int stitch_init(bContext *C, wmOperator *op)
state->static_island = RNA_int_get(op->ptr, "static_island");
state->midpoints = RNA_boolean_get(op->ptr, "midpoint_snap");
/* in uv synch selection, all uv's are visible */
- if(ts->uv_flag & UV_SYNC_SELECTION){
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
state->element_map = EDBM_make_uv_element_map(state->em, 0, 1);
- }else{
+ }
+ else {
state->element_map = EDBM_make_uv_element_map(state->em, 1, 1);
}
- if(!state->element_map){
+ if (!state->element_map) {
stitch_state_delete(state);
return 0;
}
@@ -1003,8 +1016,8 @@ static int stitch_init(bContext *C, wmOperator *op)
state->static_island %= state->element_map->totalIslands;
/* Count 'unique' uvs */
- for(i = 0; i < state->element_map->totalUVs; i++){
- if(state->element_map->buf[i].separate){
+ for (i = 0; i < state->element_map->totalUVs; i++) {
+ if (state->element_map->buf[i].separate) {
counter++;
}
}
@@ -1023,7 +1036,7 @@ static int stitch_init(bContext *C, wmOperator *op)
edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "stitch_edge_hash");
all_edges = MEM_mallocN(sizeof(*all_edges)*state->element_map->totalUVs, "stitch_all_edges");
- if(!state->selection_stack || !state->uvs || !map || !edgeHash || !all_edges){
+ if (!state->selection_stack || !state->uvs || !map || !edgeHash || !all_edges) {
stitch_state_delete(state);
return 0;
}
@@ -1031,10 +1044,10 @@ static int stitch_init(bContext *C, wmOperator *op)
/* So that we can use this as index for the UvElements */
counter = -1;
/* initialize the unique UVs and map */
- for(i = 0; i < em->bm->totvert; i++){
+ for (i = 0; i < em->bm->totvert; i++) {
UvElement *element = state->element_map->vert[i];
- for(; element; element = element->next){
- if(element->separate){
+ for (; element; element = element->next) {
+ if (element->separate) {
counter++;
state->uvs[counter] = element;
}
@@ -1061,20 +1074,20 @@ static int stitch_init(bContext *C, wmOperator *op)
all_edges[counter].element = element;
/* using an order policy, sort uvs according to address space. This avoids
* Having two different UvEdges with the same uvs on different positions */
- if(offset1 < offset2){
+ if (offset1 < offset2) {
all_edges[counter].uv1 = offset1;
all_edges[counter].uv2 = offset2;
}
- else{
+ else {
all_edges[counter].uv1 = offset2;
all_edges[counter].uv2 = offset1;
}
- if(BLI_ghash_haskey(edgeHash, &all_edges[counter])){
+ if (BLI_ghash_haskey(edgeHash, &all_edges[counter])) {
char *flag = BLI_ghash_lookup(edgeHash, &all_edges[counter]);
*flag = 0;
}
- else{
+ else {
BLI_ghash_insert(edgeHash, &all_edges[counter], &(all_edges[counter].flag));
all_edges[counter].flag = STITCH_BOUNDARY;
}
@@ -1086,14 +1099,14 @@ static int stitch_init(bContext *C, wmOperator *op)
ghi = BLI_ghashIterator_new(edgeHash);
total_edges = 0;
/* fill the edges with data */
- for(; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)){
+ for (; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)) {
UvEdge *edge = ((UvEdge *)BLI_ghashIterator_getKey(ghi));
- if(edge->flag & STITCH_BOUNDARY){
+ if (edge->flag & STITCH_BOUNDARY) {
total_edges++;
}
}
state->edges = edges = MEM_mallocN(sizeof(*edges)*total_edges, "stitch_edges");
- if(!ghi || !edges){
+ if (!ghi || !edges) {
MEM_freeN(all_edges);
stitch_state_delete(state);
return 0;
@@ -1102,9 +1115,9 @@ static int stitch_init(bContext *C, wmOperator *op)
state->total_boundary_edges = total_edges;
/* fill the edges with data */
- for(i = 0, BLI_ghashIterator_init(ghi, edgeHash); !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)){
+ for (i = 0, BLI_ghashIterator_init(ghi, edgeHash); !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)) {
UvEdge *edge = ((UvEdge *)BLI_ghashIterator_getKey(ghi));
- if(edge->flag & STITCH_BOUNDARY){
+ if (edge->flag & STITCH_BOUNDARY) {
edges[i++] = *((UvEdge *)BLI_ghashIterator_getKey(ghi));
}
}
@@ -1123,7 +1136,7 @@ static int stitch_init(bContext *C, wmOperator *op)
* a point "inside" the island, that can be provided by
* the opposite uv for a quad, or the next uv for a triangle. */
- for(i = 0; i < total_edges; i++){
+ for (i = 0; i < total_edges; i++) {
float normal[2];
stitch_calculate_edge_normal(em, edges + i, normal);
@@ -1140,7 +1153,7 @@ static int stitch_init(bContext *C, wmOperator *op)
state->selection_size = 0;
/* Load old selection if redoing operator with different settings */
- if(RNA_struct_property_is_set(op->ptr, "selection")){
+ if (RNA_struct_property_is_set(op->ptr, "selection")) {
int faceIndex, elementIndex;
UvElement *element;
@@ -1159,11 +1172,12 @@ static int stitch_init(bContext *C, wmOperator *op)
/* Clear the selection */
RNA_collection_clear(op->ptr, "selection");
- } else {
+ }
+ else {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
i = 0;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- if(uvedit_uv_selected(em, scene, l)){
+ if (uvedit_uv_selected(em, scene, l)) {
UvElement *element = ED_get_uv_element(state->element_map, efa, l);
stitch_select_uv(element, state, 1);
}
@@ -1176,19 +1190,19 @@ static int stitch_init(bContext *C, wmOperator *op)
state->tris_per_island = MEM_mallocN(sizeof(*state->tris_per_island)*state->element_map->totalIslands,
"stitch island tris");
- for(i = 0; i < state->element_map->totalIslands; i++){
+ for (i = 0; i < state->element_map->totalIslands; i++) {
state->tris_per_island[i] = 0;
}
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
UvElement *element = ED_get_uv_element(state->element_map, efa, BM_FACE_FIRST_LOOP(efa));
- if(element){
+ if (element) {
state->tris_per_island[element->island] += (efa->len > 2)? efa->len-2 : 0;
}
}
- if(!stitch_process_data(state, scene, 0)){
+ if (!stitch_process_data(state, scene, 0)) {
stitch_state_delete(state);
return 0;
}
@@ -1200,7 +1214,7 @@ static int stitch_init(bContext *C, wmOperator *op)
static int stitch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Object *obedit = CTX_data_edit_object(C);
- if(!stitch_init(C, op))
+ if (!stitch_init(C, op))
return OPERATOR_CANCELLED;
WM_event_add_modal_handler(C, op);
@@ -1222,7 +1236,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
stitch_state = (StitchState *)op->customdata;
- if(finished){
+ if (finished) {
int i;
RNA_float_set(op->ptr, "limit", stitch_state->limit_dist);
@@ -1232,7 +1246,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
RNA_boolean_set(op->ptr, "midpoint_snap", stitch_state->midpoints);
/* Store selection for re-execution of stitch */
- for(i = 0; i < stitch_state->selection_size; i++){
+ for (i = 0; i < stitch_state->selection_size; i++) {
PointerRNA itemptr;
UvElement *element = stitch_state->selection_stack[i];
@@ -1247,7 +1261,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
uvedit_live_unwrap_update(sima, scene, obedit);
}
- if(sa)
+ if (sa)
ED_area_headerprint(sa, NULL);
DAG_id_tag_update(obedit->data, 0);
@@ -1271,12 +1285,13 @@ static int stitch_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- if(!stitch_init(C, op))
+ if (!stitch_init(C, op))
return OPERATOR_CANCELLED;
- if(stitch_process_data((StitchState *)op->customdata, scene, 1)){
+ if (stitch_process_data((StitchState *)op->customdata, scene, 1)) {
stitch_exit(C, op, 1);
return OPERATOR_FINISHED;
- }else {
+ }
+ else {
return stitch_cancel(C, op);
}
}
@@ -1311,7 +1326,7 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
stitch_state = (StitchState *)op->customdata;
- switch(event->type){
+ switch(event->type) {
case MIDDLEMOUSE:
return OPERATOR_PASS_THROUGH;
@@ -1321,11 +1336,11 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
case LEFTMOUSE:
- if(event->shift && (U.flag & USER_LMOUSESELECT)){
- if(event->val == KM_RELEASE){
+ if (event->shift && (U.flag & USER_LMOUSESELECT)) {
+ if (event->val == KM_RELEASE) {
stitch_select(C, scene, event, stitch_state);
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
}
@@ -1333,7 +1348,7 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
}
case PADENTER:
case RETKEY:
- if(stitch_process_data(stitch_state, scene, 1)){
+ if (stitch_process_data(stitch_state, scene, 1)) {
stitch_exit(C, op, 1);
return OPERATOR_FINISHED;
}
@@ -1344,35 +1359,36 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
/* Increase limit */
case PADPLUSKEY:
case WHEELUPMOUSE:
- if(event->alt){
+ if (event->alt) {
stitch_state->limit_dist += 0.01;
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
break;
}
- else{
+ else {
return OPERATOR_PASS_THROUGH;
}
/* Decrease limit */
case PADMINUS:
case WHEELDOWNMOUSE:
- if(event->alt){
+ if (event->alt) {
stitch_state->limit_dist -= 0.01;
stitch_state->limit_dist = MAX2(0.01, stitch_state->limit_dist);
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
break;
- }else{
+ }
+ else {
return OPERATOR_PASS_THROUGH;
}
/* Use Limit (Default off)*/
case LKEY:
- if(event->val == KM_PRESS){
+ if (event->val == KM_PRESS) {
stitch_state->use_limit = !stitch_state->use_limit;
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
break;
@@ -1380,11 +1396,11 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
case IKEY:
- if(event->val == KM_PRESS){
+ if (event->val == KM_PRESS) {
stitch_state->static_island++;
stitch_state->static_island %= stitch_state->element_map->totalIslands;
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
break;
@@ -1392,9 +1408,9 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
case MKEY:
- if(event->val == KM_PRESS){
+ if (event->val == KM_PRESS) {
stitch_state->midpoints = !stitch_state->midpoints;
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
}
@@ -1402,13 +1418,13 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
/* Select geometry*/
case RIGHTMOUSE:
- if(!event->shift){
+ if (!event->shift) {
return stitch_cancel(C, op);
}
- if(event->val == KM_RELEASE && !(U.flag & USER_LMOUSESELECT)){
+ if (event->val == KM_RELEASE && !(U.flag & USER_LMOUSESELECT)) {
stitch_select(C, scene, event, stitch_state);
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
break;
@@ -1417,13 +1433,14 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
/* snap islands on/off */
case SKEY:
- if(event->val == KM_PRESS){
+ if (event->val == KM_PRESS) {
stitch_state->snap_islands = !stitch_state->snap_islands;
- if(!stitch_process_data(stitch_state, scene, 0)){
+ if (!stitch_process_data(stitch_state, scene, 0)) {
return stitch_cancel(C, op);
}
break;
- } else
+ }
+ else
return OPERATOR_RUNNING_MODAL;
default:
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 94879ff8e7f..107a92fd3ef 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -98,33 +98,33 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
SpaceLink *slink;
SpaceImage *sima;
- if(ED_uvedit_test(obedit)) {
+ if (ED_uvedit_test(obedit)) {
return 1;
}
- if(em && em->bm->totface && !CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) {
+ if (em && em->bm->totface && !CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY);
BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV);
}
- if(!ED_uvedit_test(obedit)) {
+ if (!ED_uvedit_test(obedit)) {
return 0;
}
ima= CTX_data_edit_image(C);
- if(!ima) {
+ if (!ima) {
/* no image in context in the 3d view, we find first image window .. */
sc= CTX_wm_screen(C);
- for(sa=sc->areabase.first; sa; sa=sa->next) {
+ for (sa=sc->areabase.first; sa; sa=sa->next) {
slink= sa->spacedata.first;
- if(slink->spacetype == SPACE_IMAGE) {
+ if (slink->spacetype == SPACE_IMAGE) {
sima= (SpaceImage*)slink;
ima= sima->image;
- if(ima) {
- if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
+ if (ima) {
+ if (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
ima= NULL;
else
break;
@@ -133,7 +133,7 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
}
}
- if(ima)
+ if (ima)
ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
/* select new UV's */
@@ -156,11 +156,11 @@ static int uvedit_have_selection(Scene *scene, BMEditMesh *em, short implicit)
/* verify if we have any selected uv's before unwrapping,
* so we can cancel the operator early */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if(BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
continue;
}
- else if(BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ else if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT))
continue;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
@@ -194,16 +194,16 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
handle = param_construct_begin();
- if(correct_aspect) {
+ if (correct_aspect) {
efa = BM_active_face_get(em->bm, TRUE);
- if(efa) {
+ if (efa) {
float aspx, aspy;
tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
- if(aspx!=aspy)
+ if (aspx!=aspy)
param_aspect_ratio(handle, aspx, aspy);
}
}
@@ -222,7 +222,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
float *uv[4];
int lsel;
- if((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT)==0))
+ if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT)==0))
continue;
/* tf= (MTexPoly *)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
@@ -305,9 +305,9 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BLI_end_edgefill();
}
- if(!implicit) {
+ if (!implicit) {
BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
- if(BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
+ if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) {
ParamKey vkeys[2];
vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1);
vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2);
@@ -332,11 +332,11 @@ static void texface_from_original_index(BMFace *efa, int index, float **uv, Para
*pin = 0;
*select = 1;
- if(index == ORIGINDEX_NONE)
+ if (index == ORIGINDEX_NONE)
return;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- if(BM_elem_index_get(l->v) == index) {
+ if (BM_elem_index_get(l->v) == index) {
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
*uv = luv->uv;
*pin = (luv->flag & MLOOPUV_PINNED)? 1 : 0;
@@ -376,17 +376,17 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
handle = param_construct_begin();
- if(correct_aspect) {
+ if (correct_aspect) {
editFace = BM_active_face_get(em->bm, TRUE);
- if(editFace) {
+ if (editFace) {
MTexPoly *tf;
float aspx, aspy;
tf= CustomData_bmesh_get(&em->bm->pdata, editFace->head.data, CD_MTEXPOLY);
ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
- if(aspx!=aspy)
+ if (aspx!=aspy)
param_aspect_ratio(handle, aspx, aspy);
}
}
@@ -419,13 +419,13 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
EDBM_init_index_arrays(em, 0, 1, 1);
/* map subsurfed faces to original editFaces */
- for(i = 0; i < numOfFaces; i++)
+ for (i = 0; i < numOfFaces; i++)
faceMap[i] = EDBM_get_face_for_index(em, origFaceIndices[i]);
edgeMap = MEM_mallocN(numOfEdges*sizeof(BMEdge *), "unwrap_edit_edge_map");
/* map subsurfed edges to original editEdges */
- for(i = 0; i < numOfEdges; i++) {
+ for (i = 0; i < numOfEdges; i++) {
/* not all edges correspond to an old edge */
edgeMap[i] = (origEdgeIndices[i] != -1)?
EDBM_get_edge_for_index(em, origEdgeIndices[i]) : NULL;
@@ -434,7 +434,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
EDBM_free_index_arrays(em);
/* Prepare and feed faces to the solver */
- for(i = 0; i < numOfFaces; i++) {
+ for (i = 0; i < numOfFaces; i++) {
ParamKey key, vkeys[4];
ParamBool pin[4], select[4];
float *co[4];
@@ -443,12 +443,12 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
face = subsurfedFaces+i;
- if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if(BM_elem_flag_test(origFace, BM_ELEM_HIDDEN))
+ if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
+ if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN))
continue;
}
else {
- if(BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) || (sel && !BM_elem_flag_test(origFace, BM_ELEM_SELECT)))
+ if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) || (sel && !BM_elem_flag_test(origFace, BM_ELEM_SELECT)))
continue;
}
@@ -475,8 +475,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
}
/* these are calculated from original mesh too */
- for(edge = subsurfedEdges, i = 0; i < numOfEdges; i++, edge++) {
- if((edgeMap[i] != NULL) && BM_elem_flag_test(edgeMap[i], BM_ELEM_SEAM)) {
+ for (edge = subsurfedEdges, i = 0; i < numOfEdges; i++, edge++) {
+ if ((edgeMap[i] != NULL) && BM_elem_flag_test(edgeMap[i], BM_ELEM_SEAM)) {
ParamKey vkeys[2];
vkeys[0] = (ParamKey)edge->v1;
vkeys[1] = (ParamKey)edge->v2;
@@ -516,7 +516,7 @@ static int minimize_stretch_init(bContext *C, wmOperator *op)
int fill_holes = RNA_boolean_get(op->ptr, "fill_holes");
short implicit = 1;
- if(!uvedit_have_selection(scene, em, implicit)) {
+ if (!uvedit_have_selection(scene, em, implicit)) {
return 0;
}
@@ -531,7 +531,7 @@ static int 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;
@@ -550,12 +550,12 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact
ms->i++;
RNA_int_set(op->ptr, "iterations", ms->i);
- if(interactive && (PIL_check_seconds_timer() - ms->lasttime > 0.5)) {
+ if (interactive && (PIL_check_seconds_timer() - ms->lasttime > 0.5)) {
char str[100];
param_flush(ms->handle);
- if(sa) {
+ if (sa) {
BLI_snprintf(str, sizeof(str), "Minimize Stretch. Blend %.2f", ms->blend);
ED_area_headerprint(sa, str);
}
@@ -572,12 +572,12 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel)
MinStretch *ms= op->customdata;
ScrArea *sa= CTX_wm_area(C);
- if(sa)
+ if (sa)
ED_area_headerprint(sa, 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
param_flush(ms->handle);
@@ -596,11 +596,11 @@ 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, 0);
minimize_stretch_exit(C, op, 0);
@@ -611,7 +611,7 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
{
MinStretch *ms;
- if(!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op))
return OPERATOR_CANCELLED;
minimize_stretch_iteration(C, op, 1);
@@ -639,7 +639,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_FINISHED;
case PADPLUSKEY:
case WHEELUPMOUSE:
- if(ms->blend < 0.95f) {
+ if (ms->blend < 0.95f) {
ms->blend += 0.1f;
ms->lasttime= 0.0f;
RNA_float_set(op->ptr, "blend", ms->blend);
@@ -648,7 +648,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, wmEvent *event)
break;
case PADMINUS:
case WHEELDOWNMOUSE:
- if(ms->blend > 0.05f) {
+ if (ms->blend > 0.05f) {
ms->blend -= 0.1f;
ms->lasttime= 0.0f;
RNA_float_set(op->ptr, "blend", ms->blend);
@@ -656,17 +656,17 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, wmEvent *event)
}
break;
case TIMER:
- if(ms->timer == event->customdata) {
+ if (ms->timer == event->customdata) {
double start= PIL_check_seconds_timer();
do {
minimize_stretch_iteration(C, op, 1);
- } while(PIL_check_seconds_timer() - start < 0.01);
+ } while (PIL_check_seconds_timer() - start < 0.01);
}
break;
}
- if(ms->iterations && ms->i >= ms->iterations) {
+ if (ms->iterations && ms->i >= ms->iterations) {
minimize_stretch_exit(C, op, 0);
return OPERATOR_FINISHED;
}
@@ -712,11 +712,11 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
ParamHandle *handle;
short implicit = 1;
- if(!uvedit_have_selection(scene, em, implicit)) {
+ if (!uvedit_have_selection(scene, em, implicit)) {
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 {
@@ -759,7 +759,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op))
ParamHandle *handle;
short implicit = 1;
- if(!uvedit_have_selection(scene, em, implicit)) {
+ if (!uvedit_have_selection(scene, em, implicit)) {
return OPERATOR_CANCELLED;
}
@@ -797,11 +797,11 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
short fillholes = scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES;
short use_subsurf = scene->toolsettings->uvcalc_flag & UVCALC_USESUBSURF;
- if(!ED_uvedit_test(obedit)) {
+ if (!ED_uvedit_test(obedit)) {
return;
}
- if(use_subsurf)
+ if (use_subsurf)
liveHandle = construct_param_handle_subsurfed(scene, em, fillholes, 0, 1);
else
liveHandle = construct_param_handle(scene, em, 0, fillholes, 0, 1);
@@ -811,7 +811,7 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
void ED_uvedit_live_unwrap_re_solve(void)
{
- if(liveHandle) {
+ if (liveHandle) {
param_lscm_solve(liveHandle);
param_flush(liveHandle);
}
@@ -819,9 +819,9 @@ void ED_uvedit_live_unwrap_re_solve(void)
void ED_uvedit_live_unwrap_end(short cancel)
{
- if(liveHandle) {
+ if (liveHandle) {
param_lscm_end(liveHandle);
- if(cancel)
+ if (cancel)
param_flush_restore(liveHandle);
param_delete(liveHandle);
liveHandle = NULL;
@@ -854,7 +854,7 @@ static void uv_map_transform_center(Scene *scene, View3D *v3d, float *result,
max[0]= max[1]= max[2]= -1e20f;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
- if(BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
+ if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
DO_MINMAX(l->v->co, min, max);
}
@@ -887,20 +887,20 @@ static void uv_map_rotation_matrix(float result[][4], RegionView3D *rv3d, Object
int k;
/* get rotation of the current view matrix */
- if(rv3d)
+ if (rv3d)
copy_m4_m4(viewmatrix, rv3d->viewmat);
else
unit_m4(viewmatrix);
/* but shifting */
- for(k=0; k<4; k++)
+ for (k=0; k<4; k++)
viewmatrix[3][k] =0.0f;
/* get rotation of the current object matrix */
copy_m4_m4(rotobj,ob->obmat);
/* but shifting */
- for(k=0; k<4; k++)
+ for (k=0; k<4; k++)
rotobj[3][k] =0.0f;
zero_m4(rotup);
@@ -943,18 +943,18 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float
uv_map_transform_center(scene, v3d, center, obedit, em);
- if(direction == VIEW_ON_EQUATOR) {
+ if (direction == VIEW_ON_EQUATOR) {
upangledeg= 90.0f;
sideangledeg= 0.0f;
}
else {
upangledeg= 0.0f;
- if(align == POLAR_ZY) sideangledeg= 0.0f;
+ if (align == POLAR_ZY) sideangledeg= 0.0f;
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
uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius);
@@ -979,7 +979,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
"Direction of the sphere or cylinder");
RNA_def_enum(ot->srna, "align", align_items, VIEW_ON_EQUATOR, "Align",
"How to determine rotation around the pole");
- if(radius)
+ if (radius)
RNA_def_float(ot->srna, "radius", 1.0f, 0.0f, FLT_MAX, "Radius",
"Radius of the sphere or cylinder", 0.0001f, 100.0f);
}
@@ -999,10 +999,10 @@ static void correct_uv_aspect(BMEditMesh *em)
ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
}
- if(aspx == aspy)
+ if (aspx == aspy)
return;
- if(aspx > aspy) {
+ if (aspx > aspy) {
scale= aspy/aspx;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -1054,10 +1054,10 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
int scale_to_bounds= RNA_boolean_get(op->ptr, "scale_to_bounds");
/* correct for image aspect ratio */
- if(correct_aspect)
+ if (correct_aspect)
correct_uv_aspect(em);
- if(scale_to_bounds) {
+ if (scale_to_bounds) {
INIT_MINMAX2(min, max);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -1074,9 +1074,9 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
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;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -1091,7 +1091,7 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op)
}
}
}
- else if(clip_to_bounds) {
+ else if (clip_to_bounds) {
/* clipping and wrapping */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
@@ -1118,7 +1118,7 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel)
const short correct_aspect= !(scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT);
const short use_subsurf = scene->toolsettings->uvcalc_flag & UVCALC_USESUBSURF;
- if(use_subsurf)
+ if (use_subsurf)
handle = construct_param_handle_subsurfed(scene, em, fill_holes, sel, correct_aspect);
else
handle= construct_param_handle(scene, em, 0, fill_holes, sel, correct_aspect);
@@ -1147,17 +1147,17 @@ static int unwrap_exec(bContext *C, wmOperator *op)
float obsize[3], unitsize[3] = {1.0f, 1.0f, 1.0f};
short implicit= 0;
- if(!uvedit_have_selection(scene, em, implicit)) {
+ if (!uvedit_have_selection(scene, em, implicit)) {
return OPERATOR_CANCELLED;
}
/* add uvs if they don't exist yet */
- if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
return OPERATOR_CANCELLED;
}
mat4_to_size(obsize, obedit->obmat);
- if(!compare_v3v3(obsize, unitsize, 1e-4f))
+ if (!compare_v3v3(obsize, unitsize, 1e-4f))
BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh.");
/* remember last method for live unwrap */
@@ -1165,13 +1165,13 @@ static int unwrap_exec(bContext *C, wmOperator *op)
scene->toolsettings->uv_subsurf_level = subsurf_level;
- if(fill_holes) scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES;
+ if (fill_holes) scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES;
else scene->toolsettings->uvcalc_flag &= ~UVCALC_FILLHOLES;
- if(correct_aspect) scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT;
+ if (correct_aspect) scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT;
else scene->toolsettings->uvcalc_flag |= UVCALC_NO_ASPECT_CORRECT;
- if(use_subsurf) scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF;
+ if (use_subsurf) scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF;
else scene->toolsettings->uvcalc_flag &= ~UVCALC_USESUBSURF;
/* execute unwrap */
@@ -1230,7 +1230,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
float rotmat[4][4];
/* add uvs if they don't exist yet */
- if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
return OPERATOR_CANCELLED;
}
@@ -1239,7 +1239,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
camera= v3d->camera->data;
}
- if(RNA_boolean_get(op->ptr, "orthographic")) {
+ if (RNA_boolean_get(op->ptr, "orthographic")) {
uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f);
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
@@ -1255,7 +1255,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
else if (camera) {
struct UvCameraInfo *uci= project_camera_info(v3d->camera, obedit->obmat, scene->r.xsch, scene->r.ysch);
- if(uci) {
+ if (uci) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
continue;
@@ -1295,7 +1295,7 @@ static int 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);
@@ -1364,7 +1364,7 @@ static void uv_sphere_project(float target[2], float source[3], float center[3],
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;
}
@@ -1386,14 +1386,14 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf))
}
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) {
+ for (i=0; i<efa->len; i++) {
+ if (i != mi) {
dx = uvs[mi][0] - uvs[i][0];
- if(dx > 0.5f) uvs[i][0] += 1.0f;
+ if (dx > 0.5f) uvs[i][0] += 1.0f;
}
}
@@ -1413,7 +1413,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
float center[3], rotmat[4][4];
/* add uvs if they don't exist yet */
- if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
return OPERATOR_CANCELLED;
}
@@ -1469,7 +1469,7 @@ static void uv_cylinder_project(float target[2], float source[3], float center[3
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;
}
@@ -1486,7 +1486,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
float center[3], rotmat[4][4];
/* add uvs if they don't exist yet */
- if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
return OPERATOR_CANCELLED;
}
@@ -1546,7 +1546,7 @@ static int cube_project_exec(bContext *C, wmOperator *op)
int cox, coy;
/* add uvs if they don't exist yet */
- if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) {
return OPERATOR_CANCELLED;
}