Code Cleanup:
authorCampbell Barton <ideasman42@gmail.com>
Wed, 8 Feb 2012 09:02:10 +0000 (09:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 8 Feb 2012 09:02:10 +0000 (09:02 +0000)
macro for copying polygon settings

source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/bmesh/intern/bmesh_interp.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/makesdna/DNA_meshdata_types.h

index 63a2a8b335b84d14c6d35258e2f9cc655c0eae23..00d7f6e2a1fc8ad54cee0edce9b7f0c1935c7df7 100644 (file)
@@ -1949,12 +1949,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
                texface = CustomData_get_n(facedata, CD_MTFACE, cdindex, i);
                texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i);
                
-               texface->tpage = texpoly->tpage;
-               texface->flag = texpoly->flag;
-               texface->transp = texpoly->transp;
-               texface->mode = texpoly->mode;
-               texface->tile = texpoly->tile;
-               texface->unwrap = texpoly->unwrap;
+               ME_MTEXFACE_CPY(texface, texpoly);
        
                for (j=0; j<3; j++) {
                        l = l3[j];
index 063b31c5b87813d044f2099d7b71b1e2da3cfdb3..2b2da712a1b91030898283288a1292491f0818c5 100644 (file)
@@ -877,12 +877,7 @@ static void emDM_drawFacesTex_common(
                        efa = ls[0]->f;
 
                        if (has_uv) {
-                               mtf.flag = tp->flag;
-                               mtf.tpage = tp->tpage;
-                               mtf.transp = tp->transp;
-                               mtf.mode = tp->mode;
-                               mtf.tile = tp->tile;
-                               mtf.unwrap = tp->unwrap;
+                               ME_MTEXFACE_CPY(&mtf, tp);
                        }
 
                        if (drawParams)
@@ -952,12 +947,7 @@ static void emDM_drawFacesTex_common(
                        efa = ls[0]->f;
 
                        if (has_uv) {
-                               mtf.flag = tp->flag;
-                               mtf.tpage = tp->tpage;
-                               mtf.transp = tp->transp;
-                               mtf.mode = tp->mode;
-                               mtf.tile = tp->tile;
-                               mtf.unwrap = tp->unwrap;
+                               ME_MTEXFACE_CPY(&mtf, tp);
                        }
 
                        if (drawParams)
index 7d13cf86687049dbaa986ef6b472b0a857332111..5a3bf09dd0dd9ebcca6e2b64d1c68caa34b4c055 100644 (file)
@@ -1846,12 +1846,7 @@ static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numT
                texface = CustomData_get_n(&me->fdata, CD_MTFACE, findex, i);
                texpoly = CustomData_get_n(&me->pdata, CD_MTEXPOLY, findex, i); 
                
-               texpoly->tpage = texface->tpage;
-               texpoly->flag = texface->flag;
-               texpoly->transp = texface->transp;
-               texpoly->mode = texface->mode;
-               texpoly->tile = texface->tile;
-               texpoly->unwrap = texface->unwrap;
+               ME_MTEXFACE_CPY(texpoly, texface);
        
                mloopuv = CustomData_get_n(&me->ldata, CD_MLOOPUV, loopstart, i);
                copy_v2_v2(mloopuv->uv, texface->uv[0]); mloopuv++;
@@ -2194,13 +2189,8 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
        for(i=0; i < numTex; i++){
                texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
                texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i);
-               
-               texface->tpage = texpoly->tpage;
-               texface->flag = texpoly->flag;
-               texface->transp = texpoly->transp;
-               texface->mode = texpoly->mode;
-               texface->tile = texpoly->tile;
-               texface->unwrap = texpoly->unwrap;
+
+               ME_MTEXFACE_CPY(texface, texpoly);
 
                for (j=0; j < mf_len; j++) {
                        mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, lindex[j], i);
index cd62a480e583be48fa965aed9ee22941cb666be4..47e5c0d891d0bfe957a521fb4b227abb1f90c375 100644 (file)
@@ -2402,12 +2402,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
                texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
                texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i);
                
-               texface->tpage = texpoly->tpage;
-               texface->flag = texpoly->flag;
-               texface->transp = texpoly->transp;
-               texface->mode = texpoly->mode;
-               texface->tile = texpoly->tile;
-               texface->unwrap = texpoly->unwrap;
+               ME_MTEXFACE_CPY(texface, texpoly);
 
                mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i);
                for (j=0; j<4; j++, mloopuv++) {
index 5a24d72fa4057c25379c50326af664d172c35252..1f8cf3c2ecec0b4bd9caebf27f0ce8f2c1490b6d 100644 (file)
@@ -159,12 +159,7 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex,
                texface = CustomData_get_n(&me->fdata, CD_MTFACE, findex, i);
                texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i);
                
-               texface->tpage = texpoly->tpage;
-               texface->flag = texpoly->flag;
-               texface->transp = texpoly->transp;
-               texface->mode = texpoly->mode;
-               texface->tile = texpoly->tile;
-               texface->unwrap = texpoly->unwrap;
+               ME_MTEXFACE_CPY(texface, texpoly);
 
                j = 0;
                BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
index 1f4f4bd7031e40fd2a21dc75bec6140312d990cb..edde4f3d7c1c65f687a71f3106a39ee4079ebdc9 100644 (file)
@@ -532,12 +532,7 @@ static int draw_tface_mapped__set_draw(void *userData, int index)
 
        memset(&mtf, 0, sizeof(mtf));
        if (tpoly) {
-               mtf.flag = tpoly->flag;
-               mtf.tpage = tpoly->tpage;
-               mtf.transp = tpoly->transp;
-               mtf.mode = tpoly->mode;
-               mtf.tile = tpoly->tile;
-               mtf.unwrap = tpoly->unwrap;
+               ME_MTEXFACE_CPY(&mtf, tpoly);
        }
 
        return draw_tface__set_draw(&mtf, (me->mcol != NULL), matnr);
@@ -558,13 +553,7 @@ static int draw_em_tf_mapped__set_draw(void *userData, int index)
 
                if (data->has_mtface) {
                        MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
-                       mtf.flag = tpoly->flag;
-                       mtf.tpage = tpoly->tpage;
-                       mtf.transp = tpoly->transp;
-                       mtf.mode = tpoly->mode;
-                       mtf.tile = tpoly->tile;
-                       mtf.unwrap = tpoly->unwrap;
-
+                       ME_MTEXFACE_CPY(&mtf, tpoly);
                }
 
                return draw_tface__set_draw_legacy(&mtf, data->has_mcol, matnr);
index 3a34ba38a76dda72b4b6650e10f8055668ea7a05..f21751ea33f13c2ff4742a56e61f538cc349e151 100644 (file)
@@ -98,6 +98,17 @@ typedef struct MTexPoly {
        short mode,tile,unwrap;
 } MTexPoly;
 
+/* can copy from/to MTexPoly/MTFace */
+#define ME_MTEXFACE_CPY(dst, src)   \
+{                                   \
+       (dst)->tpage  = (src)->tpage;   \
+       (dst)->flag   = (src)->flag;    \
+       (dst)->transp = (src)->transp;  \
+       (dst)->mode   = (src)->mode;    \
+       (dst)->tile   = (src)->tile;    \
+       (dst)->unwrap = (src)->unwrap;  \
+}
+
 typedef struct MLoopUV {
        float uv[2];
        int flag;