Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_queries.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 549cc44c338..94b221797b4 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -954,45 +954,60 @@ float BM_vert_calc_mean_tagged_edge_length(BMVert *v)
/**
* Returns the shortest edge in f.
*/
-BMEdge *BM_face_find_shortest_edge(BMFace *f)
+BMLoop *BM_face_find_shortest_loop(BMFace *f)
{
- BMIter iter;
- BMEdge *shortest_edge = NULL, *e;
+ BMLoop *shortest_loop = NULL;
float shortest_len = FLT_MAX;
- BM_ITER_ELEM(e, &iter, f, BM_EDGES_OF_FACE) {
- float len = BM_edge_calc_length(e);
+ BMLoop *l_iter;
+ BMLoop *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+
+ do {
+ const float len = len_squared_v3v3(l_iter->v->co, l_iter->next->v->co);
if (len <= shortest_len) {
- shortest_edge = e;
+ shortest_loop = l_iter;
shortest_len = len;
}
- }
+ } while ((l_iter = l_iter->next) != l_first);
- return shortest_edge;
+ return shortest_loop;
}
/**
* Returns the longest edge in f.
*/
-BMEdge *BM_face_find_longest_edge(BMFace *f)
+BMLoop *BM_face_find_longest_loop(BMFace *f)
{
- BMIter iter;
- BMEdge *longest_edge = NULL, *e;
- float longest_len = 0;
+ BMLoop *longest_loop = NULL;
+ float longest_len = 0.0f;
- BM_ITER_ELEM(e, &iter, f, BM_EDGES_OF_FACE) {
- float len = BM_edge_calc_length(e);
+ BMLoop *l_iter;
+ BMLoop *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+
+ do {
+ const float len = len_squared_v3v3(l_iter->v->co, l_iter->next->v->co);
if (len >= longest_len) {
- longest_edge = e;
+ longest_loop = l_iter;
longest_len = len;
}
- }
+ } while ((l_iter = l_iter->next) != l_first);
+
+ return longest_loop;
+}
- return longest_edge;
+BMEdge *BM_face_find_shortest_edge(BMFace *f)
+{
+ return BM_face_find_shortest_loop(f)->e;
}
+BMEdge *BM_face_find_longest_edge(BMFace *f)
+{
+ return BM_face_find_longest_loop(f)->e;
+}
/**
* Returns the edge existing between v1 and v2, or NULL if there isn't one.