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-04-01 16:11:58 +0300
committerHans Goudey <h.goudey@me.com>2022-04-01 16:12:41 +0300
commit00ba51d37bf5b152176409b393eafbb0ad9333e6 (patch)
tree499a1503c59f3558101bba52cef10d64c39a57fd /source/blender/blenkernel/intern/curves_geometry.cc
parenta250d3d1b7d8d497c21a1ef845e64f07e68beda9 (diff)
Geometry Nodes: Port set handle nodes to new data-block
This commit ports the "Set Handle Positions" and "Set Hanle Type" nodes to use the new curves data-block. The nodes become simpler and likely much faster too, though they're usually not the bottleneck anyway. Most of the code is ported from `BezierSpline` directly. The majority of the complexity comes from the interaction between different automatically calculated handle types. In comparison `BezierSpline`, the calculation of auto handles is done eagerly-- mostly because it's simpler. Eventually lazy calculation might be good to add. Differential Revision: https://developer.blender.org/D14464
Diffstat (limited to 'source/blender/blenkernel/intern/curves_geometry.cc')
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index 94402f0e548..66088714e63 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -851,6 +851,34 @@ static void transform_positions(MutableSpan<float3> positions, const float4x4 &m
});
}
+void CurvesGeometry::calculate_bezier_auto_handles()
+{
+ const VArray<int8_t> types = std::as_const(*this).curve_types();
+ if (types.is_single() && types.get_internal_single() != CURVE_TYPE_BEZIER) {
+ return;
+ }
+ const VArray<bool> cyclic = std::as_const(*this).cyclic();
+ const Span<int8_t> types_left = this->handle_types_left();
+ const Span<int8_t> types_right = this->handle_types_right();
+ const Span<float3> positions = this->positions();
+ MutableSpan<float3> positions_left = this->handle_positions_left();
+ MutableSpan<float3> positions_right = this->handle_positions_right();
+
+ threading::parallel_for(this->curves_range(), 128, [&](IndexRange range) {
+ for (const int i_curve : range) {
+ if (types[i_curve] == CURVE_TYPE_BEZIER) {
+ const IndexRange points = this->points_for_curve(i_curve);
+ curves::bezier::calculate_auto_handles(cyclic[i_curve],
+ types_left.slice(points),
+ types_right.slice(points),
+ positions.slice(points),
+ positions_left.slice(points),
+ positions_right.slice(points));
+ }
+ }
+ });
+}
+
void CurvesGeometry::translate(const float3 &translation)
{
/* Use `as_const` because the non-const functions can add the handle attributes. */