63 return "value_float_vector_2d";
65 return "value_float_vector_3d";
67 return "value_float_vector_4d";
78 return "value_int_vector_2d";
92 static float4 color_default(1);
96 "value_float_vector_2d",
106 "value_float_vector_3d",
116 "value_float_vector_4d",
127 &srna,
"value_int_vector_2d", 2,
nullptr, INT_MIN,
INT_MAX,
"Value",
"", INT_MIN,
INT_MAX);
129 &srna,
"value_color", 4, color_default, -
FLT_MAX,
FLT_MAX,
"Value",
"", 0.0f, 1.0f);
254 std::optional<bke::AttributeMetaData> meta_data = attributes.
lookup_meta_data(*name);
259 if (
ELEM(meta_data->data_type,
279 const ID *
data = (ob) ?
static_cast<const ID *
>(ob->
data) :
nullptr;
294 if (
GS(
id->name) != obdata_type) {
362 mesh.uv_maps_active_set(name);
365 mesh.uv_maps_default_set(name);
386 if (
layer ==
nullptr) {
459 ot->
name =
"Add Attribute";
461 ot->
idname =
"GEOMETRY_OT_attribute_add";
485 "Type of element that attribute is stored on");
494 "Type of data stored in attribute");
510 if (*active_index > 0) {
524 ot->
name =
"Remove Attribute";
525 ot->
description =
"Remove attribute from geometry";
526 ot->
idname =
"GEOMETRY_OT_attribute_remove";
556 if (
layer ==
nullptr) {
572 attributes.
add(unique_name,
600 IFACE_(
"Add Color Attribute"),
649 const bool was_active_color =
mesh && name ==
StringRef(
mesh->active_color_attribute);
650 const bool was_default_color =
mesh && name ==
StringRef(
mesh->default_color_attribute);
651 const bool was_active_uv =
mesh && name ==
mesh->active_uv_map_name();
652 const bool was_default_uv =
mesh && name ==
mesh->default_uv_map_name();
654 const std::string name_copy = name;
663 attributes.
add(name_copy,
667 sharing_info->remove_user_and_delete_if_last();
676 if (was_active_color) {
679 if (was_default_color) {
685 mesh->uv_maps_active_set(name_copy);
687 if (was_default_uv) {
688 mesh->uv_maps_default_set(name_copy);
731 const float weight = src_weights[i];
739 if (*active_index > 0) {
776 ot->
name =
"Add Color Attribute";
777 ot->
description =
"Add color attribute to geometry";
778 ot->
idname =
"GEOMETRY_OT_color_attribute_add";
796 ot->
srna,
"name",
nullptr,
MAX_NAME,
"Name",
"Name of new color attribute");
804 "Type of element that attribute is stored on");
811 "Type of data stored in attribute");
813 static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
816 ot->
srna,
"color", 4,
nullptr, 0.0f,
FLT_MAX,
"Color",
"Default fill color", 0.0f, 1.0f);
857 ot->
name =
"Set Render Color";
858 ot->
description =
"Set default color attribute used for rendering";
859 ot->
idname =
"GEOMETRY_OT_color_attribute_render_set";
880 if (active_name.empty()) {
913 ot->
name =
"Remove Color Attribute";
914 ot->
description =
"Remove color attribute from geometry";
915 ot->
idname =
"GEOMETRY_OT_color_attribute_remove";
977 ot->
name =
"Duplicate Color Attribute";
979 ot->
idname =
"GEOMETRY_OT_color_attribute_duplicate";
1010 C, op, 300,
IFACE_(
"Convert Attribute Domain"),
IFACE_(
"Convert"));
1039 {0,
nullptr, 0,
nullptr,
nullptr},
1052 if (ob ==
nullptr) {
1090 const char *name =
mesh->active_color_attribute;
1106 mesh->attributes_for_write(),
1107 mesh->active_color_attribute,
1122 const char *name =
mesh->active_color_attribute;
1135 C, op, 300,
IFACE_(
"Convert Color Attribute Domain"),
IFACE_(
"Convert"));
1150 ot->
name =
"Convert Color Attribute";
1151 ot->
description =
"Change how the color attribute is stored";
1152 ot->
idname =
"GEOMETRY_OT_color_attribute_convert";
1168 "Type of element that attribute is stored on");
1176 "Type of data stored in attribute");
1182 ot->
name =
"Convert Attribute";
1183 ot->
description =
"Change how the attribute is stored";
1184 ot->
idname =
"GEOMETRY_OT_attribute_convert";
1208 "Which geometry element to move the attribute to");
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
bke::AttributeStorage * get_storage() const
std::optional< bke::MutableAttributeAccessor > get_accessor() const
static AttributeOwner from_id(ID *id)
AttributeOwnerType type() const
const void * data() const
const CPPType * type() const
const CPPType & type() const
void materialize_to_uninitialized(void *dst) const
constexpr IndexRange()=default
constexpr const char * c_str() const
void materialize(MutableSpan< T > r_span) const
bool contains(const Key &key) const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
bool contains(StringRef name) const
static std::optional< AttributeAccessor > from_id(const ID &id)
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
bool domain_supported(const AttrDomain domain) const
GAttributeReader lookup(const StringRef name) const
int domain_size(const AttrDomain domain) const
Attribute & add(std::string name, bke::AttrDomain domain, bke::AttrType data_type, Attribute::DataVariant data)
StringRefNull name() const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bool is_uv_map(const AttributeMetaData &meta_data)
bool is_color_attribute(const AttributeMetaData &meta_data)
void free(Subdiv *subdiv)
std::optional< eCustomDataType > attr_type_to_custom_data_type(AttrType attr_type)
std::optional< AttrType > custom_data_type_to_attr_type(eCustomDataType data_type)
AttrType cpp_type_to_attribute_type(const CPPType &type)
const CPPType & attribute_type_to_cpp_type(AttrType type)
BLI_INLINE ColorSceneLinear4f< Alpha > decode(const ColorSceneLinearByteEncoded4b< Alpha > &color)
BLI_INLINE ColorSceneLinearByteEncoded4b< Alpha > encode(const ColorSceneLinear4f< Alpha > &color)
static bool geometry_attributes_poll_ex(bContext *C, const Object *ob)
static bool geometry_attributes_poll(bContext *C)
static void set_active_default_status_on_add(Mesh &mesh, const bke::AttrDomain domain, const bke::AttrType type, const StringRefNull name)
void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
PropertyRNA * rna_property_for_type(PointerRNA &ptr, const bke::AttrType type)
static const EnumPropertyItem * geometry_attribute_domain_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static wmOperatorStatus geometry_color_attribute_add_exec(bContext *C, wmOperator *op)
static wmOperatorStatus geometry_color_attribute_set_render_exec(bContext *C, wmOperator *op)
static EnumPropertyItem convert_attribute_mode_items[]
void GEOMETRY_OT_color_attribute_add(wmOperatorType *ot)
GPointer rna_property_for_attribute_type_retrieve_value(PointerRNA &ptr, const bke::AttrType type, void *buffer)
void GEOMETRY_OT_attribute_convert(wmOperatorType *ot)
StringRefNull rna_property_name_for_type(const bke::AttrType type)
void GEOMETRY_OT_color_attribute_duplicate(wmOperatorType *ot)
static void geometry_attribute_convert_ui(bContext *C, wmOperator *op)
void GEOMETRY_OT_color_attribute_convert(wmOperatorType *ot)
static bool geometry_attributes_with_id_type_poll_ex(bContext *C, const Object *ob, const ID_Type obdata_type)
static bool geometry_attributes_remove_poll(bContext *C)
static bool geometry_attributes_for_mesh_poll(bContext *C)
static wmOperatorStatus geometry_color_attribute_remove_exec(bContext *C, wmOperator *op)
static wmOperatorStatus geometry_color_attribute_duplicate_exec(bContext *C, wmOperator *)
static void geometry_color_attribute_convert_ui(bContext *, wmOperator *op)
void register_rna_properties_for_attribute_types(StructRNA &srna)
void GEOMETRY_OT_attribute_remove(wmOperatorType *ot)
void GEOMETRY_OT_color_attribute_render_set(wmOperatorType *ot)
void rna_property_for_attribute_type_set_value(PointerRNA &ptr, PropertyRNA &prop, const GPointer value)
bool attribute_set_poll(bContext &C, const ID &object_data)
static bool geometry_color_attributes_remove_poll(bContext *C)
static bool geometry_attribute_convert_poll(bContext *C)
static const EnumPropertyItem * geometry_attribute_convert_mode_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static void geometry_color_attribute_add_ui(bContext *, wmOperator *op)
static wmOperatorStatus geometry_color_attribute_convert_invoke(bContext *C, wmOperator *op, const wmEvent *)
static bool geometry_color_attribute_convert_poll(bContext *C)
static wmOperatorStatus geometry_color_attribute_convert_exec(bContext *C, wmOperator *op)
static wmOperatorStatus geometry_attribute_remove_exec(bContext *C, wmOperator *op)
bool convert_attribute(AttributeOwner &owner, bke::MutableAttributeAccessor attributes, const StringRef name, const bke::AttrDomain dst_domain, const bke::AttrType dst_type, ReportList *reports)
static bool geometry_color_attributes_duplicate_poll(bContext *C)
static wmOperatorStatus geometry_attribute_add_exec(bContext *C, wmOperator *op)
static wmOperatorStatus geometry_attribute_convert_invoke(bContext *C, wmOperator *op, const wmEvent *)
void GEOMETRY_OT_color_attribute_remove(wmOperatorType *ot)
static wmOperatorStatus geometry_attribute_convert_exec(bContext *C, wmOperator *op)
static wmOperatorStatus geometry_color_attribute_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus geometry_attribute_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Object * context_object(const bContext *C)
bool object_active_color_init(Object &ob, const float fill_color[4])
void WM_main_add_notifier(uint type, void *reference)
std::optional< StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
struct MDeformVert * BKE_object_defgroup_data_create(struct ID *id)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
int * BKE_attributes_active_index_p(AttributeOwner &owner)
bool BKE_attribute_remove(AttributeOwner &owner, StringRef name, struct ReportList *reports)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void BKE_attributes_active_index_validate(AttributeOwner &owner)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
std::optional< StringRef > BKE_id_attributes_default_color_name(const struct ID *id)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
std::optional< StringRef > BKE_id_attributes_active_color_name(const struct ID *id)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
const ListBaseT< bDeformGroup > * BKE_id_defgroup_list_get(const ID *id)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
void BKE_attributes_active_set(AttributeOwner &owner, StringRef name)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name)
void BKE_object_defgroup_active_index_set(Object *ob, int new_index)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
VecBase< float, 4 > float4
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
Object * CTX_data_edit_object(const bContext *C)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
const EnumPropertyItem rna_enum_attribute_type_items[]
BMDataLayerLookup BM_data_layer_lookup(const BMesh &bm, const StringRef name)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
Main * CTX_data_main(const bContext *C)
bDeformGroup * BKE_object_defgroup_new(Object *ob, StringRef name)
VecBase< int16_t, 2 > short2
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
void BKE_defvert_add_index_notest(MDeformVert *dv, int defgroup, float weight)
ID_Type GS(const char *name)
const EnumPropertyItem rna_enum_color_attribute_domain_items[]
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
std::string RNA_string_get(PointerRNA *ptr, const char *name)
VecBase< float, 3 > float3
const EnumPropertyItem * rna_enum_attribute_domain_itemf(const AttributeOwner &owner, bool include_instances, bool *r_free)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
const EnumPropertyItem rna_enum_attribute_domain_items[]
const EnumPropertyItem rna_enum_color_attribute_type_items[]
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
struct CustomDataLayer * BKE_attribute_new(Mesh &mesh, BMesh &bm, StringRef name, eCustomDataType type, bke::AttrDomain domain, struct ReportList *reports)
bool BKE_id_attributes_color_find(const struct ID *id, StringRef name)
static ArrayData from_default_value(const CPPType &type, int64_t domain_size)
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(*) ui(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports