diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index eaeb4121fe9..de23d04df0a 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -1567,12 +1567,10 @@ static void calculate_average_color(VPaintData &vpd, using Blend = typename Traits::BlendType; const Span colors = attribute.typed().template cast(); - Array> accum(nodes.size()); + Array> accum(nodes.size(), {0, {0, 0, 0}}); node_mask.foreach_index(GrainSize(1), [&](const int i) { - LocalData &tls = all_tls.local(); VPaintAverageAccum &accum2 = accum[i]; - accum2.len = 0; - memset(accum2.value, 0, sizeof(accum2.value)); + LocalData &tls = all_tls.local(); const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); @@ -1620,12 +1618,12 @@ static void calculate_average_color(VPaintData &vpd, Blend accum_value[3] = {0}; Color blend(0, 0, 0, 0); - for (int i = 0; i < nodes.size(); i++) { + node_mask.foreach_index([&](const int i) { accum_len += accum[i].len; accum_value[0] += accum[i].value[0]; accum_value[1] += accum[i].value[1]; accum_value[2] += accum[i].value[2]; - } + }); if (accum_len != 0) { blend.r = Traits::round(sqrtf(Traits::divide_round(accum_value[0], accum_len))); blend.g = Traits::round(sqrtf(Traits::divide_round(accum_value[1], accum_len)));