[Bf-blender-cvs] [b305041] master: Add DM_get_looptri_array utility function
Campbell Barton
noreply at git.blender.org
Wed Jul 22 13:45:58 CEST 2015
Commit: b305041ce6779f90a282283ff04bd36f1807c728
Author: Campbell Barton
Date: Wed Jul 22 20:54:12 2015 +1000
Branches: master
https://developer.blender.org/rBb305041ce6779f90a282283ff04bd36f1807c728
Add DM_get_looptri_array utility function
===================================================================
M source/blender/blenkernel/BKE_DerivedMesh.h
M source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 2c74815..369bd51 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 3f4b1ee..76cc6d0 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;
+}
More information about the Bf-blender-cvs
mailing list