[Bf-blender-cvs] [93534773832] master: BMesh: add BM_face_calc_uv_cross

Campbell Barton noreply at git.blender.org
Mon Jul 6 10:30:15 CEST 2020


Commit: 9353477383238d3592cdcec53bdcf2bba1ac5dad
Author: Campbell Barton
Date:   Mon Jul 6 17:41:17 2020 +1000
Branches: master
https://developer.blender.org/rB9353477383238d3592cdcec53bdcf2bba1ac5dad

BMesh: add BM_face_calc_uv_cross

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

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

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

diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 80634618f6f..7cc745f248f 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -34,6 +34,8 @@
 
 #include "BKE_customdata.h"
 
+#include "DNA_meshdata_types.h"
+
 #include "bmesh.h"
 #include "intern/bmesh_private.h"
 
@@ -1814,6 +1816,20 @@ void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_ta
   normalize_v3(r_tangent);
 }
 
+float BM_face_calc_uv_cross(const BMFace *f, const int cd_loop_uv_offset)
+{
+  float(*uvs)[2] = BLI_array_alloca(uvs, f->len);
+  const BMLoop *l_iter;
+  const BMLoop *l_first;
+  int i = 0;
+  l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+  do {
+    const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
+    copy_v2_v2(uvs[i++], luv->uv);
+  } while ((l_iter = l_iter->next) != l_first);
+  return cross_poly_v2(uvs, f->len);
+}
+
 /**
  * \brief BMESH VERT/EDGE ANGLE
  *
diff --git a/source/blender/bmesh/intern/bmesh_query.h b/source/blender/bmesh/intern/bmesh_query.h
index 31ab7e4095a..4107fc019dd 100644
--- a/source/blender/bmesh/intern/bmesh_query.h
+++ b/source/blender/bmesh/intern/bmesh_query.h
@@ -173,7 +173,8 @@ float BM_edge_calc_face_angle_with_imat3(const BMEdge *e,
 float BM_edge_calc_face_angle_signed(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3])
     ATTR_NONNULL();
-
+float BM_face_calc_uv_cross(const BMFace *f, const int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT
+    ATTR_NONNULL();
 float BM_vert_calc_edge_angle(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 float BM_vert_calc_edge_angle_ex(const BMVert *v, const float fallback) ATTR_WARN_UNUSED_RESULT
     ATTR_NONNULL();



More information about the Bf-blender-cvs mailing list