diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-11 16:41:53 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-11 18:08:41 +0300 |
commit | e9cbc700efdb2510530de17851974986292f380a (patch) | |
tree | d7b21a67acc9e6d59ff2373ed1d89d6131bffb92 /source/blender | |
parent | e6da7bb75c8eff13185a56a144dce920b3886ecb (diff) |
Cleanup: deduplicate DM's getLoopTriArray() callback.
All three functions were doing exactly the same thing, simpler to only
have one in that case!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 14 |
4 files changed, 13 insertions, 43 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 7eea8224ba1..9e33dd56b00 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -235,6 +235,17 @@ static int dm_getNumLoopTri(DerivedMesh *dm) return numlooptris; } +static const MLoopTri *dm_getLoopTriArray(DerivedMesh *dm) +{ + if (dm->looptris.array) { + BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); + } + else { + dm->recalcLoopTri(dm); + } + return dm->looptris.array; +} + static CustomData *dm_getVertCData(DerivedMesh *dm) { return &dm->vertData; @@ -278,6 +289,8 @@ void DM_init_funcs(DerivedMesh *dm) dm->dupLoopArray = dm_dupLoopArray; dm->dupPolyArray = dm_dupPolyArray; + dm->getLoopTriArray = dm_getLoopTriArray; + /* subtypes handle getting actual data */ dm->getNumLoopTri = dm_getNumLoopTri; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 46a067ea0bc..e6e59689e99 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1927,19 +1927,6 @@ void CDDM_recalc_looptri(DerivedMesh *dm) cddm->dm.looptris.array); } -static const MLoopTri *cdDM_getLoopTriArray(DerivedMesh *dm) -{ - if (dm->looptris.array) { - BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); - } - else { - dm->recalcLoopTri(dm); - - /* ccdm is an exception here, that recalcLoopTri will fill in the array too */ - } - return dm->looptris.array; -} - static void cdDM_free_internal(CDDerivedMesh *cddm) { if (cddm->pmap) MEM_freeN(cddm->pmap); @@ -1990,8 +1977,6 @@ static CDDerivedMesh *cdDM_create(const char *desc) dm->getEdgeDataArray = DM_get_edge_data_layer; dm->getTessFaceDataArray = DM_get_tessface_data_layer; - dm->getLoopTriArray = cdDM_getLoopTriArray; - dm->calcNormals = CDDM_calc_normals; dm->calcLoopNormals = CDDM_calc_loop_normals; dm->calcLoopNormalsSpaceArray = CDDM_calc_loop_normals_spacearr; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index ab614b8f460..f29af28a782 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -661,18 +661,6 @@ static void emDM_recalcLoopTri(DerivedMesh *dm) } } -static const MLoopTri *emDM_getLoopTriArray(DerivedMesh *dm) -{ - if (dm->looptris.array) { - BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); - } - else { - dm->recalcLoopTri(dm); - } - - return dm->looptris.array; -} - static void emDM_foreachMappedVert( DerivedMesh *dm, void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), @@ -2259,8 +2247,6 @@ DerivedMesh *getEditDerivedBMesh( bmdm->dm.getNumLoops = emDM_getNumLoops; bmdm->dm.getNumPolys = emDM_getNumPolys; - bmdm->dm.getLoopTriArray = emDM_getLoopTriArray; - bmdm->dm.getVert = emDM_getVert; bmdm->dm.getVertCo = emDM_getVertCo; bmdm->dm.getVertNo = emDM_getVertNo; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index c4665c40ec4..47dea5ea282 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -4505,18 +4505,6 @@ static void ccgDM_recalcLoopTri(DerivedMesh *dm) BLI_rw_mutex_unlock(&loops_cache_rwlock); } -static const MLoopTri *ccgDM_getLoopTriArray(DerivedMesh *dm) -{ - if (dm->looptris.array) { - BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); - } - else { - dm->recalcLoopTri(dm); - } - - return dm->looptris.array; -} - static void ccgDM_calcNormals(DerivedMesh *dm) { /* Nothing to do: CCG calculates normals during drawing */ @@ -4533,8 +4521,6 @@ static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm) ccgdm->dm.getNumPolys = ccgDM_getNumPolys; ccgdm->dm.getNumTessFaces = ccgDM_getNumTessFaces; - ccgdm->dm.getLoopTriArray = ccgDM_getLoopTriArray; - ccgdm->dm.getVert = ccgDM_getFinalVert; ccgdm->dm.getEdge = ccgDM_getFinalEdge; ccgdm->dm.getTessFace = ccgDM_getFinalFace; |