diff options
Diffstat (limited to 'source/blender/editors/transform/transform_snap.c')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 7663f3418fb..447c4b810ab 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -64,12 +64,15 @@ #include "BKE_anim.h" /* for duplis */ #include "BKE_context.h" -#include "ED_view3d.h" +#include "ED_image.h" #include "ED_mesh.h" +#include "ED_uvedit.h" +#include "ED_view3d.h" #include "WM_types.h" #include "UI_resources.h" +#include "UI_view2d.h" #include "MEM_guardedalloc.h" @@ -172,9 +175,8 @@ void drawSnapping(TransInfo *t) myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax); glLoadIdentity(); - aspect_sima(G.sima, &xuser_asp, &yuser_asp); - - transform_width_height_tface_uv(&wi, &hi); + ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp); + ED_space_image_width(t->sa->spacedata.first, &wi, &hi); w = (((float)wi)/256.0f)*G.sima->zoom * xuser_asp; h = (((float)hi)/256.0f)*G.sima->zoom * yuser_asp; @@ -559,20 +561,16 @@ 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; + { + /* same as above but for UV's */ + Image *ima= ED_space_image(t->sa->spacedata.first); + float aspx, aspy, co[2]; - // TRANSFORM_FIX_ME - //find_nearest_uv(&nearesttf, NULL, NULL, &face_corner); + UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1); - if (nearesttf != NULL) + if(ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) { - VECCOPY2D(t->tsnap.snapPoint, nearesttf->uv[face_corner]); - - // TRANSFORM_FIX_ME - //transform_aspect_ratio_tface_uv(&aspx, &aspy); + ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); t->tsnap.snapPoint[0] *= aspx; t->tsnap.snapPoint[1] *= aspy; @@ -1311,8 +1309,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea /* evil hack - snapping needs to be adapted for image aspect ratio */ if((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { - // TRANSFORM_FIX_ME - //transform_aspect_ratio_tface_uv(asp, asp+1); + ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp+1); } for (i=0; i<=max_index; i++) { |