sync changes from bmesh r42951 + some other minor edits.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 28 Dec 2011 22:46:10 +0000 (22:46 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 28 Dec 2011 22:46:10 +0000 (22:46 +0000)
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/mesh.c

index d7e2c73aa9ddb5a62c0af35394caaa791115517b..1cae5ee2f31dc53465a8b245e34c01158f80d4a8 100644 (file)
@@ -37,11 +37,13 @@ struct BoundBox;
 struct DispList;
 struct ListBase;
 struct EditMesh;
-struct MDeformVert;
 struct Mesh;
+struct MPoly;
+struct MLoop;
 struct MFace;
 struct MEdge;
 struct MVert;
+struct MDeformVert;
 struct MCol;
 struct Object;
 struct MTFace;
@@ -49,6 +51,7 @@ struct VecNor;
 struct CustomData;
 struct DerivedMesh;
 struct Scene;
+struct MLoopUV;
 
 #ifdef __cplusplus
 extern "C" {
@@ -166,8 +169,9 @@ void BKE_mesh_ensure_navmesh(struct Mesh *me);
 
 /*convert a triangle of loop facedata to mface facedata*/
 void mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata,
-                          struct CustomData *pdata, int lindex[4], int findex,
-                          const int polyindex, const int mf_len);
+                                 struct CustomData *pdata, int lindex[4], int findex,
+                                 const int polyindex, const int mf_len,
+                                 const int numTex, const int numCol, const int hasWCol);
 
 #ifdef __cplusplus
 }
index 61604bf1432d157e9fab8ed47b5764cea5650b82..408a141608d4b90ff122897a00fc67a90e3b38bc 100644 (file)
@@ -370,9 +370,9 @@ void mesh_get_texspace(Mesh *me, float *loc_r, float *rot_r, float *size_r)
                tex_space_mesh(me);
        }
 
-       if (loc_r) VECCOPY(loc_r, me->loc);
-       if (rot_r) VECCOPY(rot_r, me->rot);
-       if (size_r) VECCOPY(size_r, me->size);
+       if (loc_r) copy_v3_v3(loc_r, me->loc);
+       if (rot_r) copy_v3_v3(rot_r, me->rot);
+       if (size_r) copy_v3_v3(size_r, me->size);
 }
 
 float *get_mesh_orco_verts(Object *ob)
@@ -829,7 +829,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
                        a= dl->parts*dl->nr;
                        data= dl->verts;
                        while(a--) {
-                               VECCOPY(mvert->co, data);
+                               copy_v3_v3(mvert->co, data);
                                data+=3;
                                vertcount++;
                                mvert++;
@@ -852,7 +852,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
                                a= dl->parts*dl->nr;
                                data= dl->verts;
                                while(a--) {
-                                       VECCOPY(mvert->co, data);
+                                       copy_v3_v3(mvert->co, data);
                                        data+=3;
                                        vertcount++;
                                        mvert++;
@@ -875,7 +875,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
                        a= dl->nr;
                        data= dl->verts;
                        while(a--) {
-                               VECCOPY(mvert->co, data);
+                               copy_v3_v3(mvert->co, data);
                                data+=3;
                                vertcount++;
                                mvert++;
@@ -903,7 +903,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
                        a= dl->parts*dl->nr;
                        data= dl->verts;
                        while(a--) {
-                               VECCOPY(mvert->co, data);
+                               copy_v3_v3(mvert->co, data);
                                data+=3;
                                vertcount++;
                                mvert++;
@@ -992,8 +992,8 @@ void nurbs_to_mesh(Object *ob)
                me->totedge= totedge;
 
                me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert);
-               me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, allface, me->totface);
                me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge);
+               me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, allface, me->totface);
 
                mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
        } else {
@@ -1452,19 +1452,22 @@ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, c
 #ifdef USE_BMESH_FORWARD_COMPAT
 
 void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
-                          CustomData *pdata, int lindex[4], int findex,
-                          const int polyindex,
-                          const int mf_len /* 3 or 4 */
-                          )
+                                 CustomData *pdata, int lindex[4], int findex,
+                                 const int polyindex,
+                                 const int mf_len, /* 3 or 4 */
+
+                                 /* cache values to avoid lookups every time */
+                                 const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */
+                                 const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */
+                                 const int hasWCol /* CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL) */
+                                 )
 {
        MTFace *texface;
        MTexPoly *texpoly;
        MCol *mcol;
        MLoopCol *mloopcol;
        MLoopUV *mloopuv;
-       int i, j, hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
-       int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
-       int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
+       int i, j;
        
        for(i=0; i < numTex; i++){
                texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
@@ -1527,6 +1530,10 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
        MFace *mface = NULL, *mf;
        BLI_array_declare(mface);
 
+       const int numTex = CustomData_number_of_layers(pdata, CD_MTEXPOLY);
+       const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
+       const int hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
+
        mpoly = CustomData_get_layer(pdata, CD_MPOLY);
        mloop = CustomData_get_layer(ldata, CD_MLOOP);
 
@@ -1582,7 +1589,8 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
                                mf->v3 = mloop[mf->v3].v;
 
                                mesh_loops_to_mface_corners(fdata, ldata, pdata,
-                                                           lindex, k, i, 3);
+                                                           lindex, k, i, 3,
+                                                           numTex, numCol, hasWCol);
                                test_index_face(mf, fdata, totface, 3);
                        }
                        else {
@@ -1601,7 +1609,8 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
                                mf->v4 = mloop[mf->v4].v;
 
                                mesh_loops_to_mface_corners(fdata, ldata, pdata,
-                                                           lindex, k, i, 4);
+                                                           lindex, k, i, 4,
+                                                           numTex, numCol, hasWCol);
                                test_index_face(mf, fdata, totface, 4);
                        }