diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-07-06 10:41:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-07-06 11:23:38 +0300 |
commit | 9353477383238d3592cdcec53bdcf2bba1ac5dad (patch) | |
tree | 0009260b7c142df81c00144d5a0a7f669467bd36 /source/blender/bmesh | |
parent | b51b893df8623d35f657ffa3975ca9a7422b971d (diff) |
BMesh: add BM_face_calc_uv_cross
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query.c | 16 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query.h | 3 |
2 files changed, 18 insertions, 1 deletions
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(); |