Add new BMesh length query functions.

BMEdge *BM_face_find_shortest_edge(BMFace *f);
BMEdge *BM_face_find_longest_edge(BMFace *f);

Reviewed by Campbell Barton.
This commit is contained in:
Nicholas Bishop
2012-05-22 15:19:33 +00:00
parent 39f2f99794
commit 5e22802fae
2 changed files with 46 additions and 0 deletions

View File

@@ -951,6 +951,49 @@ float BM_vert_calc_mean_tagged_edge_length(BMVert *v)
}
/**
* Returns the shortest edge in f.
*/
BMEdge *BM_face_find_shortest_edge(BMFace *f)
{
BMIter iter;
BMEdge *shortest_edge = NULL, *e;
float shortest_len = FLT_MAX;
BM_ITER_ELEM(e, &iter, f, BM_EDGES_OF_FACE) {
float len = BM_edge_calc_length(e);
if (len <= shortest_len) {
shortest_edge = e;
shortest_len = len;
}
}
return shortest_edge;
}
/**
* Returns the longest edge in f.
*/
BMEdge *BM_face_find_longest_edge(BMFace *f)
{
BMIter iter;
BMEdge *longest_edge = NULL, *e;
float longest_len = 0;
BM_ITER_ELEM(e, &iter, f, BM_EDGES_OF_FACE) {
float len = BM_edge_calc_length(e);
if (len >= longest_len) {
longest_edge = e;
longest_len = len;
}
}
return longest_edge;
}
/**
* Returns the edge existing between v1 and v2, or NULL if there isn't one.
*

View File

@@ -67,6 +67,9 @@ float BM_vert_calc_edge_angle(BMVert *v);
float BM_vert_calc_shell_factor(BMVert *v);
float BM_vert_calc_mean_tagged_edge_length(BMVert *v);
BMEdge *BM_face_find_shortest_edge(BMFace *f);
BMEdge *BM_face_find_longest_edge(BMFace *f);
BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2);
int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);