Blender V4.3
curves_sculpt_selection.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_curves.hh"
6
8
10
12{
13 /* TODO: Use a generic attribute conversion utility instead of this function. */
14 bke::CurvesGeometry &curves = curves_id.geometry.wrap();
15 bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
16
17 if (const auto meta_data = attributes.lookup_meta_data(".selection")) {
18 if (meta_data->data_type == CD_PROP_BOOL) {
19 const VArray<float> selection = *attributes.lookup<float>(".selection");
20 float *dst = static_cast<float *>(
21 MEM_malloc_arrayN(selection.size(), sizeof(float), __func__));
22 selection.materialize({dst, selection.size()});
23
24 attributes.remove(".selection");
25 attributes.add(
26 ".selection", meta_data->domain, CD_PROP_FLOAT, bke::AttributeInitMoveArray(dst));
27 }
28 }
29 else {
30 const bke::AttrDomain domain = bke::AttrDomain(curves_id.selection_domain);
31 const int64_t size = attributes.domain_size(domain);
32 attributes.add(".selection",
33 domain,
36 }
37
38 return curves.attributes_for_write().lookup_for_write_span<float>(".selection");
39}
40
41} // namespace blender::ed::sculpt_paint
Low-level operations for curves.
@ CD_PROP_FLOAT
void materialize(MutableSpan< T > r_span) const
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
Definition mallocn.cc:45
bke::SpanAttributeWriter< float > float_selection_ensure(Curves &curves_id)
__int64 int64_t
Definition stdint.h:89
CurvesGeometry geometry
char selection_domain