[Bf-blender-cvs] [6594e802ab9] master: Curves: Add method to access cyclic attribute
Hans Goudey
noreply at git.blender.org
Mon Feb 28 23:20:46 CET 2022
Commit: 6594e802ab94ff1124d9157deb0ca760981e3f34
Author: Hans Goudey
Date: Mon Feb 28 17:20:37 2022 -0500
Branches: master
https://developer.blender.org/rB6594e802ab94ff1124d9157deb0ca760981e3f34
Curves: Add method to access cyclic attribute
Avoids the need to use the attribute API to access this commonly
used builtin attribute.
===================================================================
M source/blender/blenkernel/BKE_curves.hh
M source/blender/blenkernel/intern/curves_geometry.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index 209f892c651..6fa7de49eb0 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -119,6 +119,9 @@ class CurvesGeometry : public ::CurvesGeometry {
Span<int> offsets() const;
MutableSpan<int> offsets();
+ VArray<bool> cyclic() const;
+ MutableSpan<bool> cyclic();
+
/* --------------------------------------------------------------------
* Operations.
*/
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) {
More information about the Bf-blender-cvs
mailing list