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:
authorCampbell Barton <ideasman42@gmail.com>2013-01-29 07:25:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-29 07:25:47 +0400
commit69585591d6a1d1fdac1e6b6ce508ccd3d936e2ac (patch)
treec5dcb84d8070b30fbf618702ed2ffb8e0e2ac3ed /source/blender/bmesh/intern
parentcf9e619889fdcdc457e44d4b384cda091de55673 (diff)
Correct fix for r54164, the testcase I was using worked but different edge slide examples didn't.
Edge slide needed to check for concave ngons too. add BM_loop_is_convex() and expose to python too.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c18
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h2
2 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 7ed23aaf1f8..bf30db78a61 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -1007,6 +1007,22 @@ void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2)
}
/**
+ * Check if the loop is convex or concave
+ * (depends on face normal)
+ */
+bool BM_loop_is_convex(BMLoop *l)
+{
+ float e_dir_prev[3];
+ float e_dir_next[3];
+ float l_no[3];
+
+ sub_v3_v3v3(e_dir_prev, l->prev->v->co, l->v->co);
+ sub_v3_v3v3(e_dir_next, l->next->v->co, l->v->co);
+ cross_v3_v3v3(l_no, e_dir_next, e_dir_prev);
+ return dot_v3v3(l_no, l->f->no) > 0.0f;
+}
+
+/**
* Calculates the angle between the previous and next loops
* (angle at this loops face corner).
*
@@ -1034,7 +1050,7 @@ void BM_loop_calc_face_normal(BMLoop *l, float r_normal[3])
l->v->co,
l->next->v->co) != 0.0f)
{
- return;
+ /* pass */
}
else {
copy_v3_v3(r_normal, l->f->no);
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 9892700162e..4172b3905cd 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -62,6 +62,8 @@ bool BM_vert_is_manifold(BMVert *v);
bool BM_edge_is_manifold(BMEdge *e);
bool BM_edge_is_boundary(BMEdge *e);
+bool BM_loop_is_convex(BMLoop *l);
+
float BM_loop_calc_face_angle(BMLoop *l);
void BM_loop_calc_face_normal(BMLoop *l, float r_normal[3]);
void BM_loop_calc_face_tangent(BMLoop *l, float r_tangent[3]);