~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/drawimage.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: drawimage.c,v 1.90 2007/02/09 15:08:53 blendix Exp $
 
2
 * $Id: drawimage.c,v 1.98 2007/04/29 13:39:45 campbellbarton Exp $
3
3
 *
4
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
290
290
void image_changed(SpaceImage *sima, int dotile)
291
291
{
292
292
        MTFace *tface;
 
293
        MFace *mface;
293
294
        Mesh *me;
294
295
        int a;
295
296
 
312
313
                        if(me && me->mtface) {
313
314
                                
314
315
                                tface= me->mtface;
 
316
                                mface = me->mface;
315
317
                                a= me->totface;
316
318
                                while(a--) {
317
 
                                        if(tface->flag & TF_SELECT) {
 
319
                                        if(mface->flag & ME_FACE_SEL) {
318
320
                                                
319
321
                                                if(dotile==2) {
320
322
                                                        tface->mode &= ~TF_TILES;
335
337
                                                }
336
338
                                        }
337
339
                                        tface++;
 
340
                                        mface++;
338
341
                                }
339
342
 
340
343
                                object_uvs_changed(OBACT);
426
429
 
427
430
                                        glColor3ub(112, 112, 112);
428
431
                                        while(a--) {
429
 
                                                if(!(tface->flag & TF_HIDE) && (tface->flag & TF_SELECT)) {
 
432
                                                if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {
430
433
                                                        glBegin(GL_LINE_LOOP);
431
434
                                                        glVertex2fv(tface->uv[0]);
432
435
                                                        glVertex2fv(tface->uv[1]);
453
456
                                mface= me->mface;
454
457
                                a= me->totface;                 
455
458
                                while(a--) {
456
 
                                        if(tface->flag & TF_SELECT) {
 
459
                                        if(mface->flag & ME_FACE_SEL) {
457
460
                                                if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&
458
461
                                                   (!mface->v4 || tface->flag & TF_SEL4))
459
 
                                                        glColor4ubv(col2);
 
462
                                                        glColor4ubv((GLubyte *)col2);
460
463
                                                else
461
 
                                                        glColor4ubv(col1);
 
464
                                                        glColor4ubv((GLubyte *)col1);
462
465
                                                        
463
466
                                                glBegin(mface->v4?GL_QUADS:GL_TRIANGLES);
464
467
                                                        glVertex2fv(tface->uv[0]);
478
481
                        mface= me->mface;
479
482
                        a= me->totface;
480
483
                        while(a--) {
481
 
                                if(tface->flag & TF_SELECT) {
 
484
                                if(mface->flag & ME_FACE_SEL) {
482
485
                                        if(tface->flag & TF_ACTIVE){
483
486
                                                activetface= tface; 
484
487
                                                activemface= mface; 
565
568
                        mface= me->mface;
566
569
                        a= me->totface;
567
570
                        while(a--) {
568
 
                                if(tface->flag & TF_SELECT) {
 
571
                                if(mface->flag & ME_FACE_SEL) {
569
572
                                        
570
573
                                        if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]);
571
574
                                        if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]);
589
592
                        mface= me->mface;
590
593
                        a= me->totface;
591
594
                        while(a--) {
592
 
                                if(tface->flag & TF_SELECT) {
 
595
                                if(mface->flag & ME_FACE_SEL) {
593
596
                                        
594
597
                                        if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]);
595
598
                                        if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]);
612
615
                        mface= me->mface;
613
616
                        a= me->totface;
614
617
                        while(a--) {
615
 
                                if(tface->flag & TF_SELECT) {
 
618
                                if(mface->flag & ME_FACE_SEL) {
616
619
                                        
617
620
                                        if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]);
618
621
                                        if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]);
763
766
                MFace *mf= &((MFace*) me->mface)[i];
764
767
                MTFace *tf= &((MTFace*) me->mtface)[i];
765
768
                
766
 
                if (!(tf->flag & TF_SELECT))
 
769
                if (!(mf->flag & ME_FACE_SEL))
767
770
                        continue;
768
771
                
769
772
                if (tf->flag & TF_SEL1) {
835
838
                        MFace *mf= &((MFace*) me->mface)[i];
836
839
                        MTFace *tf= &((MTFace*) me->mtface)[i];
837
840
                
838
 
                        if (!(tf->flag & TF_SELECT))
 
841
                        if (!(mf->flag & ME_FACE_SEL))
839
842
                                continue;
840
843
                
841
844
                        if (tf->flag & TF_SEL1) {
948
951
                uiDefButS(block, NUM, B_SIMAGEDRAW, "X:",               160,130,70,19, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction");
949
952
                uiDefButS(block, NUM, B_SIMAGEDRAW, "Y:",               230,130,70,19, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction");
950
953
                uiBlockBeginAlign(block);
 
954
 
 
955
                uiBlockBeginAlign(block);
 
956
                uiDefButBitS(block, TOG, IMA_CLAMP_U, B_SIMAGEDRAW, "ClampX",   160,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly");
 
957
                uiDefButBitS(block, TOG, IMA_CLAMP_V, B_SIMAGEDRAW, "ClampY",   230,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically");
 
958
                uiBlockEndAlign(block);         
951
959
        }
952
960
}
953
961
 
1115
1123
        return 0;
1116
1124
}
1117
1125
 
 
1126
/* 0: disable preview 
 
1127
   otherwise refresh preview
 
1128
*/
1118
1129
void image_preview_event(int event)
1119
1130
{
1120
1131
        int exec= 0;
1124
1135
                G.scene->r.scemode &= ~R_COMP_CROP;
1125
1136
                exec= 1;
1126
1137
        }
1127
 
        else if(event==2 || (G.scene->r.scemode & R_COMP_CROP)==0) {
 
1138
        else {
1128
1139
                if(image_preview_active(curarea, NULL, NULL)) {
1129
1140
                        G.scene->r.scemode |= R_COMP_CROP;
1130
1141
                        exec= 1;
1131
1142
                }
 
1143
                else
 
1144
                        G.scene->r.scemode &= ~R_COMP_CROP;
1132
1145
        }
1133
1146
        
1134
 
        if(exec) {
1135
 
                ScrArea *sa;
 
1147
        if(exec && G.scene->nodetree) {
 
1148
                /* should work when no node editor in screen..., so we execute right away */
1136
1149
                
1137
1150
                ntreeCompositTagGenerators(G.scene->nodetree);
1138
 
        
1139
 
                for(sa=G.curscreen->areabase.first; sa; sa= sa->next) {
1140
 
                        if(sa->spacetype==SPACE_NODE) {
1141
 
                                addqueue(sa->win, UI_BUT_EVENT, B_NODE_TREE_EXEC);
1142
 
                                break;
1143
 
                        }
1144
 
                }
 
1151
 
 
1152
                G.afbreek= 0;
 
1153
                G.scene->nodetree->timecursor= set_timecursor;
 
1154
                G.scene->nodetree->test_break= blender_test_break;
 
1155
                
 
1156
                BIF_store_spare();
 
1157
                
 
1158
                ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1);       /* 1 is do_previews */
 
1159
                
 
1160
                G.scene->nodetree->timecursor= NULL;
 
1161
                G.scene->nodetree->test_break= NULL;
 
1162
                
 
1163
                scrarea_do_windraw(curarea);
 
1164
                waitcursor(0);
 
1165
                
 
1166
                allqueue(REDRAWNODE, 1);
1145
1167
        }       
1146
1168
}
1147
1169
 
1160
1182
                winy*= (G.scene->r.border.ymax - G.scene->r.border.ymin);
1161
1183
        }
1162
1184
        
1163
 
        /* while dragging we don't update the rects */
1164
 
        if(block->panel->flag & PNL_SELECT)
1165
 
                return;
1166
 
        if(get_mbut() & M_MOUSE)
1167
 
                return;
 
1185
        /* while dragging we need to update the rects, otherwise it doesn't end with correct one */
1168
1186
 
1169
1187
        BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx)-15.0f, 15.0f, (block->maxy - block->miny)-15.0f);
1170
1188
        ui_graphics_to_window_rct(sa->win, &dispf, disprect);
1191
1209
        CLAMP(disprect->ymin, 0, winy);
1192
1210
        CLAMP(disprect->ymax, 0, winy);
1193
1211
//      printf("drawrct %d %d %d %d\n", disprect->xmin, disprect->ymin,disprect->xmax, disprect->ymax);
1194
 
        
1195
 
        image_preview_event(1);
 
1212
 
1196
1213
}
1197
1214
 
1198
1215
static int is_preview_allowed(ScrArea *cur)
1958
1975
        scrarea_queue_winredraw(curarea);
1959
1976
}
1960
1977
 
1961
 
void image_viewcentre(void)
 
1978
void image_viewcenter(void)
1962
1979
{
1963
1980
        ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
1964
1981
        float size, min[2], max[2], d[2], xim=256.0f, yim=256.0f;
2032
2049
                rectf= rr->rectf;
2033
2050
        else {
2034
2051
                if(rr->rect32)
2035
 
                        rect32= rr->rect32;
 
2052
                        rect32= (unsigned int *)rr->rect32;
2036
2053
                else {
2037
2054
                        if(rr->renlay==NULL || rr->renlay->rectf==NULL) return;
2038
2055
                        rectf= rr->renlay->rectf;
2294
2311
                ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
2295
2312
                sima->spare= IMB_dupImBuf(ibuf);
2296
2313
                
2297
 
                BLI_strncpy(sima->info_spare, sima->info_str, RW_MAXTEXT);
 
2314
                if(sima->info_str)
 
2315
                        BLI_strncpy(sima->info_spare, sima->info_str, RW_MAXTEXT);
2298
2316
 
2299
2317
        }
2300
2318
}