New UV editor / Image Window features:

- Draw Faces in the UV editor
- Draw Faces, selected in the UV editor, in the 3D view
- Draw Shadow Mesh in the UV editor (for faces unselected in the 3D view)
- Select Linked UVs (LKEY)
- Unlink Selection (Alt+LKEY)
- Stick (Local) UVs to Mesh Vertex on selection
- Active Face Select
- Reload Image
- Show / Hide Faces in the UV editor (H, Shift+H, Alt+H)
- Proportional Editing (O, Shift+O)
- Stitch, Limit Stitch UVs (snap by mesh vertex)
- Weld / Align UVs (WKEY)
- UVs Snap to Pixels on/off switch
- RMB in Texture Paint or Vertex Paint mode picks color
- Select Inverse in Faceselect mode

I hope these are all the features that were commited. The new UV Mapping
panel (and code) will follow later.
This commit is contained in:
Brecht Van Lommel
2004-04-01 12:55:12 +00:00
parent d204f77251
commit d7f3f66728
12 changed files with 1347 additions and 163 deletions

View File

@@ -44,8 +44,9 @@ void reveal_tface(void);
void hide_tface(void);
void select_linked_tfaces(void);
void deselectall_tface(void);
void selectswap_tface(void);
void rotate_uv_tface(void);
struct TFace* face_pick(struct Mesh *me, short x, short y);
unsigned int face_pick(struct Mesh *me, short x, short y);
void face_select(void);
void face_borderselect(void);
float CalcNormUV(float *a, float *b, float *c);

View File

@@ -37,4 +37,9 @@ void mouse_select_sima(void);
void select_swap_tface_uv(void);
void tface_do_clip(void);
void transform_tface_uv(int mode);
void hide_tface_uv(int swap);
void reveal_tface_uv(void);
void stitch_uv_tface(int mode);
void unlink_selection(void);
void select_linked_tface_uv(void);

View File

@@ -423,6 +423,11 @@ typedef struct SpaceImaSel {
#define SI_EDITTILE 2
#define SI_CLIP_UV 4
#define SI_DRAWTOOL 8
#define SI_STICKYUVS 16
#define SI_DRAWSHADOW 32
#define SI_SELACTFACE 64
#define SI_NOPIXELSNAP 128
#define SI_LOCALSTICKY 256
/* SpaceText flags (moved from DNA_text_types.h) */

View File

@@ -63,6 +63,7 @@
#include "BKE_image.h"
#include "BDR_editface.h"
#include "BDR_editobject.h"
#include "BIF_gl.h"
#include "BIF_space.h"
@@ -300,88 +301,186 @@ void uvco_to_areaco_noclip(float *vec, short *mval)
mval[1]= y;
}
void draw_tfaces(void)
{
TFace *tface;
MFace *mface;
TFace *tface,*activetface = NULL;
MFace *mface,*activemface = NULL;
Mesh *me;
int a;
glPointSize(2.0);
char col1[4], col2[4];
glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
if(G.f & G_FACESELECT) {
me= get_mesh((G.scene->basact) ? (G.scene->basact->object) : 0);
if(me && me->tface) {
calc_image_view(G.sima, 'f'); /* float */
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
/* draw shadow mesh */
if(G.sima->flag & SI_DRAWSHADOW){
tface= me->tface;
mface= me->mface;
a= me->totface;
while(a--) {
if(tface->flag & TF_HIDE);
else if(mface->v3) {
cpack(0x707070);
glBegin(GL_LINE_LOOP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(mface->v4) glVertex2fv(tface->uv[3]);
glEnd();
}
tface++;
mface++;
}
}
/* draw transparent faces */
if(G.f & G_DRAWFACES) {
BIF_GetThemeColor4ubv(TH_FACE, col1);
BIF_GetThemeColor4ubv(TH_FACE_SELECT, col2);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
tface= me->tface;
mface= me->mface;
a= me->totface;
while(a--) {
if(mface->v3 && (tface->flag & TF_SELECT)) {
if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
(!mface->v4 || tface->flag & TF_SEL4))
glColor4ubv(col2);
else
glColor4ubv(col1);
glBegin(mface->v4?GL_QUADS:GL_TRIANGLES);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(mface->v4) glVertex2fv(tface->uv[3]);
glEnd();
}
tface++;
mface++;
}
glDisable(GL_BLEND);
}
tface= me->tface;
mface= me->mface;
a= me->totface;
while(a--) {
if(mface->v3 && (tface->flag & TF_SELECT) ) {
if(tface->flag & TF_ACTIVE){
activetface= tface;
activemface= mface;
}
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] );
glBegin(GL_LINE_LOOP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(mface->v4) glVertex2fv(tface->uv[3]);
glEnd();
setlinestyle(2);
/* colors: R=x G=y */
if(tface->flag & TF_ACTIVE) cpack(0xFF00);
else cpack(0xFFFFFF);
glBegin(GL_LINE_STRIP);
glVertex2fv( tface->uv[0] );
glVertex2fv( tface->uv[1] );
glEnd();
if(tface->flag & TF_ACTIVE) cpack(0xFF); else cpack(0xFFFFFF);
glBegin(GL_LINE_STRIP);
glVertex2fv( tface->uv[0] );
if(mface->v4) glVertex2fv( tface->uv[3] ); else glVertex2fv( tface->uv[2] );
glEnd();
cpack(0xFFFFFF);
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[0]);
if(mface->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] );
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(mface->v4) glVertex2fv(tface->uv[3]);
glEnd();
setlinestyle(0);
}
tface++;
mface++;
}
/* draw active face edges */
if (activetface){
/* colors: R=u G=v */
setlinestyle(2);
tface=activetface;
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]);
glEnd();
cpack(0xFF00);
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glEnd();
cpack(0xFF);
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[0]);
if(mface->v4) glVertex2fv(tface->uv[3]);
else glVertex2fv(tface->uv[2]);
glEnd();
cpack(0xFFFFFF);
glBegin(GL_LINE_STRIP);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(mface->v4) glVertex2fv(tface->uv[3]);
glEnd();
setlinestyle(0);
}
/* to make sure vertices markers are visible, draw them last */
BIF_GetThemeColor3ubv(TH_VERTEX, col1);
BIF_GetThemeColor3ubv(TH_VERTEX_SELECT, col2);
glColor4ubv(col2);
tface= me->tface;
mface= me->mface;
a= me->totface;
while(a--) {
if(mface->v3 && (tface->flag & TF_SELECT) ) {
glBegin(GL_POINTS);
if(tface->flag & TF_SEL1) BIF_ThemeColor(TH_VERTEX_SELECT);
else BIF_ThemeColor(TH_VERTEX);
if(tface->flag & TF_SEL1) glColor3ubv(col2);
else glColor3ubv(col1);
glVertex2fv(tface->uv[0]);
if(tface->flag & TF_SEL2) BIF_ThemeColor(TH_VERTEX_SELECT);
else BIF_ThemeColor(TH_VERTEX);
if(tface->flag & TF_SEL2) glColor3ubv(col2);
else glColor3ubv(col1);
glVertex2fv(tface->uv[1]);
if(tface->flag & TF_SEL3) BIF_ThemeColor(TH_VERTEX_SELECT);
else BIF_ThemeColor(TH_VERTEX);
if(tface->flag & TF_SEL3) glColor3ubv(col2);
else glColor3ubv(col1);
glVertex2fv(tface->uv[2]);
if(mface->v4) {
if(tface->flag & TF_SEL4) BIF_ThemeColor(TH_VERTEX_SELECT);
else BIF_ThemeColor(TH_VERTEX);
if(tface->flag & TF_SEL4) glColor3ubv(col2);
else glColor3ubv(col1);
glVertex2fv(tface->uv[3]);
}
glEnd();
}
tface++;
mface++;
}
@@ -412,6 +511,53 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty,
return rectmain;
}
static void draw_image_prop_circle(ImBuf *ibuf)
{
float aspx, aspy;
extern float prop_cent[3];
if(G.moving && G.f & G_PROPORTIONAL) {
if(ibuf==0 || ibuf->rect==0 || ibuf->x==0 || ibuf->y==0) {
aspx= aspy= 1.0;
}
else {
aspx= 256.0/ibuf->x;
aspy= 256.0/ibuf->y;
}
/* scale and translate the circle into place and draw it */
glPushMatrix();
glScalef(aspx, aspy, 1.0);
glTranslatef((1/aspx)*prop_cent[0] - prop_cent[0],
(1/aspy)*prop_cent[1] - prop_cent[1], 0.0);
draw_prop_circle();
glPopMatrix();
}
}
static void draw_image_view_icon(void)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glRasterPos2f(5.0, 5.0);
if(G.sima->flag & SI_STICKYUVS || G.sima->flag & SI_LOCALSTICKY)
BIF_draw_icon(ICON_A_WACKY_VERT_AND_SOME_LINES);
else
BIF_draw_icon(ICON_SOME_WACKY_VERTS_AND_LINES);
glRasterPos2f(25.0, 5.0);
if(G.sima->flag & SI_SELACTFACE)
BIF_draw_icon(ICON_CLIPUV_HLT);
else
BIF_draw_icon(ICON_CLIPUV_DEHLT);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
void drawimagespace(ScrArea *sa, void *spacedata)
{
ImBuf *ibuf= NULL;
@@ -516,7 +662,11 @@ void drawimagespace(ScrArea *sa, void *spacedata)
calc_image_view(G.sima, 'f'); /* float */
}
draw_image_prop_circle(ibuf);
myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
draw_image_view_icon();
draw_area_emboss(sa);
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
}

View File

@@ -70,6 +70,7 @@
#include "BIF_gl.h"
#include "BIF_mywindow.h"
#include "BIF_resources.h"
#include "BDR_editface.h"
#include "BDR_vpaint.h"
@@ -537,9 +538,42 @@ void draw_tfaces3D(Object *ob, Mesh *me)
DispList *dl;
float *v1, *v2, *v3, *v4, *extverts= NULL;
int a;
char col[4];
if(me==0 || me->tface==0) return;
glEnable(GL_DEPTH_TEST);
/* Draw Faces, selected in the UV editor */
if(G.f & G_DRAWFACES) {
mface= me->mface;
tface= me->tface;
BIF_GetThemeColor4ubv(TH_FACE_SELECT, col);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDepthMask(0); // disable write in zbuffer, needed for nice transp
for(a=me->totface; a>0; a--, mface++, tface++) {
if(mface->v3 && (tface->flag & TF_SELECT)) {
if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
(!mface->v4 || tface->flag & TF_SEL4)) {
glColor4ub(col[0], col[1], col[2], col[3]);
glBegin(mface->v4?GL_QUADS:GL_TRIANGLES);
glVertex3fv((me->mvert+mface->v1)->co);
glVertex3fv((me->mvert+mface->v2)->co);
glVertex3fv((me->mvert+mface->v3)->co);
if(mface->v4) glVertex3fv((me->mvert+mface->v4)->co);
glEnd();
}
}
}
glDisable(GL_BLEND);
glDepthMask(1); // restore write in zbuffer
}
glDisable(GL_DEPTH_TEST);
mface= me->mface;

View File

@@ -352,6 +352,30 @@ void deselectall_tface()
}
void selectswap_tface(void)
{
Mesh *me;
TFace *tface;
int a;
me= get_mesh(OBACT);
if(me==0 || me->tface==0) return;
tface= me->tface;
a= me->totface;
while(a--) {
if(tface->flag & TF_HIDE);
else {
if(tface->flag & TF_SELECT) tface->flag &= ~TF_SELECT;
else tface->flag |= TF_SELECT;
}
tface++;
}
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
}
void rotate_uv_tface()
{
Mesh *me;
@@ -427,16 +451,15 @@ void rotate_uv_tface()
* @param me the mesh with the faces to be picked
* @param x the x-coordinate to pick at
* @param y the y-coordinate to pick at
* @return the face under the cursor (0 if there was no face found)
* @return the face under the cursor (-1 if there was no face found)
*/
TFace* face_pick(Mesh *me, short x, short y)
unsigned int face_pick(Mesh *me, short x, short y)
{
unsigned int col;
int index;
TFace *ret = 0;
if (me==0 || me->tface==0) {
return ret;
return -1;
}
/* Have OpenGL draw in the back buffer with color coded face indices */
@@ -462,11 +485,9 @@ TFace* face_pick(Mesh *me, short x, short y)
/* Convert the color back to a face index */
index = framebuffer_to_index(col);
if (col==0 || index<=0 || index>me->totface) {
return ret;
return -1;
}
/* Return the face */
ret = ((TFace*)me->tface) + (index-1);
return ret;
return (index-1);
}
void face_select()
@@ -474,8 +495,10 @@ void face_select()
Object *ob;
Mesh *me;
TFace *tface, *tsel;
MFace *msel;
short mval[2];
int a;
unsigned int index;
/* Get the face under the cursor */
ob = OBACT;
@@ -484,8 +507,11 @@ void face_select()
}
me = get_mesh(ob);
getmouseco_areawin(mval);
tsel = face_pick(me, mval[0], mval[1]);
if (!tsel) return;
index = face_pick(me, mval[0], mval[1]);
if (index==-1) return;
tsel= (((TFace*)me->tface)+index);
msel= (((MFace*)me->mface)+index);
if (tsel->flag & TF_HIDE) return;
@@ -498,13 +524,24 @@ void face_select()
}
else {
tface->flag &= ~(TF_ACTIVE+TF_SELECT);
if (G.qual & LR_ALTKEY)
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
}
tface++;
}
tsel->flag |= TF_ACTIVE;
if (G.qual & LR_SHIFTKEY) {
if (G.qual & LR_ALTKEY) {
if(tsel->flag & TF_SELECT && !(~tsel->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
&& (!msel->v4 || tsel->flag & TF_SEL4))
tsel->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
else {
tsel->flag |= TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4;
tsel->flag |= TF_SELECT;
}
}
else if (G.qual & LR_SHIFTKEY) {
if (tsel->flag & TF_SELECT) {
tsel->flag &= ~TF_SELECT;
}
@@ -524,7 +561,6 @@ void face_select()
allqueue(REDRAWVIEW3D, 0);
}
void face_borderselect()
{
Mesh *me;
@@ -1386,6 +1422,7 @@ void face_draw()
IMG_BrushPtr brush;
IMG_CanvasPtr canvas = 0;
int rowBytes;
unsigned int face_index;
char *warn_packed_file = 0;
float uv[2], uv_old[2];
extern VPaint Gvp;
@@ -1416,7 +1453,9 @@ void face_draw()
if ((xy[0] != xy_old[0]) || (xy[1] != xy_old[1])) {
/* Get face to draw on */
face = face_pick(me, xy[0], xy[1]);
face_index = face_pick(me, xy[0], xy[1]);
if (face_index == -1) face = NULL;
else face = (((TFace*)me->tface)+face_index);
/* Check if this is another face. */
if (face != face_old) {

View File

@@ -31,6 +31,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifdef HAVE_CONFIG_H
@@ -82,6 +83,21 @@
#include "blendef.h"
#include "mydevice.h"
struct uvvertsort {
unsigned int v;
unsigned char tf_sel;
char flag;
TFace *tface;
};
static int compuvvert(const void *u1, const void *u2)
{
const struct uvvertsort *v1=u1, *v2=u2;
if (v1->v > v2->v) return 1;
else if (v1->v < v2->v) return -1;
return 0;
}
static int is_uv_tface_editing_allowed(void)
{
Mesh *me;
@@ -95,6 +111,18 @@ static int is_uv_tface_editing_allowed(void)
return 1;
}
static void setLinkedLimit(float *limit)
{
if(G.sima->image && G.sima->image->ibuf && G.sima->image->ibuf->x > 0 &&
G.sima->image->ibuf->y > 0) {
limit[0]= 5.0/(float)G.sima->image->ibuf->x;
limit[1]= 5.0/(float)G.sima->image->ibuf->y;
}
else
limit[0]= limit[1]= 5.0/256.0;
}
void clever_numbuts_sima(void)
{
float ocent[2], cent[2]= {0.0, 0.0};
@@ -190,25 +218,31 @@ static void sima_pixelgrid(float *loc, float sx, float sy)
float y;
float x;
if(G.sima->image && G.sima->image->ibuf) {
x= G.sima->image->ibuf->x;
y= G.sima->image->ibuf->y;
sx= floor(x*sx)/x;
if(G.sima->flag & SI_CLIP_UV) {
CLAMP(sx, 0, 1.0);
}
if(G.sima->flag & SI_NOPIXELSNAP) {
loc[0]= sx;
sy= floor(y*sy)/y;
if(G.sima->flag & SI_CLIP_UV) {
CLAMP(sy, 0, 1.0);
}
loc[1]= sy;
}
else {
loc[0]= sx;
loc[1]= sy;
if(G.sima->image && G.sima->image->ibuf) {
x= G.sima->image->ibuf->x;
y= G.sima->image->ibuf->y;
sx= floor(x*sx)/x;
if(G.sima->flag & SI_CLIP_UV) {
CLAMP(sx, 0, 1.0);
}
loc[0]= sx;
sy= floor(y*sy)/y;
if(G.sima->flag & SI_CLIP_UV) {
CLAMP(sy, 0, 1.0);
}
loc[1]= sy;
}
else {
loc[0]= sx;
loc[1]= sy;
}
}
}
@@ -299,18 +333,25 @@ void transform_tface_uv(int mode)
TFace *tface;
Mesh *me;
TransVert *transmain, *tv;
float dist, xdist, ydist, aspx, aspy;
float asp, dx1, dx2, dy1, dy2, phi, dphi, co, si;
float xref=1.0, yref=1.0, size[2], sizefac;
float dx, dy, dvec2[2], dvec[2], div, cent[2];
float x, y, min[2], max[2], vec[2], xtra[2], ivec[2];
int xim, yim, tot=0, a, b, firsttime=1, afbreek=0, midtog= 0, proj = 0;
int xim, yim, tot=0, a, b, firsttime=1, afbreek=0, align= 0;
int propmode= 0, proptot= 0, midtog= 0, proj= 0, prop_recalc= 1;
unsigned short event = 0;
short mval[2], val, xo, yo, xn, yn, xc, yc;
char str[32];
char str[80];
extern float prop_size, prop_cent[3];
extern int prop_mode;
if( is_uv_tface_editing_allowed()==0 ) return;
me= get_mesh(OBACT);
if(G.f & G_PROPORTIONAL) propmode= 1;
min[0]= min[1]= 10000.0;
max[0]= max[1]= -10000.0;
@@ -323,37 +364,57 @@ void transform_tface_uv(int mode)
else {
xim= yim= 256;
}
/* which vertices are involved */
for(a=me->totface, tface= me->tface, mface= me->mface; a>0; a--, tface++, mface++) {
if((tface->flag & TF_SELECT) && mface->v3) {
aspx = (float)xim/256.0;
aspy = (float)yim/256.0;
/* which vertices are involved? */
tface= me->tface;
mface= me->mface;
for(a=me->totface; a>0; a--, tface++, mface++) {
if(tface->flag & TF_SELECT) {
if(tface->flag & TF_SEL1) tot++;
if(tface->flag & TF_SEL2) tot++;
if(tface->flag & TF_SEL3) tot++;
if(tface->flag & TF_SEL4) tot++;
if(mface->v4 && (tface->flag & TF_SEL4)) tot++;
if(propmode) {
if(mface->v4) proptot+=4;
else proptot+=3;
}
}
}
if(tot==0) return;
if(propmode) tot= proptot;
G.moving= 1;
prop_size/= 3;
tv=transmain= MEM_callocN(tot*sizeof(TransVert), "transmain");
for(a=me->totface, tface= me->tface, mface= me->mface; a>0; a--, tface++, mface++) {
if((tface->flag & TF_SELECT) && mface->v3) {
if(tface->flag & TF_SEL1) {
tface= me->tface;
mface= me->mface;
for(a=me->totface; a>0; a--, tface++, mface++) {
if(mface->v3 && tface->flag & TF_SELECT) {
if (tface->flag & TF_SEL1 || propmode) {
tv->loc= tface->uv[0];
if(tface->flag & TF_SEL1) tv->flag= 1;
tv++;
}
if(tface->flag & TF_SEL2) {
if (tface->flag & TF_SEL2 || propmode) {
tv->loc= tface->uv[1];
if(tface->flag & TF_SEL2) tv->flag= 1;
tv++;
}
if(tface->flag & TF_SEL3) {
if (tface->flag & TF_SEL3 || propmode) {
tv->loc= tface->uv[2];
if(tface->flag & TF_SEL3) tv->flag= 1;
tv++;
}
if(tface->flag & TF_SEL4) {
tv->loc= tface->uv[3];
tv++;
if(mface->v4) {
if (tface->flag & TF_SEL4 || propmode) {
tv->loc= tface->uv[3];
if(tface->flag & TF_SEL4) tv->flag= 1;
tv++;
}
}
}
}
@@ -363,12 +424,16 @@ void transform_tface_uv(int mode)
while(a--) {
tv->oldloc[0]= tv->loc[0];
tv->oldloc[1]= tv->loc[1];
DO_MINMAX2(tv->loc, min, max);
if(tv->flag) {
DO_MINMAX2(tv->loc, min, max);
}
tv++;
}
cent[0]= (min[0]+max[0])/2.0;
cent[1]= (min[1]+max[1])/2.0;
prop_cent[0]= cent[0];
prop_cent[1]= cent[1];
ipoco_to_areaco_noclip(G.v2d, cent, mval);
xc= mval[0];
@@ -388,8 +453,35 @@ void transform_tface_uv(int mode)
while(afbreek==0) {
getmouseco_areawin(mval);
if(mval[0]!=xo || mval[1]!=yo || firsttime) {
if(((mval[0]!=xo || mval[1]!=yo) && !(mode=='w')) || firsttime) {
if(propmode && prop_recalc && transmain) {
a= tot;
tv= transmain;
while(a--) {
if(tv->oldloc[0]<min[0]) xdist= tv->oldloc[0]-min[0];
else if(tv->oldloc[0]>max[0]) xdist= tv->oldloc[0]-max[0];
else xdist= 0.0;
xdist*= aspx;
if(tv->oldloc[1]<min[1]) ydist= tv->oldloc[1]-min[1];
else if(tv->oldloc[1]>max[1]) ydist= tv->oldloc[1]-max[1];
else ydist= 0.0;
ydist*= aspy;
dist= sqrt(xdist*xdist + ydist*ydist);
if(dist==0.0) tv->fac= 1.0;
else if(dist > prop_size) tv->fac= 0.0;
else {
dist= (prop_size-dist)/prop_size;
if(prop_mode==1)
tv->fac= 3.0*dist*dist - 2.0*dist*dist*dist;
else tv->fac= dist*dist;
}
tv++;
}
prop_recalc= 0;
}
if(mode=='g') {
dx= mval[0]- xo;
@@ -418,13 +510,22 @@ void transform_tface_uv(int mode)
if(vec[1]> 1.0-max[1]) vec[1]= 1.0-max[1];
}
tv= transmain;
for(a=0; a<tot; a++, tv++) {
x= tv->oldloc[0]+vec[0];
y= tv->oldloc[1]+vec[1];
if (propmode) {
for(a=0; a<tot; a++, tv++) {
x= tv->oldloc[0]+tv->fac*vec[0];
y= tv->oldloc[1]+tv->fac*vec[1];
sima_pixelgrid(tv->loc, x, y);
sima_pixelgrid(tv->loc, x, y);
}
} else {
for(a=0; a<tot; a++, tv++) {
x= tv->oldloc[0]+vec[0];
y= tv->oldloc[1]+vec[1];
sima_pixelgrid(tv->loc, x, y);
}
}
ivec[0]= (vec[0]*xim);
ivec[1]= (vec[1]*yim);
@@ -447,7 +548,7 @@ void transform_tface_uv(int mode)
if(G.qual & LR_SHIFTKEY) phi+= dphi/30.0;
else phi+= dphi;
apply_keyb_grid(&phi, 0.0, (5.0/180)*M_PI, (1.0/180)*M_PI, U.flag & USER_AUTOROTGRID);
dx1= dx2;
@@ -457,10 +558,12 @@ void transform_tface_uv(int mode)
si= sin(phi);
asp= (float)yim/(float)xim;
tv= transmain;
for(a=0; a<tot; a++, tv++) {
if(propmode) {
co= cos(phi*tv->fac);
si= sin(phi*tv->fac);
}
x= ( co*( tv->oldloc[0]-cent[0]) - si*asp*(tv->oldloc[1]-cent[1]) ) +cent[0];
y= ( si*( tv->oldloc[0]-cent[0])/asp + co*(tv->oldloc[1]-cent[1]) ) +cent[1];
sima_pixelgrid(tv->loc, x, y);
@@ -473,15 +576,12 @@ void transform_tface_uv(int mode)
}
}
sprintf(str, "Rot: %.3f ", phi*180.0/M_PI);
headerprint(str);
}
}
else if(mode=='s') {
size[0]=size[1]= (sqrt( (float)((yc-mval[1])*(yc-mval[1])+(mval[0]-xc)*(mval[0]-xc)) ))/sizefac;
size[0]= size[1]= (sqrt((float)((yc-mval[1])*(yc-mval[1])+(mval[0]-xc)*(mval[0]-xc))))/sizefac;
if(midtog) size[proj]= 1.0;
apply_keyb_grid(size, 0.0, 0.1, 0.01, U.flag & USER_AUTOSIZEGRID);
@@ -529,22 +629,62 @@ void transform_tface_uv(int mode)
/* } */
tv= transmain;
for(a=0; a<tot; a++, tv++) {
if (propmode) {
for(a=0; a<tot; a++, tv++) {
x= size[0]*(tv->oldloc[0]-cent[0])+ cent[0] + xtra[0];
y= size[1]*(tv->oldloc[1]-cent[1])+ cent[1] + xtra[1];
sima_pixelgrid(tv->loc, x, y);
x= (tv->fac*size[0] + 1.00-tv->fac)*(tv->oldloc[0]-cent[0])+ cent[0] + xtra[0];
y= (tv->fac*size[1] + 1.00-tv->fac)*(tv->oldloc[1]-cent[1])+ cent[1] + xtra[1];
sima_pixelgrid(tv->loc, x, y);
}
} else {
for(a=0; a<tot; a++, tv++) {
x= size[0]*(tv->oldloc[0]-cent[0])+ cent[0] + xtra[0];
y= size[1]*(tv->oldloc[1]-cent[1])+ cent[1] + xtra[1];
sima_pixelgrid(tv->loc, x, y);
}
}
sprintf(str, "sizeX: %.3f sizeY: %.3f ", size[0], size[1]);
sprintf(str, "sizeX: %.3f sizeY: %.3f", size[0], size[1]);
headerprint(str);
}
else if(mode=='w') { /* weld / align */
tv= transmain;
for(a=0; a<tot; a++, tv++) {
x= tv->oldloc[0];
y= tv->oldloc[1];
if(align==0) {
x= cent[0];
y= cent[1];
}
else if(align==1) y= cent[1];
else if(align==2) x= cent[0];
tv->loc[0]= x;
tv->loc[1]= y;
if(G.sima->flag & SI_CLIP_UV) {
if(tv->loc[0]<0.0) tv->loc[0]= 0.0;
else if(tv->loc[0]>1.0) tv->loc[0]= 1.0;
if(tv->loc[1]<0.0) tv->loc[1]= 0.0;
else if(tv->loc[1]>1.0) tv->loc[1]= 1.0;
}
}
if(align==0)
sprintf(str, "Weld (X: Align along X, Y: Align along Y)");
else if(align==1)
sprintf(str, "X Axis Align (W: Weld, Y: Align along Y)");
else if(align==2)
sprintf(str, "Y Axis Align (W: Weld, X: Align along X)");
headerprint(str);
}
xo= mval[0];
yo= mval[1];
if(G.sima->lock) force_draw_plus(SPACE_VIEW3D);
if(G.sima->lock || mode=='w') force_draw_plus(SPACE_VIEW3D);
else force_draw();
firsttime= 0;
@@ -564,27 +704,69 @@ void transform_tface_uv(int mode)
afbreek= 1;
break;
case MIDDLEMOUSE:
midtog= ~midtog;
if(midtog) {
if( abs(mval[0]-xn) > abs(mval[1]-yn)) proj= 1;
else proj= 0;
firsttime= 1;
}
break;
case WHEELDOWNMOUSE:
case PADPLUSKEY:
if(propmode) {
prop_size*= 1.1;
prop_recalc= 1;
firsttime= 1;
}
break;
case WHEELUPMOUSE:
case PADMINUS:
if(propmode) {
prop_size*= 0.90909090;
prop_recalc= 1;
firsttime= 1;
}
break;
case WKEY:
case XKEY:
case YKEY:
if(event==XKEY) xref= -xref;
else yref= -yref;
if(mode!='w') {
if(event==XKEY) xref= -xref;
else yref= -yref;
}
else {
if(event==WKEY) align= 0;
else if(event==XKEY) align= 1;
else align= 2;
}
firsttime= 1;
break;
default:
arrows_move_cursor(event);
}
}
if(afbreek) break;
if(afbreek) {
if(!(event==ESCKEY || event == RIGHTMOUSE) &&
mode=='w' && align>0) {
/* implicit commit */
tv= transmain;
for(a=0; a<tot; a++, tv++) {
tv->oldloc[0]= tv->loc[0];
tv->oldloc[1]= tv->loc[1];
firsttime=1;
}
midtog= 1;
if(align==1) proj= 0;
else proj= 1;
mode= 'g';
getmouseco_areawin(mval);
xo= mval[0];
yo= mval[1];
afbreek= 0;
}
else
break;
}
}
}
@@ -598,7 +780,10 @@ void transform_tface_uv(int mode)
MEM_freeN(transmain);
if(mode=='g') if(G.sima->flag & SI_BE_SQUARE) be_square_tface_uv(me);
G.moving= 0;
prop_size*= 3;
makeDispList(OBACT);
allqueue(REDRAWVIEW3D, 0);
scrarea_queue_headredraw(curarea);
@@ -641,90 +826,262 @@ void select_swap_tface_uv(void)
allqueue(REDRAWIMAGE, 0);
}
static int msel_hit(float *limit, unsigned int *hitarray, unsigned int vertexid, float **uv, float *uv2)
{
int i;
for(i=0; i< 4; i++) {
if(hitarray[i] == vertexid) {
if(G.sima->flag & SI_LOCALSTICKY) {
if(fabs(uv[i][0]-uv2[0]) < limit[0] &&
fabs(uv[i][1]-uv2[1]) < limit[1])
return 1;
}
else return 1;
}
}
return 0;
}
void mouse_select_sima(void)
{
Mesh *me;
TFace *tface;
MFace *mface;
int temp, dist=100;
int a;
short mval[2], uval[2], val = 0;
char *flagpoin =0;
TFace *tface, *closesttface= NULL;
MFace *mface, *closestmface= NULL;
int a, redraw= 0, uvcent[2], selectsticky= 0, sticky, actface;
int temp, dist= 0x7FFFFFF, fdist= 0x7FFFFFF, fdistmin= 0x7FFFFFF;
short mval[2], uval[2], val= 0;
char *flagpoin= 0;
unsigned int hitvert[4]= {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
float *hituv[4], limit[2];
if( is_uv_tface_editing_allowed()==0 ) return;
me= get_mesh(OBACT);
getmouseco_areawin(mval);
setLinkedLimit(limit);
actface= (G.qual & LR_ALTKEY || G.sima->flag & SI_SELACTFACE);
sticky= (G.qual & LR_CTRLKEY || G.sima->flag & SI_STICKYUVS ||
G.sima->flag & SI_LOCALSTICKY);
/* go for one run through all faces. collect all information needed */
mface= me->mface;
for(a=me->totface, tface= me->tface; a>0; a--, tface++, mface++) {
if(tface->flag & TF_SELECT) {
tface= me->tface;
for(a=me->totface; a>0; a--, tface++, mface++) {
if(tface->flag & TF_SELECT && mface->v3) {
uvco_to_areaco_noclip(tface->uv[0], uval);
temp= abs(mval[0]- uval[0])+ abs(mval[1]- uval[1]);
if( tface->flag & TF_SEL1) temp+=5;
uvcent[0]= uval[0];
uvcent[1]= uval[1];
temp= abs(mval[0]-uval[0]) + abs(mval[1]-uval[1]);
if(tface->flag & TF_SEL1) temp += 5;
if(temp<dist) {
flagpoin= &tface->flag;
dist= temp;
val= TF_SEL1;
hitvert[1]= hitvert[2]= hitvert[3]= 0xFFFFFFFF;
hitvert[0]= mface->v1;
hituv[0]= tface->uv[0];
}
uvco_to_areaco_noclip(tface->uv[1], uval);
temp= abs(mval[0]- uval[0])+ abs(mval[1]- uval[1]);
if( tface->flag & TF_SEL2) temp+=5;
temp= abs(mval[0]-uval[0]) + abs(mval[1]-uval[1]);
uvcent[0] += uval[0];
uvcent[1] += uval[1];
if(tface->flag & TF_SEL2) temp += 5;
if(temp<dist) {
flagpoin= &tface->flag;
dist= temp;
val= TF_SEL2;
hitvert[0]= hitvert[2]= hitvert[3]= 0xFFFFFFFF;
hitvert[1]= mface->v2;
hituv[1]= tface->uv[1];
}
uvco_to_areaco_noclip(tface->uv[2], uval);
temp= abs(mval[0]- uval[0])+ abs(mval[1]- uval[1]);
if( tface->flag & TF_SEL3) temp+=5;
temp= abs(mval[0]-uval[0]) + abs(mval[1]-uval[1]);
uvcent[0] += uval[0];
uvcent[1] += uval[1];
if(tface->flag & TF_SEL3) temp += 5;
if(temp<dist) {
flagpoin= &tface->flag;
dist= temp;
val= TF_SEL3;
hitvert[0]= hitvert[1]= hitvert[3]= 0xFFFFFFFF;
hitvert[2]= mface->v3;
hituv[2]= tface->uv[2];
}
if(mface->v4) {
uvco_to_areaco_noclip(tface->uv[3], uval);
temp= abs(mval[0]- uval[0])+ abs(mval[1]- uval[1]);
if( tface->flag & TF_SEL4) temp+=5;
uvcent[0] += uval[0];
uvcent[1] += uval[1];
temp= abs(mval[0]-uval[0]) + abs(mval[1]-uval[1]);
if(tface->flag & TF_SEL4) temp += 5;
if(temp<dist) {
flagpoin= &tface->flag;
dist= temp;
val= TF_SEL4;
hitvert[0]= hitvert[1]= hitvert[2]= 0xFFFFFFFF;
hitvert[3] = mface->v4;
hituv[3]= tface->uv[3];
}
uvcent[0] /= 4;
uvcent[1] /= 4;
}
else {
uvcent[0] /= 3;
uvcent[1] /= 3;
}
/* find face closest to mouse */
if(actface) {
fdist= abs(mval[0]- uvcent[0])+ abs(mval[1]- uvcent[1]);
if (fdist < fdistmin){
closesttface= tface;
closestmface= mface;
fdistmin= fdist;
}
}
}
}
if(flagpoin) {
if(G.qual & LR_SHIFTKEY) {
if(*flagpoin & val) *flagpoin &= ~val;
else *flagpoin |= val;
if(!flagpoin)
return;
if(actface && closesttface) {
closesttface->flag |= TF_ACTIVE;
hitvert[0]= closestmface->v1;
hituv[0]= closesttface->uv[0];
hitvert[1]= closestmface->v2;
hituv[1]= closesttface->uv[1];
hitvert[2]= closestmface->v3;
hituv[2]= closesttface->uv[2];
if(closestmface->v4) {
hitvert[3]= closestmface->v4;
hituv[3]= closesttface->uv[3];
}
}
if(G.qual & LR_SHIFTKEY) {
/* (de)select face */
if(actface) {
if(!(~closesttface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
&& (!closestmface->v4 || closesttface->flag & TF_SEL4)) {
closesttface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
selectsticky= 0;
}
else {
closesttface->flag |= TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4;
selectsticky= 1;
}
}
/* (de)select uv node */
else {
for(a=me->totface, tface= me->tface; a>0; a--, tface++) {
if(tface->flag & TF_SELECT) {
tface->flag &= ~(TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4);
if(*flagpoin & val) {
*flagpoin &= ~val;
selectsticky= 0;
}
else {
*flagpoin |= val;
selectsticky= 1;
}
}
/* (de)select sticky uv nodes */
if(sticky || actface) {
mface= me->mface;
tface= me->tface;
/* deselect */
if(selectsticky==0) {
for(a=me->totface; a>0; a--, tface++, mface++) {
if(!(tface->flag & TF_SELECT && mface->v3)) continue;
if(closesttface && tface!=closesttface)
tface->flag &=~ TF_ACTIVE;
if (!sticky) continue;
if(msel_hit(limit,hitvert,mface->v1,hituv,tface->uv[0]))
tface->flag &= ~TF_SEL1;
if(msel_hit(limit,hitvert,mface->v2,hituv,tface->uv[1]))
tface->flag &= ~TF_SEL2;
if(msel_hit(limit,hitvert,mface->v3,hituv,tface->uv[2]))
tface->flag &= ~TF_SEL3;
if (mface->v4)
if(msel_hit(limit,hitvert,mface->v4,hituv,tface->uv[3]))
tface->flag &= ~TF_SEL4;
}
}
*flagpoin |= val;
/* select */
else {
for(a=me->totface; a>0; a--, tface++, mface++) {
if(!(tface->flag & TF_SELECT && mface->v3)) continue;
if(closesttface && tface!=closesttface)
tface->flag &=~ TF_ACTIVE;
if (!sticky) continue;
if(msel_hit(limit,hitvert,mface->v1,hituv,tface->uv[0]))
tface->flag |= TF_SEL1;
if(msel_hit(limit,hitvert,mface->v2,hituv,tface->uv[1]))
tface->flag |= TF_SEL2;
if(msel_hit(limit,hitvert,mface->v3,hituv,tface->uv[2]))
tface->flag |= TF_SEL3;
if (mface->v4)
if(msel_hit(limit,hitvert,mface->v4,hituv,tface->uv[3]))
tface->flag |= TF_SEL4;
}
}
}
}
else {
/* select face and deselect other faces */
if(actface) {
mface= me->mface;
tface= me->tface;
for(a=me->totface; a>0; a--, tface++, mface++) {
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
if(closesttface && tface!=closesttface)
tface->flag &=~ TF_ACTIVE;
}
if(closesttface)
closesttface->flag |= (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
redraw= 1;
}
/* deselect uvs, and select sticky uvs */
mface= me->mface;
tface= me->tface;
for(a=me->totface; a>0; a--, tface++, mface++) {
if(tface->flag & TF_SELECT && mface->v3) {
if(!actface) tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
if(!sticky) continue;
if(msel_hit(limit,hitvert,mface->v1,hituv,tface->uv[0]))
tface->flag |=TF_SEL1;
if(msel_hit(limit,hitvert,mface->v2,hituv,tface->uv[1]))
tface->flag |=TF_SEL2;
if(msel_hit(limit,hitvert,mface->v3,hituv,tface->uv[2]))
tface->flag |=TF_SEL3;
if(mface->v4)
if(msel_hit(limit,hitvert,mface->v4,hituv,tface->uv[3]))
tface->flag |=TF_SEL4;
}
}
if(!actface)
*flagpoin |= val;
}
if(redraw || G.f & G_DRAWFACES) {
force_draw_plus(SPACE_VIEW3D);
}
else {
glDrawBuffer(GL_FRONT);
draw_tfaces();
glFlush(); // at OSX, a flush pops up the "frontbuffer" (it does a swap, doh!)
/*at OSX, a flush pops up the "frontbuffer" (it does a swap, doh!)*/
glFlush();
glDrawBuffer(GL_BACK);
std_rmouse_transform(transform_tface_uv);
}
std_rmouse_transform(transform_tface_uv);
}
void borderselect_sima(void)
@@ -859,10 +1216,16 @@ void uvedit_selectionCB(short selecting, Object *editobj, short *mval, float rad
tface++; mface++;
}
// force_draw() is no good here...
glDrawBuffer(GL_FRONT);
draw_tfaces();
glDrawBuffer(GL_BACK);
if(G.f & G_DRAWFACES) { /* full redraw only if necessary */
draw_sel_circle(0, 0, 0, 0, 0); /* signal */
force_draw_plus(SPACE_VIEW3D);
}
else { /* force_draw() is no good here... */
glDrawBuffer(GL_FRONT);
draw_tfaces();
glDrawBuffer(GL_BACK);
}
}
}
@@ -909,3 +1272,331 @@ void mouseco_to_curtile(void)
scrarea_queue_winredraw(curarea);
}
}
void hide_tface_uv(int swap)
{
Mesh *me;
TFace *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->tface; a>0; a--, tface++, mface++) {
if(mface->v3 && tface->flag & TF_SELECT) {
if((tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))==0) {
if(!mface->v4)
tface->flag &= ~TF_SELECT;
else if(!(tface->flag & TF_SEL4))
tface->flag &= ~TF_SELECT;
}
}
}
} else {
mface= me->mface;
for(a=me->totface, tface= me->tface; a>0; a--, tface++, mface++) {
if(mface->v3 && tface->flag & TF_SELECT) {
if(tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
tface->flag &= ~TF_SELECT;
else if(mface->v4 && tface->flag & TF_SEL4)
tface->flag &= ~TF_SELECT;
}
}
}
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
}
void reveal_tface_uv(void)
{
Mesh *me;
TFace *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->tface; a>0; a--, tface++, mface++)
if(mface->v3 && !(tface->flag & TF_HIDE))
if(!(tface->flag & TF_SELECT))
tface->flag |= (TF_SELECT|TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIMAGE, 0);
}
void stitch_uv_tface(int mode)
{
MFace *mface;
TFace *tface;
Mesh *me;
unsigned int a, b, c, vtot, vtot2, tot;
float newuv[2], limit[2], *uv, *uv1;
struct uvvertsort *sortblock, *sb, *sb1, *sb2;
if( is_uv_tface_editing_allowed()==0 ) return;
limit[0]= limit[1]= 20.0;
if(mode==1) {
add_numbut(0, NUM|FLO, "Limit:", 0.1, 1000.0, &limit[0], NULL);
if (!do_clever_numbuts("Stitch UVs", 1, REDRAW))
return;
}
if(G.sima->image && G.sima->image->ibuf && G.sima->image->ibuf->x > 0 &&
G.sima->image->ibuf->y > 0) {
limit[1]= limit[0]/(float)G.sima->image->ibuf->y;
limit[0]= limit[0]/(float)G.sima->image->ibuf->x;
}
else
limit[0]= limit[1]= limit[0]/256.0;
me= get_mesh(OBACT);
tot= 0;
mface= me->mface;
for(a=me->totface, tface=me->tface; a>0; a--, tface++, mface++) {
if((tface->flag & TF_SELECT) && mface->v3) {
if(tface->flag & TF_SEL1) tot++;
if(tface->flag & TF_SEL2) tot++;
if(tface->flag & TF_SEL3) tot++;
if(mface->v4 && tface->flag & TF_SEL4) tot++;
}
}
if(tot==0) return;
sb= sortblock= MEM_callocN(sizeof(struct uvvertsort)*tot,"sortstitchuv");
mface= me->mface;
for(a=me->totface, tface=me->tface; a>0; a--, tface++, mface++) {
if((tface->flag & TF_SELECT) && mface->v3) {
if(tface->flag & TF_SEL1) {
sb->v= mface->v1;
sb->tface= tface;
sb->tf_sel= 0;
sb++;
}
if(tface->flag & TF_SEL2) {
sb->v= mface->v2;
sb->tface= tface;
sb->tf_sel= 1;
sb++;
}
if(tface->flag & TF_SEL3) {
sb->v= mface->v3;
sb->tface= tface;
sb->tf_sel= 2;
sb++;
}
if(mface->v4 && tface->flag & TF_SEL4) {
sb->v= mface->v4;
sb->tface = tface;
sb->tf_sel= 3;
sb++;
}
}
}
/* sort by vertex */
qsort(sortblock, tot, sizeof(struct uvvertsort), compuvvert);
if(mode==0) {
for (a=0, sb=sortblock; a<tot; a+=vtot, sb+=vtot) {
newuv[0]= 0; newuv[1]= 0;
vtot= 0;
for (b=a, sb1=sb; b<tot && sb1->v==sb->v; b++, sb1++) {
newuv[0] += sb1->tface->uv[sb1->tf_sel][0];
newuv[1] += sb1->tface->uv[sb1->tf_sel][1];
vtot++;
}
newuv[0] /= vtot; newuv[1] /= vtot;
for (b=a, sb1=sb; b<a+vtot; b++, sb1++) {
sb1->tface->uv[sb1->tf_sel][0]= newuv[0];
sb1->tface->uv[sb1->tf_sel][1]= newuv[1];
}
}
} else if(mode==1) {
for (a=0, sb=sortblock; a<tot; a+=vtot, sb+=vtot) {
vtot= 0;
for (b=a, sb1=sb; b<tot && sb1->v==sb->v; b++, sb1++)
vtot++;
for (b=a, sb1=sb; b<a+vtot; b++, sb1++) {
if(sb1->flag & 2) continue;
newuv[0]= 0; newuv[1]= 0;
vtot2 = 0;
for (c=b, sb2=sb1; c<a+vtot; c++, sb2++) {
uv = sb2->tface->uv[sb2->tf_sel];
uv1 = sb1->tface->uv[sb1->tf_sel];
if (fabs(uv[0]-uv1[0]) < limit[0] &&
fabs(uv[1]-uv1[1]) < limit[1]) {
newuv[0] += uv[0];
newuv[1] += uv[1];
sb2->flag |= 2;
sb2->flag |= 4;
vtot2++;
}
}
newuv[0] /= vtot2; newuv[1] /= vtot2;
for (c=b, sb2=sb1; c<a+vtot; c++, sb2++) {
if(sb2->flag & 4) {
sb2->tface->uv[sb2->tf_sel][0]= newuv[0];
sb2->tface->uv[sb2->tf_sel][1]= newuv[1];
sb2->flag &= ~4;
}
}
}
}
}
MEM_freeN(sortblock);
if(G.sima->flag & SI_BE_SQUARE) be_square_tface_uv(me);
if(G.sima->flag & SI_CLIP_UV) tface_do_clip();
allqueue(REDRAWVIEW3D, 0);
scrarea_queue_winredraw(curarea);
}
void select_linked_tface_uv(void)
{
MFace *mface;
TFace *tface;
Mesh *me;
char sel;
unsigned int a, b, c, vtot, tot;
float limit[2], *uv, *uv1;
struct uvvertsort *sortblock, *sb, *sb1, *sb2;
if( is_uv_tface_editing_allowed()==0 ) return;
me= get_mesh(OBACT);
setLinkedLimit(limit);
tot= 0;
mface= me->mface;
for(a=me->totface, tface=me->tface; a>0; a--, tface++, mface++) {
if((tface->flag & TF_SELECT) && mface->v3) {
tot += 3;
if(mface->v4) tot++;
}
}
if(tot==0) return;
sb= sortblock= MEM_callocN(sizeof(struct uvvertsort)*tot,"sortsellinkuv");
mface= me->mface;
for(a=me->totface, tface=me->tface; a>0; a--, tface++, mface++) {
if((tface->flag & TF_SELECT) && mface->v3) {
if(tface->flag & TF_SEL1) sb->flag |= 1;
sb->v= mface->v1;
sb->tface= tface;
sb->tf_sel= 0;
sb++;
if(tface->flag & TF_SEL2) sb->flag |= 1;
sb->v= mface->v2;
sb->tface= tface;
sb->tf_sel= 1;
sb++;
if(tface->flag & TF_SEL3) sb->flag |= 1;
sb->v= mface->v3;
sb->tface= tface;
sb->tf_sel= 2;
sb++;
if(mface->v4) {
if(tface->flag & TF_SEL4) sb->flag |= 1;
sb->v= mface->v4;
sb->tface= tface;
sb->tf_sel= 3;
sb++;
}
}
}
/* sort by vertex */
qsort(sortblock, tot, sizeof(struct uvvertsort), compuvvert);
sel= 1;
while(sel) {
sel= 0;
/* select all tex vertices that are near a selected tex vertex */
for (a=0, sb=sortblock; a<tot; a+=vtot, sb+=vtot) {
vtot= 0;
for (b=a, sb1=sb; b<tot && sb1->v==sb->v; b++, sb1++)
vtot++;
for (b=a, sb1=sb; b<a+vtot; b++, sb1++) {
if(sb1->flag & 1) continue;
for (c=a, sb2=sb; c<a+vtot; c++, sb2++) {
if(!(sb2->flag & 1)) continue;
uv = sb2->tface->uv[sb2->tf_sel];
uv1 = sb1->tface->uv[sb1->tf_sel];
if (fabs(uv[0]-uv1[0]) < limit[0] &&
fabs(uv[1]-uv1[1]) < limit[1]) {
sb1->flag |= 1;
sel= 1;
break;
}
}
}
}
/* if one tex vert is selected, select the whole tface */
for (a=0, sb=sortblock; a<tot; a++, sb++) {
if(sb->flag & 1) {
sb->tface->flag |= (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
}
}
/* sync the flags, one bitflag check is enough */
for (a=0, sb=sortblock; a<tot; a++, sb++) {
if(sb->tface->flag & TF_SEL1 && !(sb->flag & 1)) {
sb->flag |= 1;
sel= 1;
}
}
}
MEM_freeN(sortblock);
scrarea_queue_winredraw(curarea);
}
void unlink_selection(void)
{
Mesh *me;
TFace *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->tface; a>0; a--, tface++, mface++) {
if(mface->v3 && !(tface->flag & TF_HIDE)) {
if(mface->v4) {
if(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4))
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4);
} else {
if(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))
tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3);
}
}
}
scrarea_queue_winredraw(curarea);
}

View File

@@ -156,7 +156,7 @@ void replace_space_image(char *str) /* called from fileselect */
ima= add_image(str);
if(ima) {
if(G.sima->image != ima) {
if(G.sima->image && G.sima->image != ima) {
image_replace(G.sima->image, ima);
}
@@ -362,6 +362,20 @@ static void do_image_viewmenu(void *arg, int event)
case 2: /* Maximize Window */
/* using event B_FULL */
break;
case 5: /* Draw Shadow Mesh */
if(G.sima->flag & SI_DRAWSHADOW)
G.sima->flag &= ~SI_DRAWSHADOW;
else
G.sima->flag |= SI_DRAWSHADOW;
allqueue(REDRAWIMAGE, 0);
break;
case 6: /* Draw Faces */
if(G.f & G_DRAWFACES)
G.f &= ~G_DRAWFACES;
else
G.f |= G_DRAWFACES;
allqueue(REDRAWIMAGE, 0);
break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -375,6 +389,12 @@ static uiBlock *image_viewmenu(void *arg_unused)
block= uiNewBlock(&curarea->uiblocks, "image_viewmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_image_viewmenu, NULL);
if(G.f & G_DRAWFACES) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Draw Faces", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Faces|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
if(G.sima->flag & SI_DRAWSHADOW) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Draw Shadow Mesh", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Shadow mesh|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if(BTST(G.sima->lock, 0)) {
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
} else {
@@ -411,6 +431,37 @@ static void do_image_selectmenu(void *arg, int event)
case 1: /* Select/Deselect All */
select_swap_tface_uv();
break;
case 2: /* Unlink Selection */
unlink_selection();
break;
case 3: /* Select Linked UVs */
select_linked_tface_uv();
break;
case 4: /* Toggle Local UVs Stick to Vertex in Mesh */
if(G.sima->flag & SI_LOCALSTICKY)
G.sima->flag &= ~SI_LOCALSTICKY;
else {
G.sima->flag |= SI_LOCALSTICKY;
G.sima->flag &= ~SI_STICKYUVS;
}
allqueue(REDRAWIMAGE, 0);
break;
case 5: /* Toggle UVs Stick to Vertex in Mesh */
if(G.sima->flag & SI_STICKYUVS)
G.sima->flag &= ~SI_STICKYUVS;
else {
G.sima->flag |= SI_STICKYUVS;
G.sima->flag &= ~SI_LOCALSTICKY;
}
allqueue(REDRAWIMAGE, 0);
break;
case 6: /* Toggle Active Face Select */
if(G.sima->flag & SI_SELACTFACE)
G.sima->flag &= ~SI_SELACTFACE;
else
G.sima->flag |= SI_SELACTFACE;
allqueue(REDRAWIMAGE, 0);
break;
}
}
@@ -422,10 +473,27 @@ static uiBlock *image_selectmenu(void *arg_unused)
block= uiNewBlock(&curarea->uiblocks, "image_selectmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_image_selectmenu, NULL);
if(G.sima->flag & SI_SELACTFACE) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Active Face Select|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Active Face Select|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if(G.sima->flag & SI_LOCALSTICKY) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Stick Local UVs to Mesh Vertex|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Stick Local UVs to Mesh Vertex|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
if(G.sima->flag & SI_STICKYUVS) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Stick UVs to Mesh Vertex|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Stick UVs to Mesh Vertex|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unlink Selection|Alt L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked UVs|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
}
@@ -484,14 +552,19 @@ static void do_image_imagemenu(void *arg, int event)
case 0: /* Open */
if(G.sima->image) strcpy(name, G.sima->image->name);
else strcpy(name, U.textudir);
activate_fileselect(FILE_SPECIAL, "Open Image", name, load_space_image);
if(G.qual==LR_CTRLKEY)
activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_space_image);
else
activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_space_image);
break;
case 1:
if(G.sima->image) strcpy(name, G.sima->image->name);
else strcpy(name, U.textudir);
activate_fileselect(FILE_SPECIAL, "Replace Image", name, replace_space_image);
if(G.qual==LR_CTRLKEY)
activate_imageselect(FILE_SPECIAL, "Replace Image", name, load_space_image);
else
activate_fileselect(FILE_SPECIAL, "Replace Image", name, load_space_image);
break;
case 2: /* Pack Image */
ima = G.sima->image;
@@ -542,7 +615,25 @@ static void do_image_imagemenu(void *arg, int event)
}
}
break;
case 6: /* Reload Image */
ima = G.sima->image;
if (ima) {
if (ima->packedfile) {
PackedFile *pf;
pf = newPackedFile(ima->name);
if (pf) {
freePackedFile(ima->packedfile);
ima->packedfile = pf;
}
else
error("Image not available. Keeping packed image.");
}
free_image_buffers(ima); /* force read again */
ima->ok= 1;
image_changed(G.sima, 0);
}
allqueue(REDRAWIMAGE, 0);
break;
}
}
@@ -555,9 +646,11 @@ static uiBlock *image_imagemenu(void *arg_unused)
uiBlockSetButmFunc(block, do_image_imagemenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Replace...|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
if (G.sima->image) {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Replace...|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reload|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if (G.sima->image->packedfile) {
@@ -594,6 +687,73 @@ static uiBlock *image_imagemenu(void *arg_unused)
return block;
}
static void do_image_uvs_showhidemenu(void *arg, int event)
{
switch(event) {
case 4: /* show hidden faces */
reveal_tface_uv();
break;
case 5: /* hide selected faces */
hide_tface_uv(0);
break;
case 6: /* hide deselected faces */
hide_tface_uv(1);
break;
}
allqueue(REDRAWVIEW3D, 0);
}
static uiBlock *image_uvs_showhidemenu(void *arg_unused)
{
uiBlock *block;
short yco = 20, menuwidth = 120;
block= uiNewBlock(&curarea->uiblocks, "image_uvs_showhidemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_image_uvs_showhidemenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hidden Faces|Alt H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Selected Faces|H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Deselected Faces|Shift H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 60);
return block;
}
static void do_image_uvs_propfalloffmenu(void *arg, int event)
{
extern int prop_mode;
switch(event) {
case 0: /* proportional edit - sharp*/
prop_mode = 0;
break;
case 1: /* proportional edit - smooth*/
prop_mode = 1;
break;
}
allqueue(REDRAWVIEW3D, 0);
}
static uiBlock *image_uvs_propfalloffmenu(void *arg_unused)
{
uiBlock *block;
short yco = 20, menuwidth = 120;
extern int prop_mode;
block= uiNewBlock(&curarea->uiblocks, "image_uvs_propfalloffmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_image_uvs_propfalloffmenu, NULL);
if (prop_mode==0) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Sharp|Shift O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Sharp|Shift O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
if (prop_mode==1) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Smooth|Shift O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Smooth|Shift O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 60);
return block;
}
static void do_image_uvsmenu(void *arg, int event)
{
switch(event)
@@ -606,6 +766,25 @@ static void do_image_uvsmenu(void *arg, int event)
if(BTST(G.sima->flag, 2)) G.sima->flag = BCLR(G.sima->flag, 2);
else G.sima->flag = BSET(G.sima->flag, 2);
break;
case 3: /* Limit Stitch UVs */
stitch_uv_tface(1);
break;
case 4: /* Stitch UVs */
stitch_uv_tface(0);
break;
case 5: /* Proportional Edit (toggle) */
if(G.f & G_PROPORTIONAL)
G.f &= ~G_PROPORTIONAL;
else
G.f |= G_PROPORTIONAL;
break;
case 7: /* UVs Snap to Pixel */
if(BTST(G.sima->flag, 7)) G.sima->flag = BCLR(G.sima->flag, 7);
else G.sima->flag = BSET(G.sima->flag, 7);
break;
case 8:
transform_tface_uv('w');
break;
}
}
@@ -619,6 +798,8 @@ static uiBlock *image_uvsmenu(void *arg_unused)
// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
// uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if(BTST(G.sima->flag, 7)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "UVs Snap To Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "UVs Snap To Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
if(BTST(G.sima->flag, 0)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
@@ -626,6 +807,25 @@ static uiBlock *image_uvsmenu(void *arg_unused)
if(BTST(G.sima->flag, 2)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Layout Clipped to Image Size|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Layout Clipped to Image Size|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Weld / Align...|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Limit Stitch...|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Stitch|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if(G.f & G_PROPORTIONAL) {
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
} else {
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
}
uiDefIconTextBlockBut(block, image_uvs_propfalloffmenu, NULL, ICON_RIGHTARROW_THIN, "Proportional Falloff", 0, yco-=20, 120, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBlockBut(block, image_uvs_showhidemenu, NULL, ICON_RIGHTARROW_THIN, "Show/Hide Faces", 0, yco-=20, menuwidth, 19, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
}
@@ -683,6 +883,7 @@ void image_buttons(void)
xmax= GetButStringLength("Select");
uiDefBlockBut(block, image_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
xco+= xmax;
xmax= GetButStringLength("Image");
@@ -716,8 +917,9 @@ void image_buttons(void)
uiDefIconButS(block, TOG|BIT|0, B_BE_SQUARE, ICON_KEEPRECT, xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles constraining UV polygons to squares while editing");
uiDefIconButS(block, ICONTOG|BIT|2, B_CLIP_UV, ICON_CLIPUV_DEHLT,xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles clipping UV with image size"); */
uiDefIconButS(block, ICONTOG|BIT|2, B_CLIP_UV, ICON_CLIPUV_DEHLT,xco+=XIC,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Toggles clipping UV with image size");
*/
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SIMABROWSE, (ID *)G.sima->image, 0, &(G.sima->imanr), 0, 0, B_IMAGEDELETE, 0, 0);
@@ -788,3 +990,4 @@ void image_buttons(void)
uiDrawBlock(block);
}

View File

@@ -1026,6 +1026,9 @@ static void do_view3d_select_faceselmenu(void *arg, int event)
case 2: /* Select/Deselect all */
deselectall_tface();
break;
case 3: /* Select Inverse */
selectswap_tface();
break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -1043,6 +1046,7 @@ static uiBlock *view3d_select_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, "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, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);

View File

@@ -569,6 +569,9 @@ void BIF_InitTheme(void)
SETCOL(btheme->tima.back, 53, 53, 53, 255);
SETCOL(btheme->tima.vertex, 0xff, 0x70, 0xff, 255);
SETCOL(btheme->tima.vertex_select, 0xff, 0xff, 0x70, 255);
btheme->tima.vertex_size= 2;
SETCOL(btheme->tima.face, 0, 50, 150, 40);
SETCOL(btheme->tima.face_select, 200, 100, 200, 80);
/* space imageselect */
btheme->timasel= btheme->tv3d;
@@ -674,6 +677,14 @@ char *BIF_ThemeColorsPup(int spacetype)
sprintf(str, "Channels %%x%d|", TH_SHADE2); strcat(cp, str);
sprintf(str, "Channels Selected %%x%d|", TH_HILITE); strcat(cp, str);
}
else if(spacetype==SPACE_IMAGE) {
strcat(cp,"%l|");
sprintf(str, "Vertex %%x%d|", TH_VERTEX); strcat(cp, str);
sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); strcat(cp, str);
sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); strcat(cp, str);
sprintf(str, "Face %%x%d|", TH_FACE); strcat(cp, str);
sprintf(str, "Face Selected %%x%d", TH_FACE_SELECT); strcat(cp, str);
}
else if(spacetype==SPACE_SEQ) {
sprintf(str, "Window Sliders %%x%d|", TH_SHADE1); strcat(cp, str);
}

View File

@@ -3311,6 +3311,9 @@ void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
IMG_CanvasDispose(canvas);
allqueue(REDRAWHEADERS, 0);
break;
case RIGHTMOUSE:
sample_vpaint();
break;
}
#endif /* NAN_TPT */
}
@@ -3325,7 +3328,10 @@ void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
image_viewmove();
break;
case RIGHTMOUSE:
mouse_select_sima();
if(G.f & G_FACESELECT)
mouse_select_sima();
else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))
sample_vpaint();
break;
case AKEY:
if((G.qual==0))
@@ -3339,10 +3345,36 @@ void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if((G.qual==0))
transform_tface_uv('g');
break;
case HKEY:
if(G.qual==LR_ALTKEY)
reveal_tface_uv();
else if((G.qual==LR_SHIFTKEY))
hide_tface_uv(1);
else if((G.qual==0))
hide_tface_uv(0);
break;
case LKEY:
if((G.qual==0))
select_linked_tface_uv();
else if(G.qual==LR_ALTKEY)
unlink_selection();
break;
case NKEY:
if(G.qual==LR_CTRLKEY)
replace_names_but();
break;
case OKEY:
if (G.qual==LR_SHIFTKEY) {
extern int prop_mode;
prop_mode= !prop_mode;
}
else if((G.qual==0)) {
if(G.f & G_PROPORTIONAL)
G.f &= ~G_PROPORTIONAL;
else
G.f |= G_PROPORTIONAL;
}
break;
case RKEY:
if((G.qual==0))
transform_tface_uv('r');
@@ -3351,6 +3383,15 @@ void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if((G.qual==0))
transform_tface_uv('s');
break;
case VKEY:
if((G.qual==0))
stitch_uv_tface(0);
else if(G.qual==LR_SHIFTKEY)
stitch_uv_tface(1);
break;
case WKEY:
transform_tface_uv('w');
break;
}
}

View File

@@ -422,7 +422,7 @@ void vpaint_dogamma()
if(me->tface) mcol_to_tface(me, 1);
}
/* used for both 3d view and image window */
void sample_vpaint() /* frontbuf */
{
unsigned int col;