Geometry Nodes: Parallelize "Set Spline Type"-node
Parallelizes the loop that converts splines. It gives around a 2x speedup on curves with over 1k splines. Differential Revision: https://developer.blender.org/D13389
This commit is contained in:
parent
2531358297
commit
d2f4fb68f5
|
@ -1 +1 @@
|
|||
Subproject commit 4de1bcce5a2caa31131c40cc19f0a1851c2eb635
|
||||
Subproject commit 9030e2c6d1aca714c7122aa5b52bf2424ee4b880
|
|
@ -1 +1 @@
|
|||
Subproject commit 16467648282500cc229c271f62201ef897f2c2c3
|
||||
Subproject commit 7936dde9ece881d531b1a2ee6c45ddb56d30038c
|
|
@ -261,24 +261,28 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||
const VArray<bool> &selection = selection_evaluator.get_evaluated<bool>(0);
|
||||
|
||||
std::unique_ptr<CurveEval> new_curve = std::make_unique<CurveEval>();
|
||||
for (const int i : curve.splines().index_range()) {
|
||||
if (selection[i]) {
|
||||
switch (output_type) {
|
||||
case GEO_NODE_SPLINE_TYPE_POLY:
|
||||
new_curve->add_spline(convert_to_poly_spline(*curve.splines()[i]));
|
||||
break;
|
||||
case GEO_NODE_SPLINE_TYPE_BEZIER:
|
||||
new_curve->add_spline(convert_to_bezier(*curve.splines()[i], params));
|
||||
break;
|
||||
case GEO_NODE_SPLINE_TYPE_NURBS:
|
||||
new_curve->add_spline(convert_to_nurbs(*curve.splines()[i]));
|
||||
break;
|
||||
new_curve->resize(curve.splines().size());
|
||||
|
||||
threading::parallel_for(curve.splines().index_range(), 512, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
if (selection[i]) {
|
||||
switch (output_type) {
|
||||
case GEO_NODE_SPLINE_TYPE_POLY:
|
||||
new_curve->splines()[i] = convert_to_poly_spline(*curve.splines()[i]);
|
||||
break;
|
||||
case GEO_NODE_SPLINE_TYPE_BEZIER:
|
||||
new_curve->splines()[i] = convert_to_bezier(*curve.splines()[i], params);
|
||||
break;
|
||||
case GEO_NODE_SPLINE_TYPE_NURBS:
|
||||
new_curve->splines()[i] = convert_to_nurbs(*curve.splines()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
new_curve->splines()[i] = curve.splines()[i]->copy();
|
||||
}
|
||||
}
|
||||
else {
|
||||
new_curve->add_spline(curve.splines()[i]->copy());
|
||||
}
|
||||
}
|
||||
});
|
||||
new_curve->attributes = curve.attributes;
|
||||
geometry_set.replace_curve(new_curve.release());
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue