[Bf-blender-cvs] [591eb27] master: BMesh: check for loop side-of-loop & side-of-edge

Campbell Barton noreply at git.blender.org
Fri Nov 21 14:16:20 CET 2014


Commit: 591eb27efaf686901143595b8d6f756d0239515f
Author: Campbell Barton
Date:   Thu Nov 20 21:38:05 2014 +0100
Branches: master
https://developer.blender.org/rB591eb27efaf686901143595b8d6f756d0239515f

BMesh: check for loop side-of-loop & side-of-edge

===================================================================

M	source/blender/bmesh/intern/bmesh_queries.c
M	source/blender/bmesh/intern/bmesh_queries.h

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index d0c876e..901b96c 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -270,6 +270,36 @@ static float bm_face_calc_split_dot(BMLoop *l_a, BMLoop *l_b)
 }
 
 /**
+ * Check if a point is inside the corner defined by a loop
+ * (within the 2 planes defined by the loops corner & face normal).
+ *
+ * \return less than 0.0 when inside.
+ */
+float BM_loop_point_side_of_loop_test(const BMLoop *l, const float co[3])
+{
+	const float *axis = l->f->no;
+	return (angle_signed_on_axis_v3v3v3_v3(l->prev->v->co, l->v->co, co,             axis) -
+	        angle_signed_on_axis_v3v3v3_v3(l->prev->v->co, l->v->co, l->next->v->co, axis));
+}
+
+/**
+ * Check if a point is inside the edge defined by a loop
+ * (within the plane defined by the loops edge & face normal).
+ *
+ * \return less than 0.0 when inside.
+ */
+float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3])
+{
+	const float *axis = l->f->no;
+	float dir[3];
+	float plane[3];
+	sub_v3_v3v3(dir, l->v->co, l->next->v->co);
+	cross_v3_v3v3(plane, axis, dir);
+	return (dot_v3v3(plane, co) -
+	        dot_v3v3(plane, l->v->co));
+}
+
+/**
  * Given 2 verts, find a face they share that has the lowest angle across these verts and give back both loops.
  *
  * This can be better then #BM_vert_pair_share_face_by_len because concave splits are ranked lowest.
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index b5b423e..3dee454 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -83,6 +83,8 @@ bool    BM_edge_is_convex(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(
 
 bool    BM_loop_is_convex(const BMLoop *l) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 BLI_INLINE bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float   BM_loop_point_side_of_loop_test(const BMLoop *l, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float   BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
 float   BM_loop_calc_face_angle(BMLoop *l) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void    BM_loop_calc_face_normal(BMLoop *l, float r_normal[3]) ATTR_NONNULL();




More information about the Bf-blender-cvs mailing list