Blender V5.3
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 "BLI_array.hh"
7
8#include "BKE_curves.hh"
9
10#include "sculpt_intern.hh"
11
13
15{
16 /* TODO: Use a generic attribute conversion utility instead of this function. */
17 bke::CurvesGeometry &curves = curves_id.geometry.wrap();
18 bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
19
20 if (const auto meta_data = attributes.lookup_meta_data(".selection")) {
21 if (meta_data->data_type == bke::AttrType::Bool) {
22 const VArray<float> selection = *attributes.lookup<float>(".selection");
23 auto *dst = new ImplicitSharedValue<Array<float>>(selection.size());
24 selection.materialize(dst->data);
25
26 attributes.remove(".selection");
27 attributes.add(".selection",
28 meta_data->domain,
30 bke::AttributeInitShared(dst->data.data(), *dst));
31 dst->remove_user_and_delete_if_last();
32 }
33 }
34 else {
35 attributes.add(".selection",
36 bke::AttrDomain(curves_id.selection_domain),
39 }
40
41 return curves.attributes_for_write().lookup_for_write_span<float>(".selection");
42}
43
44} // namespace blender::ed::sculpt_paint
Low-level operations for curves.
void materialize(MutableSpan< T > r_span) const
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
GAttributeReader lookup(const StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bke::SpanAttributeWriter< float > float_selection_ensure(Curves &curves_id)