diff options
author | Hans Goudey <h.goudey@me.com> | 2021-07-23 00:20:04 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-07-23 00:20:04 +0300 |
commit | f76dfe8fb45c9c270c295ff76f6fd058e2b64d0d (patch) | |
tree | 8145dc1b7909082ffa4cde3bd4f7a2f86a3dfdc6 /source/blender/blenkernel/intern/curve_eval.cc | |
parent | 524d172742ec22ca04f2b0c83932e2cda669837c (diff) |
Cleanup: Add function to check a curve's spline types
The need for this has come up a few times.
Diffstat (limited to 'source/blender/blenkernel/intern/curve_eval.cc')
-rw-r--r-- | source/blender/blenkernel/intern/curve_eval.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc index 8e1577ab072..5c18f6f3807 100644 --- a/source/blender/blenkernel/intern/curve_eval.cc +++ b/source/blender/blenkernel/intern/curve_eval.cc @@ -48,6 +48,22 @@ blender::MutableSpan<SplinePtr> CurveEval::splines() return splines_; } +/** + * \return True if the curve contains a spline with the given type. + * + * \note If you are looping over all of the splines in the same scope anyway, + * it's better to avoid calling this function, in case there are many splines. + */ +bool CurveEval::has_spline_with_type(const Spline::Type type) const +{ + for (const SplinePtr &spline : this->splines()) { + if (spline->type() == type) { + return true; + } + } + return false; +} + void CurveEval::resize(const int size) { splines_.resize(size); |