Fix T85493: Attribute glitches while using Attribute Proximity node

The span fill was in multithreaded code, so calculated values were
sometimes reset. The fix is to move FLT_MAX fill outside of parallel_for.

Differential Revision: https://developer.blender.org/D10378
This commit is contained in:
Victor-Louis De Gusseme
2021-02-09 16:24:21 -06:00
committed by Hans Goudey
parent a86605fffd
commit 722790e8d2

View File

@@ -66,6 +66,11 @@ static void proximity_calc(MutableSpan<float> distance_span,
const bool bvh_mesh_success,
const bool bvh_pointcloud_success)
{
/* The pointcloud loop uses the values already in the span,
* which is only set if the mesh BVH is used (because it's first). */
if (!bvh_mesh_success) {
distance_span.fill(FLT_MAX);
}
IndexRange range = positions.index_range();
parallel_for(range, 512, [&](IndexRange range) {
@@ -86,11 +91,6 @@ static void proximity_calc(MutableSpan<float> distance_span,
}
}
/* The next loop(s) use the values already in the span. */
if (!bvh_mesh_success) {
distance_span.fill(FLT_MAX);
}
if (bvh_pointcloud_success) {
copy_v3_fl(nearest.co, FLT_MAX);
nearest.index = -1;