Commit: 023277359f99274bf712c4f4b89094b00e1fb925 Author: Baardaap Date: Fri Feb 3 00:09:26 2023 +0100 Branches: master https://developer.blender.org/rB023277359f99274bf712c4f4b89094b00e1fb925
Fix T104053: Limit pbvh recursion The recursion depth was checked for equality with a maximum depth, allowing leaves with more primitives if a certain depth was reached. However, a single leaf must always use the same material (including set_smooth), so if a leaf contained multiple materials it was split anyway. This meant that in the next recursion step the depth was larger than the cutoff value and it would go back to recursing until the number of primitives was small enough, ignoring the recursion depth for the rest of the process. In certain edge cases this could lead to a stack overflow. Even with the check changed from 'equality' to 'larger or equal' this could still fail in the pathological case where every primitive has another material. But that can't be helped, and it wouldn't realistically happen either. Differential Revsision: https://developer.blender.org/D17188 =================================================================== M source/blender/blenkernel/intern/pbvh.c =================================================================== diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index e9461350448..6b21568ba38 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -554,7 +554,7 @@ static void build_sub(PBVH *pbvh, } /* Decide whether this is a leaf or not */ - const bool below_leaf_limit = count <= pbvh->leaf_limit || depth == STACK_FIXED_DEPTH - 1; + const bool below_leaf_limit = count <= pbvh->leaf_limit || depth >= STACK_FIXED_DEPTH - 1; if (below_leaf_limit) { if (!leaf_needs_material_split(pbvh, offset, count)) { build_leaf(pbvh, node_index, prim_bbc, offset, count); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs