Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-02-28 18:46:34 +0300
committerHans Goudey <h.goudey@me.com>2022-02-28 18:46:34 +0300
commit9ec12c26f16ea3da1e6de95d5d5daf1057464830 (patch)
tree708e542d5d4de0efdda7b9a54def6b25b6b64039 /source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
parent81bb86c7506c0ae5f07780a63f954a8416a0d4e6 (diff)
Geometry Nodes: Begin conversion to new curves
This commit changes `CurveComponent` to store the new curve type by adding conversions to and from `CurveEval` in most nodes. This will temporarily make performance of curves in geometry nodes much worse, but as functionality is implemented for the new type and it is used in more places, performance will become better than before. We still use `CurveEval` for drawing curves, because the new `Curves` data-block has no evaluated points yet. So the `Curve` ID is still generated for rendering in the same way as before. It's also still needed for drawing curve object edit mode overlays. The old curve component isn't removed yet, because it is still used to implement the conversions to and from `CurveEval`. A few more attributes are added to make this possible: - `nurbs_weight`: The weight for each control point on NURBS curves. - `nurbs_order`: The order of the NURBS curve - `knots_mode`: Necessary for conversion, not defined yet. - `handle_type_{left/right}`: An 8 bit integer attribute. Differential Revision: https://developer.blender.org/D14145
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
index 053df030f15..d691726da27 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
@@ -367,40 +367,43 @@ static void node_geo_exec(GeoNodeExecParams params)
}
const CurveComponent *curve_component = geometry_set.get_component_for_read<CurveComponent>();
- const CurveEval &curve = *curve_component->get_for_read();
+ const std::unique_ptr<CurveEval> curve = curves_to_curve_eval(
+ *curve_component->get_for_read());
GeometryComponentFieldContext field_context{*curve_component, ATTR_DOMAIN_CURVE};
const int domain_size = curve_component->attribute_domain_size(ATTR_DOMAIN_CURVE);
+ Span<SplinePtr> src_splines = curve->splines();
+
fn::FieldEvaluator selection_evaluator{field_context, domain_size};
selection_evaluator.add(selection_field);
selection_evaluator.evaluate();
const VArray<bool> &selection = selection_evaluator.get_evaluated<bool>(0);
std::unique_ptr<CurveEval> new_curve = std::make_unique<CurveEval>();
- new_curve->resize(curve.splines().size());
+ new_curve->resize(src_splines.size());
- threading::parallel_for(curve.splines().index_range(), 512, [&](IndexRange range) {
+ threading::parallel_for(src_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]);
+ new_curve->splines()[i] = convert_to_poly_spline(*src_splines[i]);
break;
case GEO_NODE_SPLINE_TYPE_BEZIER:
- new_curve->splines()[i] = convert_to_bezier(*curve.splines()[i], params);
+ new_curve->splines()[i] = convert_to_bezier(*src_splines[i], params);
break;
case GEO_NODE_SPLINE_TYPE_NURBS:
- new_curve->splines()[i] = convert_to_nurbs(*curve.splines()[i]);
+ new_curve->splines()[i] = convert_to_nurbs(*src_splines[i]);
break;
}
}
else {
- new_curve->splines()[i] = curve.splines()[i]->copy();
+ new_curve->splines()[i] = src_splines[i]->copy();
}
}
});
- new_curve->attributes = curve.attributes;
- geometry_set.replace_curve(new_curve.release());
+ new_curve->attributes = curve->attributes;
+ geometry_set.replace_curve(curve_eval_to_curves(*new_curve));
});
params.set_output("Curve", std::move(geometry_set));