From df62deb0a7602878cc5367c0c7d3e3ac723a76c5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 31 Aug 2018 12:41:23 +0200 Subject: Remove CCGDM from PBVH The statement that PBVH needs to keep track of CCGDM is wrong, PBVH itself does not care about CCGDM at all, and it's weird for it to carry on this beast so others can access. Even more, nobody will actually caring about CCGDM itself, all the usages were checking whether there is CCGDM or not. This is as good as simply checking PBVH type. Tested with an original report T53551 and everything is still stable. --- source/blender/blenkernel/intern/subsurf_ccg.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern/subsurf_ccg.c') diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e08560cccac..221c600f502 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -4492,8 +4492,9 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) if (ob->sculpt->pbvh) { /* Note that we have to clean up exisitng pbvh instead of updating it in case it does not match current * grid_pbvh status. */ + const PBVHType pbvh_type = BKE_pbvh_type(ob->sculpt->pbvh); if (grid_pbvh) { - if (BKE_pbvh_get_ccgdm(ob->sculpt->pbvh) != NULL) { + if (pbvh_type == PBVH_GRIDS) { /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm * but this can be freed on ccgdm release, this updates the pointers * when the ccgdm gets remade, the assumption is that the topology @@ -4507,7 +4508,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) ob->sculpt->pbvh = NULL; } } - else if (BKE_pbvh_get_ccgdm(ob->sculpt->pbvh) != NULL) { + else if (pbvh_type == PBVH_GRIDS) { BKE_pbvh_free(ob->sculpt->pbvh); ob->sculpt->pbvh = NULL; } @@ -4516,10 +4517,6 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) } if (ccgdm->pbvh) { - /* For grid pbvh, keep track of ccgdm */ - if (grid_pbvh) { - BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm); - } return ccgdm->pbvh; } @@ -4571,10 +4568,6 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) pbvh_show_mask_set(ccgdm->pbvh, ob->sculpt->show_mask); } - /* For grid pbvh, keep track of ccgdm. */ - if (grid_pbvh && ccgdm->pbvh) { - BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm); - } return ccgdm->pbvh; } -- cgit v1.2.3