Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
| Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_COUNT) { | ||||
| evaluator.add(mode_param.selection); | evaluator.add(mode_param.selection); | ||||
| evaluator.evaluate(); | evaluator.evaluate(); | ||||
| const VArray<int> &cuts = evaluator.get_evaluated<int>(0); | const VArray<int> &cuts = evaluator.get_evaluated<int>(0); | ||||
| const VArray<bool> &selections = evaluator.get_evaluated<bool>(1); | const VArray<bool> &selections = evaluator.get_evaluated<bool>(1); | ||||
| threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { | threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { | ||||
| for (const int i : range) { | for (const int i : range) { | ||||
| BLI_assert(mode_param.count); | BLI_assert(mode_param.count); | ||||
| if (selections[i]) { | if (selections[i] && input_splines[i]->evaluated_points_size() > 0) { | ||||
| output_splines[i] = resample_spline(*input_splines[i], std::max(cuts[i], 1)); | output_splines[i] = resample_spline(*input_splines[i], std::max(cuts[i], 1)); | ||||
| } | } | ||||
| else { | else { | ||||
| output_splines[i] = input_splines[i]->copy(); | output_splines[i] = input_splines[i]->copy(); | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_LENGTH) { | else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_LENGTH) { | ||||
| fn::FieldEvaluator evaluator{field_context, domain_size}; | fn::FieldEvaluator evaluator{field_context, domain_size}; | ||||
| evaluator.add(*mode_param.length); | evaluator.add(*mode_param.length); | ||||
| evaluator.add(mode_param.selection); | evaluator.add(mode_param.selection); | ||||
| evaluator.evaluate(); | evaluator.evaluate(); | ||||
| const VArray<float> &lengths = evaluator.get_evaluated<float>(0); | const VArray<float> &lengths = evaluator.get_evaluated<float>(0); | ||||
| const VArray<bool> &selections = evaluator.get_evaluated<bool>(1); | const VArray<bool> &selections = evaluator.get_evaluated<bool>(1); | ||||
| threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { | threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { | ||||
| for (const int i : range) { | for (const int i : range) { | ||||
| if (selections[i]) { | if (selections[i] && input_splines[i]->evaluated_points_size() > 0) { | ||||
| /* Don't allow asymptotic count increase for low resolution values. */ | /* Don't allow asymptotic count increase for low resolution values. */ | ||||
| const float divide_length = std::max(lengths[i], 0.0001f); | const float divide_length = std::max(lengths[i], 0.0001f); | ||||
| const float spline_length = input_splines[i]->length(); | const float spline_length = input_splines[i]->length(); | ||||
| const int count = std::max(int(spline_length / divide_length) + 1, 1); | const int count = std::max(int(spline_length / divide_length) + 1, 1); | ||||
| output_splines[i] = resample_spline(*input_splines[i], count); | output_splines[i] = resample_spline(*input_splines[i], count); | ||||
| } | } | ||||
| else { | else { | ||||
| output_splines[i] = input_splines[i]->copy(); | output_splines[i] = input_splines[i]->copy(); | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_EVALUATED) { | else if (mode_param.mode == GEO_NODE_CURVE_RESAMPLE_EVALUATED) { | ||||
| fn::FieldEvaluator evaluator{field_context, domain_size}; | fn::FieldEvaluator evaluator{field_context, domain_size}; | ||||
| evaluator.add(mode_param.selection); | evaluator.add(mode_param.selection); | ||||
| evaluator.evaluate(); | evaluator.evaluate(); | ||||
| const VArray<bool> &selections = evaluator.get_evaluated<bool>(0); | const VArray<bool> &selections = evaluator.get_evaluated<bool>(0); | ||||
| threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { | threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { | ||||
| for (const int i : range) { | for (const int i : range) { | ||||
| if (selections[i]) { | if (selections[i] && input_splines[i]->evaluated_points_size() > 0) { | ||||
| output_splines[i] = resample_spline_evaluated(*input_splines[i]); | output_splines[i] = resample_spline_evaluated(*input_splines[i]); | ||||
| } | } | ||||
| else { | else { | ||||
| output_splines[i] = input_splines[i]->copy(); | output_splines[i] = input_splines[i]->copy(); | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||