Code Cleanup: use vector functions for copying / adding UV's
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user