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

« back to all changes in this revision

Viewing changes to source/blender/src/editcurve.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: editcurve.c,v 1.56 2007/01/02 20:33:10 nicholasbishop Exp $
 
2
 * $Id: editcurve.c,v 1.60 2007/05/01 14:37:59 bebraw Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
325
325
        Curve *cu;
326
326
        ListBase editnurbo;
327
327
 
328
 
        if( (G.vd->lay & G.obedit->lay)==0 ) return;
 
328
        if( G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
329
329
 
330
330
        if(okee("Separate")==0) return;
331
331
 
970
970
{
971
971
        Nurb *nu;
972
972
        
973
 
        if(G.obedit->lay & G.vd->lay);
974
 
        else return;
 
973
        if(G.vd==0 || !(G.obedit->lay & G.vd->lay))
 
974
                return;
975
975
        
976
976
        for(nu= editNurb.first; nu; nu= nu->next) {
977
977
                if( isNurbsel(nu) ) switchdirectionNurb(nu);
1033
1033
        BPoint *bp;
1034
1034
        int a, b;
1035
1035
 
1036
 
        if(G.obedit->lay & G.vd->lay);
1037
 
        else return;
 
1036
        if(!G.vd || !(G.obedit->lay & G.vd->lay))
 
1037
                return;
1038
1038
 
1039
 
        BIF_undo_push("Deselect all");
1040
 
        
1041
1039
        a= 0;
1042
1040
        for(nu= editNurb.first; nu; nu= nu->next) {
1043
1041
                if((nu->type & 7)==CU_BEZIER) {
1111
1109
        }
1112
1110
        countall();
1113
1111
        allqueue(REDRAWVIEW3D, 0);
 
1112
        BIF_undo_push("Deselect all");
1114
1113
}
1115
1114
 
1116
1115
void hideNurb(int swap)
1131
1130
                        sel= 0;
1132
1131
                        while(a--) {
1133
1132
                                if(BEZSELECTED(bezt)) {
1134
 
                                        sel++;
1135
1133
                                        bezt->f1 &= ~1;
1136
1134
                                        bezt->f2 &= ~1;
1137
1135
                                        bezt->f3 &= ~1;
1138
1136
                                        bezt->hide= 1;
1139
1137
                                }
 
1138
                                if(bezt->hide) sel++;
1140
1139
                                bezt++;
1141
1140
                        }
1142
1141
                        if(sel==nu->pntsu) nu->hide= 1;
1149
1148
                                if(swap==0 && (bp->f1 & 1)) {
1150
1149
                                        bp->f1 &= ~1;
1151
1150
                                        bp->hide= 1;
1152
 
                                        sel++;
1153
1151
                                }
1154
1152
                                else if(swap && (bp->f1 & 1)==0) {
1155
1153
                                        bp->f1 &= ~1;
1156
1154
                                        bp->hide= 1;
1157
 
                                        sel++;
1158
1155
                                }
 
1156
                                if(bp->hide) sel++;
1159
1157
                                bp++;
1160
1158
                        }
1161
1159
                        if(sel==nu->pntsu*nu->pntsv) nu->hide= 1;
2456
2454
        float cent[3],bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3];
2457
2455
        float persmat[3][3], persinv[3][3];
2458
2456
        short a,ok;
2459
 
 
2460
 
        if(G.obedit==0 || G.obedit->type!=OB_SURF) return;
 
2457
        
 
2458
        if(G.vd==0 || G.obedit==0 || G.obedit->type!=OB_SURF) return;
2461
2459
        if( (G.vd->lay & G.obedit->lay)==0 ) return;
2462
2460
 
2463
2461
        Mat3CpyMat4(persmat, G.vd->viewmat);
2464
2462
        Mat3Inv(persinv, persmat);
2465
2463
 
2466
 
        /* imat and centre and size */
 
2464
        /* imat and center and size */
2467
2465
        Mat3CpyMat4(bmat, G.obedit->obmat);
2468
2466
        Mat3Inv(imat, bmat);
2469
2467
 
2479
2477
                n[0]= G.vd->viewinv[2][0];
2480
2478
                n[1]= G.vd->viewinv[2][1];
2481
2479
                n[2]= G.vd->viewinv[2][2];
2482
 
                Normalise(n);
 
2480
                Normalize(n);
2483
2481
        }
2484
2482
 
2485
2483
        phi= M_PI/8.0;
2563
2561
        BPoint *bp, *newbp = NULL;
2564
2562
        float *curs, mat[3][3],imat[3][3], temp[3];
2565
2563
 
2566
 
        if(G.obedit==0) return;
 
2564
        if(G.obedit==0 || G.vd == 0) return;
2567
2565
        if( (G.vd->lay & G.obedit->lay)==0 ) return;
2568
2566
 
2569
2567
        Mat3CpyMat4(mat, G.obedit->obmat);
3336
3334
void adduplicate_nurb()
3337
3335
{
3338
3336
 
3339
 
        if( (G.vd->lay & G.obedit->lay)==0 ) return;
 
3337
        if(G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
3340
3338
 
3341
3339
        adduplicateflagNurb(1);
3342
3340
 
3355
3353
        short event, cut = 0;
3356
3354
 
3357
3355
        if(G.obedit==0 ) return;
3358
 
        if( (G.vd->lay & G.obedit->lay)==0 ) return;
 
3356
        if(G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
3359
3357
 
3360
3358
        if(G.obedit->type==OB_SURF) event= pupmenu("Erase %t|Selected%x0|All%x2");
3361
3359
        else event= pupmenu("Erase %t|Selected%x0|Segment%x1|All%x2");
3655
3653
        int a;
3656
3654
        
3657
3655
        ob= OBACT;
3658
 
        if(ob->type!=type) return 0;
 
3656
        if (object_data_is_libdata(ob)) {
 
3657
                error_libdata();
 
3658
                return 0;
 
3659
        } 
 
3660
        
 
3661
        if(!G.vd || ob->type!=type) return 0;
3659
3662
        if(ob->lay & G.vd->lay); else return 0;
3660
3663
        tempbase.first= tempbase.last= 0;
3661
3664
        
3665
3668
        base= FIRSTBASE;
3666
3669
        while(base) {
3667
3670
                nextb= base->next;
3668
 
                if TESTBASELIB(base) {
 
3671
                if TESTBASE(base) {
3669
3672
                        if(base->object->type==type) {
3670
3673
                                if(base->object != ob) {
3671
3674
                                
3737
3740
        BezTriple *bezt;
3738
3741
        BPoint *bp;
3739
3742
        float *curs, cent[3],vec[3],imat[3][3],mat[3][3];
3740
 
        float fac,cmat[3][3];
 
3743
        float fac,cmat[3][3], grid;
3741
3744
        int a, b;
3742
 
 
3743
 
        /* imat and centre and size */
 
3745
        
 
3746
        if (G.vd)       grid = G.vd->grid;
 
3747
        else            grid = 1.0;
 
3748
        
 
3749
        /* imat and center and size */
3744
3750
        if(G.obedit) {
3745
3751
                
3746
3752
                Mat3CpyMat4(mat, G.obedit->obmat);
3749
3755
                cent[0]-= G.obedit->obmat[3][0];
3750
3756
                cent[1]-= G.obedit->obmat[3][1];
3751
3757
                cent[2]-= G.obedit->obmat[3][2];
3752
 
 
3753
 
                Mat3CpyMat4(imat, G.vd->viewmat);
3754
 
                Mat3MulVecfl(imat, cent);
3755
 
                Mat3MulMat3(cmat, imat, mat);
3756
 
                Mat3Inv(imat, cmat);
 
3758
                
 
3759
                if (G.vd) {
 
3760
                        Mat3CpyMat4(imat, G.vd->viewmat);
 
3761
                        Mat3MulVecfl(imat, cent);
 
3762
                        Mat3MulMat3(cmat, imat, mat);
 
3763
                        Mat3Inv(imat, cmat);
 
3764
                }
3757
3765
                setflagsNurb(0);
3758
3766
        }
3759
3767
        else {
3786
3794
                        for(a=0;a<3;a++) {
3787
3795
                                VECCOPY(bezt->vec[a], cent);
3788
3796
                        }
3789
 
                        bezt->vec[1][0]+= -G.vd->grid;
3790
 
                        bezt->vec[0][0]+= -1.5*G.vd->grid;
3791
 
                        bezt->vec[0][1]+= -0.5*G.vd->grid;
3792
 
                        bezt->vec[2][0]+= -0.5*G.vd->grid;
3793
 
                        bezt->vec[2][1]+=  0.5*G.vd->grid;
 
3797
                        bezt->vec[1][0]+= -grid;
 
3798
                        bezt->vec[0][0]+= -1.5*grid;
 
3799
                        bezt->vec[0][1]+= -0.5*grid;
 
3800
                        bezt->vec[2][0]+= -0.5*grid;
 
3801
                        bezt->vec[2][1]+=  0.5*grid;
3794
3802
                        for(a=0;a<3;a++) Mat3MulVecfl(imat, bezt->vec[a]);
3795
3803
 
3796
3804
                        bezt++;
3801
3809
                        for(a=0;a<3;a++) {
3802
3810
                                VECCOPY(bezt->vec[a], cent);
3803
3811
                        }
3804
 
                        bezt->vec[1][0]+= G.vd->grid;
 
3812
                        bezt->vec[1][0]+= grid;
3805
3813
                        for(a=0;a<3;a++) Mat3MulVecfl(imat, bezt->vec[a]);
3806
3814
 
3807
3815
                        calchandlesNurb(nu);
3808
3816
                }
3809
3817
                else {
 
3818
                        
3810
3819
                        nu->pntsu= 4;
3811
3820
                        nu->pntsv= 1;
3812
3821
                        nu->orderu= 4;
3821
3830
                        }
3822
3831
 
3823
3832
                        bp= nu->bp;
3824
 
                        bp->vec[0]+= -1.5*G.vd->grid; 
3825
 
                        bp++;
3826
 
                        bp->vec[0]+= -G.vd->grid;
3827
 
                        bp->vec[1]+= G.vd->grid; 
3828
 
                        bp++;
3829
 
                        bp->vec[0]+= G.vd->grid;
3830
 
                        bp->vec[1]+= G.vd->grid; 
3831
 
                        bp++;
3832
 
                        bp->vec[0]+= 1.5*G.vd->grid;
 
3833
                        bp->vec[0]+= -1.5*grid; 
 
3834
                        bp++;
 
3835
                        bp->vec[0]+= -grid;
 
3836
                        bp->vec[1]+=  grid; 
 
3837
                        bp++;
 
3838
                        bp->vec[0]+= grid;
 
3839
                        bp->vec[1]+= grid; 
 
3840
                        bp++;
 
3841
                        bp->vec[0]+= 1.5*grid;
3833
3842
 
3834
3843
                        bp= nu->bp;
3835
3844
                        for(a=0;a<4;a++, bp++) Mat3MulVecfl(imat,bp->vec);
3858
3867
                }
3859
3868
 
3860
3869
                bp= nu->bp;
3861
 
                bp->vec[0]+= -2.0*G.vd->grid; 
 
3870
                bp->vec[0]+= -2.0*grid; 
3862
3871
                bp++;
3863
 
                bp->vec[0]+= -G.vd->grid;
 
3872
                bp->vec[0]+= -grid;
3864
3873
                bp++; bp++;
3865
 
                bp->vec[0]+= G.vd->grid;
 
3874
                bp->vec[0]+= grid;
3866
3875
                bp++;
3867
 
                bp->vec[0]+= 2.0*G.vd->grid;
 
3876
                bp->vec[0]+= 2.0*grid;
3868
3877
 
3869
3878
                bp= nu->bp;
3870
3879
                for(a=0;a<5;a++, bp++) Mat3MulVecfl(imat,bp->vec);
3891
3900
                        }
3892
3901
                        bezt->h1= bezt->h2= HD_AUTO;
3893
3902
                        bezt->f1= bezt->f2= bezt->f3= 1;
3894
 
                        bezt->vec[1][0]+= -G.vd->grid;
 
3903
                        bezt->vec[1][0]+= -grid;
3895
3904
                        for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
3896
3905
                        bezt->radius = bezt->weight = 1.0;
3897
3906
                        
3901
3910
                        }
3902
3911
                        bezt->h1= bezt->h2= HD_AUTO;
3903
3912
                        bezt->f1= bezt->f2= bezt->f3= 1;
3904
 
                        bezt->vec[1][1]+= G.vd->grid;
3905
 
                        for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
3906
 
                        bezt->radius = bezt->weight = 1.0;
3907
 
 
3908
 
                        bezt++;
3909
 
                        for(a=0;a<3;a++) {
3910
 
                                VECCOPY(bezt->vec[a], cent);
3911
 
                        }
3912
 
                        bezt->h1= bezt->h2= HD_AUTO;
3913
 
                        bezt->f1= bezt->f2= bezt->f3= 1;
3914
 
                        bezt->vec[1][0]+= G.vd->grid;
3915
 
                        for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
3916
 
                        bezt->radius = bezt->weight = 1.0;
3917
 
 
3918
 
                        bezt++;
3919
 
                        for(a=0;a<3;a++) {
3920
 
                                VECCOPY(bezt->vec[a], cent);
3921
 
                        }
3922
 
                        bezt->h1= bezt->h2= HD_AUTO;
3923
 
                        bezt->f1= bezt->f2= bezt->f3= 1;
3924
 
                        bezt->vec[1][1]+= -G.vd->grid;
 
3913
                        bezt->vec[1][1]+= grid;
 
3914
                        for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
 
3915
                        bezt->radius = bezt->weight = 1.0;
 
3916
 
 
3917
                        bezt++;
 
3918
                        for(a=0;a<3;a++) {
 
3919
                                VECCOPY(bezt->vec[a], cent);
 
3920
                        }
 
3921
                        bezt->h1= bezt->h2= HD_AUTO;
 
3922
                        bezt->f1= bezt->f2= bezt->f3= 1;
 
3923
                        bezt->vec[1][0]+= grid;
 
3924
                        for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
 
3925
                        bezt->radius = bezt->weight = 1.0;
 
3926
 
 
3927
                        bezt++;
 
3928
                        for(a=0;a<3;a++) {
 
3929
                                VECCOPY(bezt->vec[a], cent);
 
3930
                        }
 
3931
                        bezt->h1= bezt->h2= HD_AUTO;
 
3932
                        bezt->f1= bezt->f2= bezt->f3= 1;
 
3933
                        bezt->vec[1][1]+= -grid;
3925
3934
                        for(a=0;a<3;a++) Mat3MulVecfl(imat,bezt->vec[a]);
3926
3935
                        bezt->radius = bezt->weight = 1.0;
3927
3936
 
3940
3949
                                VECCOPY(bp->vec, cent);
3941
3950
 
3942
3951
                                if(xzproj==0) {
3943
 
                                        bp->vec[0]+= nurbcircle[a][0]*G.vd->grid;
3944
 
                                        bp->vec[1]+= nurbcircle[a][1]*G.vd->grid;
 
3952
                                        bp->vec[0]+= nurbcircle[a][0]*grid;
 
3953
                                        bp->vec[1]+= nurbcircle[a][1]*grid;
3945
3954
                                }
3946
3955
                                else {
3947
 
                                        bp->vec[0]+= 0.25*nurbcircle[a][0]*G.vd->grid-.75*G.vd->grid;
3948
 
                                        bp->vec[2]+= 0.25*nurbcircle[a][1]*G.vd->grid;
 
3956
                                        bp->vec[0]+= 0.25*nurbcircle[a][0]*grid-.75*grid;
 
3957
                                        bp->vec[2]+= 0.25*nurbcircle[a][1]*grid;
3949
3958
                                }
3950
3959
                                if(a & 1) bp->vec[3]= 0.25*sqrt(2.0);
3951
3960
                                else bp->vec[3]= 1.0;
3980
3989
                                        VECCOPY(bp->vec, cent);
3981
3990
                                        bp->f1= 1;
3982
3991
                                        fac= (float)a -1.5;
3983
 
                                        bp->vec[0]+= fac*G.vd->grid;
 
3992
                                        bp->vec[0]+= fac*grid;
3984
3993
                                        fac= (float)b -1.5;
3985
 
                                        bp->vec[1]+= fac*G.vd->grid;
 
3994
                                        bp->vec[1]+= fac*grid;
3986
3995
                                        if(a==1 || a==2) if(b==1 || b==2) {
3987
 
                                                bp->vec[2]+= G.vd->grid;
 
3996
                                                bp->vec[2]+= grid;
3988
3997
                                        }
3989
3998
                                        Mat3MulVecfl(imat,bp->vec);
3990
3999
                                        bp->vec[3]= 1.0;
4008
4017
                        nu->flag= CU_SMOOTH;
4009
4018
                        BLI_addtail(&editNurb, nu); /* temporal for extrude and translate */
4010
4019
                        vec[0]=vec[1]= 0.0;
4011
 
                        vec[2]= -G.vd->grid;
 
4020
                        vec[2]= -grid;
4012
4021
                        Mat3MulVecfl(imat, vec);
4013
4022
                        translateflagNurb(1, vec);
4014
4023
                        extrudeflagNurb(1);
4047
4056
                        for(a=0; a<5; a++) {
4048
4057
                                bp->f1= 1;
4049
4058
                                VECCOPY(bp->vec, cent);
4050
 
                                bp->vec[0]+= nurbcircle[a][0]*G.vd->grid;
4051
 
                                bp->vec[2]+= nurbcircle[a][1]*G.vd->grid;
 
4059
                                bp->vec[0]+= nurbcircle[a][0]*grid;
 
4060
                                bp->vec[2]+= nurbcircle[a][1]*grid;
4052
4061
                                if(a & 1) bp->vec[3]= 0.5*sqrt(2.0);
4053
4062
                                else bp->vec[3]= 1.0;
4054
4063
                                Mat3MulVecfl(imat,bp->vec);
4148
4157
        Curve *cu;
4149
4158
        int type, newname= 0;
4150
4159
 
 
4160
        if(G.vd==0) return;
4151
4161
        if(G.scene->id.lib) return;
4152
4162
 
4153
4163
        /* this function also comes from an info window */
4154
4164
        if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
4155
 
        if(G.vd==0) return;
4156
4165
 
4157
4166
        if(stype>=10 && stype<20) type= CU_2D+1;
4158
4167
        else if(stype>=20 && stype<30) type= CU_2D+2;