[Bf-blender-cvs] [5097105b3c6] master: Sculpt: Fix T102567: multires crash with high subdivision levels

Joseph Eagar noreply at git.blender.org
Sun Nov 20 16:32:26 CET 2022


Commit: 5097105b3c62d9ec086c6d5b25ac75a1759ddb5c
Author: Joseph Eagar
Date:   Sun Nov 20 07:30:14 2022 -0800
Branches: master
https://developer.blender.org/rB5097105b3c62d9ec086c6d5b25ac75a1759ddb5c

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.

===================================================================

M	source/blender/blenkernel/intern/pbvh.c

===================================================================

diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 942d124ded4..aa7a9804437 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -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;



More information about the Bf-blender-cvs mailing list