From 1d60415115d02448eb85a5c499a7f29fe92fe75d Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 8 Dec 2023 11:15:06 +0100 Subject: [PATCH] 3D Paint Brush: Disable Node Splitting Node splitting seems to be broken and when triggered it crashes blender. The cause for this is that SplitNodePair stores a full node and uses assign operators, that can free unallocated space. Although node splitting is important for performance point of view, we should reevaluate how we want node splitting to work. This PR only disables it, so it won't crash when used. Pull Request: https://projects.blender.org/blender/blender/pulls/115928 --- source/blender/blenkernel/intern/pbvh_pixels.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 94b79009e57..c2cd60cbed9 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -30,6 +30,15 @@ namespace blender::bke::pbvh::pixels { +/** + * Splitting of pixel nodes has been disabled as it was designed for C. When migrating to CPP + * the splitting data structure will corrupt memory. + * + * TODO(jbakker): This should be fixed or replaced with a different solution. If we go into a + * direction of compute shaders this might not be needed anymore. + */ +constexpr bool PBVH_PIXELS_SPLIT_NODES_ENABLED = false; + /** * Calculate the delta of two neighbor UV coordinates in the given image buffer. */ @@ -805,7 +814,7 @@ using namespace blender::bke::pbvh::pixels; void BKE_pbvh_build_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image_user) { - if (update_pixels(pbvh, mesh, image, image_user)) { + if (update_pixels(pbvh, mesh, image, image_user) && PBVH_PIXELS_SPLIT_NODES_ENABLED) { split_pixel_nodes(pbvh, mesh, image, image_user); } }