Fix for bug #8380: snapping in the uv editor didn't work with

non-square images.

Fix for uv limit stitch, was broken since editmode integration.
This commit is contained in:
Brecht Van Lommel 2008-02-27 19:35:27 +00:00
parent 780ea713d5
commit 35f094f209
2 changed files with 17 additions and 8 deletions

@ -1314,7 +1314,7 @@ void stitch_limit_uv_tface(void)
{
MTFace *tf;
int a, vtot;
float newuv[2], limit[2];
float newuv[2], limit[2], pixellimit;
UvMapVert *vlist, *iterv;
EditMesh *em = G.editMesh;
EditVert *ev;
@ -1330,20 +1330,23 @@ void stitch_limit_uv_tface(void)
return;
}
limit[0]= limit[1]= 20.0;
add_numbut(0, NUM|FLO, "Limit:", 0.1, 1000.0, &limit[0], NULL);
pixellimit= 20.0f;
add_numbut(0, NUM|FLO, "Limit:", 0.1, 1000.0, &pixellimit, NULL);
if (!do_clever_numbuts("Stitch UVs", 1, REDRAW))
return;
limit[0]= limit[1]= limit[0]/256.0;
if(G.sima->image) {
ImBuf *ibuf= imagewindow_get_ibuf(G.sima);
if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
limit[1]= limit[0]/(float)ibuf->y;
limit[0]= limit[0]/(float)ibuf->x;
limit[0]= pixellimit/(float)ibuf->x;
limit[1]= pixellimit/(float)ibuf->y;
}
else
limit[0]= limit[1]= pixellimit/256.0;
}
else
limit[0]= limit[1]= pixellimit/256.0;
/*vmap= make_uv_vert_map(me->mface, tf, me->totface, me->totvert, 1, limit);*/
EM_init_index_arrays(0, 0, 1);
@ -1364,7 +1367,7 @@ void stitch_limit_uv_tface(void)
efa = EM_get_face_for_index(iterv->f);
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (tf[iterv->f].flag & TF_SEL_MASK(iterv->tfindex)) {
if (tf->flag & TF_SEL_MASK(iterv->tfindex)) {
newuv[0] += tf->uv[iterv->tfindex][0];
newuv[1] += tf->uv[iterv->tfindex][1];
vtot++;

@ -502,13 +502,19 @@ void CalcSnapGeometry(TransInfo *t, float *vec)
else if (t->spacetype == SPACE_IMAGE)
{ /* same as above but for UV's */
MTFace *nearesttf=NULL;
float aspx, aspy;
int face_corner;
find_nearest_uv(&nearesttf, NULL, NULL, &face_corner);
if (nearesttf != NULL)
{
VECCOPY2D(t->tsnap.snapPoint, nearesttf->uv[face_corner]);
transform_aspect_ratio_tface_uv(&aspx, &aspy);
t->tsnap.snapPoint[0] *= aspx;
t->tsnap.snapPoint[1] *= aspy;
//Mat4MulVecfl(G.obedit->obmat, t->tsnap.snapPoint);
t->tsnap.status |= POINT_INIT;