Revert "Sculpt/Paint: Use cached triangulation when building PBVH"
This reverts commit 676137f043.
This change worked locally with a specific test file and local changes,
but didn't work in general, since we don't reliably retrieve the new
looptris after setting them the first time. This can be improved again
in the future, but probably along with a more general look about ownership
is handled with PBVH.
This commit is contained in:
@@ -2189,6 +2189,7 @@ static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
|
||||
static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool respect_hide)
|
||||
{
|
||||
Mesh *me = BKE_object_get_original_mesh(ob);
|
||||
const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
|
||||
PBVH *pbvh = BKE_pbvh_new(PBVH_FACES);
|
||||
BKE_pbvh_respect_hide_set(pbvh, respect_hide);
|
||||
|
||||
@@ -2196,7 +2197,11 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool
|
||||
const Span<MPoly> polys = me->polys();
|
||||
const Span<MLoop> loops = me->loops();
|
||||
|
||||
const Span<MLoopTri> looptris = me->looptris();
|
||||
MLoopTri *looptri = static_cast<MLoopTri *>(
|
||||
MEM_malloc_arrayN(looptris_num, sizeof(*looptri), __func__));
|
||||
|
||||
BKE_mesh_recalc_looptri(
|
||||
loops.data(), polys.data(), verts.data(), me->totloop, me->totpoly, looptri);
|
||||
|
||||
BKE_pbvh_build_mesh(pbvh,
|
||||
me,
|
||||
@@ -2207,8 +2212,8 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool
|
||||
&me->vdata,
|
||||
&me->ldata,
|
||||
&me->pdata,
|
||||
looptris.data(),
|
||||
looptris.size());
|
||||
looptri,
|
||||
looptris_num);
|
||||
|
||||
pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
|
||||
pbvh_show_face_sets_set(pbvh, ob->sculpt->show_face_sets);
|
||||
|
||||
@@ -959,6 +959,10 @@ void BKE_pbvh_free(PBVH *pbvh)
|
||||
}
|
||||
}
|
||||
|
||||
if (pbvh->looptri) {
|
||||
MEM_freeN((void *)pbvh->looptri);
|
||||
}
|
||||
|
||||
if (pbvh->nodes) {
|
||||
MEM_freeN(pbvh->nodes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user