646
BIF_undo_push("Hide UV face");
644
647
allqueue(REDRAWVIEW3D, 0);
645
648
allqueue(REDRAWIMAGE, 0);
649
void select_linked_tfaces()
652
void select_linked_tfaces(int mode)
658
int a, doit=1, mark=0;
659
char *cpmain, *linkflag;
661
unsigned int index=0;
658
665
if(me==0 || me->tface==0 || me->totface==0) return;
667
if (mode==0 || mode==1) {
668
if (!(ob->lay & G.vd->lay))
669
error("The active object is not in this layer");
671
getmouseco_areawin(mval);
672
if (!face_pick(me, mval[0], mval[1], &index)) return;
676
select_linked_tfaces_with_seams(mode, me, index);
660
680
cpmain= MEM_callocN(me->totvert, "cpmain");
681
linkflag= MEM_callocN(sizeof(char)*me->totface, "linkflaguv");
683
if (mode==0 || mode==1) {
684
/* only put face under cursor in array */
685
mf= ((MFace*)me->mface) + index;
686
cpmain[mf->v1]= cpmain[mf->v2]= cpmain[mf->v3]= 1;
687
if (mf->v4) cpmain[mf->v4]= 1;
691
/* fill array by selection */
694
for(a=0; a<me->totface; a++, tf++, mf++) {
695
if(tf->flag & TF_HIDE);
696
else if(tf->flag & TF_SELECT) {
701
if(mf->v4) cpmain[mf->v4]= 1;
665
/* select connected: fill array */
670
if(tface->flag & TF_HIDE);
671
else if(tface->flag & TF_SELECT) {
673
cpmain[mface->v1]= 1;
674
cpmain[mface->v2]= 1;
675
cpmain[mface->v3]= 1;
676
if(mface->v4) cpmain[mface->v4]= 1;
682
/* reverse: using array select the faces */
688
if(tface->flag & TF_HIDE);
689
else if((tface->flag & TF_SELECT)==0) {
692
if(cpmain[mface->v4]) {
693
tface->flag |= TF_SELECT;
697
if( cpmain[mface->v1] || cpmain[mface->v2] || cpmain[mface->v3] ) {
698
tface->flag |= TF_SELECT;
711
/* expand selection */
714
for(a=0; a<me->totface; a++, tf++, mf++) {
715
if(tf->flag & TF_HIDE);
716
else if(mf->v3 && !linkflag[a]) {
719
if(cpmain[mf->v1] || cpmain[mf->v2] || cpmain[mf->v3])
721
else if(mf->v4 && cpmain[mf->v4])
726
cpmain[mf->v1]= cpmain[mf->v2]= cpmain[mf->v3]= 1;
727
if(mf->v4) cpmain[mf->v4]= 1;
735
if(mode==0 || mode==2) {
736
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
738
tf->flag |= TF_SELECT;
740
tf->flag &= ~TF_SELECT;
743
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
744
if(linkflag[a] && (tf->flag & TF_SELECT))
748
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
750
tf->flag &= ~TF_SELECT;
753
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
755
tf->flag |= TF_SELECT;
707
759
MEM_freeN(cpmain);
762
BIF_undo_push("Select linked UV face");
709
763
allqueue(REDRAWVIEW3D, 0);
710
764
allqueue(REDRAWIMAGE, 0);
714
767
void deselectall_tface()
887
BIF_undo_push("Rotate UV face");
831
888
makeDispList(OBACT);
832
889
allqueue(REDRAWVIEW3D, 0);
833
890
allqueue(REDRAWIMAGE, 0);
893
void minmax_tface(float *min, float *max)
901
float vec[3], bmat[3][3];
906
if(me==0 || me->tface==0) return;
908
Mat3CpyMat4(bmat, ob->obmat);
913
for (a=me->totface; a>0; a--, mf++, tf++) {
914
if (!mf->v3 || tf->flag & TF_HIDE || !(tf->flag & TF_SELECT))
917
VECCOPY(vec, (mv+mf->v1)->co);
918
Mat3MulVecfl(bmat, vec);
919
VecAddf(vec, vec, ob->obmat[3]);
920
DO_MINMAX(vec, min, max);
922
VECCOPY(vec, (mv+mf->v2)->co);
923
Mat3MulVecfl(bmat, vec);
924
VecAddf(vec, vec, ob->obmat[3]);
925
DO_MINMAX(vec, min, max);
927
VECCOPY(vec, (mv+mf->v3)->co);
928
Mat3MulVecfl(bmat, vec);
929
VecAddf(vec, vec, ob->obmat[3]);
930
DO_MINMAX(vec, min, max);
933
VECCOPY(vec, (mv+mf->v4)->co);
934
Mat3MulVecfl(bmat, vec);
935
VecAddf(vec, vec, ob->obmat[3]);
936
DO_MINMAX(vec, min, max);
837
942
* Returns the face under the give position in screen coordinates.
838
943
* Code extracted from face_select routine.
839
944
* Question: why is all of the backbuffer drawn?
840
945
* We're only interested in one pixel!
841
946
* @author Maarten Gribnau
842
* @param me the mesh with the faces to be picked
843
* @param x the x-coordinate to pick at
844
* @param y the y-coordinate to pick at
845
* @return the face under the cursor (-1 if there was no face found)
947
* @param me the mesh with the faces to be picked
948
* @param x the x-coordinate to pick at
949
* @param y the y-coordinate to pick at
950
* @param index the index of the face
951
* @return 1 if found, 0 if none found
847
int face_pick(Mesh *me, short x, short y)
953
int face_pick(Mesh *me, short x, short y, unsigned int *index)
849
955
unsigned int col;
852
if (me==0 || me->tface==0) {
957
if (me==0 || me->tface==0)
856
960
/* Have OpenGL draw in the back buffer with color coded face indices */
857
961
if (curarea->win_swap==WIN_EQUAL) {
888
994
TFace *tface, *tsel;
997
unsigned int a, index;
893
999
/* Get the face under the cursor */
895
1001
if (!(ob->lay & G.vd->lay)) {
896
error("Active object not in this layer!");
1002
error("The active object is not in this layer");
898
1004
me = get_mesh(ob);
899
1005
getmouseco_areawin(mval);
900
index = face_pick(me, mval[0], mval[1]);
901
if (index==-1) return;
1006
if (!face_pick(me, mval[0], mval[1], &index)) return;
903
1008
tsel= (((TFace*)me->tface)+index);
904
1009
msel= (((MFace*)me->mface)+index);
1043
1154
MENUSTRING("Cube", UV_CUBE_MAPPING) "|"
1044
1155
MENUSTRING("Cylinder", UV_CYL_MAPPING) "|"
1045
1156
MENUSTRING("Sphere", UV_SPHERE_MAPPING) "|"
1157
MENUSTRING("LSCM", UV_LSCM_MAPPING) "|"
1046
1158
MENUSTRING("Bounds to 1/8", UV_BOUNDS8_MAPPING) "|"
1047
1159
MENUSTRING("Bounds to 1/4", UV_BOUNDS4_MAPPING) "|"
1048
1160
MENUSTRING("Bounds to 1/2", UV_BOUNDS2_MAPPING) "|"
1255
1375
* @param v4 vertex 4 coordinates.
1256
1376
* @return number of vertices of this face
1258
int face_get_vertex_coordinates(Mesh* mesh, TFace* face, float v1[3], float v2[3], float v3[3], float v4[3])
1378
static int face_get_vertex_coordinates(Mesh* mesh, TFace* face, float v1[3], float v2[3], float v3[3], float v4[3])
1260
1380
int num_vertices;
1288
1408
* @param u (u,v) coordinate.
1289
1409
* @param v (u,v) coordinate.
1291
void face_get_uv(TFace* face, int v1, int v2, int v3, float a, float b, float* u, float* v)
1411
static void face_get_uv(TFace* face, int v1, int v2, int v3, float a, float b, float* u, float* v)
1293
1413
float uv01[2], uv21[2];
1331
1451
* 0 == no intersection, (u,v) invalid
1332
1452
* 1 == intersection, (u,v) valid
1334
int face_pick_uv(Object* object, Mesh* mesh, TFace* face, short x, short y, float* u, float* v)
1454
static int face_pick_uv(Object* object, Mesh* mesh, TFace* face, short x, short y, float* u, float* v)
1336
1456
float org[3], dir[3];
1384
1504
Image *img=NULL, *img_old = NULL;
1385
1505
IMG_BrushPtr brush;
1386
1506
IMG_CanvasPtr canvas = 0;
1387
int rowBytes, face_index;
1507
unsigned int rowBytes, face_index;
1388
1508
char *warn_packed_file = 0;
1389
1509
float uv[2], uv_old[2];
1390
1510
extern VPaint Gvp;
1394
1515
error("No active object"); return;
1396
1517
if (!(ob->lay & G.vd->lay)) {
1397
error("Active object not in this layer"); return;
1518
error("The active object is not in this layer"); return;
1399
1520
me = get_mesh(ob);
1401
error("Active object does not have a mesh"); return;
1522
error("The active object does not have a mesh obData"); return;
1404
1525
brush = IMG_BrushCreate(Gvp.size, Gvp.size, Gvp.r, Gvp.g, Gvp.b, Gvp.a);
1406
error("Can not create brush"); return;
1527
error("Can't create brush"); return;
1530
if (U.flag & USER_LMOUSESELECT) mousebut = R_MOUSE;
1531
else mousebut = L_MOUSE;
1409
1533
persp(PERSP_VIEW);
1411
1535
getmouseco_areawin(xy_old);
1412
while (get_mbut() & L_MOUSE) {
1536
while (get_mbut() & mousebut) {
1413
1537
getmouseco_areawin(xy);
1414
1538
/* Check if cursor has moved */
1415
1539
if ((xy[0] != xy_old[0]) || (xy[1] != xy_old[1])) {
1417
1541
/* Get face to draw on */
1418
face_index = face_pick(me, xy[0], xy[1]);
1419
if (face_index == -1) face = NULL;
1542
if (!face_pick(me, xy[0], xy[1], &face_index)) face = NULL;
1420
1543
else face = (((TFace*)me->tface)+face_index);
1422
1545
/* Check if this is another face. */
1518
1641
if (warn_packed_file) {
1519
error("Painting in packed images not supported: %s", warn_packed_file);
1642
error("Painting in packed images is not supported: %s", warn_packed_file);
1522
1645
persp(PERSP_WIN);
1647
BIF_undo_push("UV face draw");
1524
1648
allqueue(REDRAWVIEW3D, 0);
1525
1649
allqueue(REDRAWIMAGE, 0);
1526
1650
allqueue(REDRAWHEADERS, 0);