diff options
author | Hans Goudey <h.goudey@me.com> | 2022-03-01 01:20:37 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-01 01:20:37 +0300 |
commit | 6594e802ab94ff1124d9157deb0ca760981e3f34 (patch) | |
tree | de2cfd494461690bb62b28512f686b8d21d0ae8f /source/blender/blenkernel/intern/curves_geometry.cc | |
parent | 4c407f20a62c7d437a9b3f2498b658f968102573 (diff) |
Curves: Add method to access cyclic attribute
Avoids the need to use the attribute API to access this commonly
used builtin attribute.
Diffstat (limited to 'source/blender/blenkernel/intern/curves_geometry.cc')
-rw-r--r-- | source/blender/blenkernel/intern/curves_geometry.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 68797942b56..3eea579230a 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -18,6 +18,7 @@ namespace blender::bke { static const std::string ATTR_POSITION = "position"; static const std::string ATTR_RADIUS = "radius"; static const std::string ATTR_CURVE_TYPE = "curve_type"; +static const std::string ATTR_CYCLIC = "cyclic"; /* -------------------------------------------------------------------- */ /** \name Constructors/Destructor @@ -168,6 +169,23 @@ Span<int> CurvesGeometry::offsets() const return {this->curve_offsets, this->curve_size + 1}; } +VArray<bool> CurvesGeometry::cyclic() const +{ + const bool *data = (const bool *)CustomData_get_layer_named( + &this->curve_data, CD_PROP_INT8, ATTR_CURVE_TYPE.c_str()); + if (data != nullptr) { + return VArray<bool>::ForSpan(Span(data, this->curve_size)); + } + return VArray<bool>::ForSingle(false, this->curve_size); +} + +MutableSpan<bool> CurvesGeometry::cyclic() +{ + bool *data = (bool *)CustomData_add_layer_named( + &this->curve_data, CD_PROP_BOOL, CD_CALLOC, nullptr, this->curve_size, ATTR_CYCLIC.c_str()); + return {data, this->curve_size}; +} + void CurvesGeometry::resize(const int point_size, const int curve_size) { if (point_size != this->point_size) { |