diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 2c74815a494..369bd51856a 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -800,5 +800,11 @@ struct MEdge *DM_get_edge_array(struct DerivedMesh *dm, bool *allocated); struct MLoop *DM_get_loop_array(struct DerivedMesh *dm, bool *allocated); struct MPoly *DM_get_poly_array(struct DerivedMesh *dm, bool *allocated); struct MFace *DM_get_tessface_array(struct DerivedMesh *dm, bool *allocated); +const MLoopTri *DM_get_looptri_array( + DerivedMesh *dm, + const MVert *mvert, + const MPoly *mpoly, int mpoly_len, + const MLoop *mloop, int mloop_len, + bool *allocated); #endif /* __BKE_DERIVEDMESH_H__ */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3f4b1eec512..76cc6d01214 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3882,3 +3882,35 @@ MFace *DM_get_tessface_array(DerivedMesh *dm, bool *allocated) return mface; } + +const MLoopTri *DM_get_looptri_array( + DerivedMesh *dm, + const MVert *mvert, + const MPoly *mpoly, int mpoly_len, + const MLoop *mloop, int mloop_len, + bool *allocated) +{ + const MLoopTri *looptri = dm->getLoopTriArray(dm); + *allocated = false; + + if (looptri == NULL) { + if (mpoly_len > 0) { + const int looptris_num = poly_to_tri_count(mpoly_len, mloop_len); + MLoopTri *looptri_data; + + looptri_data = MEM_mallocN(sizeof(MLoopTri) * looptris_num, __func__); + + BKE_mesh_recalc_looptri( + mloop, mpoly, + mvert, + mloop_len, mpoly_len, + looptri_data); + + looptri = looptri_data; + + *allocated = true; + } + } + + return looptri; +}