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

« back to all changes in this revision

Viewing changes to source/blender/src/edit.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: edit.c,v 1.99 2007/01/22 00:48:53 nicholasbishop Exp $
 
2
 * $Id: edit.c,v 1.106 2007/04/14 13:18:24 campbellbarton Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
73
73
#include "BKE_anim.h"
74
74
#include "BKE_curve.h"
75
75
#include "BKE_depsgraph.h"
 
76
#include "BKE_DerivedMesh.h"
76
77
#include "BKE_displist.h"
77
78
#include "BKE_global.h"
78
79
#include "BKE_ipo.h"
138
139
/* local protos ---------------*/
139
140
void snap_curs_to_firstsel(void);
140
141
 
141
 
/* flag==2 only border, flag==3 cross+border */
 
142
/* flag==2 only border, flag==3 cross+border
 
143
   flag==5 cross + border + start&end frame
 
144
 */
142
145
int get_border(rcti *rect, short flag)
143
146
{
144
147
        float dvec[4], fac1, fac2;
168
171
                /* draws the selection initial cross */
169
172
                sdrawXORline4(0, 0,  mvalo[1],  curarea->winx,  mvalo[1]);
170
173
                sdrawXORline4(1, mvalo[0],  0,  mvalo[0],  curarea->winy); 
171
 
                glFlush();
 
174
                bglFlush();
172
175
                
173
176
                while(TRUE) {
174
177
                
180
183
                                /* aiming cross */
181
184
                                sdrawXORline4(0, 0,  mval[1],  curarea->winx,  mval[1]);
182
185
                                sdrawXORline4(1, mval[0],  0,  mval[0],  curarea->winy);
183
 
                                glFlush();
 
186
                                bglFlush();
184
187
 
185
188
                                mvalo[0]= mval[0];
186
189
                                mvalo[1]= mval[1];
227
230
                sdrawXORline4(1, x1, mvalo[1], mvalo[0], mvalo[1]); 
228
231
                sdrawXORline4(2, mvalo[0], mvalo[1], mvalo[0], y1); 
229
232
                sdrawXORline4(3,  mvalo[0], y1, x1, y1); 
230
 
                glFlush();
 
233
                bglFlush();
231
234
                        
232
235
                while(TRUE) {
233
236
                        getmouseco_areawin(mval);
285
288
                                        areamouseco_to_ipoco(&sipo->v2d, mval, dvec, dvec+1);
286
289
                                        areamouseco_to_ipoco(&sipo->v2d, mvalo+2, dvec+2, dvec+3);
287
290
 
288
 
                                        sprintf(str, "Time: %.4f  Y %.4f", dvec[0]-dvec[2], dvec[1]-dvec[3]);
289
 
                                        glRasterPos2i(30,  30);
290
 
                                        glColor3f(0.0, 0.0, 0.0); 
291
 
                                        BMF_DrawString(G.fonts, str);
292
 
                                        glRasterPos2i(31,  31);
293
 
                                        glColor3f(0.9, 0.9, 0.9); 
 
291
                                        if (flag == 5) {
 
292
                                                /* setting preview range */
 
293
                                                if (dvec[0] < dvec[2])
 
294
                                                        sprintf(str, "Preview Range: %d to %d", (int)dvec[0], (int)dvec[2]);
 
295
                                                else
 
296
                                                        sprintf(str, "Preview Range: %d to %d", (int)dvec[2], (int)dvec[0]);
 
297
                                        }
 
298
                                        else
 
299
                                                sprintf(str, "Time: %.4f  Y %.4f", dvec[0]-dvec[2], dvec[1]-dvec[3]);
 
300
                                        
 
301
                                        BIF_ThemeColor(TH_BACK);
 
302
                                        glRecti(14, 24, 165, 38);
 
303
                                        
 
304
                                        glColor3f(0.0, 0.0, 0.0); 
 
305
                                        glRasterPos2i(15,  27);
 
306
                                        BMF_DrawString(G.fonts, str);
 
307
                                        glColor3f(0.8, 0.8, 0.8); 
 
308
                                        glRasterPos2i(16,  28);
 
309
                                        BMF_DrawString(G.fonts, str);
 
310
                                }
 
311
                                else if ((ELEM3(curarea->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_TIME)) && flag==5) {
 
312
                                        /* only while setting preview range */
 
313
                                        View2D *v2d;
 
314
                                        
 
315
                                        switch (curarea->spacetype) 
 
316
                                        {
 
317
                                                case SPACE_ACTION:
 
318
                                                {
 
319
                                                        SpaceAction *saaction= curarea->spacedata.first;
 
320
                                                        v2d= &saaction->v2d;
 
321
                                                }
 
322
                                                        break;
 
323
                                                case SPACE_NLA:
 
324
                                                {
 
325
                                                        SpaceNla *snla= curarea->spacedata.first;
 
326
                                                        v2d= &snla->v2d;
 
327
                                                }
 
328
                                                        break;
 
329
                                                default:
 
330
                                                        v2d= G.v2d;
 
331
                                                        break;
 
332
                                        }
 
333
                                        
 
334
                                        mvalo[2]= x1;
 
335
                                        mvalo[3]= y1;
 
336
                                        areamouseco_to_ipoco(v2d, mval, dvec, dvec+1);
 
337
                                        areamouseco_to_ipoco(v2d, mvalo+2, dvec+2, dvec+3);
 
338
                                        
 
339
                                        if (dvec[0] < dvec[2])
 
340
                                                sprintf(str, "Preview Range: %d to %d", (int)dvec[0], (int)dvec[2]);
 
341
                                        else
 
342
                                                sprintf(str, "Preview Range: %d to %d", (int)dvec[2], (int)dvec[0]);
 
343
                                        
 
344
                                        BIF_ThemeColor(TH_BACK);
 
345
                                        glRecti(14, 24, 165, 38);
 
346
                                        
 
347
                                        glColor3f(0.0, 0.0, 0.0); 
 
348
                                        glRasterPos2i(15,  27);
 
349
                                        BMF_DrawString(G.fonts, str);
 
350
                                        glColor3f(0.8, 0.8, 0.8); 
 
351
                                        glRasterPos2i(16,  28);
294
352
                                        BMF_DrawString(G.fonts, str);
295
353
                                }
296
354
 
297
 
                                glFlush();
 
355
                                bglFlush();
298
356
 
299
357
                                mvalo[0]= mval[0];
300
358
                                mvalo[1]= mval[1];
327
385
                        rect->ymax= mval[1];
328
386
                        retval= event;
329
387
 
330
 
                        /* normalise */
 
388
                        /* normalize */
331
389
                        if(rect->xmin>rect->xmax) SWAP(int, rect->xmin, rect->xmax);
332
390
                        if(rect->ymin>rect->ymax) SWAP(int, rect->ymin, rect->ymax);
333
391
                        
342
400
                if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_IPO) {
343
401
                        scrarea_queue_winredraw(curarea);
344
402
                }
 
403
                else if ELEM3(curarea->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_TIME) {
 
404
                        scrarea_queue_winredraw(curarea); // only really needed for 
 
405
                }
345
406
        }
346
407
        
347
 
        glFlush();
 
408
        bglFlush();
348
409
        glReadBuffer(GL_BACK);
349
410
        glDrawBuffer(GL_BACK);
350
411
 
399
460
        }
400
461
        //setlinestyle(0);
401
462
 
402
 
        glFlush();
 
463
        bglFlush();
403
464
        persp(PERSP_VIEW);
404
465
        glDrawBuffer(GL_BACK);
405
466
        glReadBuffer(GL_BACK);
509
570
{
510
571
        Mesh *me;
511
572
        Curve *cu;
512
 
        int tot=0, totf=0, subsurf;
513
 
        
 
573
        DerivedMesh *dm;
 
574
        int tot=0, totf=0;
 
575
 
514
576
        switch(ob->type) {
515
577
        case OB_MESH:
516
 
                G.totmesh+=totob;
517
 
                me= get_mesh(ob);
518
 
                if(me) {
519
 
                        ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf);
520
 
                        int totvert, totface;
521
 
                        
522
 
                        subsurf= 1;
523
 
                        if (md) {
524
 
                                SubsurfModifierData *smd = (SubsurfModifierData*) md;
525
 
                                if(smd->modifier.mode & eModifierMode_Realtime)
526
 
                                        subsurf= 1<<(2*smd->levels);
527
 
                        }
528
 
                        
529
 
                        totvert= subsurf*me->totvert*totob;
530
 
                        totface= subsurf*me->totface*totob;
531
 
                        
532
 
                        G.totvert+= totvert;
533
 
                        G.totface+= totface;
534
 
                        if(sel) {
535
 
                                G.totvertsel+= totvert;
536
 
                                G.totfacesel+= totface;
537
 
                        }
538
 
                }
539
 
                break;
 
578
                        G.totmesh+=totob;
 
579
                        me= get_mesh(ob);
 
580
                        if(me) {
 
581
                                        int totvert, totedge, totface;
 
582
                                        dm = mesh_get_derived_final(ob, get_viewedit_datamask());
 
583
                                        totvert = dm->getNumVerts(dm);
 
584
                                        totedge = dm->getNumEdges(dm);
 
585
                                        totface = dm->getNumFaces(dm);
 
586
 
 
587
                                        G.totvert+= totvert*totob;
 
588
                                        G.totedge+= totedge*totob;
 
589
                                        G.totface+= totface*totob;
 
590
                                        if(sel) {
 
591
                                                        G.totvertsel+= totvert;
 
592
                                                        G.totfacesel+= totface;
 
593
                                        }
 
594
                        }
 
595
                        break;
540
596
 
541
597
        case OB_LAMP:
542
598
                G.totlamp+=totob;
839
895
        MetaElem *ml;
840
896
        EditVert *eve;
841
897
        EditBone        *ebo;
842
 
        float total, centre[3], centroid[3];
 
898
        float total, center[3], centroid[3];
843
899
        int a;
844
900
 
845
901
        tottrans= 0; // global!
1067
1123
                centroid[2]/= total;
1068
1124
        }
1069
1125
 
1070
 
        centre[0]= (min[0]+max[0])/2.0;
1071
 
        centre[1]= (min[1]+max[1])/2.0;
1072
 
        centre[2]= (min[2]+max[2])/2.0;
 
1126
        center[0]= (min[0]+max[0])/2.0;
 
1127
        center[1]= (min[1]+max[1])/2.0;
 
1128
        center[2]= (min[2]+max[2])/2.0;
1073
1129
        
1074
1130
}
1075
1131
 
1780
1836
        }
1781
1837
}
1782
1838
 
1783
 
void minmax_verts(float *min, float *max)
 
1839
int minmax_verts(float *min, float *max)
1784
1840
{
1785
1841
        TransVert *tv;
1786
1842
        float centroid[3], vec[3], bmat[3][3];
1789
1845
        tottrans=0;
1790
1846
        if ELEM5(G.obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE) 
1791
1847
                make_trans_verts(bmat[0], bmat[1], 0);
1792
 
        if(tottrans==0) return;
 
1848
        if(tottrans==0) return 0;
1793
1849
 
1794
1850
        Mat3CpyMat4(bmat, G.obedit->obmat);
1795
1851
        
1804
1860
        
1805
1861
        MEM_freeN(transvmain);
1806
1862
        transvmain= 0;
 
1863
        return 1;
1807
1864
}
1808
1865