diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-05 17:25:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-05 17:25:42 +0400 |
commit | baa843d0d3f9936f01bb569f3512972daaadd070 (patch) | |
tree | 1c784a2b8ab7fe0f9ddc3795104272f8ad2d684f /source | |
parent | 543fb27fd0a54287b32f3d2c0066c10a120a596d (diff) |
Code Cleanup: use vector functions for copying / adding UV's
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_interp.c | 3 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 6 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 14 |
6 files changed, 16 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 15740076dc0..35759c204fb 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -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); } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 2a78bbca7fb..39e10373441 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -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); } } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 3352766a859..483897b94ea 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -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); } } } diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 086dd897ad9..06251a15a5c 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -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++; } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 9e2a2abe837..b081941e71b 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -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++; } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 090752d7b02..5c21fa6c1c1 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -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]); } } } |