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)
This commit is contained in:
@@ -93,8 +93,12 @@ float (*mesh_getVertexCos(struct Mesh *me, int *numVerts_r))[3];
|
||||
|
||||
/* map from uv vertex to face (for select linked, stitch, uv suburf) */
|
||||
|
||||
struct UvVertMap;
|
||||
typedef struct UvVertMap UvVertMap;
|
||||
/* UvVertMap */
|
||||
|
||||
typedef struct UvVertMap {
|
||||
struct UvMapVert **vert;
|
||||
struct UvMapVert *buf;
|
||||
} UvVertMap;
|
||||
|
||||
typedef struct UvMapVert {
|
||||
struct UvMapVert *next;
|
||||
|
||||
@@ -1130,13 +1130,6 @@ float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3]
|
||||
#endif
|
||||
}
|
||||
|
||||
/* UvVertMap */
|
||||
|
||||
struct UvVertMap {
|
||||
struct UvMapVert **vert;
|
||||
struct UvMapVert *buf;
|
||||
};
|
||||
|
||||
UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned int totface, unsigned int totvert, int selected, float *limit)
|
||||
{
|
||||
UvVertMap *vmap;
|
||||
|
||||
@@ -34,10 +34,11 @@
|
||||
#define BDR_EDITFACE_H
|
||||
|
||||
struct MTFace;
|
||||
struct EditFace;
|
||||
struct Mesh;
|
||||
struct MCol;
|
||||
|
||||
struct MTFace *get_active_tface(struct MCol **mcol);
|
||||
struct MTFace *get_active_tface(struct EditFace **efa, struct MCol **mcol);
|
||||
void calculate_uv_map(unsigned short mapmode);
|
||||
void default_uv(float uv[][2], float size);
|
||||
void make_tfaces(struct Mesh *me);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#ifndef BIF_EDITMESH_H
|
||||
#define BIF_EDITMESH_H
|
||||
|
||||
#include "BKE_mesh.h"
|
||||
|
||||
struct EditMesh;
|
||||
struct EditFace;
|
||||
struct EditEdge;
|
||||
@@ -238,4 +240,11 @@ int merge_target( int target, int uvmerge);
|
||||
void pathselect(void);
|
||||
void loop_to_region(void);
|
||||
void region_to_loop(void);
|
||||
|
||||
UvVertMap *make_uv_vert_map_EM(int selected, int do_face_idx_array, float *limit);
|
||||
UvMapVert *get_uv_map_vert_EM(UvVertMap *vmap, unsigned int v);
|
||||
void free_uv_vert_map_EM(UvVertMap *vmap);
|
||||
|
||||
int EM_texFaceCheck(void); /* can we edit UV's for this mesh?*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
struct Mesh;
|
||||
|
||||
struct EditMesh;
|
||||
#define TF_PIN_MASK(id) (TF_PIN1 << id)
|
||||
#define TF_SEL_MASK(id) (TF_SEL1 << id)
|
||||
|
||||
@@ -65,7 +65,7 @@ void toggle_uv_select(int mode);
|
||||
void pin_tface_uv(int mode);
|
||||
void weld_align_menu_tface_uv(void);
|
||||
void weld_align_tface_uv(char tool);
|
||||
void be_square_tface_uv(struct Mesh *me);
|
||||
void be_square_tface_uv(struct EditMesh *em);
|
||||
void select_pinned_tface_uv(void);
|
||||
|
||||
void sima_sample_color(void);
|
||||
|
||||
@@ -104,5 +104,6 @@ extern EditVert *findnearestvert(int *dist, short sel, short strict);
|
||||
|
||||
/* ******************* editmesh_tools.c */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,15 +303,16 @@ 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);
|
||||
|
||||
if(dotile==2) {
|
||||
tface->mode &= ~TF_TILES;
|
||||
@@ -336,16 +332,12 @@ void image_changed(SpaceImage *sima, int dotile)
|
||||
else id_lib_extern(&sima->image->id);
|
||||
}
|
||||
}
|
||||
tface++;
|
||||
mface++;
|
||||
}
|
||||
|
||||
object_uvs_changed(OBACT);
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void uvco_to_areaco(float *vec, short *mval)
|
||||
@@ -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);
|
||||
@@ -415,35 +406,23 @@ void draw_tfaces(void)
|
||||
/* draw mesh without modifiers applied */
|
||||
|
||||
if (G.obedit) {
|
||||
DerivedMesh *dm = editmesh_get_derived_base();
|
||||
|
||||
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,12 +784,12 @@ 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];
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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,14 +728,11 @@ 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
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
@@ -370,15 +369,14 @@ 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,14 +465,13 @@ 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]);
|
||||
@@ -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;
|
||||
}
|
||||
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;
|
||||
EditMesh *em = G.editMesh;
|
||||
EditFace *efa = NULL;
|
||||
EditSelection *ese;
|
||||
|
||||
if(OBACT==NULL || OBACT->type!=OB_MESH)
|
||||
if(!EM_texFaceCheck())
|
||||
return NULL;
|
||||
|
||||
me= get_mesh(OBACT);
|
||||
if(me==0 || me->mtface==0)
|
||||
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,16 +1257,22 @@ void face_select()
|
||||
mface = me->mface;
|
||||
a = me->totface;
|
||||
while (a--) {
|
||||
if (G.qual & LR_SHIFTKEY)
|
||||
if (G.qual & LR_SHIFTKEY) {
|
||||
if (me->mtface) {
|
||||
tface->flag &= ~TF_ACTIVE;
|
||||
else {
|
||||
}
|
||||
} else {
|
||||
if (me->mtface) {
|
||||
tface->flag &= ~TF_ACTIVE;
|
||||
}
|
||||
mface->flag &= ~ME_FACE_SEL;
|
||||
}
|
||||
if (me->mtface) {
|
||||
tface++;
|
||||
}
|
||||
mface++;
|
||||
}
|
||||
|
||||
if (me->mtface)
|
||||
tsel->flag |= TF_ACTIVE;
|
||||
|
||||
if (G.qual & LR_SHIFTKEY) {
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ************** */
|
||||
@@ -1710,6 +1715,8 @@ void mouse_mesh(void)
|
||||
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,6 +2087,8 @@ 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");
|
||||
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -1689,6 +1692,9 @@ 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();
|
||||
|
||||
@@ -1700,8 +1706,6 @@ void exit_editmode(int flag) /* freedata==0 at render, 1= freedata, 2= do undo b
|
||||
|
||||
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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
@@ -592,6 +593,9 @@ static void do_lasso_select(short mcords[][2], short moves, short 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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -652,15 +652,12 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static short select_children(Object *ob, int recursive)
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -218,6 +218,12 @@ void recalcData(TransInfo *t)
|
||||
|
||||
if (G.obedit) {
|
||||
if (G.obedit->type == OB_MESH) {
|
||||
if(t->spacetype==SPACE_IMAGE) {
|
||||
flushTransUVs(t);
|
||||
if (G.sima->flag & SI_LIVE_UNWRAP)
|
||||
unwrap_lscm_live_re_solve();
|
||||
} else {
|
||||
|
||||
retopo_do_all();
|
||||
|
||||
/* mirror modifier clipping? */
|
||||
@@ -231,6 +237,7 @@ void recalcData(TransInfo *t)
|
||||
|
||||
recalc_editnormals();
|
||||
}
|
||||
}
|
||||
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
|
||||
Nurb *nu= editNurb.first;
|
||||
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user