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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Lukas Fittl
  • Date: 2006-09-20 01:57:27 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060920015727-gmoqlxwstx9wwqs3
Tags: 2.42a-1ubuntu1
* Merge from Debian unstable (Closes: Malone #55903). Remaining changes:
  - debian/genpot: Add python scripts from Lee June <blender@eyou.com> to
    generate a reasonable PO template from the sources. Since gettext is used
    in a highly nonstandard way, xgettext does not work for this job.
  - debian/rules: Call the scripts, generate po/blender.pot, and clean it up
    in the clean target.
  - Add a proper header to the generated PO template.
* debian/control: Build depend on libavformat-dev >= 3:0.cvs20060823-3.1,
  otherwise this package will FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
450
450
        Mesh *me;
451
451
        int toggle, a;
452
452
 
453
 
        if(G.obedit) return;
 
453
        if(G.obedit || G.vd==NULL) return;
454
454
 
455
455
        /* reset flags */
456
456
        me= G.main->mesh.first;
494
494
        Mesh *me;
495
495
        int a;
496
496
 
497
 
        if(G.obedit) return;
 
497
        if(G.obedit || G.vd==NULL) return;
498
498
 
499
499
        base= FIRSTBASE;
500
500
        while(base) {
604
604
 
605
605
typedef struct MocNode {
606
606
        struct MocNode *next;
607
 
        int index[MOC_NODE_RES];
 
607
        long index[MOC_NODE_RES];
608
608
} MocNode;
609
609
 
610
610
static int mesh_octree_get_base_offs(float *co, float *offs, float *div)
622
622
        return (vx*MOC_RES*MOC_RES) + vy*MOC_RES + vz;
623
623
}
624
624
 
625
 
static void mesh_octree_add_node(MocNode **bt, int index)
 
625
static void mesh_octree_add_node(MocNode **bt, long index)
626
626
{
627
627
        if(*bt==NULL) {
628
628
                *bt= MEM_callocN(sizeof(MocNode), "MocNode");
654
654
/* temporal define, just to make nicer code below */
655
655
#define MOC_ADDNODE(vx, vy, vz) mesh_octree_add_node(basetable + ((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz), index)
656
656
 
657
 
static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, int index)
 
657
static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, long index)
658
658
{
659
659
        float fx, fy, fz;
660
660
        int vx, vy, vz;
695
695
        
696
696
}
697
697
 
698
 
static int mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
 
698
static long mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
699
699
{
700
700
        float *vec;
701
701
        int a;
708
708
                        /* does mesh verts and editmode, code looks potential dangerous, octree should really be filled OK! */
709
709
                        if(mvert) {
710
710
                                vec= (mvert+(*bt)->index[a]-1)->co;
711
 
                                
712
711
                                if(FloatCompare(vec, co, MOC_THRESH))
713
712
                                        return (*bt)->index[a]-1;
714
713
                        }
715
714
                        else {
716
 
                                EditVert *eve= (EditVert *)INT_TO_POINTER((*bt)->index[a]);
717
 
                                
 
715
                                EditVert *eve= (EditVert *)((*bt)->index[a]);
718
716
                                if(FloatCompare(eve->co, co, MOC_THRESH))
719
 
                                        return (int)eve;
 
717
                                        return (*bt)->index[a];
720
718
                        }
721
719
                }
722
720
                else return -1;
730
728
 
731
729
/* mode is 's' start, or 'e' end, or 'u' use */
732
730
/* if end, ob can be NULL */
733
 
int mesh_octree_table(Object *ob, float *co, char mode)
 
731
long mesh_octree_table(Object *ob, float *co, char mode)
734
732
{
735
733
        MocNode **bt;
736
734
        static MocNode **basetable= NULL;
756
754
                
757
755
                /* for quick unit coordinate calculus */
758
756
                VECCOPY(offs, bb->vec[0]);
759
 
                offs[0]+= MOC_THRESH;           /* we offset it 1 threshold unit extra */
760
 
                offs[1]+= MOC_THRESH;
761
 
                offs[2]+= MOC_THRESH;
 
757
                offs[0]-= MOC_THRESH;           /* we offset it 1 threshold unit extra */
 
758
                offs[1]-= MOC_THRESH;
 
759
                offs[2]-= MOC_THRESH;
762
760
                        
763
 
                VecSubf(div, bb->vec[6], offs);
764
 
                div[0]+= MOC_THRESH;            /* and divide with 1 threshold unit more extra (try 8x8 unit grid on paint) */
765
 
                div[1]+= MOC_THRESH;
766
 
                div[2]+= MOC_THRESH;
 
761
                VecSubf(div, bb->vec[6], bb->vec[0]);
 
762
                div[0]+= 2*MOC_THRESH;          /* and divide with 2 threshold unit more extra (try 8x8 unit grid on paint) */
 
763
                div[1]+= 2*MOC_THRESH;
 
764
                div[2]+= 2*MOC_THRESH;
767
765
                
768
766
                VecMulf(div, 1.0f/MOC_RES);
769
767
                if(div[0]==0.0f) div[0]= 1.0f;
770
768
                if(div[1]==0.0f) div[1]= 1.0f;
771
769
                if(div[2]==0.0f) div[2]= 1.0f;
772
 
        
773
 
                if(basetable) /* happens when entering wpaint without closing it */
 
770
                        
 
771
                if(basetable) /* happens when entering this call without ending it */
774
772
                        mesh_octree_table(ob, co, 'e');
775
773
                
776
774
                basetable= MEM_callocN(MOC_RES*MOC_RES*MOC_RES*sizeof(void *), "sym table");
779
777
                        EditVert *eve;
780
778
                        
781
779
                        for(eve= G.editMesh->verts.first; eve; eve= eve->next) {
782
 
                                mesh_octree_add_nodes(basetable, eve->co, offs, div, POINTER_TO_INT(eve));
 
780
                                mesh_octree_add_nodes(basetable, eve->co, offs, div, (long)(eve));
783
781
                        }
784
782
                }
785
783
                else {          
786
784
                        MVert *mvert;
787
 
                        int a;
 
785
                        long a;
788
786
                        
789
787
                        for(a=1, mvert= me->mvert; a<=me->totvert; a++, mvert++) {
790
788
                                mesh_octree_add_nodes(basetable, mvert->co, offs, div, a);
817
815
        
818
816
        return mesh_octree_table(ob, vec, 'u');
819
817
}
 
818
 
 
819
EditVert *editmesh_get_x_mirror_vert(Object *ob, float *co)
 
820
{
 
821
        float vec[3];
 
822
        long poinval;
 
823
        
 
824
        vec[0]= -co[0];
 
825
        vec[1]= co[1];
 
826
        vec[2]= co[2];
 
827
        
 
828
        poinval= mesh_octree_table(ob, vec, 'u');
 
829
        if(poinval != -1)
 
830
                return (EditVert *)(poinval);
 
831
        return NULL;
 
832
}
 
833