BLI: add threading namespace
This namespace groups threading related functions/classes. This avoids adding more threading related stuff to the blender namespace. Also it makes naming a bit easier, e.g. the c++ version of BLI_task_isolate could become blender::threading::isolate_task or something similar. Differential Revision: https://developer.blender.org/D11624
This commit is contained in:
@@ -78,7 +78,7 @@ static void align_rotations_auto_pivot(const VArray<float3> &vectors,
|
||||
const float3 local_main_axis,
|
||||
const MutableSpan<float3> rotations)
|
||||
{
|
||||
parallel_for(IndexRange(vectors.size()), 128, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(vectors.size()), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 vector = vectors[i];
|
||||
if (is_zero_v3(vector)) {
|
||||
@@ -129,7 +129,7 @@ static void align_rotations_fixed_pivot(const VArray<float3> &vectors,
|
||||
return;
|
||||
}
|
||||
|
||||
parallel_for(IndexRange(vectors.size()), 128, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(vectors.size()), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 vector = vectors[i];
|
||||
if (is_zero_v3(vector)) {
|
||||
|
@@ -95,7 +95,7 @@ static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryCompon
|
||||
MutableSpan<ColorGeometry4f> results = attribute_result.as_span();
|
||||
|
||||
ColorBand *color_ramp = &node_storage->color_ramp;
|
||||
parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]);
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryCompon
|
||||
GVArray_Typed<float> attribute_in = component.attribute_get_for_read<float>(
|
||||
input_name, result_domain, float(0.0f));
|
||||
MutableSpan<float> results = attribute_result.as_span<float>();
|
||||
parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = BKE_curvemapping_evaluateF(cumap, 3, attribute_in[i]);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryCompon
|
||||
GVArray_Typed<float3> attribute_in = component.attribute_get_for_read<float3>(
|
||||
input_name, result_domain, float3(0.0f));
|
||||
MutableSpan<float3> results = attribute_result.as_span<float3>();
|
||||
parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
BKE_curvemapping_evaluate3F(cumap, results[i], attribute_in[i]);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ static void execute_on_component(const GeoNodeExecParams ¶ms, GeometryCompon
|
||||
component.attribute_get_for_read<ColorGeometry4f>(
|
||||
input_name, result_domain, ColorGeometry4f(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
MutableSpan<ColorGeometry4f> results = attribute_result.as_span<ColorGeometry4f>();
|
||||
parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
BKE_curvemapping_evaluateRGBF(cumap, results[i], attribute_in[i]);
|
||||
}
|
||||
|
@@ -209,7 +209,7 @@ static void map_range_float(const VArray<float> &attribute_input,
|
||||
|
||||
switch (interpolation_type) {
|
||||
case NODE_MAP_RANGE_LINEAR: {
|
||||
parallel_for(span.index_range(), 2048, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 2048, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = map_linear(span[i], min_from, max_from, min_to, max_to);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ static void map_range_float(const VArray<float> &attribute_input,
|
||||
}
|
||||
case NODE_MAP_RANGE_STEPPED: {
|
||||
const float steps = params.get_input<float>("Steps");
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = map_stepped(span[i], min_from, max_from, min_to, max_to, steps);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ static void map_range_float(const VArray<float> &attribute_input,
|
||||
break;
|
||||
}
|
||||
case NODE_MAP_RANGE_SMOOTHSTEP: {
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = map_smoothstep(span[i], min_from, max_from, min_to, max_to);
|
||||
}
|
||||
@@ -234,7 +234,7 @@ static void map_range_float(const VArray<float> &attribute_input,
|
||||
break;
|
||||
}
|
||||
case NODE_MAP_RANGE_SMOOTHERSTEP: {
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = map_smootherstep(span[i], min_from, max_from, min_to, max_to);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ static void map_range_float(const VArray<float> &attribute_input,
|
||||
const float clamp_min = min_to < max_to ? min_to : max_to;
|
||||
const float clamp_max = min_to < max_to ? max_to : min_to;
|
||||
|
||||
parallel_for(results.index_range(), 2048, [&](IndexRange range) {
|
||||
threading::parallel_for(results.index_range(), 2048, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = std::clamp(results[i], clamp_min, clamp_max);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ static void map_range_float3(const VArray<float3> &attribute_input,
|
||||
|
||||
switch (interpolation_type) {
|
||||
case NODE_MAP_RANGE_LINEAR: {
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i].x = map_linear(span[i].x, min_from.x, max_from.x, min_to.x, max_to.x);
|
||||
results[i].y = map_linear(span[i].y, min_from.y, max_from.y, min_to.y, max_to.y);
|
||||
@@ -284,7 +284,7 @@ static void map_range_float3(const VArray<float3> &attribute_input,
|
||||
}
|
||||
case NODE_MAP_RANGE_STEPPED: {
|
||||
const float3 steps = params.get_input<float3>("Steps_001");
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i].x = map_stepped(
|
||||
span[i].x, min_from.x, max_from.x, min_to.x, max_to.x, steps.x);
|
||||
@@ -297,7 +297,7 @@ static void map_range_float3(const VArray<float3> &attribute_input,
|
||||
break;
|
||||
}
|
||||
case NODE_MAP_RANGE_SMOOTHSTEP: {
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i].x = map_smoothstep(span[i].x, min_from.x, max_from.x, min_to.x, max_to.x);
|
||||
results[i].y = map_smoothstep(span[i].y, min_from.y, max_from.y, min_to.y, max_to.y);
|
||||
@@ -307,7 +307,7 @@ static void map_range_float3(const VArray<float3> &attribute_input,
|
||||
break;
|
||||
}
|
||||
case NODE_MAP_RANGE_SMOOTHERSTEP: {
|
||||
parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i].x = map_smootherstep(span[i].x, min_from.x, max_from.x, min_to.x, max_to.x);
|
||||
results[i].y = map_smootherstep(span[i].y, min_from.y, max_from.y, min_to.y, max_to.y);
|
||||
|
@@ -159,7 +159,7 @@ static void do_math_operation(const VArray<float> &span_a,
|
||||
{
|
||||
bool success = try_dispatch_float_math_fl_fl_fl_to_fl(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(span_result.size()), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(span_result.size()), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
span_result[i] = math_function(span_a[i], span_b[i], span_c[i]);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ static void do_math_operation(const VArray<float> &span_a,
|
||||
{
|
||||
bool success = try_dispatch_float_math_fl_fl_to_fl(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(span_result.size()), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(span_result.size()), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
span_result[i] = math_function(span_a[i], span_b[i]);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ static void do_math_operation(const VArray<float> &span_input,
|
||||
{
|
||||
bool success = try_dispatch_float_math_fl_to_fl(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(span_result.size()), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(span_result.size()), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
span_result[i] = math_function(span_input[i]);
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ static void do_mix_operation_float(const int blend_mode,
|
||||
VMutableArray<float> &results)
|
||||
{
|
||||
const int size = results.size();
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float factor = factors[i];
|
||||
float3 a{inputs_a[i]};
|
||||
@@ -107,7 +107,7 @@ static void do_mix_operation_float3(const int blend_mode,
|
||||
VMutableArray<float3> &results)
|
||||
{
|
||||
const int size = results.size();
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float factor = factors[i];
|
||||
float3 a = inputs_a[i];
|
||||
@@ -125,7 +125,7 @@ static void do_mix_operation_color4f(const int blend_mode,
|
||||
VMutableArray<ColorGeometry4f> &results)
|
||||
{
|
||||
const int size = results.size();
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float factor = factors[i];
|
||||
ColorGeometry4f a = inputs_a[i];
|
||||
|
@@ -71,7 +71,7 @@ static void proximity_calc(MutableSpan<float> distance_span,
|
||||
const bool store_locations)
|
||||
{
|
||||
IndexRange range = positions.index_range();
|
||||
parallel_for(range, 512, [&](IndexRange range) {
|
||||
threading::parallel_for(range, 512, [&](IndexRange range) {
|
||||
BVHTreeNearest nearest_from_mesh;
|
||||
BVHTreeNearest nearest_from_pointcloud;
|
||||
|
||||
|
@@ -126,7 +126,7 @@ static void randomize_attribute(MutableSpan<T> span,
|
||||
/* The operations could be templated too, but it doesn't make the code much shorter. */
|
||||
switch (operation) {
|
||||
case GEO_NODE_ATTRIBUTE_RANDOMIZE_REPLACE_CREATE:
|
||||
parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const T random_value = random_value_in_range<T>(ids[i], seed, min, max);
|
||||
span[i] = random_value;
|
||||
@@ -134,7 +134,7 @@ static void randomize_attribute(MutableSpan<T> span,
|
||||
});
|
||||
break;
|
||||
case GEO_NODE_ATTRIBUTE_RANDOMIZE_ADD:
|
||||
parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const T random_value = random_value_in_range<T>(ids[i], seed, min, max);
|
||||
span[i] = span[i] + random_value;
|
||||
@@ -142,7 +142,7 @@ static void randomize_attribute(MutableSpan<T> span,
|
||||
});
|
||||
break;
|
||||
case GEO_NODE_ATTRIBUTE_RANDOMIZE_SUBTRACT:
|
||||
parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const T random_value = random_value_in_range<T>(ids[i], seed, min, max);
|
||||
span[i] = span[i] - random_value;
|
||||
@@ -150,7 +150,7 @@ static void randomize_attribute(MutableSpan<T> span,
|
||||
});
|
||||
break;
|
||||
case GEO_NODE_ATTRIBUTE_RANDOMIZE_MULTIPLY:
|
||||
parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const T random_value = random_value_in_range<T>(ids[i], seed, min, max);
|
||||
span[i] = span[i] * random_value;
|
||||
@@ -170,7 +170,7 @@ static void randomize_attribute_bool(MutableSpan<bool> span,
|
||||
{
|
||||
BLI_assert(operation == GEO_NODE_ATTRIBUTE_RANDOMIZE_REPLACE_CREATE);
|
||||
UNUSED_VARS_NDEBUG(operation);
|
||||
parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(span.index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const bool random_value = BLI_hash_int_2d_to_float(ids[i], seed) > 0.5f;
|
||||
span[i] = random_value;
|
||||
@@ -190,7 +190,7 @@ Array<uint32_t> get_geometry_element_ids_as_uints(const GeometryComponent &compo
|
||||
BLI_assert(hashes.size() == hash_attribute->size());
|
||||
const CPPType &cpp_type = hash_attribute->type();
|
||||
GVArray_GSpan items{*hash_attribute};
|
||||
parallel_for(hashes.index_range(), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(hashes.index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
hashes[i] = cpp_type.hash(items[i]);
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ static void execute_on_component(GeometryComponent &component, const GeoNodeExec
|
||||
mapping_name, result_domain, {0, 0, 0});
|
||||
|
||||
MutableSpan<ColorGeometry4f> colors = attribute_out.as_span();
|
||||
parallel_for(IndexRange(mapping_attribute.size()), 128, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(mapping_attribute.size()), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
TexResult texture_result = {0};
|
||||
const float3 position = mapping_attribute[i];
|
||||
|
@@ -186,7 +186,7 @@ static void do_math_operation_fl3_fl3_to_fl3(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_fl3_to_fl3(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 a = span_a[i];
|
||||
const float3 b = span_b[i];
|
||||
@@ -218,7 +218,7 @@ static void do_math_operation_fl3_fl3_fl3_to_fl3(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_fl3_fl3_to_fl3(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 a = span_a[i];
|
||||
const float3 b = span_b[i];
|
||||
@@ -251,7 +251,7 @@ static void do_math_operation_fl3_fl3_fl_to_fl3(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_fl3_fl_to_fl3(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 a = span_a[i];
|
||||
const float3 b = span_b[i];
|
||||
@@ -282,7 +282,7 @@ static void do_math_operation_fl3_fl3_to_fl(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_fl3_to_fl(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 a = span_a[i];
|
||||
const float3 b = span_b[i];
|
||||
@@ -312,7 +312,7 @@ static void do_math_operation_fl3_fl_to_fl3(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_fl_to_fl3(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 a = span_a[i];
|
||||
const float b = span_b[i];
|
||||
@@ -340,7 +340,7 @@ static void do_math_operation_fl3_to_fl3(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_to_fl3(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 in = span_a[i];
|
||||
const float3 out = math_function(in);
|
||||
@@ -367,7 +367,7 @@ static void do_math_operation_fl3_to_fl(const VArray<float3> &input_a,
|
||||
|
||||
bool success = try_dispatch_float_math_fl3_to_fl(
|
||||
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
|
||||
parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const float3 in = span_a[i];
|
||||
const float out = math_function(in);
|
||||
|
@@ -154,7 +154,7 @@ static void do_vector_rotate_around_axis(const VArray<float3> &vector,
|
||||
VArray_Span<float3> span_axis{axis};
|
||||
VArray_Span<float> span_angle{angle};
|
||||
|
||||
parallel_for(IndexRange(results.size()), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(results.size()), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
float angle = (invert) ? -span_angle[i] : span_angle[i];
|
||||
results[i] = vector_rotate_around_axis(span_vector[i], span_center[i], span_axis[i], angle);
|
||||
@@ -173,7 +173,7 @@ static void do_vector_rotate_around_fixed_axis(const VArray<float3> &vector,
|
||||
VArray_Span<float3> span_center{center};
|
||||
VArray_Span<float> span_angle{angle};
|
||||
|
||||
parallel_for(IndexRange(results.size()), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(results.size()), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
float angle = (invert) ? -span_angle[i] : span_angle[i];
|
||||
results[i] = vector_rotate_around_axis(span_vector[i], span_center[i], axis, angle);
|
||||
@@ -191,7 +191,7 @@ static void do_vector_rotate_euler(const VArray<float3> &vector,
|
||||
VArray_Span<float3> span_center{center};
|
||||
VArray_Span<float3> span_rotation{rotation};
|
||||
|
||||
parallel_for(IndexRange(results.size()), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(results.size()), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
results[i] = vector_rotate_euler(span_vector[i], span_center[i], span_rotation[i], invert);
|
||||
}
|
||||
|
@@ -76,7 +76,7 @@ static void geo_node_curve_reverse_exec(GeoNodeExecParams params)
|
||||
GVArray_Typed<bool> selection = curve_component.attribute_get_for_read(
|
||||
selection_name, ATTR_DOMAIN_CURVE, true);
|
||||
|
||||
parallel_for(splines.index_range(), 128, [&](IndexRange range) {
|
||||
threading::parallel_for(splines.index_range(), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
if (!selection[i]) {
|
||||
continue;
|
||||
|
@@ -71,7 +71,7 @@ namespace blender::nodes {
|
||||
*/
|
||||
static void evaluate_splines(Span<SplinePtr> splines)
|
||||
{
|
||||
parallel_for_each(splines, [](const SplinePtr &spline) {
|
||||
threading::parallel_for_each(splines, [](const SplinePtr &spline) {
|
||||
/* These functions fill the corresponding caches on each spline. */
|
||||
spline->evaluated_positions();
|
||||
spline->evaluated_tangents();
|
||||
@@ -192,7 +192,7 @@ static void copy_evaluated_point_attributes(Span<SplinePtr> splines,
|
||||
Span<int> offsets,
|
||||
ResultAttributes &data)
|
||||
{
|
||||
parallel_for(splines.index_range(), 64, [&](IndexRange range) {
|
||||
threading::parallel_for(splines.index_range(), 64, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const Spline &spline = *splines[i];
|
||||
const int offset = offsets[i];
|
||||
@@ -225,7 +225,7 @@ static void copy_uniform_sample_point_attributes(Span<SplinePtr> splines,
|
||||
Span<int> offsets,
|
||||
ResultAttributes &data)
|
||||
{
|
||||
parallel_for(splines.index_range(), 64, [&](IndexRange range) {
|
||||
threading::parallel_for(splines.index_range(), 64, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const Spline &spline = *splines[i];
|
||||
const int offset = offsets[i];
|
||||
@@ -313,7 +313,7 @@ static void copy_spline_domain_attributes(const CurveComponent &curve_component,
|
||||
|
||||
static void create_default_rotation_attribute(ResultAttributes &data)
|
||||
{
|
||||
parallel_for(IndexRange(data.result_size), 512, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(data.result_size), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
data.rotations[i] = float4x4::from_normalized_axis_data(
|
||||
{0, 0, 0}, data.normals[i], data.tangents[i])
|
||||
|
@@ -62,7 +62,7 @@ static void copy_attributes_to_points(CurveEval &curve,
|
||||
if (source_attribute_names.contains_as("tilt")) {
|
||||
const GVArray_Typed<float> tilt_attribute = mesh_component.attribute_get_for_read<float>(
|
||||
"tilt", ATTR_DOMAIN_POINT, 0.0f);
|
||||
parallel_for(splines.index_range(), 256, [&](IndexRange range) {
|
||||
threading::parallel_for(splines.index_range(), 256, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
copy_attribute_to_points<float>(
|
||||
*tilt_attribute, point_to_vert_maps[i], splines[i]->tilts());
|
||||
@@ -73,7 +73,7 @@ static void copy_attributes_to_points(CurveEval &curve,
|
||||
if (source_attribute_names.contains_as("radius")) {
|
||||
const GVArray_Typed<float> radius_attribute = mesh_component.attribute_get_for_read<float>(
|
||||
"radius", ATTR_DOMAIN_POINT, 1.0f);
|
||||
parallel_for(splines.index_range(), 256, [&](IndexRange range) {
|
||||
threading::parallel_for(splines.index_range(), 256, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
copy_attribute_to_points<float>(
|
||||
*radius_attribute, point_to_vert_maps[i], splines[i]->radii());
|
||||
@@ -97,7 +97,7 @@ static void copy_attributes_to_points(CurveEval &curve,
|
||||
|
||||
const CustomDataType data_type = bke::cpp_type_to_custom_data_type(mesh_attribute->type());
|
||||
|
||||
parallel_for(splines.index_range(), 128, [&](IndexRange range) {
|
||||
threading::parallel_for(splines.index_range(), 128, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
/* Create attribute on the spline points. */
|
||||
splines[i]->attributes.create(name, data_type);
|
||||
|
@@ -189,7 +189,7 @@ static void add_instances_from_component(InstancesComponent &instances,
|
||||
* (anything except for collection mode with "Whole Collection" turned off). */
|
||||
if (possible_handles.size() == 1) {
|
||||
const int handle = possible_handles.first();
|
||||
parallel_for(IndexRange(domain_size), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(domain_size), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
handles[i] = handle;
|
||||
transforms[i] = float4x4::from_loc_eul_scale(positions[i], rotations[i], scales[i]);
|
||||
@@ -200,7 +200,7 @@ static void add_instances_from_component(InstancesComponent &instances,
|
||||
else {
|
||||
const int seed = params.get_input<int>("Seed");
|
||||
Array<uint32_t> ids = get_geometry_element_ids_as_uints(src_geometry, ATTR_DOMAIN_POINT);
|
||||
parallel_for(IndexRange(domain_size), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(IndexRange(domain_size), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
const int index = BLI_hash_int_2d(ids[i], seed) % possible_handles.size();
|
||||
const int handle = possible_handles[index];
|
||||
|
@@ -60,7 +60,7 @@ static void select_mesh_by_material(const Mesh &mesh,
|
||||
material_indices.append(i);
|
||||
}
|
||||
}
|
||||
parallel_for(r_selection.index_range(), 1024, [&](IndexRange range) {
|
||||
threading::parallel_for(r_selection.index_range(), 1024, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
r_selection[i] = material_indices.contains(mesh.mpoly[i].mat_nr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user