diff options
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_marking.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 4e29756104a..2cc84671e41 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -619,7 +619,7 @@ void BM_editselection_center(BMEditSelection *ese, float r_center[3]) } else if (ese->htype == BM_FACE) { BMFace *efa = (BMFace *)ese->ele; - BM_face_calc_center_bounds(efa, r_center); + BM_face_calc_center_mean(efa, r_center); } } @@ -710,8 +710,28 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) cross_v3_v3v3(r_plane, efa->no, vec); } else { - if (efa->len == 4) { - BMVert *verts[4] = {NULL}; + if (efa->len == 3) { + BMVert *verts[3]; + float lens[3]; + float difs[3]; + int order[3] = {0, 1, 2}; + + BM_face_as_array_vert_tri(efa, verts); + + lens[0] = len_v3v3(verts[0]->co, verts[1]->co); + lens[1] = len_v3v3(verts[1]->co, verts[2]->co); + lens[2] = len_v3v3(verts[2]->co, verts[0]->co); + + /* find the shortest or the longest loop */ + difs[0] = fabsf(lens[1] - lens[2]); + difs[1] = fabsf(lens[2] - lens[0]); + difs[2] = fabsf(lens[0] - lens[1]); + + axis_sort_v3(difs, order); + sub_v3_v3v3(r_plane, verts[order[0]]->co, verts[(order[0] + 1) % 3]->co); + } + else if (efa->len == 4) { + BMVert *verts[4]; float vecA[3], vecB[3]; // BM_iter_as_array(NULL, BM_VERTS_OF_FACE, efa, (void **)verts, 4); |