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-03-18 20:24:05 +0300
committerHans Goudey <h.goudey@me.com>2022-03-18 20:24:05 +0300
commit298d8a7b4aedb76600b3774727ec203e6c4d0586 (patch)
treee963b54d67627258818b4f1ef1fa993d6a982407 /source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
parentd2726e46262a4f8cecc9a060ecc26ffc5928854c (diff)
Curves: Port reverse curves node to the new data-block
Create a function on CurvesGeometry that can also be used for an edit mode operator in the future. Dealing with CustomData directly means the code is a bit more verbose than would be ideal, but this would be a simple thing to clean up in the future if we get an attribute API here. Also change the reverse node to first work on a read-only geometry component, and only get write access if there is a curve selected. Differential Revision: https://developer.blender.org/D14375
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
index 8393f9615aa..de29735bd2d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
@@ -2,7 +2,7 @@
#include "BLI_task.hh"
-#include "BKE_spline.hh"
+#include "BKE_curves.hh"
#include "node_geometry_util.hh"
@@ -25,7 +25,7 @@ static void node_geo_exec(GeoNodeExecParams params)
}
Field<bool> selection_field = params.get_input<Field<bool>>("Selection");
- CurveComponent &component = geometry_set.get_component_for_write<CurveComponent>();
+ const CurveComponent &component = *geometry_set.get_component_for_read<CurveComponent>();
GeometryComponentFieldContext field_context{component, ATTR_DOMAIN_CURVE};
const int domain_size = component.attribute_domain_size(ATTR_DOMAIN_CURVE);
@@ -33,16 +33,13 @@ static void node_geo_exec(GeoNodeExecParams params)
selection_evaluator.add(selection_field);
selection_evaluator.evaluate();
const IndexMask selection = selection_evaluator.get_evaluated_as_mask(0);
+ if (selection.is_empty()) {
+ return;
+ }
- std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*component.get_for_write());
- MutableSpan<SplinePtr> splines = curve->splines();
- threading::parallel_for(selection.index_range(), 128, [&](IndexRange range) {
- for (const int i : range) {
- splines[selection[i]]->reverse();
- }
- });
-
- component.replace(curve_eval_to_curves(*curve));
+ Curves &curves_id = *geometry_set.get_curves_for_write();
+ bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
+ curves.reverse_curves(selection);
});
params.set_output("Curve", std::move(geometry_set));