Code Cleanup: use vector functions for copying / adding UV's
authorCampbell Barton <ideasman42@gmail.com>
Sun, 5 Feb 2012 13:25:42 +0000 (13:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 5 Feb 2012 13:25:42 +0000 (13:25 +0000)
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/bmesh/intern/bmesh_interp.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c

index 15740076dc0b2cf8f4b3073727cbef03f1cc1d89..35759c204fba36fd320b851d5b5c57882431c122 100644 (file)
@@ -1959,8 +1959,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
                for (j=0; j<3; j++) {
                        l = l3[j];
                        mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
-                       texface->uv[j][0] = mloopuv->uv[0];
-                       texface->uv[j][1] = mloopuv->uv[1];
+                       copy_v2_v2(texface->uv[j], mloopuv->uv);
                }
        }
 
index 2a78bbca7fb8ed5dbabef31717052f253c0fb7d0..39e103734419a654129064356272600f40e09732 100644 (file)
@@ -1851,12 +1851,12 @@ static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numT
                texpoly->unwrap = texface->unwrap;
        
                mloopuv = CustomData_get_n(&me->ldata, CD_MLOOPUV, loopstart, i);
-               mloopuv->uv[0] = texface->uv[0][0]; mloopuv->uv[1] = texface->uv[0][1]; mloopuv++;
-               mloopuv->uv[0] = texface->uv[1][0]; mloopuv->uv[1] = texface->uv[1][1]; mloopuv++;
-               mloopuv->uv[0] = texface->uv[2][0]; mloopuv->uv[1] = texface->uv[2][1]; mloopuv++;
+               copy_v2_v2(mloopuv->uv, texface->uv[0]); mloopuv++;
+               copy_v2_v2(mloopuv->uv, texface->uv[1]); mloopuv++;
+               copy_v2_v2(mloopuv->uv, texface->uv[2]); mloopuv++;
 
                if (mf->v4) {
-                       mloopuv->uv[0] = texface->uv[3][0]; mloopuv->uv[1] = texface->uv[3][1]; mloopuv++;
+                       copy_v2_v2(mloopuv->uv, texface->uv[3]); mloopuv++;
                }
        }
 
@@ -2201,8 +2201,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
 
                for (j=0; j < mf_len; j++) {
                        mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, lindex[j], i);
-                       texface->uv[j][0] = mloopuv->uv[0];
-                       texface->uv[j][1] = mloopuv->uv[1];
+                       copy_v2_v2(texface->uv[j], mloopuv->uv);
                }
        }
 
index 3352766a859e135b549f919495f364926d2699fb..483897b94eaef20f64a94fc1684dc4186736bd3d 100644 (file)
@@ -2410,8 +2410,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
 
                mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i);
                for (j=0; j<4; j++, mloopuv++) {
-                       texface->uv[j][0] = mloopuv->uv[0];
-                       texface->uv[j][1] = mloopuv->uv[1];
+                       copy_v2_v2(texface->uv[j], mloopuv->uv);
                }
        }
 
@@ -2445,8 +2444,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
 
                lof = CustomData_get(ldata, loopstart, CD_ORIGSPACE_MLOOP);
                for (j=0; j<4; j++, lof++) {
-                       of->uv[j][0] = lof->uv[0];
-                       of->uv[j][1] = lof->uv[1];
+                       copy_v2_v2(of->uv[j], lof->uv);
                }
        }
 }
index 086dd897ad94ccc5fba98008849f3a4f5bf82ccb..06251a15a5c6a053482974994ca82d57373306fd 100644 (file)
@@ -150,8 +150,7 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex,
                j = 0;
                BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
                        mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
-                       texface->uv[j][0] = mloopuv->uv[0];
-                       texface->uv[j][1] = mloopuv->uv[1];
+                       copy_v2_v2(texface->uv[j], mloopuv->uv);
 
                        j++;
                }
index 9e2a2abe83718f06730e77d40ff304dbd9bdd185..b081941e71ba7d455a3a6abafdc6bfe4a581889f 100644 (file)
@@ -194,8 +194,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
                                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
                                        luv= CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
 
-                                       tf_uvorig[i][0] = luv->uv[0];
-                                       tf_uvorig[i][1] = luv->uv[1];
+                                       copy_v2_v2(tf_uvorig[i], luv->uv);
 
                                        i++;
                                }
@@ -245,8 +244,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
                                                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
                                                        luv= CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
 
-                                                       tf_uvorig[i][0] = luv->uv[0];
-                                                       tf_uvorig[i][1] = luv->uv[1];
+                                                       copy_v2_v2(tf_uvorig[i], luv->uv);
 
                                                        i++;
                                                }
index 090752d7b0214c5abf8edc9b8f75d19548f31f68..5c21fa6c1c1d827217d49a68048e0ce8e4cc86f8 100644 (file)
@@ -512,16 +512,14 @@ void poly_uv_center(BMEditMesh *em, BMFace *f, float cent[2])
        MLoopUV *luv;
        BMIter liter;
 
-       cent[0] = cent[1] = 0.0f;
+       zero_v2(cent);
 
        BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) {
                luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-               cent[0] += luv->uv[0];
-               cent[1] += luv->uv[1];
+               add_v2_v2(cent, luv->uv);
        }
 
-       cent[0] /= (float) f->len;
-       cent[1] /= (float) f->len;
+       mul_v2_fl(cent, 1.0f / (float)f->len);
 }
 
 
@@ -2951,8 +2949,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
                        if (BM_GetIndex(l->v) >= 0 && 
                            (!uvedit_uv_selected(em, scene, l))) {
                                    luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-                                   coords[BM_GetIndex(l->v)*2] += luv->uv[0];
-                                   coords[BM_GetIndex(l->v)*2+1] += luv->uv[1];
+                                       add_v2_v2(&coords[BM_GetIndex(l->v) * 2], luv->uv);
                                    change = 1;
                        }
                }
@@ -2978,8 +2975,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
                        if (uvedit_uv_selected(em, scene, l) && BM_GetIndex(l->v) >= 0
                            && (users = usercount[BM_GetIndex(l->v)])) {
                                luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-                               luv->uv[0] = coords[BM_GetIndex(l->v)*2];
-                               luv->uv[1] = coords[BM_GetIndex(l->v)*2+1];
+                               copy_v2_v2(luv->uv, &coords[BM_GetIndex(l->v) * 2]);
                        }
                }
        }