26 curves.tag_topology_changed();
32 curves.update_curve_types();
33 curves.tag_topology_changed();
39 curves.tag_positions_changed();
45 curves.tag_radii_changed();
51 curves.tag_normals_changed();
57 curves.tag_material_index_changed();
87 return curves.points_num();
89 return curves.curves_num();
97 const int vertex_group_index)
113 if (vertex_group_index < 0) {
127 if (vertex_group_index < 0) {
143 for (
const auto [group_index, group] :
curves->vertex_group_names.enumerate()) {
144 const auto get_fn = [&, group_index = group_index]() {
160 static auto attributes = []() {
168 map.
add_new(
"radius", std::move(radius));
171 map.
add_new(
"tilt", std::move(tilt));
174 map.
add_new(
"handle_left", std::move(handle_left));
177 map.
add_new(
"handle_right", std::move(handle_right));
179 static auto handle_type_clamp = mf::build::SI1_SO<int8_t, int8_t>(
180 "Handle Type Validate",
184 mf::build::exec_presets::AllSpanOrSingle());
188 map.
add_new(
"handle_type_left", std::move(handle_type_left));
192 map.
add_new(
"handle_type_right", std::move(handle_type_right));
194 static float default_nurbs_weight = 1.0f;
197 map.
add_new(
"nurbs_weight", std::move(nurbs_weight));
199 static const auto nurbs_order_clamp = mf::build::SI1_SO<int8_t, int8_t>(
200 "NURBS Order Validate",
201 [](
int8_t value) {
return std::max<int8_t>(value, 1); },
202 mf::build::exec_presets::AllSpanOrSingle());
203 static int nurbs_order_default = 4;
207 map.
add_new(
"nurbs_order", std::move(nurbs_order));
209 static const auto normal_mode_clamp = mf::build::SI1_SO<int8_t, int8_t>(
210 "Normal Mode Validate",
214 mf::build::exec_presets::AllSpanOrSingle());
217 map.
add_new(
"normal_mode", std::move(normal_mode));
220 map.
add_new(
"custom_normal", std::move(custom_normal));
222 static const auto knots_mode_clamp = mf::build::SI1_SO<int8_t, int8_t>(
223 "Knots Mode Validate",
225 return std::clamp<int8_t>(
228 mf::build::exec_presets::AllSpanOrSingle());
231 map.
add_new(
"knots_mode", std::move(knots_mode));
233 static const auto curve_type_clamp = mf::build::SI1_SO<int8_t, int8_t>(
234 "Curve Type Validate",
238 mf::build::exec_presets::AllSpanOrSingle());
241 map.
add_new(
"curve_type", std::move(curve_type));
243 static const auto resolution_clamp = mf::build::SI1_SO<int, int>(
244 "Resolution Validate",
245 [](
int value) {
return std::max<int>(value, 1); },
246 mf::build::exec_presets::AllSpanOrSingle());
247 static int resolution_default = 12;
251 map.
add_new(
"resolution", std::move(resolution));
254 map.
add_new(
"cyclic", std::move(cyclic));
256 static const auto material_index_clamp = mf::build::SI1_SO<int, int>(
257 "Material Index Validate",
260 return std::clamp<int>(value, 0, std::numeric_limits<short>::max());
262 mf::build::exec_presets::AllSpanOrSingle());
265 map.
add_new(
"material_index", std::move(material_index));
275 "position",
"handle_left",
"handle_right",
"nurbs_weight",
"surface_uv_coordinate"};
282 fn.domain_supported = [](
const void * ,
const AttrDomain domain) {
286 fn.builtin_domain_and_type = [](
const void * ,
287 const StringRef name) -> std::optional<AttributeDomainAndType> {
298 fn.lookup_meta_data = [](
const void *owner,
StringRef name) -> std::optional<AttributeMetaData> {
325 fn.adapt_domain = [](
const void *owner,
330 return curves.adapt_domain(varray, from_domain, to_domain);
332 fn.foreach_attribute = [](
const void *owner,
338 if (!should_continue) {
344 const auto get_fn = [&]() {
348 AttributeIter iter(attr.name(), attr.domain(), attr.data_type(), get_fn);
380 fn.remove = [](
void *owner,
const StringRef name) ->
bool {
384 curves.vertex_group_names, name, [&]() { return curves.deform_verts_for_write(); }))
391 if (!info->deletable) {
395 const std::optional<AttrUpdateOnChange>
fn =
changed_tags().lookup_try(name);
396 const bool removed =
storage.remove(name);
405 fn.add = [](
void *owner,
414 if (info->domain != domain || info->type != type) {
425 if (
const std::optional<AttrUpdateOnChange>
fn =
changed_tags().lookup_try(name)) {
434 curves.attribute_storage.wrap(),
440 &
curves.vertex_group_names,
441 [&]() {
return curves.deform_verts_for_write(); });
456 if (
const std::optional<AttrUpdateOnChange>
fn =
changed_tags().lookup_try(name)) {
Low-level operations for curves.
Object is a sort of wrapper for general info.
void add_new(const Key &key, const Value &value)
constexpr bool is_empty() const
static VArray from_single(T value, const int64_t size)
std::optional< AttrStorageType > storage_type
const AttributeAccessor * accessor
std::variant< ArrayData, SingleData > DataVariant
AttrDomain domain() const
void assign_data(DataVariant &&data)
AttrType data_type() const
#define storage(slot, qualifiers)
static void tag_curve_types_changed(void *owner)
static GAttributeWriter try_get_vertex_group_for_write(void *owner, const StringRef name)
static void tag_topology_changed(void *owner)
static bool foreach_vertex_group(const void *owner, FunctionRef< void(const AttributeIter &)> fn)
static void tag_material_index_changed(void *owner)
static void tag_normals_changed(void *owner)
static const auto & changed_tags()
static void tag_radii_changed(void *owner)
static void tag_positions_changed(void *owner)
static int get_domain_size(const void *owner, const AttrDomain domain)
static const auto & builtin_attributes()
const AttributeAccessorFunctions & get_attribute_accessor_functions()
static GAttributeReader try_get_vertex_group(const void *owner, const StringRef name)
static GAttributeReader reader_for_vertex_group_index(const CurvesGeometry &curves, const Span< MDeformVert > dverts, const int vertex_group_index)
static const auto & array_storage_required()
static AttributeAccessorFunctions get_curves_accessor_functions()
GAttributeReader attribute_to_reader(const Attribute &attribute, const AttrDomain domain, const int64_t domain_size)
Set< StringRef > rename_attributes(AttributeStorage &storage, const Map< StringRef, StringRef > &name_map, const bool overwrite, const Map< StringRef, AttrBuiltinInfo > &builtin_attributes, const Set< StringRef > &array_storage_required, const FunctionRef< int(AttrDomain)> domain_size_fn, std::optional< ListBaseT< bDeformGroup > * > vertex_groups, FunctionRef< MutableSpan< MDeformVert >()> get_mutable_dverts)
GAttributeWriter attribute_to_writer(void *owner, const Map< StringRef, AttrUpdateOnChange > &changed_tags, const int64_t domain_size, Attribute &attribute)
bool try_delete_vertex_group(ListBaseT< bDeformGroup > &vertex_groups, const StringRef name, FunctionRef< MutableSpan< MDeformVert >()> get_mutable_dverts)
Attribute::DataVariant attribute_init_to_data(const bke::AttrType data_type, const int64_t domain_size, const AttributeInit &initializer, const bool require_array_data)
VMutableArray< float > varray_for_mutable_deform_verts(MutableSpan< MDeformVert > dverts, int defgroup_index)
VArray< float > varray_for_deform_verts(Span< MDeformVert > dverts, int defgroup_index)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int BKE_defgroup_name_index(const ListBaseT< bDeformGroup > *defbase, StringRef name)
@ NURBS_KNOT_MODE_ENDPOINT_BEZIER
BMesh const char void * data
@ NORMAL_MODE_MINIMUM_TWIST
AttributeValidator validator