diff options
author | Luca Rood <dev@lucarood.com> | 2016-11-23 22:19:03 +0300 |
---|---|---|
committer | Luca Rood <dev@lucarood.com> | 2016-12-01 17:41:56 +0300 |
commit | 7fe7835d13de669be3b65b4e36000e8883f7117b (patch) | |
tree | 5748a049c198e612225e0a330d602e436197d37a /source/blender/blenkernel/intern/editderivedmesh.c | |
parent | 69a75b0169c64b14f00de7b7e2da45720cdc4d06 (diff) |
Fix (unreported) looptri array not being recalculated in ccgDM and emDM
In ccgDM and emDM, looptri array recalculation was being handled
directly by `*DM_getLoopTriArray` (`getLoopTriArray` callback), while
`*DM_recalcLoopTri` (`recalcLoopTri` callback) was doing nothing.
This results in the array not being recalculated when other functions
that depend on the array data called the recalc function.
This moves all the recalculation code to `*DM_recalcLoopTri` and makes
`*DM_getLoopTriArray` call that.
This commit also makes a minor change to the `getNumLoopTri` function,
so that it returns the correct number without having to recalculate the
looptri array.
Reviewed By: mont29
Differential Revision: https://developer.blender.org/D2375
Diffstat (limited to 'source/blender/blenkernel/intern/editderivedmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 05cf5f6d7bd..e7c0e69b1cb 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -621,10 +621,33 @@ static void emDM_recalcTessellation(DerivedMesh *UNUSED(dm)) /* do nothing */ } -static void emDM_recalcLoopTri(DerivedMesh *UNUSED(dm)) +static void emDM_recalcLoopTri(DerivedMesh *dm) { - /* Nothing to do: emDM tessellation is known, - * allocate and fill in with emDM_getLoopTriArray */ + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMLoop *(*looptris)[3] = bmdm->em->looptris; + MLoopTri *mlooptri; + const int tottri = bmdm->em->tottri; + int i; + + DM_ensure_looptri_data(dm); + mlooptri = dm->looptris.array; + + BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); + BLI_assert(tottri == dm->looptris.num); + + BM_mesh_elem_index_ensure(bmdm->em->bm, BM_FACE | BM_LOOP); + + for (i = 0; i < tottri; i++) { + BMLoop **ltri = looptris[i]; + MLoopTri *lt = &mlooptri[i]; + + ARRAY_SET_ITEMS( + lt->tri, + BM_elem_index_get(ltri[0]), + BM_elem_index_get(ltri[1]), + BM_elem_index_get(ltri[2])); + lt->poly = BM_elem_index_get(ltri[0]->f); + } } static const MLoopTri *emDM_getLoopTriArray(DerivedMesh *dm) @@ -633,32 +656,9 @@ static const MLoopTri *emDM_getLoopTriArray(DerivedMesh *dm) BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); } else { - EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; - BMLoop *(*looptris)[3] = bmdm->em->looptris; - MLoopTri *mlooptri; - const int tottri = bmdm->em->tottri; - int i; - - DM_ensure_looptri_data(dm); - mlooptri = dm->looptris.array; - - BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); - BLI_assert(tottri == dm->looptris.num); - - BM_mesh_elem_index_ensure(bmdm->em->bm, BM_FACE | BM_LOOP); - - for (i = 0; i < tottri; i++) { - BMLoop **ltri = looptris[i]; - MLoopTri *lt = &mlooptri[i]; - - ARRAY_SET_ITEMS( - lt->tri, - BM_elem_index_get(ltri[0]), - BM_elem_index_get(ltri[1]), - BM_elem_index_get(ltri[2])); - lt->poly = BM_elem_index_get(ltri[0]->f); - } + dm->recalcLoopTri(dm); } + return dm->looptris.array; } |