59 return "value_float_vector_2d";
61 return "value_float_vector_3d";
71 return "value_int_vector_2d";
89 "value_float_vector_2d",
99 "value_float_vector_3d",
108 RNA_def_int(&srna,
"value_int", 0, INT_MIN, INT_MAX,
"Value",
"", INT_MIN, INT_MAX);
110 &srna,
"value_int_vector_2d", 2,
nullptr, INT_MIN, INT_MAX,
"Value",
"", INT_MIN, INT_MAX);
112 &srna,
"value_color", 4, color_default, -
FLT_MAX,
FLT_MAX,
"Value",
"", 0.0f, 1.0f);
220 const ID *data = (ob) ?
static_cast<const ID *
>(ob->
data) :
nullptr;
224 return AttributeAccessor::from_id(*data).has_value();
234 ID *data = (ob) ?
static_cast<ID *
>(ob->
data) :
nullptr;
264 ID *
id =
static_cast<ID *
>(ob->
data);
273 if (layer ==
nullptr) {
314 ot->
name =
"Add Attribute";
316 ot->
idname =
"GEOMETRY_OT_attribute_add";
340 "Type of element that attribute is stored on");
349 "Type of data stored in attribute");
356 ID *
id =
static_cast<ID *
>(ob->
data);
365 if (*active_index > 0) {
378 ot->
name =
"Remove Attribute";
380 ot->
idname =
"GEOMETRY_OT_attribute_remove";
393 ID *
id =
static_cast<ID *
>(ob->
data);
405 if (layer ==
nullptr) {
433 IFACE_(
"Add Color Attribute"),
449 ID *data =
static_cast<ID *
>(ob->
data);
467 ID *ob_data =
static_cast<ID *
>(ob->
data);
472 Mesh *mesh =
reinterpret_cast<Mesh *
>(ob_data);
475 const std::string name = layer->name;
496 VArray<float> src_varray = *attributes.lookup_or_default<
float>(
499 attributes.remove(name);
504 for (
const int i :
IndexRange(mesh->verts_num)) {
505 const float weight = src_weights[i];
512 if (*active_index > 0) {
539 ot->
name =
"Add Color Attribute";
541 ot->
idname =
"GEOMETRY_OT_color_attribute_add";
559 ot->
srna,
"name",
nullptr,
MAX_NAME,
"Name",
"Name of new color attribute");
567 "Type of element that attribute is stored on");
574 "Type of data stored in attribute");
576 static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
579 ot->
srna,
"color", 4,
nullptr, 0.0f,
FLT_MAX,
"Color",
"Default fill color", 0.0f, 1.0f);
587 ID *
id =
static_cast<ID *
>(ob->
data);
607 ot->
name =
"Set Render Color";
608 ot->
description =
"Set default color attribute used for rendering";
609 ot->
idname =
"GEOMETRY_OT_color_attribute_render_set";
628 ID *
id =
static_cast<ID *
>(ob->
data);
630 if (active_name.empty()) {
651 const ID *data =
static_cast<ID *
>(ob->
data);
663 ot->
name =
"Remove Color Attribute";
665 ot->
idname =
"GEOMETRY_OT_color_attribute_remove";
678 ID *
id =
static_cast<ID *
>(ob->
data);
680 if (active_name ==
nullptr) {
686 if (new_layer ==
nullptr) {
709 const ID *data =
static_cast<ID *
>(ob->
data);
721 ot->
name =
"Duplicate Color Attribute";
723 ot->
idname =
"GEOMETRY_OT_color_attribute_duplicate";
754 C, op, 300,
IFACE_(
"Convert Attribute Domain"),
IFACE_(
"Convert"));
786 ID *
id =
static_cast<ID *
>(ob->
data);
793 const std::optional<bke::AttributeMetaData> meta_data = attributes.
lookup_meta_data(name);
840 C, op, 300,
IFACE_(
"Convert Color Attribute Domain"),
IFACE_(
"Convert"));
855 ot->
name =
"Convert Color Attribute";
856 ot->
description =
"Change how the color attribute is stored";
857 ot->
idname =
"GEOMETRY_OT_color_attribute_convert";
873 "Type of element that attribute is stored on");
881 "Type of data stored in attribute");
887 ot->
name =
"Convert Attribute";
889 ot->
idname =
"GEOMETRY_OT_attribute_convert";
901 {0,
nullptr, 0,
nullptr,
nullptr},
913 "Which geometry element to move the attribute to");
930 BLI_assert(mesh->attributes().contains(name));
931 BLI_assert(mesh->runtime->edit_mesh ==
nullptr);
939 const std::string name_copy = name;
940 const GVArray varray = *attributes.lookup_or_default(name_copy, dst_domain, dst_type);
946 attributes.remove(name_copy);
const char * BKE_id_attributes_default_color_name(const struct ID *id)
const struct CustomDataLayer * BKE_id_attributes_color_find(const struct ID *id, const char *name)
void BKE_id_attributes_default_color_set(struct ID *id, const char *name)
void BKE_id_attributes_active_color_set(struct ID *id, const char *name)
struct CustomDataLayer * BKE_attribute_new(AttributeOwner &owner, const char *name, eCustomDataType type, blender::bke::AttrDomain domain, struct ReportList *reports)
const char * BKE_id_attributes_active_color_name(const struct ID *id)
struct CustomDataLayer * BKE_attribute_duplicate(AttributeOwner &owner, const char *name, struct ReportList *reports)
int * BKE_attributes_active_index_p(AttributeOwner &owner)
bool BKE_attribute_remove(AttributeOwner &owner, const char *name, struct ReportList *reports)
void BKE_attributes_active_set(AttributeOwner &owner, const char *name)
#define ATTR_DOMAIN_MASK_COLOR
#define ATTR_DOMAIN_AS_MASK(domain)
struct CustomDataLayer * BKE_attributes_active_get(AttributeOwner &owner)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Object * CTX_data_edit_object(const bContext *C)
Main * CTX_data_main(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
#define CD_TYPE_AS_MASK(_type)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
void BLI_kdtree_nd_ free(KDTree *tree)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
void DEG_id_tag_update(ID *id, unsigned int flags)
#define CD_MASK_COLOR_ALL
Read Guarded memory(de)allocation.
const EnumPropertyItem * rna_enum_attribute_domain_itemf(const AttributeOwner &owner, bool include_instances, bool *r_free)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
static AttributeOwner from_id(ID *id)
int64_t alignment() const
ColorSceneLinear4f< Alpha > decode() const
const CPPType & type() const
void materialize_to_uninitialized(void *dst) const
constexpr const char * c_str() const
void materialize(MutableSpan< T > r_span) const
std::optional< AttributeMetaData > lookup_meta_data(const StringRef attribute_id) const
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
bool ED_geometry_attribute_convert(Mesh *mesh, const char *name, const eCustomDataType dst_type, const blender::bke::AttrDomain dst_domain, ReportList *reports)
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void MEM_freeN(void *vmemh)
eCustomDataType cpp_type_to_custom_data_type(const CPPType &type)
const CPPType * custom_data_type_to_cpp_type(eCustomDataType type)
GPointer rna_property_for_attribute_type_retrieve_value(PointerRNA &ptr, const eCustomDataType type, void *buffer)
static bool geometry_attributes_poll(bContext *C)
void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
static const EnumPropertyItem * geometry_attribute_domain_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static int geometry_attribute_add_exec(bContext *C, wmOperator *op)
void GEOMETRY_OT_color_attribute_add(wmOperatorType *ot)
StringRefNull rna_property_name_for_type(const eCustomDataType type)
static int geometry_attribute_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void GEOMETRY_OT_attribute_convert(wmOperatorType *ot)
void GEOMETRY_OT_color_attribute_duplicate(wmOperatorType *ot)
static int geometry_attribute_remove_exec(bContext *C, wmOperator *op)
void GEOMETRY_OT_color_attribute_convert(wmOperatorType *ot)
static bool geometry_attributes_remove_poll(bContext *C)
static int geometry_color_attribute_convert_exec(bContext *C, wmOperator *op)
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)
static int geometry_color_attribute_add_exec(bContext *C, wmOperator *op)
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 void geometry_color_attribute_add_ui(bContext *, wmOperator *op)
static int geometry_color_attribute_duplicate_exec(bContext *C, wmOperator *op)
static int geometry_color_attribute_set_render_exec(bContext *C, wmOperator *op)
static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
PropertyRNA * rna_property_for_type(PointerRNA &ptr, const eCustomDataType type)
static int geometry_color_attribute_convert_invoke(bContext *C, wmOperator *op, const wmEvent *)
static bool geometry_color_attribute_convert_poll(bContext *C)
static int geometry_color_attribute_remove_exec(bContext *C, wmOperator *op)
static bool geometry_color_attributes_duplicate_poll(bContext *C)
void GEOMETRY_OT_color_attribute_remove(wmOperatorType *ot)
static void geometry_attribute_convert_ui(bContext *, wmOperator *op)
static int geometry_attribute_convert_invoke(bContext *C, wmOperator *op, const wmEvent *)
static int geometry_color_attribute_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Object * context_object(const bContext *C)
bool object_active_color_fill(Object &ob, const float fill_color[4], bool only_selected)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *values)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
const EnumPropertyItem rna_enum_color_attribute_domain_items[]
const EnumPropertyItem rna_enum_attribute_domain_items[]
const EnumPropertyItem rna_enum_attribute_type_items[]
const EnumPropertyItem rna_enum_color_attribute_type_items[]
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
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)
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)
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)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
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_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
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)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
char * active_color_attribute
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* ui)(bContext *C, wmOperator *op)
struct ReportList * reports
void WM_main_add_notifier(uint type, void *reference)
int 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)
int 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)