From e324172d9ca6690e8bd2c0a53f0f7ad529d8e241 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 11 Aug 2017 15:53:38 +0200 Subject: Fix transform snap code using 'allocated' flags to get verts/edges/etc. arrays again from DM. This was... horribly wrong, CDDM will often *not* need to allocate anything to return arrays of mesh items! Just check whether array pointer is NULL. Also, remove `DM_get_looptri_array`, that one is useless currently, `dm->getLoopTriArray` will always return cached array (computing it if needed). --- source/blender/blenkernel/BKE_DerivedMesh.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source/blender/blenkernel/BKE_DerivedMesh.h') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 63ff1149a68..a31a51f9402 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -832,11 +832,5 @@ struct MEdge *DM_get_edge_array(struct DerivedMesh *dm, bool *r_allocated); struct MLoop *DM_get_loop_array(struct DerivedMesh *dm, bool *r_allocated); struct MPoly *DM_get_poly_array(struct DerivedMesh *dm, bool *r_allocated); struct MFace *DM_get_tessface_array(struct DerivedMesh *dm, bool *r_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 *r_allocated); #endif /* __BKE_DERIVEDMESH_H__ */ -- cgit v1.2.3 From c034193821ec7e67a0ae1050c8ccef7b5cd5473b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 11 Aug 2017 16:18:01 +0200 Subject: Cleanup: remove useless `DM_ensure_looptri()`. That one was doing exactly same thing as `dm->getLoopTriArray()`, no point in having twice the same code here... --- source/blender/blenkernel/BKE_DerivedMesh.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_DerivedMesh.h') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index a31a51f9402..5a4fdcf2510 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -625,7 +625,6 @@ void DM_ensure_normals(DerivedMesh *dm); void DM_ensure_tessface(DerivedMesh *dm); void DM_ensure_looptri_data(DerivedMesh *dm); -void DM_ensure_looptri(DerivedMesh *dm); void DM_verttri_from_looptri(MVertTri *verttri, const MLoop *mloop, const MLoopTri *looptri, int looptri_num); void DM_update_tessface_data(DerivedMesh *dm); -- cgit v1.2.3 From 00cb3527902b11b5f136432e8670e299789b6716 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 11 Aug 2017 16:51:19 +0200 Subject: Fix T52149: LoopTriArray computation was not correctly protected against concurrency. Note: this commit seems to work as expected (also with transform snapping etc.). However, it is rather unsafe - not enough for 2.79 at least, unless we get much more testing on it. It also depends on three previous ones. Note that using a global lock here is far from ideal, we should rather have a lock per DM, but that will do for now, whole DM thing is doomed to oblivion anyway in 2.8. Also, we may need a `DM_DIRTY_LOOPTRIS` dirty flag at some point. Looks like we can survive without it for now though... Probably because cached looptris are never copied accross DM's? --- source/blender/blenkernel/BKE_DerivedMesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_DerivedMesh.h') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 5a4fdcf2510..e2577689101 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -220,7 +220,7 @@ struct DerivedMesh { /** Recalculates mesh tessellation */ void (*recalcTessellation)(DerivedMesh *dm); - /** Loop tessellation cache */ + /** Loop tessellation cache (WARNING! Only call inside threading-protected code!) */ void (*recalcLoopTri)(DerivedMesh *dm); /** accessor functions */ const struct MLoopTri *(*getLoopTriArray)(DerivedMesh * dm); -- cgit v1.2.3