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>2007-09-10 16:26:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-09-10 16:26:36 +0400
commite8a808da24e0c791a557aae7e3930550982f45c7 (patch)
tree804b01e82ee92e2081aa5aa5b56105342e021fdb /source/blender/src
parent0e3460dd1b6b9521f1833998b63d7753639c5339 (diff)
UV Editing is now done in editmode rather then UV/Face Select mode.
Notes * you cant edit UV's in the image window in "UV Face Select" mode. (removed UV from the name) * going into Face Select mode no longer adds UV's and does not need UV's to work. * The UV Calculation menu is now in editmode (Alt+W) Todo.. * Image replace - partly broken in stable also. * Rotate/Mirror UV/VCol are still only in Face Select mode. * Hide/Reveal is not quite right, (issue with editmode flushing)
Diffstat (limited to 'source/blender/src')
-rw-r--r--source/blender/src/buttons_editing.c17
-rw-r--r--source/blender/src/drawimage.c256
-rw-r--r--source/blender/src/drawmesh.c29
-rw-r--r--source/blender/src/drawobject.c8
-rw-r--r--source/blender/src/editface.c336
-rw-r--r--source/blender/src/editmesh.c13
-rw-r--r--source/blender/src/editmesh_lib.c131
-rw-r--r--source/blender/src/editmesh_mods.c103
-rw-r--r--source/blender/src/editmesh_tools.c14
-rw-r--r--source/blender/src/editobject.c16
-rw-r--r--source/blender/src/editsima.c655
-rw-r--r--source/blender/src/editview.c9
-rw-r--r--source/blender/src/header_image.c8
-rw-r--r--source/blender/src/header_view3d.c22
-rw-r--r--source/blender/src/space.c29
-rw-r--r--source/blender/src/transform_conversions.c28
-rw-r--r--source/blender/src/transform_generics.c34
-rw-r--r--source/blender/src/unwrapper.c88
-rw-r--r--source/blender/src/vpaint.c10
19 files changed, 891 insertions, 915 deletions
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index 99bb2733fcb..122ad6e3a50 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -719,8 +719,8 @@ static void delete_customdata_layer(void *data1, void *data2)
if(!CustomData_has_layer(data, type)) {
if(type == CD_MCOL && (G.f & G_VERTEXPAINT))
G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */
- if(type == CD_MTFACE && (G.f & G_FACESELECT))
- set_faceselect(); /* get out of faceselect mode */
+ /*if(type == CD_MTFACE && (G.f & G_FACESELECT))
+ set_faceselect();*/ /* get out of faceselect mode */
}
/*reconstruct active layer*/
@@ -4378,7 +4378,7 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me)
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
- uiDefButBitI(block, TOG, G_DRAWFACES, REDRAWVIEW3D, "Draw Faces", 955,88,150,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades");
+ uiDefButBitI(block, TOG, G_DRAWFACES, REDRAWVIEW3D|REDRAWIMAGE, "Draw Faces", 955,88,150,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades");
uiDefButBitI(block, TOG, G_DRAWEDGES, REDRAWVIEW3D, "Draw Edges", 955,66,150,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights");
uiDefButBitI(block, TOG, G_DRAWCREASES, REDRAWVIEW3D, "Draw Creases", 955,44,150,19, &G.f, 0, 0, 0, 0, "Displays creases created for subsurf weighting");
uiDefButBitI(block, TOG, G_DRAWSEAMS, REDRAWVIEW3D, "Draw Seams", 955,22,150,19, &G.f, 0, 0, 0, 0, "Displays UV unwrapping seams");
@@ -4838,7 +4838,7 @@ void do_fpaintbuts(unsigned short event)
case B_COPY_TF_COL:
case B_COPY_TF_TEX:
me= get_mesh(OBACT);
- activetf= get_active_tface(&activemcol);
+ activetf= get_active_tface(NULL, &activemcol);
if(me && activetf) {
for (a=0, tf=me->mtface, mf=me->mface; a < me->totface; a++, tf++, mf++) {
@@ -4892,7 +4892,7 @@ void do_fpaintbuts(unsigned short event)
break;
case B_TFACE_HALO:
- activetf = get_active_tface(NULL);
+ activetf = get_active_tface(NULL, NULL);
if(activetf) {
activetf->mode &= ~TF_BILLBOARD2;
allqueue(REDRAWBUTSEDIT, 0);
@@ -4900,7 +4900,7 @@ void do_fpaintbuts(unsigned short event)
break;
case B_TFACE_BILLB:
- activetf = get_active_tface(NULL);
+ activetf = get_active_tface(NULL, NULL);
if(activetf) {
activetf->mode &= ~TF_BILLBOARD;
allqueue(REDRAWBUTSEDIT, 0);
@@ -5272,7 +5272,7 @@ static void editing_panel_mesh_texface(void)
block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_texface", UI_EMBOSS, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Texture face", "Editing", 960, 0, 318, 204)==0) return;
- tf = get_active_tface(NULL);
+ tf = get_active_tface(NULL, NULL);
if(tf) {
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, TF_TEX, B_REDR_3D_IMA, "Tex", 600,160,60,19, &tf->mode, 0, 0, 0, 0, "Render face with texture");
@@ -5465,6 +5465,7 @@ void editing_panels()
if(G.obedit) {
editing_panel_mesh_tools(ob, ob->data);
editing_panel_mesh_tools1(ob, ob->data);
+ editing_panel_mesh_uvautocalculation();
}
else if(G.f & G_SCULPTMODE) {
uiNewPanelTabbed("Multires", "Editing");
@@ -5474,7 +5475,7 @@ void editing_panels()
} else {
if(G.f & G_FACESELECT) {
editing_panel_mesh_texface();
- editing_panel_mesh_uvautocalculation();
+ editing_panel_mesh_uvautocalculation(); /* draw hidden edge option from this needs to be elsewhere */
}
if(G.f & (G_VERTEXPAINT | G_TEXTUREPAINT | G_WEIGHTPAINT) ) {
editing_panel_mesh_paint();
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index e1e9f7a8595..d8e6a1a334e 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -43,6 +43,7 @@
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
+#include "BLI_editVert.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -242,19 +243,16 @@ void calc_image_view(SpaceImage *sima, char mode)
void what_image(SpaceImage *sima)
{
MTFace *activetf;
- Mesh *me;
if(sima->mode==SI_TEXTURE) {
/* viewer overrides faceselect */
- if(sima->image && sima->image->source==IMA_SRC_VIEWER);
- else if((G.f & G_FACESELECT)) {
-
+ if(sima->image && sima->image->source==IMA_SRC_VIEWER) {}
+ else if (G.obedit == OBACT) {
sima->image= NULL;
- me= get_mesh(OBACT);
- activetf = get_active_tface(NULL);
+ activetf = get_active_tface(NULL, NULL);
- if(me && me->mtface && activetf && activetf->mode & TF_TEX) {
+ if(activetf && activetf->mode & TF_TEX) {
sima->image= activetf->tpage;
if(sima->flag & SI_EDITTILE);
@@ -267,7 +265,6 @@ void what_image(SpaceImage *sima)
}
}
}
-
}
}
@@ -285,22 +282,20 @@ ImBuf *imagewindow_get_ibuf(SpaceImage *sima)
return NULL;
}
-
+extern int EM_texFaceCheck(void); /* from editmesh.c */
/* called to assign images to UV faces */
void image_changed(SpaceImage *sima, int dotile)
{
MTFace *tface;
- MFace *mface;
- Mesh *me;
- int a;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
if(sima->image==NULL)
sima->flag &= ~SI_DRAWTOOL;
if(sima->mode==SI_TEXTURE) {
- if(G.f & G_FACESELECT) {
-
+ if(EM_texFaceCheck()) {
/* skip assigning these procedural images... */
if(sima->image) {
if(sima->image->type==IMA_TYPE_R_RESULT)
@@ -308,41 +303,38 @@ void image_changed(SpaceImage *sima, int dotile)
if(sima->image->type==IMA_TYPE_COMPOSITE)
return;
}
-
- me= get_mesh(OBACT);
- if(me && me->mtface) {
+ /*
+ tface= me->mtface;
+ mface = me->mface;
+ a= me->totface;
+ while(a--) {
+ if(mface->flag & ME_FACE_SEL) {
+ */
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
- tface= me->mtface;
- mface = me->mface;
- a= me->totface;
- while(a--) {
- if(mface->flag & ME_FACE_SEL) {
-
- if(dotile==2) {
- tface->mode &= ~TF_TILES;
- }
- else {
- tface->tpage= sima->image;
- tface->mode |= TF_TEX;
-
- if(dotile) tface->tile= sima->curtile;
- }
-
- if(sima->image) {
- if(sima->image->tpageflag & IMA_TILES) tface->mode |= TF_TILES;
- else tface->mode &= ~TF_TILES;
-
- if(sima->image->id.us==0) id_us_plus(&sima->image->id);
- else id_lib_extern(&sima->image->id);
- }
+ if(dotile==2) {
+ tface->mode &= ~TF_TILES;
+ }
+ else {
+ tface->tpage= sima->image;
+ tface->mode |= TF_TEX;
+
+ if(dotile) tface->tile= sima->curtile;
+ }
+
+ if(sima->image) {
+ if(sima->image->tpageflag & IMA_TILES) tface->mode |= TF_TILES;
+ else tface->mode &= ~TF_TILES;
+
+ if(sima->image->id.us==0) id_us_plus(&sima->image->id);
+ else id_lib_extern(&sima->image->id);
}
- tface++;
- mface++;
}
-
- object_uvs_changed(OBACT);
- allqueue(REDRAWBUTSEDIT, 0);
}
+ object_uvs_changed(OBACT);
+ allqueue(REDRAWBUTSEDIT, 0);
}
}
}
@@ -384,27 +376,26 @@ void uvco_to_areaco_noclip(float *vec, int *mval)
void draw_tfaces(void)
{
MTFace *tface,*activetface = NULL;
- MFace *mface,*activemface = NULL;
- Mesh *me;
- int a;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
+
+ /*int a;*/
char col1[4], col2[4];
float pointsize= BIF_GetThemeValuef(TH_VERTEX_SIZE);
- if(G.f & G_FACESELECT) {
- me= get_mesh(OBACT);
-
- if(me && me->mtface) {
+ if (G.obedit) {
+ if (CustomData_has_layer(&em->fdata, CD_MTFACE)) {
calc_image_view(G.sima, 'f'); /* float */
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
glLoadIdentity();
/* draw shadow mesh */
- if ((G.sima->flag & SI_DRAWSHADOW) && !(G.obedit==OBACT)) {
+ if ((G.sima->flag & SI_DRAWSHADOW) && !(G.obedit==OBACT)) { /* TODO - editmesh */
DerivedMesh *dm;
/* draw final mesh with modifiers applied */
- dm = mesh_get_derived_final(OBACT,
- CD_MASK_BAREMESH | CD_MASK_MTFACE);
+ /* should test - editmesh_get_derived_cage_and_final */
+ dm = editmesh_get_derived_base();
glColor3ub(112, 112, 112);
if (dm->drawUVEdges) dm->drawUVEdges(dm);
@@ -414,36 +405,24 @@ void draw_tfaces(void)
else if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT)) {
/* draw mesh without modifiers applied */
- if (G.obedit) {
- DerivedMesh *dm = editmesh_get_derived_base();
-
+ if (G.obedit) {
glColor3ub(112, 112, 112);
- dm->drawUVEdges(dm);
-
- dm->release(dm);
- }
- else {
- tface= me->mtface;
- mface= me->mface;
- a= me->totface;
-
- glColor3ub(112, 112, 112);
- while(a--) {
- if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ /*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/
+ if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
glBegin(GL_LINE_LOOP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
- }
- tface++;
- mface++;
+ }
}
}
}
- if((G.sima->flag & SI_DRAWTOOL) || (G.obedit==OBACT))
+ if((G.sima->flag & SI_DRAWTOOL) || !(G.obedit==OBACT))
return; /* only draw shadow mesh */
/* draw transparent faces */
@@ -452,47 +431,37 @@ void draw_tfaces(void)
BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- tface= me->mtface;
- mface= me->mface;
- a= me->totface;
- while(a--) {
- if(mface->flag & ME_FACE_SEL) {
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
- (!mface->v4 || tface->flag & TF_SEL4))
+ (!efa->v4 || tface->flag & TF_SEL4))
glColor4ubv((GLubyte *)col2);
else
glColor4ubv((GLubyte *)col1);
- glBegin(mface->v4?GL_QUADS:GL_TRIANGLES);
+ glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
}
- tface++;
- mface++;
}
glDisable(GL_BLEND);
}
-
-
- tface= me->mtface;
- mface= me->mface;
- a= me->totface;
- while(a--) {
- if(mface->flag & ME_FACE_SEL) {
- if(tface->flag & TF_ACTIVE){
- activetface= tface;
- activemface= mface;
- }
-
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
cpack(0x0);
glBegin(GL_LINE_LOOP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
setlinestyle(2);
@@ -504,36 +473,34 @@ void draw_tfaces(void)
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[0]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
else glVertex2fv(tface->uv[2]);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
setlinestyle(0);
}
-
- tface++;
- mface++;
}
/* draw active face edges */
- if (activetface){
+ /*if (activetface){*/
/* colors: R=u G=v */
-
+ activetface = get_active_tface(&efa, NULL);
+ if (activetface) {
setlinestyle(2);
tface=activetface;
- mface=activemface;
+ /*mface=activemface;*/
cpack(0x0);
glBegin(GL_LINE_LOOP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
cpack(0xFF00);
@@ -545,7 +512,7 @@ void draw_tfaces(void)
cpack(0xFF);
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[0]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
else glVertex2fv(tface->uv[2]);
glEnd();
@@ -553,7 +520,7 @@ void draw_tfaces(void)
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
- if(mface->v4) glVertex2fv(tface->uv[3]);
+ if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
setlinestyle(0);
@@ -564,21 +531,16 @@ void draw_tfaces(void)
glPointSize(pointsize);
bglBegin(GL_POINTS);
- tface= me->mtface;
- mface= me->mface;
- a= me->totface;
- while(a--) {
- if(mface->flag & ME_FACE_SEL) {
-
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
if(tface->flag & TF_SEL3); else bglVertex2fv(tface->uv[2]);
- if(mface->v4) {
+ if(efa->v4) {
if(tface->flag & TF_SEL4); else bglVertex2fv(tface->uv[3]);
}
}
- tface++;
- mface++;
}
bglEnd();
@@ -588,21 +550,16 @@ void draw_tfaces(void)
cpack(0xFF);
bglBegin(GL_POINTS);
- tface= me->mtface;
- mface= me->mface;
- a= me->totface;
- while(a--) {
- if(mface->flag & ME_FACE_SEL) {
-
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]);
- if(mface->v4) {
+ if(efa->v4) {
if(tface->unwrap & TF_PIN4) bglVertex2fv(tface->uv[3]);
}
}
- tface++;
- mface++;
}
bglEnd();
@@ -611,21 +568,16 @@ void draw_tfaces(void)
glPointSize(pointsize);
bglBegin(GL_POINTS);
- tface= me->mtface;
- mface= me->mface;
- a= me->totface;
- while(a--) {
- if(mface->flag & ME_FACE_SEL) {
-
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
if(tface->flag & TF_SEL3) bglVertex2fv(tface->uv[2]);
- if(mface->v4) {
+ if(efa->v4) {
if(tface->flag & TF_SEL4) bglVertex2fv(tface->uv[3]);
}
}
- tface++;
- mface++;
}
bglEnd();
@@ -748,11 +700,12 @@ void image_editvertex_buts(uiBlock *block)
static float ocent[2];
float cent[2]= {0.0, 0.0};
int imx= 256, imy= 256;
- int i, nactive= 0, step, digits;
- Mesh *me;
+ int nactive= 0, step, digits;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
+ MTFace *tf;
if( is_uv_tface_editing_allowed_silent()==0 ) return;
- me= get_mesh(OBACT);
if (G.sima->image) {
ImBuf *ibuf= imagewindow_get_ibuf(G.sima);
@@ -762,12 +715,9 @@ void image_editvertex_buts(uiBlock *block)
}
}
- for (i=0; i<me->totface; i++) {
- MFace *mf= &((MFace*) me->mface)[i];
- MTFace *tf= &((MTFace*) me->mtface)[i];
-
- if (!(mf->flag & ME_FACE_SEL))
- continue;
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (!(efa->f & SELECT)) continue;
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (tf->flag & TF_SEL1) {
cent[0]+= tf->uv[0][0];
@@ -784,7 +734,7 @@ void image_editvertex_buts(uiBlock *block)
cent[1]+= tf->uv[2][1];
nactive++;
}
- if (mf->v4 && (tf->flag & TF_SEL4)) {
+ if (efa->v4 && (tf->flag & TF_SEL4)) {
cent[0]+= tf->uv[3][0];
cent[1]+= tf->uv[3][1];
nactive++;
@@ -834,13 +784,13 @@ void image_editvertex_buts(uiBlock *block)
delta[1]= ocent[1]/imy - cent[1];
}
- for (i=0; i<me->totface; i++) {
+ /*for (i=0; i<me->totface; i++) {
MFace *mf= &((MFace*) me->mface)[i];
- MTFace *tf= &((MTFace*) me->mtface)[i];
-
- if (!(mf->flag & ME_FACE_SEL))
- continue;
-
+ MTFace *tf= &((MTFace*) me->mtface)[i];*/
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (!(efa->f & SELECT)) continue;
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
if (tf->flag & TF_SEL1) {
tf->uv[0][0]+= delta[0];
tf->uv[0][1]+= delta[1];
@@ -853,7 +803,7 @@ void image_editvertex_buts(uiBlock *block)
tf->uv[2][0]+= delta[0];
tf->uv[2][1]+= delta[1];
}
- if (mf->v4 && (tf->flag & TF_SEL4)) {
+ if (efa->v4 && (tf->flag & TF_SEL4)) {
tf->uv[3][0]+= delta[0];
tf->uv[3][1]+= delta[1];
}
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c
index b1f30547860..41e08a9ab18 100644
--- a/source/blender/src/drawmesh.c
+++ b/source/blender/src/drawmesh.c
@@ -622,16 +622,19 @@ EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
{
EdgeHash *eh = BLI_edgehash_new();
int i;
-
+ MFace *mf;
+ MTFace *tf = NULL;
+
for (i=0; i<me->totface; i++) {
- MFace *mf = &me->mface[i];
- MTFace *tf = &me->mtface[i];
+ mf = &me->mface[i];
+ if (me->mtface)
+ tf = &me->mtface[i];
if (mf->v3) {
if (!(mf->flag&ME_HIDE)) {
unsigned int flags = eEdge_Visible;
if (mf->flag&ME_FACE_SEL) flags |= eEdge_Select;
- if (tf->flag&TF_ACTIVE) {
+ if (tf && tf->flag&TF_ACTIVE) {
flags |= eEdge_Active;
if (mf->flag&ME_FACE_SEL) flags |= eEdge_SelectAndActive;
}
@@ -645,7 +648,7 @@ EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
get_marked_edge_info__orFlags(eh, mf->v3, mf->v1, flags);
}
- if (tf->flag&TF_ACTIVE) {
+ if (tf && tf->flag&TF_ACTIVE) {
get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, eEdge_ActiveFirst);
get_marked_edge_info__orFlags(eh, mf->v1, mf->v4?mf->v4:mf->v3, eEdge_ActiveLast);
}
@@ -725,13 +728,10 @@ static int draw_tfaces3D__drawFaceOpts(void *userData, int index)
{
Mesh *me = (Mesh*)userData;
- if (me->mtface) {
- MFace *mface = &me->mface[index];
- if (!(mface->flag&ME_HIDE) && (mface->flag&ME_FACE_SEL))
- return 2; /* Don't set color */
- else
- return 0;
- } else
+ MFace *mface = &me->mface[index];
+ if (!(mface->flag&ME_HIDE) && (mface->flag&ME_FACE_SEL))
+ return 2; /* Don't set color */
+ else
return 0;
}
static void draw_tfaces3D(Object *ob, Mesh *me, DerivedMesh *dm)
@@ -1061,10 +1061,9 @@ static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmoot
MTFace *tface = (me->mtface)? &me->mtface[index]: NULL;
MFace *mface = (me->mface)? &me->mface[index]: NULL;
- if (tface) {
- if ((mface->flag&ME_HIDE) || (tface->mode&TF_INVISIBLE))
+ if ((mface->flag&ME_HIDE) || (tface && (tface->mode&TF_INVISIBLE)))
return 0;
- }
+
*drawSmooth_r = 1;
return 1;
}
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 1be02ba8923..1f7a3df73a9 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -2134,7 +2134,7 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
draw_wire = 1;
}
else if( (ob==OBACT && (G.f & (G_FACESELECT|G_TEXTUREPAINT))) || (G.vd->drawtype==OB_TEXTURE && dt>OB_SOLID)) {
- int faceselect= (ob==OBACT && (G.f & G_FACESELECT) && me->mtface);
+ int faceselect= (ob==OBACT && (G.f & G_FACESELECT));
if ((G.vd->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&(G_FACESELECT|G_PICKSEL)) && !draw_wire) {
draw_mesh_object_outline(ob, dm);
@@ -2199,7 +2199,7 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mcol) {
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1);
}
- else if((G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) && me->mtface) {
+ else if(G.f & (G_VERTEXPAINT+G_TEXTUREPAINT)) {
glColor3f(1.0f, 1.0f, 1.0f);
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0);
}
@@ -4346,7 +4346,7 @@ static int bbs_mesh_solid__setDrawOpts(void *userData, int index, int *drawSmoot
{
Mesh *me = userData;
- if (!me->mtface || !(me->mface[index].flag&ME_HIDE)) {
+ if (!(me->mface[index].flag&ME_HIDE)) {
set_framebuffer_index_color(index+1);
return 1;
} else {
@@ -4377,7 +4377,7 @@ static void bbs_mesh_solid(Object *ob)
/* draw edges for seam marking in faceselect mode, but not when painting,
so that painting doesn't get interrupted on an edge */
- if ((G.f & G_FACESELECT) && !(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) && me->mtface) {
+ if ((G.f & G_FACESELECT) && !(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))) {
struct { Mesh *me; EdgeHash *eh; int offset; } userData;
userData.me = me;
diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c
index cb35f09d12b..b22a3b30f0b 100644
--- a/source/blender/src/editface.c
+++ b/source/blender/src/editface.c
@@ -40,6 +40,7 @@
#include "BLI_arithb.h"
#include "BLI_heap.h"
#include "BLI_edgehash.h"
+#include "BLI_editVert.h"
#include "MTC_matrixops.h"
@@ -71,6 +72,7 @@
#include "BSE_drawview.h" /* for backdrawview3d */
#include "BIF_editsima.h"
+#include "BIF_editmesh.h"
#include "BIF_interface.h"
#include "BIF_mywindow.h"
#include "BIF_toolbox.h"
@@ -124,7 +126,7 @@
/* returns 0 if not found, otherwise 1 */
int facesel_face_pick(Mesh *me, short *mval, unsigned int *index, short rect)
{
- if (!me || !me->mtface || me->totface==0)
+ if (!me || me->totface==0)
return 0;
if (G.vd->flag & V3D_NEEDBACKBUFDRAW) {
@@ -175,27 +177,24 @@ static int facesel_edge_pick(Mesh *me, short *mval, unsigned int *index)
return 1;
}
-static void uv_calc_center_vector(float *result, Object *ob, Mesh *me)
+/* only operates on the edit object - this is all thats needed at the moment */
+static void uv_calc_center_vector(float *result, Object *ob, EditMesh *em)
{
float min[3], max[3], *cursx;
- int a;
- MTFace *tface;
- MFace *mface;
-
+
+ EditFace *efa;
switch (G.vd->around)
{
case V3D_CENTER: /* bounding box center */
min[0]= min[1]= min[2]= 1e20f;
max[0]= max[1]= max[2]= -1e20f;
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(mface->flag & ME_FACE_SEL) {
- DO_MINMAX((me->mvert+mface->v1)->co, min, max);
- DO_MINMAX((me->mvert+mface->v2)->co, min, max);
- DO_MINMAX((me->mvert+mface->v3)->co, min, max);
- if(mface->v4) DO_MINMAX((me->mvert+mface->v4)->co, min, max);
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ DO_MINMAX(efa->v1->co, min, max);
+ DO_MINMAX(efa->v2->co, min, max);
+ DO_MINMAX(efa->v3->co, min, max);
+ if(efa->v4) DO_MINMAX(efa->v4->co, min, max);
}
}
VecMidf(result, min, max);
@@ -340,27 +339,27 @@ static void uv_calc_shift_project(float *target, float *shift, float rotmat[][4]
void calculate_uv_map(unsigned short mapmode)
{
- Mesh *me;
MTFace *tface;
- MFace *mface;
+ /*MFace *mface;*/
Object *ob;
float dx, dy, rotatematrix[4][4], radius= 1.0, min[3], cent[3], max[3];
float fac= 1.0, upangledeg= 0.0, sideangledeg= 90.0;
- int i, b, mi, a, n;
+ int i, b, mi, n;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
+
if(G.scene->toolsettings->uvcalc_mapdir==1) {
upangledeg= 90.0;
sideangledeg= 0.0;
- }
- else {
+ } else {
upangledeg= 0.0;
if(G.scene->toolsettings->uvcalc_mapalign==1) sideangledeg= 0.0;
else sideangledeg= 90.0;
}
-
- me= get_mesh(ob=OBACT);
- if(me==0 || me->mtface==0) return;
- if(me->totface==0) return;
+
+ ob=OBACT;
+ if (!EM_texFaceCheck()) return;
switch(mapmode) {
case B_UVAUTO_BOUNDS:
@@ -369,16 +368,15 @@ void calculate_uv_map(unsigned short mapmode)
cent[0] = cent[1] = cent[2] = 0.0;
uv_calc_map_matrix(rotatematrix, ob, upangledeg, sideangledeg, 1.0f);
-
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(mface->flag & ME_FACE_SEL) {
- uv_calc_shift_project(tface->uv[0],cent,rotatematrix,3,(me->mvert+mface->v1)->co,min,max);
- uv_calc_shift_project(tface->uv[1],cent,rotatematrix,3,(me->mvert+mface->v2)->co,min,max);
- uv_calc_shift_project(tface->uv[2],cent,rotatematrix,3,(me->mvert+mface->v3)->co,min,max);
- if(mface->v4)
- uv_calc_shift_project(tface->uv[3],cent,rotatematrix,3,(me->mvert+mface->v4)->co,min,max);
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ uv_calc_shift_project(tface->uv[0],cent,rotatematrix,3, efa->v1->co, min,max);
+ uv_calc_shift_project(tface->uv[1],cent,rotatematrix,3, efa->v2->co, min,max);
+ uv_calc_shift_project(tface->uv[2],cent,rotatematrix,3, efa->v3->co,min,max);
+ if(efa->v4)
+ uv_calc_shift_project(tface->uv[3],cent,rotatematrix,3, efa->v4->co,min,max);
}
}
@@ -386,11 +384,10 @@ void calculate_uv_map(unsigned short mapmode)
dx= (max[0]-min[0]);
dy= (max[1]-min[1]);
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(mface->flag & ME_FACE_SEL) {
- if(mface->v4) b= 3; else b= 2;
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(efa->v4) b= 3; else b= 2;
for(; b>=0; b--) {
tface->uv[b][0]= ((tface->uv[b][0]-min[0])*fac)/dx;
tface->uv[b][1]= 1.0-fac+((tface->uv[b][1]-min[1])/* *fac */)/dy;
@@ -402,31 +399,30 @@ void calculate_uv_map(unsigned short mapmode)
case B_UVAUTO_WINDOW:
cent[0] = cent[1] = cent[2] = 0.0;
Mat4CpyMat4(rotatematrix,ob->obmat);
-
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(mface->flag & ME_FACE_SEL) {
- uv_calc_shift_project(tface->uv[0],cent,rotatematrix,4,(me->mvert+mface->v1)->co,NULL,NULL);
- uv_calc_shift_project(tface->uv[1],cent,rotatematrix,4,(me->mvert+mface->v2)->co,NULL,NULL);
- uv_calc_shift_project(tface->uv[2],cent,rotatematrix,4,(me->mvert+mface->v3)->co,NULL,NULL);
- if(mface->v4)
- uv_calc_shift_project(tface->uv[3],cent,rotatematrix,4,(me->mvert+mface->v4)->co,NULL,NULL);
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ uv_calc_shift_project(tface->uv[0],cent,rotatematrix,4, efa->v1->co, NULL,NULL);
+ uv_calc_shift_project(tface->uv[1],cent,rotatematrix,4, efa->v2->co, NULL,NULL);
+ uv_calc_shift_project(tface->uv[2],cent,rotatematrix,4, efa->v3->co, NULL,NULL);
+ if(efa->v4)
+ uv_calc_shift_project(tface->uv[3],cent,rotatematrix,4, efa->v4->co, NULL,NULL);
}
}
break;
case B_UVAUTO_RESET:
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, tface++, mface++)
- if(mface->flag & ME_FACE_SEL)
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
default_uv(tface->uv, 1.0);
+ }
+ }
break;
case B_UVAUTO_CYLINDER:
case B_UVAUTO_SPHERE:
- uv_calc_center_vector(cent, ob, me);
+ uv_calc_center_vector(cent, ob, em);
if(mapmode==B_UVAUTO_CYLINDER) radius = G.scene->toolsettings->uvcalc_radius;
@@ -435,17 +431,15 @@ void calculate_uv_map(unsigned short mapmode)
Mat4One(rotatematrix);
else
uv_calc_map_matrix(rotatematrix,ob,upangledeg,sideangledeg,radius);
-
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(mface->flag & ME_FACE_SEL) {
- uv_calc_shift_project(tface->uv[0],cent,rotatematrix,mapmode,(me->mvert+mface->v1)->co,NULL,NULL);
- uv_calc_shift_project(tface->uv[1],cent,rotatematrix,mapmode,(me->mvert+mface->v2)->co,NULL,NULL);
- uv_calc_shift_project(tface->uv[2],cent,rotatematrix,mapmode,(me->mvert+mface->v3)->co,NULL,NULL);
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ uv_calc_shift_project(tface->uv[0],cent,rotatematrix,mapmode, efa->v1->co, NULL,NULL);
+ uv_calc_shift_project(tface->uv[1],cent,rotatematrix,mapmode, efa->v2->co, NULL,NULL);
+ uv_calc_shift_project(tface->uv[2],cent,rotatematrix,mapmode, efa->v3->co, NULL,NULL);
n = 3;
- if(mface->v4) {
- uv_calc_shift_project(tface->uv[3],cent,rotatematrix,mapmode,(me->mvert+mface->v4)->co,NULL,NULL);
+ if(efa->v4) {
+ uv_calc_shift_project(tface->uv[3],cent,rotatematrix,mapmode, efa->v4->co, NULL,NULL);
n=4;
}
@@ -471,15 +465,14 @@ void calculate_uv_map(unsigned short mapmode)
float no[3];
short cox, coy;
float *loc= ob->obmat[3];
- MVert *mv= me->mvert;
+ /*MVert *mv= me->mvert;*/
float cubesize = G.scene->toolsettings->uvcalc_cubesize;
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(mface->flag & ME_FACE_SEL) {
- CalcNormFloat((mv+mface->v1)->co, (mv+mface->v2)->co, (mv+mface->v3)->co, no);
-
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, no);
+
no[0]= fabs(no[0]);
no[1]= fabs(no[1]);
no[2]= fabs(no[2]);
@@ -489,43 +482,42 @@ void calculate_uv_map(unsigned short mapmode)
else if(no[1]>=no[0] && no[1]>=no[2]) coy= 2;
else { cox= 1; coy= 2; }
- tface->uv[0][0]= 0.5+0.5*cubesize*(loc[cox] + (mv+mface->v1)->co[cox]);
- tface->uv[0][1]= 0.5+0.5*cubesize*(loc[coy] + (mv+mface->v1)->co[coy]);
+ tface->uv[0][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v1->co[cox]);
+ tface->uv[0][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v1->co[coy]);
dx = floor(tface->uv[0][0]);
dy = floor(tface->uv[0][1]);
tface->uv[0][0] -= dx;
tface->uv[0][1] -= dy;
- tface->uv[1][0]= 0.5+0.5*cubesize*(loc[cox] + (mv+mface->v2)->co[cox]);
- tface->uv[1][1]= 0.5+0.5*cubesize*(loc[coy] + (mv+mface->v2)->co[coy]);
+ tface->uv[1][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v2->co[cox]);
+ tface->uv[1][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v2->co[coy]);
tface->uv[1][0] -= dx;
tface->uv[1][1] -= dy;
- tface->uv[2][0]= 0.5+0.5*cubesize*(loc[cox] + (mv+mface->v3)->co[cox]);
- tface->uv[2][1]= 0.5+0.5*cubesize*(loc[coy] + (mv+mface->v3)->co[coy]);
+ tface->uv[2][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v3->co[cox]);
+ tface->uv[2][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v3->co[coy]);
tface->uv[2][0] -= dx;
tface->uv[2][1] -= dy;
- if(mface->v4) {
- tface->uv[3][0]= 0.5+0.5*cubesize*(loc[cox] + (mv+mface->v4)->co[cox]);
- tface->uv[3][1]= 0.5+0.5*cubesize*(loc[coy] + (mv+mface->v4)->co[coy]);
+ if(efa->v4) {
+ tface->uv[3][0]= 0.5+0.5*cubesize*(loc[cox] + efa->v4->co[cox]);
+ tface->uv[3][1]= 0.5+0.5*cubesize*(loc[coy] + efa->v4->co[coy]);
tface->uv[3][0] -= dx;
tface->uv[3][1] -= dy;
}
}
}
+ break;
}
- break;
default:
return;
} /* end switch mapmode */
/* clipping and wrapping */
if(G.sima && G.sima->flag & SI_CLIP_UV) {
- tface= me->mtface;
- mface= me->mface;
- for(a=0; a<me->totface; a++, mface++, tface++) {
- if(!(mface->flag & ME_FACE_SEL)) continue;
-
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (!(efa->f & SELECT)) continue;
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
dx= dy= 0;
- if(mface->v4) b= 3; else b= 2;
+ if(efa->v4) b= 3; else b= 2;
for(; b>=0; b--) {
while(tface->uv[b][0] + dx < 0.0) dx+= 0.5;
while(tface->uv[b][0] + dx > 1.0) dx-= 0.5;
@@ -533,7 +525,7 @@ void calculate_uv_map(unsigned short mapmode)
while(tface->uv[b][1] + dy > 1.0) dy-= 0.5;
}
- if(mface->v4) b= 3; else b= 2;
+ if(efa->v4) b= 3; else b= 2;
for(; b>=0; b--) {
tface->uv[b][0]+= dx;
CLAMP(tface->uv[b][0], 0.0, 1.0);
@@ -552,42 +544,40 @@ void calculate_uv_map(unsigned short mapmode)
allqueue(REDRAWIMAGE, 0);
}
-MTFace *get_active_tface(MCol **mcol)
+MTFace *get_active_tface(EditFace **act_efa, MCol **mcol)
{
- Mesh *me;
- MTFace *tf;
- MFace *mf;
- int a;
-
- if(OBACT==NULL || OBACT->type!=OB_MESH)
- return NULL;
+ EditMesh *em = G.editMesh;
+ EditFace *efa = NULL;
+ EditSelection *ese;
- me= get_mesh(OBACT);
- if(me==0 || me->mtface==0)
+ if(!EM_texFaceCheck())
return NULL;
-
- for(a=0, tf=me->mtface; a < me->totface; a++, tf++) {
- if(tf->flag & TF_ACTIVE) {
- if(mcol) *mcol = (me->mcol)? &me->mcol[a*4]: NULL;
- return tf;
+
+ for (ese = em->selected.last; ese; ese=ese->prev){
+ if(ese->type == EDITFACE) {
+ efa = (EditFace *)ese->data;
+ break;
}
}
-
- for(a=0, tf=me->mtface, mf=me->mface; a < me->totface; a++, tf++, mf++) {
- if(mf->flag & ME_FACE_SEL) {
- if(mcol) *mcol = (me->mcol)? &me->mcol[a*4]: NULL;
- return tf;
+ if (!efa) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT)
+ break;
}
}
-
- for(a=0, tf=me->mtface, mf=me->mface; a < me->totface; a++, tf++, mf++) {
- if((mf->flag & ME_HIDE)==0) {
- if(mcol) *mcol = (me->mcol)? &me->mcol[a*4]: NULL;
- return tf;
+
+ if (efa) {
+ if (mcol) {
+ if (CustomData_has_layer(&em->fdata, CD_MCOL))
+ *mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
+ else
+ *mcol = NULL;
}
+ if (act_efa) *act_efa = efa;
+ return CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
}
-
+ if (act_efa) *act_efa= NULL;
if(mcol) *mcol = NULL;
return NULL;
}
@@ -634,7 +624,7 @@ void reveal_tface()
int a;
me= get_mesh(OBACT);
- if(me==0 || me->mtface==0 || me->totface==0) return;
+ if(me==0 || me->totface==0) return;
mface= me->mface;
a= me->totface;
@@ -646,7 +636,7 @@ void reveal_tface()
mface++;
}
- BIF_undo_push("Reveal UV face");
+ BIF_undo_push("Reveal face");
object_tface_flags_changed(OBACT, 0);
}
@@ -658,7 +648,7 @@ void hide_tface()
int a;
me= get_mesh(OBACT);
- if(me==0 || me->mtface==0 || me->totface==0) return;
+ if(me==0 || me->totface==0) return;
if(G.qual & LR_ALTKEY) {
reveal_tface();
@@ -682,7 +672,7 @@ void hide_tface()
mface++;
}
- BIF_undo_push("Hide UV face");
+ BIF_undo_push("Hide face");
object_tface_flags_changed(OBACT, 0);
}
@@ -696,7 +686,7 @@ void select_linked_tfaces(int mode)
ob = OBACT;
me = get_mesh(ob);
- if(me==0 || me->mtface==0 || me->totface==0) return;
+ if(me==0 || me->totface==0) return;
if (mode==0 || mode==1) {
if (!(ob->lay & G.vd->lay))
@@ -716,7 +706,7 @@ void deselectall_tface()
int a, sel;
me= get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(me==0) return;
mface= me->mface;
a= me->totface;
@@ -738,7 +728,7 @@ void deselectall_tface()
mface++;
}
- BIF_undo_push("(De)select all UV face");
+ BIF_undo_push("(De)select all faces");
object_tface_flags_changed(OBACT, 0);
}
@@ -750,7 +740,7 @@ void selectswap_tface(void)
int a;
me= get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(me==0) return;
mface= me->mface;
a= me->totface;
@@ -763,7 +753,7 @@ void selectswap_tface(void)
mface++;
}
- BIF_undo_push("Select inverse UV face");
+ BIF_undo_push("Select inverse face");
object_tface_flags_changed(OBACT, 0);
}
@@ -1182,7 +1172,7 @@ void seam_mark_clear_tface(short mode)
int a;
me= get_mesh(OBACT);
- if(me==0 || me->mtface==0 || me->totface==0) return;
+ if(me==0 || me->totface==0) return;
if (mode == 0)
mode = pupmenu("Seams%t|Mark Border Seam %x1|Clear Seam %x2");
@@ -1257,7 +1247,7 @@ void face_select()
if (!facesel_face_pick(me, mval, &index, 1)) return;
- tsel= (((MTFace*)me->mtface)+index);
+ tsel= (((MTFace*)me->mtface)+index); /* check me->mtface before using */
msel= (((MFace*)me->mface)+index);
if (msel->flag & ME_HIDE) return;
@@ -1267,17 +1257,23 @@ void face_select()
mface = me->mface;
a = me->totface;
while (a--) {
- if (G.qual & LR_SHIFTKEY)
- tface->flag &= ~TF_ACTIVE;
- else {
- tface->flag &= ~TF_ACTIVE;
+ if (G.qual & LR_SHIFTKEY) {
+ if (me->mtface) {
+ tface->flag &= ~TF_ACTIVE;
+ }
+ } else {
+ if (me->mtface) {
+ tface->flag &= ~TF_ACTIVE;
+ }
mface->flag &= ~ME_FACE_SEL;
}
- tface++;
+ if (me->mtface) {
+ tface++;
+ }
mface++;
}
-
- tsel->flag |= TF_ACTIVE;
+ if (me->mtface)
+ tsel->flag |= TF_ACTIVE;
if (G.qual & LR_SHIFTKEY) {
if (msel->flag & ME_FACE_SEL)
@@ -1297,7 +1293,6 @@ void face_select()
void face_borderselect()
{
Mesh *me;
- MTFace *tface;
MFace *mface;
rcti rect;
struct ImBuf *ibuf;
@@ -1306,7 +1301,7 @@ void face_borderselect()
char *selar;
me= get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(me==0) return;
if(me->totface==0) return;
val= get_border(&rect, 3);
@@ -1339,7 +1334,7 @@ void face_borderselect()
}
mface= me->mface;
- for(a=1; a<=me->totface; a++, tface++, mface++) {
+ for(a=1; a<=me->totface; a++, mface++) {
if(selar[a]) {
if(mface->flag & ME_HIDE);
else {
@@ -1450,9 +1445,10 @@ void set_faceselect() /* toggle */
}
else if (me && (ob->lay & G.vd->lay)) {
G.f |= G_FACESELECT;
+ /*
if(me->mtface==NULL)
make_tfaces(me);
-
+ */
setcursor_space(SPACE_VIEW3D, CURSOR_FACESEL);
BIF_undo_push("Set UV Faceselect");
}
@@ -1461,7 +1457,7 @@ void set_faceselect() /* toggle */
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
- allqueue(REDRAWIMAGE, 0);
+ /*allqueue(REDRAWIMAGE, 0);*/
}
/* Texture Paint */
@@ -1619,71 +1615,3 @@ void texpaint_pick_uv(Object *ob, Mesh *mesh, unsigned int faceindex, short *xy,
dm->release(dm);
}
-
- /* Selects all faces which have the same uv-texture as the active face
- * @author Roel Spruit
- * @return Void
- * Errors: - Active object not in this layer
- * - No active face or active face has no UV-texture
- */
-void get_same_uv(void)
-{
- Object *ob;
- Mesh *me;
- MTFace *tface;
- MFace *mface;
- short a, foundtex=0;
- Image *ima;
- char uvname[160];
-
- ob = OBACT;
- if (!(ob->lay & G.vd->lay)) {
- error("The active object is not in this layer");
- return;
- }
- me = get_mesh(ob);
-
-
- /* Search for the active face with a UV-Texture */
- tface = me->mtface;
- a = me->totface;
- while (a--) {
- if(tface->flag & TF_ACTIVE){
- ima=tface->tpage;
- if(ima && ima->name){
- strcpy(uvname,ima->name);
- a=0;
- foundtex=1;
- }
- }
- tface++;
- }
-
- if(!foundtex) {
- error("No active face, or active face has no UV texture");
- return;
- }
-
- /* select everything with the same texture */
- tface = me->mtface;
- mface = me->mface;
- a = me->totface;
- while (a--) {
- ima=tface->tpage;
- if(!(mface->flag & ME_HIDE) && ima && ima->name){
- if(!strcmp(ima->name, uvname)){
- mface->flag |= ME_FACE_SEL;
- }
- else mface->flag &= ~ME_FACE_SEL;
- }
- else mface->flag &= ~ME_FACE_SEL;
- tface++;
- mface++;
- }
-
- /* image window redraw */
- BIF_undo_push("Get same UV");
-
- object_tface_flags_changed(OBACT, 0);
-}
-
diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c
index fe6708f5959..bc492dd859e 100644
--- a/source/blender/src/editmesh.c
+++ b/source/blender/src/editmesh.c
@@ -2164,3 +2164,16 @@ EditFace *EM_get_face_for_index(int index)
{
return g_em_face_array?g_em_face_array[index]:NULL;
}
+
+/* can we edit UV's for this mesh?*/
+int EM_texFaceCheck(void)
+{
+ /* some of these checks could be a touch overkill */
+ if ( (G.obedit) &&
+ (G.obedit->type == OB_MESH) &&
+ (G.editMesh) &&
+ (G.editMesh->faces.first) &&
+ (CustomData_has_layer(&G.editMesh->fdata, CD_MTFACE)))
+ return 1;
+ return 0;
+}
diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c
index 78cf2d17c04..d6781c8e430 100644
--- a/source/blender/src/editmesh_lib.c
+++ b/source/blender/src/editmesh_lib.c
@@ -2070,3 +2070,134 @@ void EM_fgon_flags(void)
}
}
+
+/* editmesh vertmap, copied from intern.mesh.c
+ * if do_face_idx_array is 0 it means we need to run it as well as freeing
+ * */
+
+UvVertMap *make_uv_vert_map_EM(int selected, int do_face_idx_array, float *limit)
+{
+ EditMesh *em = G.editMesh;
+ EditVert *ev;
+ EditFace *efa;
+ int totverts;
+
+ /* vars from original func */
+ UvVertMap *vmap;
+ UvMapVert *buf;
+ MTFace *tf;
+ unsigned int a;
+ int i, totuv, nverts;
+
+ if (do_face_idx_array)
+ EM_init_index_arrays(0, 0, 1);
+
+ /* we need the vert */
+ for (ev= em->verts.first, totverts=0; ev; ev= ev->next, totverts++) {
+ ev->tmp.l = totverts;
+ }
+
+ totuv = 0;
+
+ /* generate UvMapVert array */
+ for (efa= em->faces.first; efa; efa= efa->next)
+ if(!selected || ((!efa->h) && (efa->f & SELECT)))
+ totuv += (efa->v4)? 4: 3;
+
+ if(totuv==0)
+ return NULL;
+
+ vmap= (UvVertMap*)MEM_mallocN(sizeof(*vmap), "UvVertMap");
+ if (!vmap)
+ return NULL;
+
+ vmap->vert= (UvMapVert**)MEM_callocN(sizeof(*vmap->vert)*totverts, "UvMapVert*");
+ buf= vmap->buf= (UvMapVert*)MEM_mallocN(sizeof(*vmap->buf)*totuv, "UvMapVert");
+
+ if (!vmap->vert || !vmap->buf) {
+ free_uv_vert_map(vmap);
+ return NULL;
+ }
+
+ for (a=0, efa= em->faces.first; efa; a++, efa= efa->next) {
+ if(!selected || ((!efa->h) && (efa->f & SELECT))) {
+ nverts= (efa->v4)? 4: 3;
+
+ for(i=0; i<nverts; i++) {
+ buf->tfindex= i;
+ buf->f= a;
+ buf->separate = 0;
+
+ buf->next= vmap->vert[(*(&efa->v1 + i))->tmp.l];
+ vmap->vert[(*(&efa->v1 + i))->tmp.l]= buf;
+
+ buf++;
+ }
+ }
+ }
+
+ /* sort individual uvs for each vert */
+ for(a=0, ev=em->verts.first; ev; a++, ev= ev->next) {
+ UvMapVert *newvlist= NULL, *vlist=vmap->vert[a];
+ UvMapVert *iterv, *v, *lastv, *next;
+ float *uv, *uv2, uvdiff[2];
+
+ while(vlist) {
+ v= vlist;
+ vlist= vlist->next;
+ v->next= newvlist;
+ newvlist= v;
+
+ efa = EM_get_face_for_index(v->f);
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ uv = tf->uv[v->tfindex];
+
+ lastv= NULL;
+ iterv= vlist;
+
+ while(iterv) {
+ next= iterv->next;
+ efa = EM_get_face_for_index(iterv->f);
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ uv2 = tf->uv[iterv->tfindex];
+
+ Vec2Subf(uvdiff, uv2, uv);
+
+ if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) {
+ if(lastv) lastv->next= next;
+ else vlist= next;
+ iterv->next= newvlist;
+ newvlist= iterv;
+ }
+ else
+ lastv=iterv;
+
+ iterv= next;
+ }
+
+ newvlist->separate = 1;
+ }
+
+ vmap->vert[a]= newvlist;
+ }
+
+ if (do_face_idx_array)
+ EM_free_index_arrays();
+
+ return vmap;
+}
+
+UvMapVert *get_uv_map_vert_EM(UvVertMap *vmap, unsigned int v)
+{
+ return vmap->vert[v];
+}
+
+void free_uv_vert_map_EM(UvVertMap *vmap)
+{
+ if (vmap) {
+ if (vmap->vert) MEM_freeN(vmap->vert);
+ if (vmap->buf) MEM_freeN(vmap->buf);
+ MEM_freeN(vmap);
+ }
+}
+
diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c
index 10b0f3ea246..e5e84b5c9b7 100644
--- a/source/blender/src/editmesh_mods.c
+++ b/source/blender/src/editmesh_mods.c
@@ -85,6 +85,7 @@ editmesh_mods.c, UI level access, no geometry changes
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_toolbox.h"
+#include "BIF_editsima.h"
#ifdef WITH_VERSE
#include "BIF_verse.h"
@@ -1332,6 +1333,8 @@ void select_mesh_group_menu()
if (selcount) { /* update if data was selected */
G.totfacesel+=selcount;
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Select Similar Faces");
}
return;
@@ -1613,6 +1616,8 @@ void loop_multiselect(int looptype)
}
MEM_freeN(edarray);
allqueue(REDRAWVIEW3D,0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
}
/* ***************** MAIN MOUSE SELECTION ************** */
@@ -1708,8 +1713,10 @@ void mouse_mesh(void)
EM_selectmode_flush();
countall();
-
+
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
}
rightmouse_transform();
@@ -1837,6 +1844,9 @@ void selectconnected_mesh(int qual)
countall();
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
BIF_undo_push("Select Linked");
}
@@ -1937,6 +1947,8 @@ void hide_mesh(int swap)
G.totedgesel= G.totfacesel= G.totvertsel= 0;
allqueue(REDRAWVIEW3D, 0);
+ if(EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
BIF_undo_push("Hide");
}
@@ -1981,6 +1993,72 @@ void reveal_mesh(void)
BIF_undo_push("Reveal");
}
+void hide_tface_uv(int swap)
+{
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
+ MTFace *tface;
+
+ if( is_uv_tface_editing_allowed()==0 ) return;
+
+ if(swap) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if((tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))==0) {
+ if(!efa->v4)
+ EM_select_face(efa, 0);
+ else if(!(tface->flag & TF_SEL4))
+ EM_select_face(efa, 0);
+ }
+ }
+ }
+ } else {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
+ EM_select_face(efa, 0);
+ else if(efa->v4 && tface->flag & TF_SEL4)
+ EM_select_face(efa, 0);
+ }
+ }
+ }
+
+ /*deselects too many but ok for now*/
+ EM_deselect_flush();
+ EM_validate_selections();
+
+ BIF_undo_push("Hide UV");
+
+ object_tface_flags_changed(OBACT, 0);
+}
+
+void reveal_tface_uv(void)
+{
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
+ MTFace *tface;
+
+ if( is_uv_tface_editing_allowed()==0 ) return;
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (!(efa->h)) {
+ if (!(efa->f & SELECT)) {
+ EM_select_face(efa, 1);
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ tface->flag |= (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
+ }
+ }
+ }
+
+ EM_selectmode_flush();
+
+ BIF_undo_push("Reveal UV");
+
+ object_tface_flags_changed(OBACT, 0);
+}
+
void select_faces_by_numverts(int numverts)
{
EditMesh *em = G.editMesh;
@@ -2009,7 +2087,9 @@ void select_faces_by_numverts(int numverts)
countall();
addqueue(curarea->win, REDRAW, 0);
-
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
if (numverts==3)
BIF_undo_push("Select Triangles");
else if (numverts==4)
@@ -2116,6 +2196,9 @@ void select_sharp_edges(void)
countall();
addqueue(curarea->win, REDRAW, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
BIF_undo_push("Select Sharp Edges");
}
@@ -2259,6 +2342,8 @@ void select_linked_flat_faces(void)
countall();
addqueue(curarea->win, REDRAW, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Select Linked Flat Faces");
}
@@ -2329,6 +2414,8 @@ void select_non_manifold(void)
countall();
addqueue(curarea->win, REDRAW, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Select Non Manifold");
}
@@ -2367,6 +2454,8 @@ void selectswap_mesh(void) /* UI level */
countall();
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Select Swap");
@@ -2387,6 +2476,10 @@ void deselectall_mesh(void) /* this toggles!!!, UI level */
}
countall();
+
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
allqueue(REDRAWVIEW3D, 0);
}
}
@@ -2432,6 +2525,8 @@ void select_more(void)
countall();
addqueue(curarea->win, REDRAW, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Select More");
}
@@ -2499,6 +2594,8 @@ void select_less(void)
countall();
BIF_undo_push("Select Less");
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
}
@@ -2552,6 +2649,8 @@ void selectrandom_mesh(void) /* randomly selects a user-set % of vertices/edges/
BIF_undo_push("Select Random:Faces");
}
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
}
void editmesh_select_by_material(int index)
diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c
index b0e72244eb6..6cdc393d2c5 100644
--- a/source/blender/src/editmesh_tools.c
+++ b/source/blender/src/editmesh_tools.c
@@ -5837,7 +5837,7 @@ static void collapse_edgeuvs(void)
int curtag, balanced, collectionfound= 0, vcount;
float avg[2];
- if (!CustomData_has_layer(&G.editMesh->fdata, CD_MTFACE))
+ if (!EM_texFaceCheck())
return;
uvverts.first = uvverts.last = uvedges.first = uvedges.last = allcollections.first = allcollections.last = NULL;
@@ -5939,7 +5939,7 @@ static void collapseuvs(void)
int uvcount;
float uvav[2];
- if (!CustomData_has_layer(&G.editMesh->fdata, CD_MTFACE))
+ if (!EM_texFaceCheck())
return;
uvcount = 0;
@@ -6047,7 +6047,7 @@ int collapseEdges(void)
VECCOPY(((EditEdge*)curredge->eed)->v2->co,avgcount);
}
- if (CustomData_has_layer(&G.editMesh->fdata, CD_MTFACE)) {
+ if (EM_texFaceCheck()) {
/*uv collapse*/
for(eve=G.editMesh->verts.first; eve; eve=eve->next) eve->f1 = 0;
for(eed=G.editMesh->edges.first; eed; eed=eed->next) eed->f1 = 0;
@@ -6066,6 +6066,8 @@ int collapseEdges(void)
countall();
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
return mergecount;
}
@@ -6294,6 +6296,8 @@ void pathselect(void)
countall();
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
}
}
else{
@@ -6331,6 +6335,8 @@ void region_to_loop(void)
countall();
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Face Region to Edge Loop");
}
@@ -6489,6 +6495,8 @@ void loop_to_region(void)
freecollections(&allcollections);
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
BIF_undo_push("Edge Loop to Face Region");
}
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index d4c0f76b656..1bb546982f8 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -1613,7 +1613,10 @@ void enter_editmode(int wc)
G.obedit= ob;
make_editMesh();
allqueue(REDRAWBUTSLOGIC, 0);
- if(G.f & G_FACESELECT) allqueue(REDRAWIMAGE, 0);
+ /*if(G.f & G_FACESELECT) allqueue(REDRAWIMAGE, 0);*/
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
}
if (ob->type==OB_ARMATURE){
arm= base->object->data;
@@ -1688,7 +1691,10 @@ void exit_editmode(int flag) /* freedata==0 at render, 1= freedata, 2= do undo b
/* temporal */
countall();
-
+
+ if(EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
if(retopo_mesh_paint_check())
retopo_end_okee();
@@ -1699,9 +1705,7 @@ void exit_editmode(int flag) /* freedata==0 at render, 1= freedata, 2= do undo b
load_editMesh();
if(freedata) free_editMesh(G.editMesh);
-
- if(G.f & G_FACESELECT)
- allqueue(REDRAWIMAGE, 0);
+
if(G.f & G_WEIGHTPAINT)
mesh_octree_table(G.obedit, NULL, 'e');
}
@@ -3365,7 +3369,7 @@ void copy_attr_tface(short event)
MTFace *tface;
MFace *mface;
MCol *activemcol;
- MTFace *activetf= get_active_tface(&activemcol);
+ MTFace *activetf= get_active_tface(NULL, &activemcol);
int a;
if(activetf==NULL) return;
diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c
index 06593227dbf..6da1af19e3a 100644
--- a/source/blender/src/editsima.c
+++ b/source/blender/src/editsima.c
@@ -47,6 +47,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
+#include "BLI_editVert.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -91,6 +92,7 @@
#include "BIF_toolbox.h"
#include "BIF_transform.h"
#include "BIF_writeimage.h"
+#include "BIF_editmesh.h"
#include "BSE_drawipo.h"
#include "BSE_edit.h"
@@ -107,9 +109,9 @@
#include "blendef.h"
#include "multires.h"
#include "mydevice.h"
+#include "editmesh.h"
/* local prototypes */
-void clever_numbuts_sima(void);
void sel_uvco_inside_radius(short , MTFace *, int , float *, float *, short);
void uvedit_selectionCB(short , Object *, short *, float ); /* used in edit.c*/
@@ -130,21 +132,15 @@ void object_tface_flags_changed(Object *ob, int updateButtons)
int is_uv_tface_editing_allowed_silent(void)
{
- Mesh *me;
-
- if(G.obedit) return 0;
+ if(!EM_texFaceCheck()) return 0;
if(G.sima->mode!=SI_TEXTURE) return 0;
- if(!(G.f & G_FACESELECT)) return 0;
- me= get_mesh(OBACT);
- if(me==0 || me->mtface==0) return 0;
- if(multires_level1_test()) return 0;
-
+ if(multires_level1_test()) return 0;
return 1;
}
int is_uv_tface_editing_allowed(void)
{
- if(G.obedit) error("Unable to perform action in Edit Mode");
+ if(!G.obedit) error("Unable to perform action in Edit Mode");
return is_uv_tface_editing_allowed_silent();
}
@@ -160,110 +156,15 @@ void get_connected_limit_tface_uv(float *limit)
limit[0]= limit[1]= 0.05/256.0;
}
-void clever_numbuts_sima(void)
-{
- float ocent[2], cent[2]= {0.0, 0.0};
- int imx= 256, imy= 256;
- int i, nactive= 0;
- Mesh *me;
-
- if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
-
- if (G.sima->image) {
- ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
- if(ibuf) {
- imx= ibuf->x;
- imy= ibuf->y;
- }
- }
-
- for (i=0; i<me->totface; i++) {
- MFace *mf= &((MFace*) me->mface)[i];
- MTFace *tf= &((MTFace*) me->mtface)[i];
-
- if (!(mf->flag & ME_FACE_SEL))
- continue;
-
- if (tf->flag & TF_SEL1) {
- cent[0]+= tf->uv[0][0];
- cent[1]+= tf->uv[0][1];
- nactive++;
- }
- if (tf->flag & TF_SEL2) {
- cent[0]+= tf->uv[1][0];
- cent[1]+= tf->uv[1][1];
- nactive++;
- }
- if (tf->flag & TF_SEL3) {
- cent[0]+= tf->uv[2][0];
- cent[1]+= tf->uv[2][1];
- nactive++;
- }
- if (mf->v4 && (tf->flag & TF_SEL4)) {
- cent[0]+= tf->uv[3][0];
- cent[1]+= tf->uv[3][1];
- nactive++;
- }
- }
-
- if (nactive) {
- cent[0]= (cent[0]*imx)/nactive;
- cent[1]= (cent[1]*imy)/nactive;
-
- add_numbut(0, NUM|FLO, "LocX:", -imx*20, imx*20, &cent[0], NULL);
- add_numbut(1, NUM|FLO, "LocY:", -imy*20, imy*20, &cent[1], NULL);
-
- ocent[0]= cent[0];
- ocent[1]= cent[1];
- if (do_clever_numbuts((nactive==1)?"Active Vertex":"Selected Center", 2, REDRAW)) {
- float delta[2];
-
- delta[0]= (cent[0]-ocent[0])/imx;
- delta[1]= (cent[1]-ocent[1])/imy;
-
- for (i=0; i<me->totface; i++) {
- MFace *mf= &((MFace*) me->mface)[i];
- MTFace *tf= &((MTFace*) me->mtface)[i];
-
- if (!(mf->flag & ME_FACE_SEL))
- continue;
-
- if (tf->flag & TF_SEL1) {
- tf->uv[0][0]+= delta[0];
- tf->uv[0][1]+= delta[1];
- }
- if (tf->flag & TF_SEL2) {
- tf->uv[1][0]+= delta[0];
- tf->uv[1][1]+= delta[1];
- }
- if (tf->flag & TF_SEL3) {
- tf->uv[2][0]+= delta[0];
- tf->uv[2][1]+= delta[1];
- }
- if (mf->v4 && (tf->flag & TF_SEL4)) {
- tf->uv[3][0]+= delta[0];
- tf->uv[3][1]+= delta[1];
- }
- }
-
- object_uvs_changed(OBACT);
- }
- }
-}
-
-void be_square_tface_uv(Mesh *me)
+void be_square_tface_uv(EditMesh *em)
{
+ EditFace *efa;
MTFace *tface;
- MFace *mface;
- int a;
-
/* if 1 vertex selected: doit (with the selected vertex) */
- mface= (MFace*)me->mface;
- tface= (MTFace*)me->mtface;
- for(a=me->totface; a>0; a--, tface++, mface++) {
- if(mface->v4) {
- if(mface->flag & ME_FACE_SEL) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->v4) {
+ if (efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tface->flag & TF_SEL1) {
if( tface->uv[1][0] == tface->uv[2][0] ) {
tface->uv[1][1]= tface->uv[0][1];
@@ -361,14 +262,13 @@ void mirrormenu_tface_uv(void)
void weld_align_tface_uv(char tool)
{
- MFace *mface;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
MTFace *tface;
- Mesh *me;
float min[2], max[2], cent[2];
int a;
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
if (!minmax_tface_uv(min, max))
return;
@@ -377,34 +277,32 @@ void weld_align_tface_uv(char tool)
cent[1]= (min[1]+max[1])/2.0;
if(tool == 'x' || tool == 'w') {
- tface= me->mtface;
- mface= me->mface;
- for(a=me->totface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tface->flag & TF_SEL1)
tface->uv[0][0]= cent[0];
if(tface->flag & TF_SEL2)
tface->uv[1][0]= cent[0];
if(tface->flag & TF_SEL3)
tface->uv[2][0]= cent[0];
- if(mface->v4 && (tface->flag & TF_SEL4))
+ if(efa->v4 && (tface->flag & TF_SEL4))
tface->uv[3][0]= cent[0];
}
}
}
if(tool == 'y' || tool == 'w') {
- tface= me->mtface;
- mface= me->mface;
- for(a=me->totface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tface->flag & TF_SEL1)
tface->uv[0][1]= cent[1];
if(tface->flag & TF_SEL2)
tface->uv[1][1]= cent[1];
if(tface->flag & TF_SEL3)
tface->uv[2][1]= cent[1];
- if(mface->v4 && (tface->flag & TF_SEL4))
+ if(efa->v4 && (tface->flag & TF_SEL4))
tface->uv[3][1]= cent[1];
}
}
@@ -433,17 +331,17 @@ void weld_align_menu_tface_uv(void)
void select_invert_tface_uv(void)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
MTFace *tface;
MFace *mface;
int a;
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(efa->f & SELECT) {
+ tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE);
tface->flag ^= TF_SEL1;
tface->flag ^= TF_SEL2;
tface->flag ^= TF_SEL3;
@@ -458,28 +356,27 @@ void select_invert_tface_uv(void)
void select_swap_tface_uv(void)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
MTFace *tface;
- MFace *mface;
- int a, sel=0;
+ int sel=0;
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
-
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE);
if(tface->flag & (TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4)) {
sel= 1;
break;
}
}
}
-
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
- if(mface->v4) {
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE);
+ if(efa->v4) {
if(sel) tface->flag &= ~(TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4);
else tface->flag |= (TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4);
}
@@ -490,7 +387,7 @@ void select_swap_tface_uv(void)
}
}
- BIF_undo_push("Select swap UV");
+ BIF_undo_push("Select swap");
allqueue(REDRAWIMAGE, 0);
}
@@ -511,29 +408,26 @@ static int msel_hit(float *limit, unsigned int *hitarray, unsigned int vertexid,
return 0;
}
-static void find_nearest_tface(MTFace **nearesttf, MFace **nearestmf)
+static void find_nearest_tface(MTFace **nearesttf, EditFace **nearestefa)
{
- Mesh *me;
+ EditMesh *em= G.editMesh;
MTFace *tf;
- MFace *mf;
- int a, i, nverts, mindist, dist, fcenter[2], uval[2];
+ EditFace *efa;
+ /*MFace *mf;*/
+ int i, nverts, mindist, dist, fcenter[2], uval[2];
short mval[2];
getmouseco_areawin(mval);
mindist= 0x7FFFFFF;
*nearesttf= NULL;
- *nearestmf= NULL;
-
- me= get_mesh(OBACT);
- mf= (MFace*)me ->mface;
- tf= (MTFace*)me->mtface;
-
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(mf->flag & ME_FACE_SEL) {
-
+ *nearestefa= NULL;
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
fcenter[0]= fcenter[1]= 0;
- nverts= mf->v4? 4: 3;
+ nverts= efa->v4? 4: 3;
for(i=0; i<nverts; i++) {
uvco_to_areaco_noclip(tf->uv[i], uval);
fcenter[0] += uval[0];
@@ -546,7 +440,7 @@ static void find_nearest_tface(MTFace **nearesttf, MFace **nearestmf)
dist= abs(mval[0]- fcenter[0])+ abs(mval[1]- fcenter[1]);
if (dist < mindist) {
*nearesttf= tf;
- *nearestmf= mf;
+ *nearestefa= efa;
mindist= dist;
}
}
@@ -582,25 +476,22 @@ static int nearest_uv_between(MTFace *tf, int nverts, int id, short *mval, int *
static void find_nearest_uv(MTFace **nearesttf, unsigned int *nearestv, int *nearestuv)
{
- Mesh *me;
+ EditMesh *em= G.editMesh;
+ EditFace *efa;
MTFace *tf;
- MFace *mf;
- int a, i, nverts, mindist, dist, uval[2];
+ /*MFace *mf;*/
+ int i, nverts, mindist, dist, uval[2];
short mval[2];
getmouseco_areawin(mval);
mindist= 0x7FFFFFF;
*nearesttf= NULL;
-
- me= get_mesh(OBACT);
- mf= (MFace*)me->mface;
- tf= (MTFace*)me->mtface;
-
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(mf->flag & ME_FACE_SEL) {
-
- nverts= mf->v4? 4: 3;
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ nverts= efa->v4? 4: 3;
for(i=0; i<nverts; i++) {
uvco_to_areaco_noclip(tf->uv[i], uval);
dist= abs(mval[0]-uval[0]) + abs(mval[1]-uval[1]);
@@ -618,10 +509,10 @@ static void find_nearest_uv(MTFace **nearesttf, unsigned int *nearestv, int *nea
*nearesttf= tf;
*nearestuv= i;
- if (i==0) *nearestv= mf->v1;
- else if (i==1) *nearestv= mf->v2;
- else if (i==2) *nearestv= mf->v3;
- else *nearestv= mf->v4;
+ if (i==0) *nearestv= efa->v1->tmp.l;
+ else if (i==1) *nearestv= efa->v2->tmp.l;
+ else if (i==2) *nearestv= efa->v3->tmp.l;
+ else *nearestv= efa->v4->tmp.l;
}
}
}
@@ -630,15 +521,15 @@ static void find_nearest_uv(MTFace **nearesttf, unsigned int *nearestv, int *nea
void mouse_select_sima(void)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
MTFace *tf, *nearesttf;
- MFace *mf, *nearestmf=NULL;
+ EditFace *nearestefa=NULL;
int a, selectsticky, sticky, actface, nearestuv, i;
unsigned int hitv[4], nearestv;
float *hituv[4], limit[2];
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
get_connected_limit_tface_uv(limit);
actface= (G.qual & LR_ALTKEY || G.sima->flag & SI_SELACTFACE);
@@ -654,7 +545,7 @@ void mouse_select_sima(void)
}
if(actface) {
- find_nearest_tface(&nearesttf, &nearestmf);
+ find_nearest_tface(&nearesttf, &nearestefa);
if(nearesttf==NULL)
return;
@@ -663,10 +554,12 @@ void mouse_select_sima(void)
for (i=0; i<4; i++)
hituv[i]= nearesttf->uv[i];
- hitv[0]= nearestmf->v1;
- hitv[1]= nearestmf->v2;
- hitv[2]= nearestmf->v3;
- hitv[3]= nearestmf->v4? nearestmf->v4: 0xFFFFFFFF;
+ hitv[0]= nearestefa->v1->tmp.l;
+ hitv[1]= nearestefa->v2->tmp.l;
+ hitv[2]= nearestefa->v3->tmp.l;
+
+ if (nearestefa->v4) hitv[3]= nearestefa->v4->tmp.l;
+ else hitv[3]= 0xFFFFFFFF;
}
else {
find_nearest_uv(&nearesttf, &nearestv, &nearestuv);
@@ -685,7 +578,7 @@ void mouse_select_sima(void)
/* (de)select face */
if(actface) {
if(!(~nearesttf->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
- && (!nearestmf->v4 || nearesttf->flag & TF_SEL4)) {
+ && (!nearestefa->v4 || nearesttf->flag & TF_SEL4)) {
nearesttf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
selectsticky= 0;
}
@@ -708,42 +601,47 @@ void mouse_select_sima(void)
/* (de)select sticky uv nodes */
if(sticky || actface) {
- mf= (MFace*)me->mface;
- tf= (MTFace*)me->mtface;
+ EditVert *ev;
+
+ for (a=0, ev=em->verts.first; ev; ev = ev->next, a++)
+ ev->tmp.l = a;
+
/* deselect */
if(selectsticky==0) {
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(!(mf->flag & ME_FACE_SEL)) continue;
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(!(efa->f & SELECT)) continue;
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(nearesttf && tf!=nearesttf) tf->flag &=~ TF_ACTIVE;
if (!sticky) continue;
- if(msel_hit(limit, hitv, mf->v1, hituv, tf->uv[0], sticky))
+ if(msel_hit(limit, hitv, efa->v1->tmp.l, hituv, tf->uv[0], sticky))
tf->flag &= ~TF_SEL1;
- if(msel_hit(limit, hitv, mf->v2, hituv, tf->uv[1], sticky))
+ if(msel_hit(limit, hitv, efa->v2->tmp.l, hituv, tf->uv[1], sticky))
tf->flag &= ~TF_SEL2;
- if(msel_hit(limit, hitv, mf->v3, hituv, tf->uv[2], sticky))
+ if(msel_hit(limit, hitv, efa->v3->tmp.l, hituv, tf->uv[2], sticky))
tf->flag &= ~TF_SEL3;
- if (mf->v4)
- if(msel_hit(limit, hitv, mf->v4, hituv, tf->uv[3], sticky))
+ if (efa->v4)
+ if(msel_hit(limit, hitv, efa->v4->tmp.l, hituv, tf->uv[3], sticky))
tf->flag &= ~TF_SEL4;
}
}
/* select */
else {
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(!(mf->flag & ME_FACE_SEL)) continue;
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(!(efa->f & SELECT)) continue;
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(nearesttf && tf!=nearesttf)
tf->flag &=~ TF_ACTIVE;
if (!sticky) continue;
- if(msel_hit(limit, hitv, mf->v1, hituv, tf->uv[0], sticky))
+ if(msel_hit(limit, hitv, efa->v1->tmp.l, hituv, tf->uv[0], sticky))
tf->flag |= TF_SEL1;
- if(msel_hit(limit, hitv, mf->v2, hituv, tf->uv[1], sticky))
+ if(msel_hit(limit, hitv, efa->v2->tmp.l, hituv, tf->uv[1], sticky))
tf->flag |= TF_SEL2;
- if(msel_hit(limit, hitv, mf->v3, hituv, tf->uv[2], sticky))
+ if(msel_hit(limit, hitv, efa->v3->tmp.l, hituv, tf->uv[2], sticky))
tf->flag |= TF_SEL3;
- if (mf->v4)
- if(msel_hit(limit, hitv, mf->v4, hituv, tf->uv[3], sticky))
+ if (efa->v4)
+ if(msel_hit(limit, hitv, efa->v4->tmp.l, hituv, tf->uv[3], sticky))
tf->flag |= TF_SEL4;
}
}
@@ -752,9 +650,8 @@ void mouse_select_sima(void)
else {
/* select face and deselect other faces */
if(actface) {
- mf= (MFace*)me->mface;
- tf= (MTFace*)me->mtface;
- for(a=me->totface; a>0; a--, tf++, mf++) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
if(nearesttf && tf!=nearesttf)
tf->flag &= ~TF_ACTIVE;
@@ -764,21 +661,20 @@ void mouse_select_sima(void)
}
/* deselect uvs, and select sticky uvs */
- mf= (MFace*)me->mface;
- tf= (MTFace*)me->mtface;
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(mf->flag & ME_FACE_SEL) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(efa->f & SELECT) {
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(!actface) tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
if(!sticky) continue;
- if(msel_hit(limit, hitv, mf->v1, hituv, tf->uv[0], sticky))
+ if(msel_hit(limit, hitv, efa->v1->tmp.l, hituv, tf->uv[0], sticky))
tf->flag |= TF_SEL1;
- if(msel_hit(limit, hitv, mf->v2, hituv, tf->uv[1], sticky))
+ if(msel_hit(limit, hitv, efa->v2->tmp.l, hituv, tf->uv[1], sticky))
tf->flag |= TF_SEL2;
- if(msel_hit(limit, hitv, mf->v3, hituv, tf->uv[2], sticky))
+ if(msel_hit(limit, hitv, efa->v3->tmp.l, hituv, tf->uv[2], sticky))
tf->flag |= TF_SEL3;
- if(mf->v4)
- if(msel_hit(limit, hitv, mf->v4, hituv, tf->uv[3], sticky))
+ if(efa->v4)
+ if(msel_hit(limit, hitv, efa->v4->tmp.l, hituv, tf->uv[3], sticky))
tf->flag |= TF_SEL4;
}
}
@@ -795,16 +691,15 @@ void mouse_select_sima(void)
void borderselect_sima(short whichuvs)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
MTFace *tface;
- MFace *mface;
rcti rect;
rctf rectf;
- int a, val;
+ int val;
short mval[2];
- if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
+ if( is_uv_tface_editing_allowed()==0) return;
val= get_border(&rect, 3);
@@ -816,10 +711,9 @@ void borderselect_sima(short whichuvs)
mval[1]= rect.ymax;
areamouseco_to_ipoco(G.v2d, mval, &rectf.xmax, &rectf.ymax);
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
-
- if(mface->flag & ME_FACE_SEL) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if(efa->f & SELECT) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (whichuvs == UV_SELECT_ALL) {
@@ -835,7 +729,7 @@ void borderselect_sima(short whichuvs)
if(val==LEFTMOUSE) tface->flag |= TF_SEL3;
else tface->flag &= ~TF_SEL3;
}
- if(mface->v4 && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) {
+ if(efa->v4 && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) {
if(val==LEFTMOUSE) tface->flag |= TF_SEL4;
else tface->flag &= ~TF_SEL4;
}
@@ -858,7 +752,7 @@ void borderselect_sima(short whichuvs)
if(val==LEFTMOUSE) tface->flag |= TF_SEL3;
else tface->flag &= ~TF_SEL3;
}
- if ((mface->v4) && (tface->unwrap & TF_PIN4) && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) {
+ if ((efa->v4) && (tface->unwrap & TF_PIN4) && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) {
if(val==LEFTMOUSE) tface->flag |= TF_SEL4;
else tface->flag &= ~TF_SEL4;
}
@@ -920,37 +814,29 @@ static void getSpaceImageDimension(SpaceImage *sima, float *xy)
void uvedit_selectionCB(short selecting, Object *editobj, short *mval, float rad)
{
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
float offset[2];
- Mesh *me;
- MFace *mface;
MTFace *tface;
- int i;
float ellipse[2]; // we need to deal with ellipses, as
// non square textures require for circle
// selection. this ellipse is normalized; r = 1.0
-
- me = get_mesh(editobj);
getSpaceImageDimension(curarea->spacedata.first, ellipse);
ellipse[0] /= rad;
ellipse[1] /= rad;
areamouseco_to_ipoco(G.v2d, mval, &offset[0], &offset[1]);
-
- mface= me->mface;
- tface= me->mtface;
-
+
if (selecting) {
- for(i = 0; i < me->totface; i++) {
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
sel_uvco_inside_radius(selecting, tface, 0, offset, ellipse, TF_SEL1);
sel_uvco_inside_radius(selecting, tface, 1, offset, ellipse, TF_SEL2);
sel_uvco_inside_radius(selecting, tface, 2, offset, ellipse, TF_SEL3);
- if (mface->v4)
+ if (efa->v4)
sel_uvco_inside_radius(selecting, tface, 3, offset, ellipse, TF_SEL4);
-
- tface++; mface++;
-
}
if(G.f & G_DRAWFACES) { /* full redraw only if necessary */
@@ -1009,78 +895,18 @@ void mouseco_to_curtile(void)
}
}
-void hide_tface_uv(int swap)
-{
- Mesh *me;
- MTFace *tface;
- MFace *mface;
- int a;
-
- if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
-
- if(swap) {
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
- if((tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))==0) {
- if(!mface->v4)
- mface->flag &= ~ME_FACE_SEL;
- else if(!(tface->flag & TF_SEL4))
- mface->flag &= ~ME_FACE_SEL;
- }
- }
- }
- } else {
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
- if(tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
- mface->flag &= ~ME_FACE_SEL;
- else if(mface->v4 && tface->flag & TF_SEL4)
- mface->flag &= ~ME_FACE_SEL;
- }
- }
- }
-
- BIF_undo_push("Hide UV");
-
- object_tface_flags_changed(OBACT, 0);
-}
-
-void reveal_tface_uv(void)
-{
- Mesh *me;
- MTFace *tface;
- MFace *mface;
- int a;
-
- if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
-
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(!(mface->flag & ME_HIDE)) {
- if(!(mface->flag & ME_FACE_SEL)) {
- mface->flag |= ME_FACE_SEL;
- tface->flag |= (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
- }
- }
- }
-
- BIF_undo_push("Reveal UV");
-
- object_tface_flags_changed(OBACT, 0);
-}
-
void stitch_uv_tface(int mode)
{
- Mesh *me;
MTFace *tf;
int a, vtot;
float newuv[2], limit[2];
UvMapVert *vlist, *iterv, *v;
- UvVertMap *vmap;
+ EditMesh *em = G.editMesh;
+ EditVert *ev;
+ EditFace *efa;
+
+ struct UvVertMap *vmap;
+
if(is_uv_tface_editing_allowed()==0)
return;
@@ -1102,16 +928,15 @@ void stitch_uv_tface(int mode)
}
}
- me= get_mesh(OBACT);
- tf= me->mtface;
-
- vmap= make_uv_vert_map(me->mface, tf, me->totface, me->totvert, 1, limit);
+ /*vmap= make_uv_vert_map(me->mface, tf, me->totface, me->totvert, 1, limit);*/
+ EM_init_index_arrays(0, 0, 1);
+ vmap= make_uv_vert_map_EM(1, 0, limit);
if(vmap == NULL)
return;
if(mode==0) {
- for(a=0; a<me->totvert; a++) {
- v = get_uv_map_vert(vmap, a);
+ for(a=0, ev= em->verts.first; ev; a++, ev= ev->next) {
+ v = get_uv_map_vert_EM(vmap, a);
if(v == NULL)
continue;
@@ -1120,9 +945,11 @@ void stitch_uv_tface(int mode)
vtot= 0;
for(iterv=v; iterv; iterv=iterv->next) {
- if (tf[iterv->f].flag & TF_SEL_MASK(iterv->tfindex)) {
- newuv[0] += tf[iterv->f].uv[iterv->tfindex][0];
- newuv[1] += tf[iterv->f].uv[iterv->tfindex][1];
+ efa = EM_get_face_for_index(iterv->f);
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if (tf->flag & TF_SEL_MASK(iterv->tfindex)) {
+ newuv[0] += tf->uv[iterv->tfindex][0];
+ newuv[1] += tf->uv[iterv->tfindex][1];
vtot++;
}
}
@@ -1131,16 +958,18 @@ void stitch_uv_tface(int mode)
newuv[0] /= vtot; newuv[1] /= vtot;
for(iterv=v; iterv; iterv=iterv->next) {
- if (tf[iterv->f].flag & TF_SEL_MASK(iterv->tfindex)) {
- tf[iterv->f].uv[iterv->tfindex][0]= newuv[0];
- tf[iterv->f].uv[iterv->tfindex][1]= newuv[1];
+ efa = EM_get_face_for_index(iterv->f);
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if (tf->flag & TF_SEL_MASK(iterv->tfindex)) {
+ tf->uv[iterv->tfindex][0]= newuv[0];
+ tf->uv[iterv->tfindex][1]= newuv[1];
}
}
}
}
} else if(mode==1) {
- for(a=0; a<me->totvert; a++) {
- vlist= get_uv_map_vert(vmap, a);
+ for(a=0, ev= em->verts.first; ev; a++, ev= ev->next) {
+ vlist= get_uv_map_vert_EM(vmap, a);
while(vlist) {
newuv[0]= 0; newuv[1]= 0;
@@ -1149,9 +978,12 @@ void stitch_uv_tface(int mode)
for(iterv=vlist; iterv; iterv=iterv->next) {
if((iterv != vlist) && iterv->separate)
break;
+ efa = EM_get_face_for_index(iterv->f);
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
if (tf[iterv->f].flag & TF_SEL_MASK(iterv->tfindex)) {
- newuv[0] += tf[iterv->f].uv[iterv->tfindex][0];
- newuv[1] += tf[iterv->f].uv[iterv->tfindex][1];
+ newuv[0] += tf->uv[iterv->tfindex][0];
+ newuv[1] += tf->uv[iterv->tfindex][1];
vtot++;
}
}
@@ -1162,21 +994,23 @@ void stitch_uv_tface(int mode)
for(iterv=vlist; iterv; iterv=iterv->next) {
if((iterv != vlist) && iterv->separate)
break;
- if (tf[iterv->f].flag & TF_SEL_MASK(iterv->tfindex)) {
- tf[iterv->f].uv[iterv->tfindex][0]= newuv[0];
- tf[iterv->f].uv[iterv->tfindex][1]= newuv[1];
+ efa = EM_get_face_for_index(iterv->f);
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if (tf->flag & TF_SEL_MASK(iterv->tfindex)) {
+ tf->uv[iterv->tfindex][0]= newuv[0];
+ tf->uv[iterv->tfindex][1]= newuv[1];
}
}
}
-
vlist= iterv;
}
}
}
- free_uv_vert_map(vmap);
-
- if(G.sima->flag & SI_BE_SQUARE) be_square_tface_uv(me);
+ free_uv_vert_map_EM(vmap);
+ EM_free_index_arrays();
+
+ if(G.sima->flag & SI_BE_SQUARE) be_square_tface_uv(em);
BIF_undo_push("Stitch UV");
@@ -1185,21 +1019,18 @@ void stitch_uv_tface(int mode)
void select_linked_tface_uv(int mode)
{
- Mesh *me;
- MFace *mf;
+ EditMesh *em= G.editMesh;
+ EditFace *efa;
MTFace *tf, *nearesttf=NULL;
UvVertMap *vmap;
UvMapVert *vlist, *iterv, *startv;
unsigned int *stack, stacksize= 0, nearestv;
char *flag;
- int a, nearestuv, i, nverts;
+ int a, nearestuv, i, nverts, j;
float limit[2];
-
if(is_uv_tface_editing_allowed()==0)
return;
- me= get_mesh(OBACT);
-
if (mode == 2) {
nearesttf= NULL;
nearestuv= 0;
@@ -1211,45 +1042,53 @@ void select_linked_tface_uv(int mode)
}
get_connected_limit_tface_uv(limit);
- vmap= make_uv_vert_map(me->mface, me->mtface, me->totface, me->totvert, 1, limit);
+ vmap= make_uv_vert_map_EM(1, 1, limit);
if(vmap == NULL)
return;
- stack= MEM_mallocN(sizeof(*stack)*me->totface, "UvLinkStack");
- flag= MEM_callocN(sizeof(*flag)*me->totface, "UvLinkFlag");
+ stack= MEM_mallocN(sizeof(*stack)* BLI_countlist(&em->faces), "UvLinkStack");
+ flag= MEM_callocN(sizeof(*flag)*BLI_countlist(&em->faces), "UvLinkFlag");
if (mode == 2) {
- tf= me->mtface;
- mf= me->mface;
- for(a=0; a<me->totface; a++, tf++, mf++)
- if(!(mf->flag & ME_HIDE) && (mf->flag & ME_FACE_SEL))
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(!(efa->h) && (efa->f & SELECT)) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) {
stack[stacksize]= a;
stacksize++;
flag[a]= 1;
}
- }
- else {
- tf= me->mtface;
- for(a=0; a<me->totface; a++, tf++)
+ }
+ }
+ } else {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tf == nearesttf) {
stack[stacksize]= a;
stacksize++;
flag[a]= 1;
break;
}
+ }
}
while(stacksize > 0) {
stacksize--;
a= stack[stacksize];
- mf= me->mface+a;
- tf= me->mtface+a;
+
+ for (j=0, efa= em->faces.first; efa; efa= efa->next, j++) {
+ if (j==a) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ break;
+ }
+ }
- nverts= mf->v4? 4: 3;
+ nverts= efa->v4? 4: 3;
for(i=0; i<nverts; i++) {
- vlist= get_uv_map_vert(vmap, *(&mf->v1 + i));
+ /* make_uv_vert_map_EM sets verts tmp.l to the indicies */
+ vlist= get_uv_map_vert_EM(vmap, (*(&efa->v1 + i))->tmp.l);
+
startv= vlist;
for(iterv=vlist; iterv; iterv=iterv->next) {
@@ -1272,17 +1111,19 @@ void select_linked_tface_uv(int mode)
}
if(mode==0 || mode==2) {
- for(a=0, tf=me->mtface; a<me->totface; a++, tf++)
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(flag[a])
tf->flag |= (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
else
tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
+ }
}
else if(mode==1) {
- mf= me->mface;
- for(a=0, tf=me->mtface; a<me->totface; a++, tf++, mf++) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
if(flag[a]) {
- if (mf->v4) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if (efa->v4) {
if((tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)))
break;
}
@@ -1291,21 +1132,28 @@ void select_linked_tface_uv(int mode)
}
}
- if (a<me->totface) {
- for(a=0, tf=me->mtface; a<me->totface; a++, tf++)
- if(flag[a])
+ /*if (a<me->totface) {*/
+ if (efa) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(flag[a]) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
+ }
+ }
}
else {
- for(a=0, tf=me->mtface; a<me->totface; a++, tf++)
- if(flag[a])
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(flag[a]) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
tf->flag |= (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
+ }
+ }
}
}
MEM_freeN(stack);
MEM_freeN(flag);
- free_uv_vert_map(vmap);
+ free_uv_vert_map_EM(vmap);
BIF_undo_push("Select linked UV");
scrarea_queue_winredraw(curarea);
@@ -1313,18 +1161,17 @@ void select_linked_tface_uv(int mode)
void unlink_selection(void)
{
- Mesh *me;
+ EditMesh *em= G.editMesh;
+ EditFace *efa;
MTFace *tface;
- MFace *mface;
int a;
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
- mface= me->mface;
- for(a=me->totface, tface= me->mtface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
- if(mface->v4) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if(efa->v4) {
if(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4))
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
} else {
@@ -1363,30 +1210,28 @@ void toggle_uv_select(int mode)
void pin_tface_uv(int mode)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
MTFace *tface;
- MFace *mface;
int a;
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
- mface= me->mface;
- tface= me->mtface;
- for(a=me->totface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(mode ==1){
if(tface->flag & TF_SEL1) tface->unwrap |= TF_PIN1;
if(tface->flag & TF_SEL2) tface->unwrap |= TF_PIN2;
if(tface->flag & TF_SEL3) tface->unwrap |= TF_PIN3;
- if(mface->v4)
+ if(efa->v4)
if(tface->flag & TF_SEL4) tface->unwrap |= TF_PIN4;
}
else if (mode ==0){
if(tface->flag & TF_SEL1) tface->unwrap &= ~TF_PIN1;
if(tface->flag & TF_SEL2) tface->unwrap &= ~TF_PIN2;
if(tface->flag & TF_SEL3) tface->unwrap &= ~TF_PIN3;
- if(mface->v4)
+ if(efa->v4)
if(tface->flag & TF_SEL4) tface->unwrap &= ~TF_PIN4;
}
}
@@ -1398,23 +1243,20 @@ void pin_tface_uv(int mode)
void select_pinned_tface_uv(void)
{
- Mesh *me;
+ EditMesh *em= G.editMesh;
+ EditFace *efa;
MTFace *tface;
- MFace *mface;
int a;
if( is_uv_tface_editing_allowed()==0 ) return;
- me= get_mesh(OBACT);
- mface= me->mface;
- tface= me->mtface;
- for(a=me->totface; a>0; a--, tface++, mface++) {
- if(mface->flag & ME_FACE_SEL) {
-
+ for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) {
+ if(efa->f & SELECT) {
+ tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (tface->unwrap & TF_PIN1) tface->flag |= TF_SEL1;
if (tface->unwrap & TF_PIN2) tface->flag |= TF_SEL2;
if (tface->unwrap & TF_PIN3) tface->flag |= TF_SEL3;
- if(mface->v4) {
+ if(efa->v4) {
if (tface->unwrap & TF_PIN4) tface->flag |= TF_SEL4;
}
@@ -1427,36 +1269,24 @@ void select_pinned_tface_uv(void)
int minmax_tface_uv(float *min, float *max)
{
- Mesh *me;
+ EditMesh *em= G.editMesh;
+ EditFace *efa;
MTFace *tf;
- MFace *mf;
- int a, sel;
-
+ int sel;
+
if( is_uv_tface_editing_allowed()==0 ) return 0;
- me= get_mesh(OBACT);
INIT_MINMAX2(min, max);
sel= 0;
- mf= (MFace*)me->mface;
- tf= (MTFace*)me->mtface;
- for(a=me->totface; a>0; a--, tf++, mf++) {
- if(mf->flag & ME_HIDE);
- else if(mf->flag & ME_FACE_SEL) {
-
- if (tf->flag & TF_SEL1) {
- DO_MINMAX2(tf->uv[0], min, max);
- }
- if (tf->flag & TF_SEL2) {
- DO_MINMAX2(tf->uv[1], min, max);
- }
- if (tf->flag & TF_SEL3) {
- DO_MINMAX2(tf->uv[2], min, max);
- }
- if (mf->v4 && tf->flag & TF_SEL4) {
- DO_MINMAX2(tf->uv[3], min, max);
- }
-
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->h);
+ else if(efa->f & SELECT) {
+ tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+ if (tf->flag & TF_SEL1) DO_MINMAX2(tf->uv[0], min, max);
+ if (tf->flag & TF_SEL2) DO_MINMAX2(tf->uv[1], min, max);
+ if (tf->flag & TF_SEL3) DO_MINMAX2(tf->uv[2], min, max);
+ if (efa->v4 && tf->flag & TF_SEL4) DO_MINMAX2(tf->uv[3], min, max);
sel = 1;
}
}
@@ -1578,11 +1408,6 @@ void sima_sample_color(void)
static void load_image_filesel(char *str) /* called from fileselect */
{
Image *ima= NULL;
-
- if(G.obedit) {
- error("Can't perfom this in editmode");
- return;
- }
ima= BKE_add_image_file(str);
if(ima) {
@@ -1609,6 +1434,9 @@ static void image_replace(Image *old, Image *new)
new->xrep= old->xrep;
new->yrep= old->yrep;
+ /* TODO - This is incorrect!! -
+ * replace should take all layers into account,
+ * should also work with editmode */
me= G.main->mesh.first;
while(me) {
@@ -1637,12 +1465,7 @@ static void image_replace(Image *old, Image *new)
static void replace_image_filesel(char *str) /* called from fileselect */
{
Image *ima=0;
-
- if(G.obedit) {
- error("Can't perfom this in editmode");
- return;
- }
-
+
ima= BKE_add_image_file(str);
if(ima) {
diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c
index 9bed12cb3da..80bebf0ec68 100644
--- a/source/blender/src/editview.c
+++ b/source/blender/src/editview.c
@@ -74,6 +74,7 @@
#include "BKE_mesh.h"
#include "BKE_object.h" /* fly mode where_is_object to get camera location */
#include "BKE_utildefines.h"
+#include "BKE_customdata.h"
#include "BIF_butspace.h"
#include "BIF_editaction.h"
@@ -591,7 +592,10 @@ static void do_lasso_select(short mcords[][2], short moves, short select)
do_lasso_select_armature(mcords, moves, select);
BIF_undo_push("Lasso select");
-
+
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
allqueue(REDRAWVIEW3D, 0);
countall();
}
@@ -1686,6 +1690,9 @@ void borderselect(void)
if(G.obedit->type==OB_MESH) {
do_mesh_box_select(&rect, (val==LEFTMOUSE));
allqueue(REDRAWVIEW3D, 0);
+ if (EM_texFaceCheck())
+ allqueue(REDRAWIMAGE, 0);
+
}
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
do_nurbs_box_select(&rect, val==LEFTMOUSE);
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index d6878d70165..649ce1438f9 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -72,6 +72,7 @@
#include "BIF_space.h"
#include "BIF_transform.h"
#include "BIF_toolbox.h"
+#include "BIF_editmesh.h"
#include "BSE_drawview.h"
#include "BSE_filesel.h"
@@ -137,7 +138,7 @@ void do_image_buttons(unsigned short event)
break;
case B_SIMAGEDRAW:
- if(G.f & G_FACESELECT) {
+ if (EM_texFaceCheck()) {
make_repbind(G.sima->image);
image_changed(G.sima, 1);
}
@@ -1132,7 +1133,7 @@ void image_buttons(void)
uiDefPulldownBut(block, image_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
xco+= xmax;
- if((G.f & G_FACESELECT) && !(ima && (G.sima->flag & SI_DRAWTOOL))) {
+ if((EM_texFaceCheck()) && !(ima && (G.sima->flag & SI_DRAWTOOL))) {
xmax= GetButStringLength("Select");
uiDefPulldownBut(block, image_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
xco+= xmax;
@@ -1145,8 +1146,7 @@ void image_buttons(void)
xmax= GetButStringLength(menuname);
uiDefPulldownBut(block, image_imagemenu, NULL, menuname, xco, -2, xmax-3, 24, "");
xco+= xmax;
-
- if((G.f & G_FACESELECT) && !(ima && (G.sima->flag & SI_DRAWTOOL))) {
+ if((EM_texFaceCheck()) && !(ima && (G.sima->flag & SI_DRAWTOOL))) {
xmax= GetButStringLength("UVs");
uiDefPulldownBut(block, image_uvsmenu, NULL, "UVs", xco, -2, xmax-3, 24, "");
xco+= xmax;
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c
index 79c86012276..c5b45b7ff33 100644
--- a/source/blender/src/header_view3d.c
+++ b/source/blender/src/header_view3d.c
@@ -1396,10 +1396,7 @@ void do_view3d_select_faceselmenu(void *arg, int event)
case 3: /* Select Inverse */
selectswap_tface();
break;
- case 4: /* Select Same UV */
- get_same_uv();
- break;
- case 5: /* Select Linked */
+ case 4: /* Select Linked */
select_linked_tfaces(2);
break;
}
@@ -1422,10 +1419,9 @@ static uiBlock *view3d_select_faceselmenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Same UV", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Linked Faces|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Linked Faces|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
@@ -4391,7 +4387,7 @@ uiBlock *view3d_sculptmenu(void *arg_unused)
static void do_view3d_facesel_propertiesmenu(void *arg, int event)
{
- MTFace *tf = get_active_tface(NULL);
+ MTFace *tf = get_active_tface(NULL, NULL);
if (tf) {
switch(event) {
@@ -4448,7 +4444,7 @@ static void do_view3d_facesel_propertiesmenu(void *arg, int event)
static uiBlock *view3d_facesel_propertiesmenu(void *arg_unused)
{
- MTFace *tf = get_active_tface(NULL);
+ MTFace *tf = get_active_tface(NULL, NULL);
uiBlock *block;
short yco = 20, menuwidth = 120;
@@ -4559,7 +4555,7 @@ static void do_view3d_faceselmenu(void *arg, int event)
case 1: /* copy UVs */
case 2: /* copy vertex colors */
me= get_mesh(OBACT);
- activetf = get_active_tface(&activemcol);
+ activetf = get_active_tface(NULL, &activemcol);
if (me && activetf) {
mf = me->mface;
@@ -4588,9 +4584,7 @@ static void do_view3d_faceselmenu(void *arg, int event)
case 3: /* set vertex colors */
clear_vpaint_selectedfaces();
break;
- case 8: /* uv calculation */
- uv_autocalc_tface();
- break;
+ /*case 8: uv calculation - removed */
case 7: /* rotate UVs */
rotate_uv_tface();
break;
@@ -4621,7 +4615,7 @@ static uiBlock *view3d_faceselmenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unwrap UVs|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
+
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate UVs|R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Mirror UVs|M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
@@ -4677,7 +4671,7 @@ static char *view3d_modeselect_pup(void)
if (ob->type == OB_MESH) {
str += sprintf(str, formatstr, "Sculpt Mode", V3D_SCULPTMODE_SEL, ICON_SCULPTMODE_HLT);
- str += sprintf(str, formatstr, "UV Face Select", V3D_FACESELECTMODE_SEL, ICON_FACESEL_HLT);
+ str += sprintf(str, formatstr, "Face Select", V3D_FACESELECTMODE_SEL, ICON_FACESEL_HLT);
str += sprintf(str, formatstr, "Vertex Paint", V3D_VERTEXPAINTMODE_SEL, ICON_VPAINT_HLT);
str += sprintf(str, formatstr, "Texture Paint", V3D_TEXTUREPAINTMODE_SEL, ICON_TPAINT_HLT);
str += sprintf(str, formatstr, "Weight Paint", V3D_WEIGHTPAINTMODE_SEL, ICON_WPAINT_HLT);
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index 1798e522f85..2221d21ae90 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -652,11 +652,8 @@ static void align_view_to_selected(View3D *v3d)
Object *obact= OBACT;
if (obact && obact->type==OB_MESH) {
Mesh *me= obact->data;
-
- if (me->mtface) {
- faceselect_align_view_to_selected(v3d, me, axis);
- addqueue(v3d->area->win, REDRAW, 1);
- }
+ faceselect_align_view_to_selected(v3d, me, axis);
+ addqueue(v3d->area->win, REDRAW, 1);
}
}
}
@@ -2360,8 +2357,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
BIF_undo();
else if(G.f & G_TEXTUREPAINT)
imagepaint_undo();
- else if (G.f & G_FACESELECT)
- uv_autocalc_tface();
+ /*else if (G.f & G_FACESELECT)
+ uv_autocalc_tface();*/
else {
single_user();
}
@@ -2401,7 +2398,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
Transform();
}
else if(G.qual==LR_ALTKEY) {
- /* if(G.obedit && G.obedit->type==OB_MESH) write_videoscape(); */
+ if(G.obedit) {
+ uv_autocalc_tface();
+ }
}
else if(G.qual==LR_CTRLKEY) {
if(G.obedit) {
@@ -4743,8 +4742,8 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
} else if (event == RIGHTMOUSE) {
event = LEFTMOUSE;
}
- }
-
+ }
+
if (sima->image && (sima->flag & SI_DRAWTOOL)) {
switch(event) {
case CKEY:
@@ -4769,13 +4768,13 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else
sima_sample_color();
}
- else if(G.f & G_FACESELECT)
+ else if(EM_texFaceCheck())
gesture();
else
sima_sample_color();
break;
case RIGHTMOUSE:
- if(G.f & G_FACESELECT)
+ if(EM_texFaceCheck())
mouse_select_sima();
else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))
sample_vpaint();
@@ -4845,7 +4844,8 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
}
break;
case PKEY:
- if(G.f & G_FACESELECT) {
+ /*if(G.f & G_FACESELECT) {*/
+ if (EM_texFaceCheck()) {
if(G.qual==LR_CTRLKEY)
pack_charts_tface_uv();
else if(G.qual==LR_SHIFTKEY)
@@ -4854,8 +4854,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
pin_tface_uv(0);
else
pin_tface_uv(1);
- }
- else {
+ } else {
if(G.qual==LR_SHIFTKEY) {
toggle_blockhandler(sa, IMAGE_HANDLER_PREVIEW, 0);
scrarea_queue_winredraw(sa);
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 5d69e87a123..00df69ee631 100644
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -1847,26 +1847,31 @@ static void createTransUVs(TransInfo *t)
{
TransData *td = NULL;
TransData2D *td2d = NULL;
- Mesh *me;
- MFace *mf;
MTFace *tf;
- int a, count=0, countsel=0;
+ int count=0, countsel=0;
int propmode = t->flag & T_PROP_EDIT;
+ EditMesh *em = G.editMesh;
+ EditFace *efa;
+
if(is_uv_tface_editing_allowed()==0) return;
- me= get_mesh(OBACT);
/* count */
+ /*
tf= me->mtface;
mf= me->mface;
for(a=me->totface; a>0; a--, tf++, mf++) {
if(mf->v3 && mf->flag & ME_FACE_SEL) {
+ */
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tf->flag & TF_SEL1) countsel++;
if(tf->flag & TF_SEL2) countsel++;
if(tf->flag & TF_SEL3) countsel++;
- if(mf->v4 && (tf->flag & TF_SEL4)) countsel++;
+ if(efa->v4 && (tf->flag & TF_SEL4)) countsel++;
if(propmode)
- count += (mf->v4)? 4: 3;
+ count += (efa->v4)? 4: 3;
}
}
@@ -1884,10 +1889,15 @@ static void createTransUVs(TransInfo *t)
td= t->data;
td2d= t->data2d;
+ /*
tf= me->mtface;
mf= me->mface;
for(a=me->totface; a>0; a--, tf++, mf++) {
if(mf->v3 && mf->flag & ME_FACE_SEL) {
+ */
+ for (efa= em->faces.first; efa; efa= efa->next) {
+ if (efa->f & SELECT) {
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(tf->flag & TF_SEL1 || propmode)
UVsToTransData(td++, td2d++, tf->uv[0], (tf->flag & TF_SEL1));
if(tf->flag & TF_SEL2 || propmode)
@@ -1895,7 +1905,7 @@ static void createTransUVs(TransInfo *t)
if(tf->flag & TF_SEL3 || propmode)
UVsToTransData(td++, td2d++, tf->uv[2], (tf->flag & TF_SEL3));
- if(mf->v4 && (tf->flag & TF_SEL4 || propmode))
+ if(efa->v4 && (tf->flag & TF_SEL4 || propmode))
UVsToTransData(td++, td2d++, tf->uv[3], (tf->flag & TF_SEL4));
}
}
@@ -1909,7 +1919,7 @@ void flushTransUVs(TransInfo *t)
TransData2D *td;
int a, width, height;
Object *ob= OBACT;
- Mesh *me= get_mesh(ob);
+ EditMesh *em = G.editMesh;
float aspx, aspy, invx, invy;
transform_aspect_ratio_tface_uv(&aspx, &aspy);
@@ -1930,7 +1940,7 @@ void flushTransUVs(TransInfo *t)
/* always call this, also for cancel (it transforms non-selected vertices...) */
if((G.sima->flag & SI_BE_SQUARE))
- be_square_tface_uv(me);
+ be_square_tface_uv(em);
/* this is overkill if G.sima->lock is not set, but still needed */
object_uvs_changed(ob);
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c
index 8e999e8bb31..33ced3b292c 100644
--- a/source/blender/src/transform_generics.c
+++ b/source/blender/src/transform_generics.c
@@ -218,18 +218,25 @@ void recalcData(TransInfo *t)
if (G.obedit) {
if (G.obedit->type == OB_MESH) {
- retopo_do_all();
-
- /* mirror modifier clipping? */
- if(t->state != TRANS_CANCEL)
- clipMirrorModifier(t, G.obedit);
-
- if(G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR)
- editmesh_apply_to_mirror(t);
+ if(t->spacetype==SPACE_IMAGE) {
+ flushTransUVs(t);
+ if (G.sima->flag & SI_LIVE_UNWRAP)
+ unwrap_lscm_live_re_solve();
+ } else {
- DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
-
- recalc_editnormals();
+ retopo_do_all();
+
+ /* mirror modifier clipping? */
+ if(t->state != TRANS_CANCEL)
+ clipMirrorModifier(t, G.obedit);
+
+ if(G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR)
+ editmesh_apply_to_mirror(t);
+
+ DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
+
+ recalc_editnormals();
+ }
}
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
Nurb *nu= editNurb.first;
@@ -314,11 +321,6 @@ void recalcData(TransInfo *t)
else
where_is_pose(ob);
}
- else if(t->spacetype==SPACE_IMAGE) {
- flushTransUVs(t);
- if (G.sima->flag & SI_LIVE_UNWRAP)
- unwrap_lscm_live_re_solve();
- }
else {
for(base= FIRSTBASE; base; base= base->next) {
Object *ob= base->object;
diff --git a/source/blender/src/unwrapper.c b/source/blender/src/unwrapper.c
index d92508f7729..0b7bd896caf 100644
--- a/source/blender/src/unwrapper.c
+++ b/source/blender/src/unwrapper.c
@@ -49,9 +49,11 @@
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_utildefines.h"
+#include "BKE_customdata.h"
#include "BLI_arithb.h"
#include "BLI_edgehash.h"
+#include "BLI_editVert.h"
#include "BIF_editsima.h"
#include "BIF_space.h"
@@ -189,44 +191,52 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
/* Parametrizer */
-ParamHandle *construct_param_handle(Mesh *me, short implicit, short fill, short sel)
+ParamHandle *construct_param_handle(EditMesh *em, short implicit, short fill, short sel)
{
int a;
MTFace *tf;
- MFace *mf;
+ /*MFace *mf;
MVert *mv;
- MEdge *medge;
+ MEdge *medge;*/
+
+ EditFace *efa;
+ EditEdge *eed;
+ EditVert *ev;
+
ParamHandle *handle;
handle = param_construct_begin();
- mv= me->mvert;
- mf= me->mface;
- tf= me->mtface;
- for (a=0; a<me->totface; a++, mf++, tf++) {
+ /* we need the vert */
+ for (ev= em->verts.first, a=0; ev; ev= ev->next, a++)
+ ev->tmp.l = a;
+
+ for (efa= em->faces.first; efa; efa= efa->next) {
ParamKey key, vkeys[4];
ParamBool pin[4], select[4];
float *co[4];
float *uv[4];
int nverts;
- if (mf->flag & ME_HIDE)
+ tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
+ if (efa->h)
continue;
- if (sel && !(mf->flag & ME_FACE_SEL))
+ if (sel && !(efa->f & SELECT))
continue;
if (implicit && !(tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)))
continue;
- key = (ParamKey)mf;
- vkeys[0] = (ParamKey)mf->v1;
- vkeys[1] = (ParamKey)mf->v2;
- vkeys[2] = (ParamKey)mf->v3;
+ key = (ParamKey)efa;
+ vkeys[0] = (ParamKey)efa->v1->tmp.l;
+ vkeys[1] = (ParamKey)efa->v2->tmp.l;
+ vkeys[2] = (ParamKey)efa->v3->tmp.l;
- co[0] = (mv+mf->v1)->co;
- co[1] = (mv+mf->v2)->co;
- co[2] = (mv+mf->v3)->co;
+ co[0] = efa->v1->co;
+ co[1] = efa->v2->co;
+ co[2] = efa->v3->co;
uv[0] = tf->uv[0];
uv[1] = tf->uv[1];
@@ -240,9 +250,9 @@ ParamHandle *construct_param_handle(Mesh *me, short implicit, short fill, short
select[1] = ((tf->flag & TF_SEL2) != 0);
select[2] = ((tf->flag & TF_SEL3) != 0);
- if (mf->v4) {
- vkeys[3] = (ParamKey)mf->v4;
- co[3] = (mv+mf->v4)->co;
+ if (efa->v4) {
+ vkeys[3] = (ParamKey)efa->v4->tmp.l;
+ co[3] = efa->v4->co;
uv[3] = tf->uv[3];
pin[3] = ((tf->unwrap & TF_PIN4) != 0);
select[3] = ((tf->flag & TF_SEL4) != 0);
@@ -255,12 +265,11 @@ ParamHandle *construct_param_handle(Mesh *me, short implicit, short fill, short
}
if (!implicit) {
- for(medge=me->medge, a=me->totedge; a>0; a--, medge++) {
- if(medge->flag & ME_SEAM) {
+ for (eed= em->edges.first; eed; eed= eed->next) {
+ if(eed->seam) {
ParamKey vkeys[2];
-
- vkeys[0] = (ParamKey)medge->v1;
- vkeys[1] = (ParamKey)medge->v2;
+ vkeys[0] = (ParamKey)eed->v1->tmp.l;
+ vkeys[1] = (ParamKey)eed->v2->tmp.l;
param_edge_set_seam(handle, vkeys);
}
}
@@ -271,17 +280,19 @@ ParamHandle *construct_param_handle(Mesh *me, short implicit, short fill, short
return handle;
}
+
+extern int EM_texFaceCheck();
+
void unwrap_lscm(short seamcut)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
ParamHandle *handle;
short abf = G.scene->toolsettings->unwrapper == 1;
short fillholes = G.scene->toolsettings->uvcalc_flag & 1;
- me= get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(!EM_texFaceCheck()) return;
- handle = construct_param_handle(me, 0, fillholes, seamcut == 0);
+ handle = construct_param_handle(em, 0, fillholes, seamcut == 0);
param_lscm_begin(handle, PARAM_FALSE, abf);
param_lscm_solve(handle);
@@ -304,17 +315,16 @@ void unwrap_lscm(short seamcut)
void minimize_stretch_tface_uv(void)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
ParamHandle *handle;
double lasttime;
short doit = 1, escape = 0, val, blend = 0;
unsigned short event = 0;
short fillholes = G.scene->toolsettings->uvcalc_flag & 1;
- me = get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(!EM_texFaceCheck()) return;
- handle = construct_param_handle(me, 1, fillholes, 1);
+ handle = construct_param_handle(em, 1, fillholes, 1);
lasttime = PIL_check_seconds_timer();
@@ -397,13 +407,12 @@ void minimize_stretch_tface_uv(void)
void pack_charts_tface_uv(void)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
ParamHandle *handle;
- me = get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(!EM_texFaceCheck()) return;
- handle = construct_param_handle(me, 1, 0, 1);
+ handle = construct_param_handle(em, 1, 0, 1);
param_pack(handle);
param_flush(handle);
param_delete(handle);
@@ -422,14 +431,13 @@ static ParamHandle *liveHandle = NULL;
void unwrap_lscm_live_begin(void)
{
- Mesh *me;
+ EditMesh *em = G.editMesh;
short abf = G.scene->toolsettings->unwrapper == 1;
short fillholes = G.scene->toolsettings->uvcalc_flag & 1;
- me= get_mesh(OBACT);
- if(me==0 || me->mtface==0) return;
+ if(!EM_texFaceCheck()) return;
- liveHandle = construct_param_handle(me, 0, fillholes, 1);
+ liveHandle = construct_param_handle(em, 0, fillholes, 1);
param_lscm_begin(liveHandle, PARAM_TRUE, abf);
}
diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c
index a1b08831a89..2f82cd2e2b2 100644
--- a/source/blender/src/vpaint.c
+++ b/source/blender/src/vpaint.c
@@ -177,7 +177,7 @@ void do_shared_vertexcol(Mesh *me)
mface= me->mface;
mcol= (char *)me->mcol;
for(a=me->totface; a>0; a--, mface++, mcol+=16) {
- if(tface==0 || (tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) {
+ if((tface && tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) {
scol= scolmain+4*mface->v1;
scol[0]++; scol[1]+= mcol[1]; scol[2]+= mcol[2]; scol[3]+= mcol[3];
scol= scolmain+4*mface->v2;
@@ -207,7 +207,7 @@ void do_shared_vertexcol(Mesh *me)
mface= me->mface;
mcol= (char *)me->mcol;
for(a=me->totface; a>0; a--, mface++, mcol+=16) {
- if(tface==0 || (tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) {
+ if((tface && tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) {
scol= scolmain+4*mface->v1;
mcol[1]= scol[1]; mcol[2]= scol[2]; mcol[3]= scol[3];
scol= scolmain+4*mface->v2;
@@ -329,7 +329,7 @@ void clear_vpaint_selectedfaces()
ob= OBACT;
me= get_mesh(ob);
- if(me==0 || me->mtface==0 || me->totface==0) return;
+ if(me==0 || me->totface==0) return;
if(!me->mcol)
make_vertexcol(0);
@@ -1371,9 +1371,9 @@ void vertex_paint()
if(me==NULL || me->totface==0) return;
if(ob->lay & G.vd->lay); else error("Active object is not in this layer");
- if(me->mtface==NULL && me->mcol==NULL) make_vertexcol(1);
+ if(me->mcol==NULL) make_vertexcol(1);
- if(me->mtface==NULL && me->mcol==NULL) return;
+ if(me->mcol==NULL) return;
/* ALLOCATIONS! No return after his line */