[Bf-blender-cvs] [44b593a] master: Add BM_vert_edge_pair utility function
Campbell Barton
noreply at git.blender.org
Wed Dec 23 06:43:27 CET 2015
Commit: 44b593ae2d08c5294116a473328b741ec3fc0224
Author: Campbell Barton
Date: Wed Dec 23 16:07:48 2015 +1100
Branches: master
https://developer.blender.org/rB44b593ae2d08c5294116a473328b741ec3fc0224
Add BM_vert_edge_pair utility function
===================================================================
M source/blender/bmesh/intern/bmesh_queries.c
M source/blender/bmesh/intern/bmesh_queries.h
M source/blender/editors/transform/transform_orientations.c
===================================================================
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index 0c5f51b..5ed8ab2 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -775,6 +775,28 @@ bool BM_vert_is_edge_pair(const BMVert *v)
}
/**
+ * Access a verts 2 connected edges.
+ *
+ * \return true when only 2 verts are found.
+ */
+bool BM_vert_edge_pair(BMVert *v, BMEdge **r_e_a, BMEdge **r_e_b)
+{
+ BMEdge *e_a = v->e;
+ if (e_a) {
+ BMEdge *e_b = BM_DISK_EDGE_NEXT(e_a, v);
+ if ((e_b != e_a) && (BM_DISK_EDGE_NEXT(e_b, v) == e_a)) {
+ *r_e_a = e_a;
+ *r_e_b = e_b;
+ return true;
+ }
+ }
+
+ *r_e_a = NULL;
+ *r_e_b = NULL;
+ return false;
+}
+
+/**
* Returns the number of edges around this vertex.
*/
int BM_vert_edge_count(const BMVert *v)
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 257743b..a132236 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -85,6 +85,7 @@ int BM_vert_face_count(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL
BMEdge *BM_vert_other_disk_edge(BMVert *v, BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_vert_is_edge_pair(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+bool BM_vert_edge_pair(BMVert *v, BMEdge **r_e_a, BMEdge **r_e_b);
bool BM_vert_face_check(BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_vert_is_wire(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 2ea18d5..57c77fb 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -756,10 +756,10 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
if (bm_mesh_verts_select_get_n(em->bm, &v, 1) == 1) {
copy_v3_v3(normal, v->no);
+ BMEdge *e_pair[2];
- if (BM_vert_is_edge_pair(v)) {
+ if (BM_vert_edge_pair(v, &e_pair[0], &e_pair[1])) {
bool v_pair_swap = false;
- BMEdge *e_pair[2] = {v->e, BM_DISK_EDGE_NEXT(v->e, v)};
BMVert *v_pair[2] = {BM_edge_other_vert(e_pair[0], v), BM_edge_other_vert(e_pair[1], v)};
float dir_pair[2][3];
More information about the Bf-blender-cvs
mailing list