diff options
author | Hans Goudey <h.goudey@me.com> | 2021-06-28 22:15:58 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-06-28 22:15:58 +0300 |
commit | 790cb28766813c94733637e46a6527eaf9a04a6b (patch) | |
tree | 3c40c360a4442d3c43bb3d2fb5c7126fe57b1c22 /source/blender/blenkernel/intern | |
parent | dc0c81337da54f00bed30e7b144f837407740fcc (diff) |
Curve: Add functions to retrieve const access to spline list
While the const correctness of `ListBase` is quite limited, it's helpful
to have a way to retrieve the `Nurb` list from curve object data without
casting away const from the curve.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 341a2b555d8..aaf61e41894 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -442,6 +442,15 @@ ListBase *BKE_curve_editNurbs_get(Curve *cu) return NULL; } +const ListBase *BKE_curve_editNurbs_get_for_read(const Curve *cu) +{ + if (cu->editnurb) { + return &cu->editnurb->nurbs; + } + + return NULL; +} + short BKE_curve_type_get(const Curve *cu) { int type = cu->type; @@ -2691,7 +2700,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_ is_editmode = 1; } - LISTBASE_FOREACH (Nurb *, nu, nurbs) { + LISTBASE_FOREACH (const Nurb *, nu, nurbs) { if (nu->hide && is_editmode) { continue; } @@ -5078,6 +5087,15 @@ ListBase *BKE_curve_nurbs_get(Curve *cu) return &cu->nurb; } +const ListBase *BKE_curve_nurbs_get_for_read(const Curve *cu) +{ + if (cu->editnurb) { + return BKE_curve_editNurbs_get_for_read(cu); + } + + return &cu->nurb; +} + void BKE_curve_nurb_active_set(Curve *cu, const Nurb *nu) { if (nu == NULL) { |