2.5
authorMartin Poirier <theeth@yahoo.com>
Tue, 20 Jan 2009 19:58:05 +0000 (19:58 +0000)
committerMartin Poirier <theeth@yahoo.com>
Tue, 20 Jan 2009 19:58:05 +0000 (19:58 +0000)
EditMesh snap still had stubs instead of proper editmesh calls
Misc correction for 2D edit with NDOF (not testable without ndof support)

source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_snap.c

index fce7d4b37974fdc562f1e0a23788531c37faec56..a630277c87af272f5f217542d41f89c45efe7cfd 100644 (file)
@@ -2804,7 +2804,7 @@ void initTranslation(TransInfo *t)
        t->num.flag = 0;
        t->num.idx_max = t->idx_max;
        
-       t->ndof.axis = 1|2|4;
+       t->ndof.axis = (t->flag & T_2D_EDIT)? 1|2: 1|2|4;
 
        if(t->spacetype == SPACE_VIEW3D) {
                View3D *v3d = t->view;
index 7e27fb32044ecdd114b8ef7c9f388f0e2c5a62ff..023b97058d3483cebc13705f9bcd522b30906366 100644 (file)
@@ -65,6 +65,7 @@
 #include "BKE_context.h"
 
 #include "ED_view3d.h"
+#include "ED_mesh.h"
 
 #include "WM_types.h"
 
 
 //#include "blendef.h" /* for selection modes */
 
-static EditVert *EM_get_vert_for_index(int x) {return 0;}      // XXX
-static EditEdge *EM_get_edge_for_index(int x) {return 0;}      // XXX
-static EditFace *EM_get_face_for_index(int x) {return 0;}      // XXX
-static void EM_init_index_arrays(int x, int y, int z) {} // XXX
-static void EM_free_index_arrays(void) {}              // XXX
-
 /********************* PROTOTYPES ***********************/
 
 void setSnappingCallback(TransInfo *t);
@@ -516,7 +511,7 @@ void CalcSnapGeometry(TransInfo *t, float *vec)
                        int found = 0;
                        int dist = 40; // Use a user defined value here
                        
-                       found = snapObjects(t, &dist, vec, no, t->mode);
+                       found = snapObjects(t, &dist, vec, no, t->tsnap.mode);
                        if (found == 1)
                        {
                                float tangent[3];
@@ -550,7 +545,7 @@ void CalcSnapGeometry(TransInfo *t, float *vec)
                        int found = 0;
                        int dist = 40; // Use a user defined value here
 
-                       found = snapObjects(t, &dist, vec, no, t->mode);
+                       found = snapObjects(t, &dist, vec, no, t->tsnap.mode);
                        if (found == 1)
                        {
                                VECCOPY(t->tsnap.snapPoint, vec);
@@ -764,7 +759,7 @@ void TargetSnapClosest(TransInfo *t)
 }
 /*================================================================*/
 
-int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth, short EditMesh)
+int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, EditMesh *em, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth)
 {
        int retval = 0;
        int totvert = dm->getNumVerts(dm);
@@ -808,10 +803,10 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                        int index = 0;
                                        int i;
                                        
-                                       if (EditMesh)
+                                       if (em != NULL)
                                        {
                                                index_array = dm->getFaceDataArray(dm, CD_ORIGINDEX);
-                                               EM_init_index_arrays(0, 0, 1);
+                                               EM_init_index_arrays(em, 0, 0, 1);
                                        }
                                        
                                        for( i = 0; i < totface; i++) {
@@ -822,7 +817,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                                
                                                test = 1; /* reset for every face */
                                        
-                                               if (EditMesh)
+                                               if (em != NULL)
                                                {
                                                        if (index_array)
                                                        {
@@ -940,7 +935,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                                }
                                        }
                                        
-                                       if (EditMesh)
+                                       if (em != NULL)
                                        {
                                                EM_free_index_arrays();
                                        }
@@ -953,10 +948,10 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                        int index = 0;
                                        int i;
                                        
-                                       if (EditMesh)
+                                       if (em != NULL)
                                        {
                                                index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
-                                               EM_init_index_arrays(1, 0, 0);
+                                               EM_init_index_arrays(em, 1, 0, 0);
                                        }
                                        
                                        for( i = 0; i < totvert; i++) {
@@ -965,7 +960,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                                
                                                test = 1; /* reset for every vert */
                                        
-                                               if (EditMesh)
+                                               if (em != NULL)
                                                {
                                                        if (index_array)
                                                        {
@@ -1031,7 +1026,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                                }
                                        }
 
-                                       if (EditMesh)
+                                       if (em != NULL)
                                        {
                                                EM_free_index_arrays();
                                        }
@@ -1046,10 +1041,10 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                        int index = 0;
                                        int i;
                                        
-                                       if (EditMesh)
+                                       if (em != NULL)
                                        {
                                                index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
-                                               EM_init_index_arrays(0, 1, 0);
+                                               EM_init_index_arrays(em, 0, 1, 0);
                                        }
                                        
                                        for( i = 0; i < totedge; i++) {
@@ -1058,7 +1053,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                                
                                                test = 1; /* reset for every vert */
                                        
-                                               if (EditMesh)
+                                               if (em != NULL)
                                                {
                                                        if (index_array)
                                                        {
@@ -1163,7 +1158,7 @@ int snapDerivedMesh(TransInfo *t, Object *ob, DerivedMesh *dm, float obmat[][4],
                                                }
                                        }
 
-                                       if (EditMesh)
+                                       if (em != NULL)
                                        {
                                                EM_free_index_arrays();
                                        }
@@ -1194,7 +1189,7 @@ int snapObjects(TransInfo *t, int *dist, float *loc, float *no, int mode) {
                
                dm = editmesh_get_derived_cage(t->scene, t->obedit, em, CD_MASK_BAREMESH);
                
-               retval = snapDerivedMesh(t, ob, dm, ob->obmat, ray_start, ray_normal, t->mval, loc, no, dist, &depth, 1);
+               retval = snapDerivedMesh(t, ob, dm, em, ob->obmat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
                
                dm->release(dm);
        }
@@ -1220,7 +1215,7 @@ int snapObjects(TransInfo *t, int *dist, float *loc, float *no, int mode) {
                                                DerivedMesh *dm = mesh_get_derived_final(t->scene, ob, CD_MASK_BAREMESH);
                                                int val;
                                                
-                                               val = snapDerivedMesh(t, ob, dm, dupli_ob->mat, ray_start, ray_normal, t->mval, loc, no, dist, &depth, 0);
+                                               val = snapDerivedMesh(t, ob, dm, NULL, dupli_ob->mat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
        
                                                retval = retval || val;
        
@@ -1235,7 +1230,7 @@ int snapObjects(TransInfo *t, int *dist, float *loc, float *no, int mode) {
                                DerivedMesh *dm = mesh_get_derived_final(t->scene, ob, CD_MASK_BAREMESH);
                                int val;
                                
-                               val = snapDerivedMesh(t, ob, dm, ob->obmat, ray_start, ray_normal, t->mval, loc, no, dist, &depth, 0);
+                               val = snapDerivedMesh(t, ob, dm, NULL, ob->obmat, ray_start, ray_normal, t->mval, loc, no, dist, &depth);
                                
                                retval = retval || val;