Sculpt: Fix T102567: multires crash with high subdivision levels
Previous fix did not work for ngons. The pbvh leaf limit minimum is now set to the maximum ngon's vertex count.
This commit is contained in:
parent
41d29a1603
commit
5097105b3c
Notes:
blender-bot
2023-02-14 07:39:44 +01:00
Referenced by issue #102567, Regression: sculpt multireslevel 7 crashes Blender
|
@ -834,11 +834,19 @@ void BKE_pbvh_build_grids(PBVH *pbvh,
|
|||
pbvh->grid_hidden = grid_hidden;
|
||||
pbvh->subdiv_ccg = subdiv_ccg;
|
||||
|
||||
/* Find maximum number of grids per face. */
|
||||
int max_grids = 1;
|
||||
MPoly *mpoly = BKE_mesh_polys(me);
|
||||
|
||||
for (int i = 0; i < me->totpoly; i++) {
|
||||
max_grids = max_ii(max_grids, mpoly[i].totloop);
|
||||
}
|
||||
|
||||
/* Ensure leaf limit is at least 4 so there's room
|
||||
* to split at original face boundaries.
|
||||
* Fixes T102209.
|
||||
*/
|
||||
pbvh->leaf_limit = max_ii(LEAF_LIMIT / (gridsize * gridsize), 4);
|
||||
pbvh->leaf_limit = max_ii(LEAF_LIMIT / (gridsize * gridsize), max_grids);
|
||||
|
||||
/* We need the base mesh attribute layout for PBVH draw. */
|
||||
pbvh->vdata = &me->vdata;
|
||||
|
|
Loading…
Reference in New Issue