[Bf-blender-cvs] [5e013d47a1c] geometry-nodes-curve-support: Geometry Nodes Curves: Fix writing to cyclic attribute
Hans Goudey
noreply at git.blender.org
Tue Apr 6 00:24:32 CEST 2021
Commit: 5e013d47a1c07ed53d0dc8eb18c446a0084a8294
Author: Hans Goudey
Date: Mon Apr 5 17:23:34 2021 -0500
Branches: geometry-nodes-curve-support
https://developer.blender.org/rB5e013d47a1c07ed53d0dc8eb18c446a0084a8294
Geometry Nodes Curves: Fix writing to cyclic attribute
===================================================================
M source/blender/blenkernel/intern/geometry_component_curve.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc
index dd115871343..6d567e68e00 100644
--- a/source/blender/blenkernel/intern/geometry_component_curve.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curve.cc
@@ -240,12 +240,25 @@ static bool get_cyclic_value(Spline *const &spline)
return spline->is_cyclic;
}
-static ReadAttributePtr make_cyclic_attribute(const DCurve &curve)
+static void set_cyclic_value(Spline *&spline, const bool &value)
+{
+ spline->is_cyclic = value;
+ spline->mark_cache_invalid();
+}
+
+static ReadAttributePtr make_cyclic_read_attribute(const DCurve &curve)
{
return std::make_unique<DerivedArrayReadAttribute<Spline *, bool, get_cyclic_value>>(
ATTR_DOMAIN_CURVE, curve.splines.as_span());
}
+static WriteAttributePtr make_cyclic_write_attribute(DCurve &curve)
+{
+ return std::make_unique<
+ DerivedArrayWriteAttribute<Spline *, bool, get_cyclic_value, set_cyclic_value>>(
+ ATTR_DOMAIN_CURVE, curve.splines.as_mutable_span());
+}
+
/**
* In this function all the attribute providers for a curve component are created. Most data
* in this function is statically allocated, because it does not change over time.
@@ -273,8 +286,8 @@ static ComponentAttributeProviders create_attribute_providers_for_curve()
BuiltinAttributeProvider::NonCreatable,
BuiltinAttributeProvider::Writable,
BuiltinAttributeProvider::NonDeletable,
- make_cyclic_attribute,
- nullptr);
+ make_cyclic_read_attribute,
+ make_cyclic_write_attribute);
return ComponentAttributeProviders({&resolution, &length, &cyclic}, {});
}
More information about the Bf-blender-cvs
mailing list