diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-11 11:47:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-11 11:47:09 +0400 |
commit | 9ae0523921fa4baeb37bcdd36f208da952f4337f (patch) | |
tree | c83e79ef9a40f9018baa375ff1c5911998c4448a /source | |
parent | ff6867a768674353fb8bbd5c6e7b418a9fa1ad80 (diff) |
fix [#30897] UVEditor: Snap Cursor to Selected
was writing the 3rd component of a 2D vector.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 6 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 29 |
3 files changed, 18 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index b4e1a71d45e..7fba2699fc7 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -154,6 +154,7 @@ void interp_v4_v4v4v4(float p[4], const float v1[4], const float v2[4], const fl void interp_v4_v4v4v4v4(float p[4], const float v1[4], const float v2[4], const float v3[4], const float v4[4], const float w[4]); void mid_v3_v3v3(float r[3], const float a[3], const float b[3]); +void mid_v2_v2v2(float r[2], const float a[2], const float b[2]); /********************************* Comparison ********************************/ diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 65600a31042..4b3ba7244d4 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -109,6 +109,12 @@ void mid_v3_v3v3(float v[3], const float v1[3], const float v2[3]) v[2] = 0.5f * (v1[2] + v2[2]); } +void mid_v2_v2v2(float v[2], const float v1[2], const float v2[2]) +{ + v[0] = 0.5f * (v1[0] + v2[0]); + v[1] = 0.5f * (v1[1] + v2[1]); +} + /********************************** Angles ***********************************/ /* Return the angle in radians between vecs 1-2 and 2-3 in radians diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index c836e536d17..bacee2e0a76 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -614,7 +614,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float return sel; } -static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3]) +static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[2]) { BMEditMesh *em = BMEdit_FromObject(obedit); BMFace *efa; @@ -624,7 +624,7 @@ static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3 MLoopUV *luv; unsigned int sel= 0; - zero_v3(co); + zero_v2(co); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (!uvedit_face_visible(scene, ima, efa, tf)) @@ -639,36 +639,29 @@ static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3 } } - mul_v3_fl(co, 1.0f/(float)sel); + mul_v2_fl(co, 1.0f/(float)sel); return (sel != 0); } -static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, char mode) +static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2], char mode) { - float min[2], max[2]; - int change= 0; + int change = FALSE; - if (mode==V3D_CENTER) { /* bounding box */ + if (mode == V3D_CENTER) { /* bounding box */ + float min[2], max[2]; if (ED_uvedit_minmax(scene, ima, obedit, min, max)) { - change = 1; - - cent[0]= (min[0]+max[0])/2.0f; - cent[1]= (min[1]+max[1])/2.0f; + mid_v2_v2v2(cent, min, max); + change = TRUE; } } else { if (ED_uvedit_median(scene, ima, obedit, cent)) { - change = 1; + change = TRUE; } - } - if (change) { - return 1; - } - - return 0; + return change; } /************************** find nearest ****************************/ |