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
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static VArray ForSingle(T value, const int64_t size)
GAttributeReader lookup(const StringRef attribute_id) const
std::optional< AttributeMetaData > lookup_meta_data(const StringRef attribute_id) const
int domain_size(const AttrDomain domain) const
bool remove(const StringRef attribute_id)
bool add(const StringRef attribute_id, const AttrDomain domain, const eCustomDataType data_type, const AttributeInit &initializer)
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)
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type pos vertex_in(1, Type::UINT, "data") .vertex_out(overlay_edit_curve_handle_iface) .geometry_layout(PrimitiveIn Frequency::GEOMETRY storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) .push_constant(Type Frequency::GEOMETRY selection[]
__int64 int64_t
Definition stdint.h:89
CurvesGeometry geometry
char selection_domain