Blender V4.5
rna_attribute.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
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "rna_internal.hh"
15
17
18#include "BKE_attribute.hh"
19
20#include "WM_types.hh"
21
23
25 {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
26 {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
27 {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
28 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with 32-bit floating-point values"},
30 "BYTE_COLOR",
31 0,
32 "Byte Color",
33 "RGBA color with 8-bit positive integer values"},
34 {CD_PROP_STRING, "STRING", 0, "String", "Text string"},
35 {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
36 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
37 {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"},
38 {CD_PROP_INT16_2D, "INT16_2D", 0, "2D 16-Bit Integer Vector", "16-bit signed integer vector"},
39 {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
40 {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
41 {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
42 {0, nullptr, 0, nullptr, nullptr},
43};
44
46 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color 32-bit floating-point values"},
48 "BYTE_COLOR",
49 0,
50 "Byte Color",
51 "RGBA color with 8-bit positive integer values"},
52 {0, nullptr, 0, nullptr, nullptr}};
53
55 {CD_AUTO_FROM_NAME, "AUTO", 0, "Auto", ""},
56 {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
57 {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
58 {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
59 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with 32-bit floating-point values"},
61 "BYTE_COLOR",
62 0,
63 "Byte Color",
64 "RGBA color with 8-bit positive integer values"},
65 {CD_PROP_STRING, "STRING", 0, "String", "Text string"},
66 {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
67 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
68 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
69 {CD_PROP_INT16_2D, "INT16_2D", 0, "2D 16-Bit Integer Vector", "16-bit signed integer vector"},
70 {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
71 {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
72 {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
73 {0, nullptr, 0, nullptr, nullptr},
74};
75
77 /* Not implement yet */
78 // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"},
79 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
80 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
81 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
82 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
83 /* Not implement yet */
84 // {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"},
85 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
86 {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"},
87 {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
88 {0, nullptr, 0, nullptr, nullptr},
89};
90
92 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
93 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
94 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
95 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
96 {0, nullptr, 0, nullptr, nullptr},
97};
98
100 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
101 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
102 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
103 {0, nullptr, 0, nullptr, nullptr},
104};
105
107 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
108 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
109 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
110 {0, nullptr, 0, nullptr, nullptr},
111};
112
114 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
115 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
116 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
117 {0, nullptr, 0, nullptr, nullptr},
118};
119
121 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
122 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
123 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
124 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
125 {0, nullptr, 0, nullptr, nullptr},
126};
127
129 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
130 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
131 {0, nullptr, 0, nullptr, nullptr},
132};
133
135 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
136 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
137 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
138 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
139 {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"},
140 {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
141 {0, nullptr, 0, nullptr, nullptr},
142};
143
145 {int(AttrDomain::Auto), "AUTO", 0, "Auto", ""},
146 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
147 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
148 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
149 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
150 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
151 {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"},
152 {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
153 {0, nullptr, 0, nullptr, nullptr},
154};
155
157 {int(AttrDomain::Point), "POINT", 0, "Vertex", ""},
158 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", ""},
159 {0, nullptr, 0, nullptr, nullptr}};
160
162 {int(AttrDomain::Point), "POINT", 0, "Control Point", ""},
163 {int(AttrDomain::Curve), "CURVE", 0, "Curve", ""},
164 {0, nullptr, 0, nullptr, nullptr}};
165
166#ifdef RNA_RUNTIME
167
168# include <fmt/format.h>
169
170# include "DNA_customdata_types.h"
172# include "DNA_mesh_types.h"
173# include "DNA_meshdata_types.h"
174
175# include "BLI_string.h"
176
177# include "BKE_customdata.hh"
178
179# include "DEG_depsgraph.hh"
180
181# include "BLT_translation.hh"
182
183# include "WM_api.hh"
184
186
187/* Attribute */
188
189static AttributeOwner owner_from_attribute_pointer_rna(PointerRNA *ptr)
190{
191 ID *owner_id = ptr->owner_id;
192 const CustomDataLayer *layer = static_cast<const CustomDataLayer *>(ptr->data);
193 /* TODO: Because we don't know the path to the `ptr`, we need to look though all possible
194 * candidates and search for the `layer` currently. This should be just a simple lookup. */
195 if (GS(owner_id->name) == ID_GP) {
196 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(owner_id);
197 /* First check the layer attributes. */
198 CustomData *layers_data = &grease_pencil->layers_data;
199 for (int i = 0; i < layers_data->totlayer; i++) {
200 if (&layers_data->layers[i] == layer) {
202 }
203 }
204 /* Now check all the drawings. */
205 for (GreasePencilDrawingBase *base : grease_pencil->drawings()) {
206 if (base->type == GP_DRAWING) {
207 GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(base);
208 CustomData *curve_data = &drawing->geometry.curve_data;
209 for (int i = 0; i < curve_data->totlayer; i++) {
210 if (&curve_data->layers[i] == layer) {
212 }
213 }
214 CustomData *point_data = &drawing->geometry.point_data;
215 for (int i = 0; i < point_data->totlayer; i++) {
216 if (&point_data->layers[i] == layer) {
218 }
219 }
220 }
221 }
222 }
223 return AttributeOwner::from_id(owner_id);
224}
225
226static AttributeOwner owner_from_pointer_rna(PointerRNA *ptr)
227{
228 /* For non-ID attribute owners, check the `ptr->type` to derive the `AttributeOwnerType`
229 * and construct an `AttributeOwner` from that type and `ptr->data`. */
230 if (ptr->type == &RNA_GreasePencilDrawing) {
232 }
233 return AttributeOwner::from_id(ptr->owner_id);
234}
235
236static std::optional<std::string> rna_Attribute_path(const PointerRNA *ptr)
237{
238 const CustomDataLayer *layer = static_cast<const CustomDataLayer *>(ptr->data);
239 char layer_name_esc[sizeof(layer->name) * 2];
240 BLI_str_escape(layer_name_esc, layer->name, sizeof(layer_name_esc));
241 return fmt::format("attributes[\"{}\"]", layer_name_esc);
242}
243
244static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type)
245{
246 switch (type) {
247 case CD_PROP_FLOAT:
248 return &RNA_FloatAttribute;
249 case CD_PROP_INT32:
250 return &RNA_IntAttribute;
251 case CD_PROP_FLOAT3:
252 return &RNA_FloatVectorAttribute;
253 case CD_PROP_COLOR:
254 return &RNA_FloatColorAttribute;
256 return &RNA_ByteColorAttribute;
257 case CD_PROP_STRING:
258 return &RNA_StringAttribute;
259 case CD_PROP_BOOL:
260 return &RNA_BoolAttribute;
261 case CD_PROP_FLOAT2:
262 return &RNA_Float2Attribute;
263 case CD_PROP_INT8:
264 return &RNA_ByteIntAttribute;
265 case CD_PROP_INT16_2D:
266 return &RNA_Short2Attribute;
267 case CD_PROP_INT32_2D:
268 return &RNA_Int2Attribute;
270 return &RNA_QuaternionAttribute;
271 case CD_PROP_FLOAT4X4:
272 return &RNA_Float4x4Attribute;
273 default:
274 return nullptr;
275 }
276}
277
278static StructRNA *rna_Attribute_refine(PointerRNA *ptr)
279{
280 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
281 return srna_by_custom_data_layer_type(eCustomDataType(layer->type));
282}
283
284static void rna_Attribute_name_set(PointerRNA *ptr, const char *value)
285{
286 const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
287 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
288 BKE_attribute_rename(owner, layer->name, value, nullptr);
289}
290
291static int rna_Attribute_name_editable(const PointerRNA *ptr, const char **r_info)
292{
293 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
294 AttributeOwner owner = owner_from_attribute_pointer_rna(const_cast<PointerRNA *>(ptr));
295 if (BKE_attribute_required(owner, layer->name)) {
296 *r_info = N_("Cannot modify name of required geometry attribute");
297 return false;
298 }
299
300 return true;
301}
302
303static int rna_Attribute_type_get(PointerRNA *ptr)
304{
305 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
306 return layer->type;
307}
308
310 bool include_instances,
311 bool *r_free)
312{
313 EnumPropertyItem *item = nullptr;
314 const EnumPropertyItem *domain_item = nullptr;
315 int totitem = 0, a;
316
317 static EnumPropertyItem mesh_vertex_domain_item = {
318 int(AttrDomain::Point), "POINT", 0, N_("Vertex"), N_("Attribute per point/vertex")};
319
320 for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) {
321 domain_item = &rna_enum_attribute_domain_items[a];
322
323 if (owner.type() == AttributeOwnerType::PointCloud &&
324 !ELEM(domain_item->value, int(AttrDomain::Point)))
325 {
326 continue;
327 }
328 if (owner.type() == AttributeOwnerType::Curves &&
329 !ELEM(domain_item->value, int(AttrDomain::Point), int(AttrDomain::Curve)))
330 {
331 continue;
332 }
333 if (owner.type() == AttributeOwnerType::Mesh && !ELEM(domain_item->value,
334 int(AttrDomain::Point),
335 int(AttrDomain::Edge),
336 int(AttrDomain::Face),
337 int(AttrDomain::Corner)))
338 {
339 continue;
340 }
341 if (owner.type() == AttributeOwnerType::GreasePencil &&
342 !ELEM(domain_item->value, int(AttrDomain::Layer)))
343 {
344 continue;
345 }
346 if (!include_instances && domain_item->value == int(AttrDomain::Instance)) {
347 continue;
348 }
349
350 if (domain_item->value == int(AttrDomain::Point) && owner.type() == AttributeOwnerType::Mesh) {
351 RNA_enum_item_add(&item, &totitem, &mesh_vertex_domain_item);
352 }
353 else {
354 RNA_enum_item_add(&item, &totitem, domain_item);
355 }
356 }
357 RNA_enum_item_end(&item, &totitem);
358
359 *r_free = true;
360 return item;
361}
362
363static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext * /*C*/,
365 PropertyRNA * /*prop*/,
366 bool *r_free)
367{
368 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
369 return rna_enum_attribute_domain_itemf(owner, true, r_free);
370}
371
372static int rna_Attribute_domain_get(PointerRNA *ptr)
373{
374 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
375 return int(BKE_attribute_domain(owner, static_cast<const CustomDataLayer *>(ptr->data)));
376}
377
378static bool rna_Attribute_is_internal_get(PointerRNA *ptr)
379{
380 const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
382}
383
384static bool rna_Attribute_is_required_get(PointerRNA *ptr)
385{
386 const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
387 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
388 return BKE_attribute_required(owner, layer->name);
389}
390
391static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
392{
393 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
394 CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
395 if (!(CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL)) {
396 iter->valid = false;
397 }
398
399 const int length = BKE_attribute_data_length(owner, layer);
400 const size_t struct_size = CustomData_get_elem_size(layer);
402
403 rna_iterator_array_begin(iter, ptr, layer->data, struct_size, length, 0, nullptr);
404}
405
406static int rna_Attribute_data_length(PointerRNA *ptr)
407{
408 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
409 CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
410 return BKE_attribute_data_length(owner, layer);
411}
412
413static void rna_Attribute_update_data(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
414{
415 ID *id = ptr->owner_id;
416
417 /* cheating way for importers to avoid slow updates */
418 if (id->us > 0) {
419 DEG_id_tag_update(id, 0);
421 }
422}
423
424/* Color Attribute */
425
426static void rna_ByteColorAttributeValue_color_get(PointerRNA *ptr, float *values)
427{
428 MLoopCol *mlcol = (MLoopCol *)ptr->data;
429 srgb_to_linearrgb_uchar4(values, &mlcol->r);
430}
431
432static void rna_ByteColorAttributeValue_color_set(PointerRNA *ptr, const float *values)
433{
434 MLoopCol *mlcol = (MLoopCol *)ptr->data;
435 linearrgb_to_srgb_uchar4(&mlcol->r, values);
436}
437
438static void rna_ByteColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values)
439{
440 MLoopCol *col = (MLoopCol *)ptr->data;
441 values[0] = col->r / 255.0f;
442 values[1] = col->g / 255.0f;
443 values[2] = col->b / 255.0f;
444 values[3] = col->a / 255.0f;
445}
446
447static void rna_ByteColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values)
448{
449 MLoopCol *col = (MLoopCol *)ptr->data;
450 col->r = round_fl_to_uchar_clamp(values[0] * 255.0f);
451 col->g = round_fl_to_uchar_clamp(values[1] * 255.0f);
452 col->b = round_fl_to_uchar_clamp(values[2] * 255.0f);
453 col->a = round_fl_to_uchar_clamp(values[3] * 255.0f);
454}
455
456static void rna_FloatColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values)
457{
458 MPropCol *col = (MPropCol *)ptr->data;
459 linearrgb_to_srgb_v4(values, col->color);
460}
461
462static void rna_FloatColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values)
463{
464 MPropCol *col = (MPropCol *)ptr->data;
465 srgb_to_linearrgb_v4(col->color, values);
466}
467
468/* String Attribute */
469
470static void rna_StringAttributeValue_s_get(PointerRNA *ptr, char *value)
471{
472 const MStringProperty *mstring = static_cast<const MStringProperty *>(ptr->data);
473 const int len = std::min<int>(mstring->s_len, sizeof(mstring->s) - 1);
474 memcpy(value, mstring->s, len);
475 /* RNA accessors require this. */
476 value[len] = '\0';
477}
478
479static int rna_StringAttributeValue_s_length(PointerRNA *ptr)
480{
481 const MStringProperty *mstring = static_cast<const MStringProperty *>(ptr->data);
482 const int len = std::min<int>(mstring->s_len, sizeof(mstring->s) - 1);
483 return len;
484}
485
486static void rna_StringAttributeValue_s_set(PointerRNA *ptr, const char *value)
487{
488 /* NOTE: RNA does not support byte-strings which contain null bytes.
489 * If `PROP_BYTESTRING` supported this then a value & length could be passed in
490 * and `MStringProperty` could be set with values to include null bytes. */
491 MStringProperty *mstring = static_cast<MStringProperty *>(ptr->data);
492 mstring->s_len = BLI_strnlen(value, sizeof(MStringProperty::s));
493 memcpy(mstring->s, value, mstring->s_len);
494}
495
496/* Attribute Group */
497
498static PointerRNA rna_AttributeGroupID_new(
499 ID *id, ReportList *reports, const char *name, const int type, const int domain)
500{
503 owner, name, eCustomDataType(type), AttrDomain(domain), reports);
504
505 if (!layer) {
506 return PointerRNA_NULL;
507 }
508
509 if ((GS(id->name) == ID_ME) && ELEM(layer->type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) {
510 Mesh *mesh = (Mesh *)id;
511 if (!mesh->active_color_attribute) {
512 mesh->active_color_attribute = BLI_strdup(layer->name);
513 }
514 if (!mesh->default_color_attribute) {
516 }
517 }
518
521
522 PointerRNA ptr = RNA_pointer_create_discrete(id, &RNA_Attribute, layer);
523 return ptr;
524}
525
526static void rna_AttributeGroupID_remove(ID *id, ReportList *reports, PointerRNA *attribute_ptr)
527{
529 const CustomDataLayer *layer = (const CustomDataLayer *)attribute_ptr->data;
530 BKE_attribute_remove(owner, layer->name, reports);
531 attribute_ptr->invalidate();
532
535}
536
537static bool rna_Attributes_layer_skip(CollectionPropertyIterator * /*iter*/, void *data)
538{
540 return !(CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL);
541}
542
543static bool rna_Attributes_noncolor_layer_skip(CollectionPropertyIterator *iter, void *data)
544{
546
547 /* Check valid domain here, too, keep in line with rna_AttributeGroup_color_length(). */
548 PointerRNA attribute_pointer(iter->parent.owner_id, &RNA_Attribute, data);
549 const AttributeOwner owner = owner_from_attribute_pointer_rna(&attribute_pointer);
550 const AttrDomain domain = BKE_attribute_domain(owner, layer);
552 return true;
553 }
554
555 return !(CD_TYPE_AS_MASK(layer->type) & CD_MASK_COLOR_ALL) || (layer->flag & CD_FLAG_TEMPORARY);
556}
557
558/* Attributes are spread over multiple domains in separate CustomData, we use repeated
559 * array iterators to loop over all. */
560static void rna_AttributeGroup_next_domain(AttributeOwner &owner,
563 bool(skip)(CollectionPropertyIterator *iter,
564 void *data))
565{
566 do {
567 CustomDataLayer *prev_layers = (iter->internal.array.endptr == nullptr) ?
568 nullptr :
569 (CustomDataLayer *)iter->internal.array.endptr -
570 iter->internal.array.length;
571 CustomData *customdata = BKE_attributes_iterator_next_domain(owner, prev_layers);
572 if (customdata == nullptr) {
573 return;
574 }
576 iter, ptr, customdata->layers, sizeof(CustomDataLayer), customdata->totlayer, false, skip);
577 } while (!iter->valid);
578}
579
581{
582 memset(&iter->internal.array, 0, sizeof(iter->internal.array));
583 AttributeOwner owner = owner_from_pointer_rna(ptr);
584 rna_AttributeGroup_next_domain(owner, iter, ptr, rna_Attributes_layer_skip);
585}
586
588{
590
591 if (!iter->valid) {
592 AttributeOwner owner = owner_from_pointer_rna(&iter->parent);
593 rna_AttributeGroup_next_domain(owner, iter, &iter->parent, rna_Attributes_layer_skip);
594 }
595}
596
598{
599 /* Refine to the proper type. */
600 CustomDataLayer *layer = static_cast<CustomDataLayer *>(rna_iterator_array_get(iter));
601 StructRNA *type = srna_by_custom_data_layer_type(eCustomDataType(layer->type));
602 if (type == nullptr) {
603 return PointerRNA_NULL;
604 }
605 return RNA_pointer_create_with_parent(iter->parent, type, layer);
606}
607
609{
610 memset(&iter->internal.array, 0, sizeof(iter->internal.array));
611 AttributeOwner owner = owner_from_pointer_rna(ptr);
612 rna_AttributeGroup_next_domain(owner, iter, ptr, rna_Attributes_noncolor_layer_skip);
613}
614
616{
618
619 if (!iter->valid) {
620 AttributeOwner owner = owner_from_pointer_rna(&iter->parent);
621 rna_AttributeGroup_next_domain(owner, iter, &iter->parent, rna_Attributes_noncolor_layer_skip);
622 }
623}
624
626{
627 /* Refine to the proper type. */
628 CustomDataLayer *layer = static_cast<CustomDataLayer *>(rna_iterator_array_get(iter));
629 StructRNA *type = srna_by_custom_data_layer_type(eCustomDataType(layer->type));
630 if (type == nullptr) {
631 return PointerRNA_NULL;
632 }
633 return RNA_pointer_create_with_parent(iter->parent, type, layer);
634}
635
637{
638 AttributeOwner owner = owner_from_pointer_rna(ptr);
640}
641
643{
644 AttributeOwner owner = owner_from_pointer_rna(ptr);
646}
647
648bool rna_AttributeGroup_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
649{
650 AttributeOwner owner = owner_from_pointer_rna(ptr);
651
654 {
655 rna_pointer_create_with_ancestors(*ptr, &RNA_Attribute, layer, *r_ptr);
656 return true;
657 }
658
659 /* Support retrieving UV seam name convention with older name. To be removed as part of 5.0
660 * breaking changes. */
661 if (STREQ(key, ".uv_seam")) {
663 owner, "uv_seam", CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL))
664 {
665 rna_pointer_create_with_ancestors(*ptr, &RNA_Attribute, layer, *r_ptr);
666 return true;
667 }
668 }
669
670 *r_ptr = PointerRNA_NULL;
671 return false;
672}
673
674static int rna_AttributeGroupID_active_index_get(PointerRNA *ptr)
675{
676 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
677 return *BKE_attributes_active_index_p(owner);
678}
679
680static PointerRNA rna_AttributeGroupID_active_get(PointerRNA *ptr)
681{
682 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
683 const std::optional<blender::StringRef> name = BKE_attributes_active_name_get(owner);
684 if (!name) {
685 return PointerRNA_NULL;
686 }
689 return RNA_pointer_create_with_parent(*ptr, &RNA_Attribute, layer);
690}
691
692static void rna_AttributeGroupID_active_set(PointerRNA *ptr,
693 PointerRNA attribute_ptr,
694 ReportList * /*reports*/)
695{
696 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
697 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
698 if (layer) {
699 BKE_attributes_active_set(owner, layer->name);
700 }
701 else {
703 }
704}
705
706static void rna_AttributeGroupID_active_index_set(PointerRNA *ptr, int value)
707{
708 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
709 *BKE_attributes_active_index_p(owner) = std::max(-1, value);
710}
711
712static void rna_AttributeGroupID_active_index_range(
713 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
714{
715 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
716 *min = -1;
718
719 *softmin = *min;
720 *softmax = *max;
721}
722
723static void rna_AttributeGroup_update_active(Main *bmain, Scene *scene, PointerRNA *ptr)
724{
725 rna_Attribute_update_data(bmain, scene, ptr);
726}
727
728static void rna_AttributeGroup_update_active_color(Main * /*bmain*/,
729 Scene * /*scene*/,
731{
732 ID *id = ptr->owner_id;
733
734 /* Cheating way for importers to avoid slow updates. */
735 if (id->us > 0) {
736 DEG_id_tag_update(id, 0);
738 }
739}
740
741static int rna_AttributeGroupID_domain_size(ID *id, const int domain)
742{
744 return BKE_attribute_domain_size(owner, domain);
745}
746
747static PointerRNA rna_AttributeGroupMesh_active_color_get(PointerRNA *ptr)
748{
749 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
751 owner,
752 BKE_id_attributes_active_color_name(ptr->owner_id).value_or(""),
755
756 PointerRNA attribute_ptr = RNA_pointer_create_discrete(ptr->owner_id, &RNA_Attribute, layer);
757 return attribute_ptr;
758}
759
760static void rna_AttributeGroupMesh_active_color_set(PointerRNA *ptr,
761 PointerRNA attribute_ptr,
762 ReportList * /*reports*/)
763{
764 ID *id = ptr->owner_id;
765 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
766 if (layer) {
768 }
769 else {
771 }
772}
773
774static int rna_AttributeGroupMesh_active_color_index_get(PointerRNA *ptr)
775{
776 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
778 owner,
779 BKE_id_attributes_active_color_name(ptr->owner_id).value_or(""),
782
784}
785
786static void rna_AttributeGroupMesh_active_color_index_set(PointerRNA *ptr, int value)
787{
788 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
791
792 if (!layer) {
793 fprintf(stderr, "%s: error setting active color index to %d\n", __func__, value);
794 return;
795 }
796
798}
799
800static void rna_AttributeGroupMesh_active_color_index_range(
801 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
802{
803 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
804 *min = 0;
806
807 *softmin = *min;
808 *softmax = *max;
809}
810
811static int rna_AttributeGroupMesh_render_color_index_get(PointerRNA *ptr)
812{
813 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
815 ptr->owner_id, BKE_id_attributes_default_color_name(ptr->owner_id).value_or(""));
816
818}
819
820static void rna_AttributeGroupMesh_render_color_index_set(PointerRNA *ptr, int value)
821{
822 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
825
826 if (!layer) {
827 fprintf(stderr, "%s: error setting render color index to %d\n", __func__, value);
828 return;
829 }
830
832}
833
834static void rna_AttributeGroupMesh_render_color_index_range(
835 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
836{
837 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
838 *min = 0;
840
841 *softmin = *min;
842 *softmax = *max;
843}
844
845static void rna_AttributeGroupMesh_default_color_name_get(PointerRNA *ptr, char *value)
846{
847 const ID *id = ptr->owner_id;
848 const StringRef name = BKE_id_attributes_default_color_name(id).value_or("");
849 name.copy_unsafe(value);
850}
851
852static int rna_AttributeGroupMesh_default_color_name_length(PointerRNA *ptr)
853{
854 const ID *id = ptr->owner_id;
855 const StringRef name = BKE_id_attributes_default_color_name(id).value_or("");
856 return name.size();
857}
858
859static void rna_AttributeGroupMesh_default_color_name_set(PointerRNA *ptr, const char *value)
860{
861 ID *id = ptr->owner_id;
862 if (GS(id->name) == ID_ME) {
863 Mesh *mesh = (Mesh *)id;
865 if (value[0]) {
866 mesh->default_color_attribute = BLI_strdup(value);
867 }
868 }
869}
870
871static void rna_AttributeGroupMesh_active_color_name_get(PointerRNA *ptr, char *value)
872{
873 const ID *id = ptr->owner_id;
874 const StringRef name = BKE_id_attributes_active_color_name(id).value_or("");
875 name.copy_unsafe(value);
876}
877
878static int rna_AttributeGroupMesh_active_color_name_length(PointerRNA *ptr)
879{
880 const ID *id = ptr->owner_id;
881 const StringRef name = BKE_id_attributes_active_color_name(id).value_or("");
882 return name.size();
883}
884
885static void rna_AttributeGroupMesh_active_color_name_set(PointerRNA *ptr, const char *value)
886{
887 ID *id = ptr->owner_id;
888 if (GS(id->name) == ID_ME) {
889 Mesh *mesh = (Mesh *)id;
891 if (value[0]) {
892 mesh->active_color_attribute = BLI_strdup(value);
893 }
894 }
895}
896
897static PointerRNA rna_AttributeGroupGreasePencilDrawing_new(ID *grease_pencil_id,
898 GreasePencilDrawing *drawing,
900 const char *name,
901 const int type,
902 const int domain)
903{
906 owner, name, eCustomDataType(type), AttrDomain(domain), reports);
907
908 if (!layer) {
909 return PointerRNA_NULL;
910 }
911
912 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
913 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
914
915 PointerRNA ptr = RNA_pointer_create_discrete(grease_pencil_id, &RNA_Attribute, layer);
916 return ptr;
917}
918
919static void rna_AttributeGroupGreasePencilDrawing_remove(ID *grease_pencil_id,
920 GreasePencilDrawing *drawing,
922 PointerRNA *attribute_ptr)
923{
925 const CustomDataLayer *layer = (const CustomDataLayer *)attribute_ptr->data;
926 BKE_attribute_remove(owner, layer->name, reports);
927 attribute_ptr->invalidate();
928
929 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
930 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
931}
932
933static PointerRNA rna_AttributeGroupGreasePencilDrawing_active_get(PointerRNA *ptr)
934{
935 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
937 const std::optional<blender::StringRef> name = BKE_attributes_active_name_get(owner);
938 if (!name) {
939 return PointerRNA_NULL;
940 }
943 return RNA_pointer_create_discrete(ptr->owner_id, &RNA_Attribute, layer);
944}
945
946static void rna_AttributeGroupGreasePencilDrawing_active_set(PointerRNA *ptr,
947 PointerRNA attribute_ptr,
948 ReportList * /*reports*/)
949{
950 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
952 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
953 if (layer) {
954 BKE_attributes_active_set(owner, layer->name);
955 }
956 else {
958 }
959}
960
961static bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA *ptr,
962 const PointerRNA value)
963{
964 AttributeOwner owner = owner_from_attribute_pointer_rna(const_cast<PointerRNA *>(&value));
965 return owner.is_valid() && owner.type() == AttributeOwnerType::GreasePencilDrawing &&
966 owner.get_grease_pencil_drawing() == static_cast<GreasePencilDrawing *>(ptr->data);
967}
968
969static int rna_AttributeGroupGreasePencilDrawing_active_index_get(PointerRNA *ptr)
970{
971 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
973 return *BKE_attributes_active_index_p(owner);
974}
975
976static void rna_AttributeGroupGreasePencilDrawing_active_index_set(PointerRNA *ptr, int value)
977{
978 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
980 *BKE_attributes_active_index_p(owner) = std::max(-1, value);
981}
982
983static void rna_AttributeGroupGreasePencilDrawing_active_index_range(
984 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
985{
986 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
988 *min = -1;
990
991 *softmin = *min;
992 *softmax = *max;
993}
994
995static int rna_AttributeGroupGreasePencilDrawing_domain_size(GreasePencilDrawing *drawing,
996 const int domain)
997{
999 return BKE_attribute_domain_size(owner, domain);
1000}
1001
1002#else
1003
1005{
1006 StructRNA *srna;
1007 PropertyRNA *prop;
1008
1009 srna = RNA_def_struct(brna, "FloatAttribute", "Attribute");
1010 RNA_def_struct_sdna(srna, "CustomDataLayer");
1012 srna, "Float Attribute", "Geometry attribute that stores floating-point values");
1013
1014 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1015 RNA_def_property_struct_type(prop, "FloatAttributeValue");
1018 "rna_Attribute_data_begin",
1019 "rna_iterator_array_next",
1020 "rna_iterator_array_end",
1021 "rna_iterator_array_get",
1022 "rna_Attribute_data_length",
1023 nullptr,
1024 nullptr,
1025 nullptr);
1026 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1027
1028 srna = RNA_def_struct(brna, "FloatAttributeValue", nullptr);
1029 RNA_def_struct_sdna(srna, "MFloatProperty");
1031 srna, "Float Attribute Value", "Floating-point value in geometry attribute");
1032 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
1033 RNA_def_property_float_sdna(prop, nullptr, "f");
1034 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1035}
1036
1038{
1039 StructRNA *srna;
1040 PropertyRNA *prop;
1041
1042 /* Float Vector Attribute */
1043 srna = RNA_def_struct(brna, "FloatVectorAttribute", "Attribute");
1044 RNA_def_struct_sdna(srna, "CustomDataLayer");
1046 srna, "Float Vector Attribute", "Geometry attribute that stores floating-point 3D vectors");
1047
1048 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1049 RNA_def_property_struct_type(prop, "FloatVectorAttributeValue");
1052 "rna_Attribute_data_begin",
1053 "rna_iterator_array_next",
1054 "rna_iterator_array_end",
1055 "rna_iterator_array_get",
1056 "rna_Attribute_data_length",
1057 nullptr,
1058 nullptr,
1059 nullptr);
1060 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1061
1062 /* Float Vector Attribute Value */
1063 srna = RNA_def_struct(brna, "FloatVectorAttributeValue", nullptr);
1064 RNA_def_struct_sdna(srna, "vec3f");
1066 srna, "Float Vector Attribute Value", "Vector value in geometry attribute");
1067
1068 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1069 RNA_def_property_ui_text(prop, "Vector", "3D vector");
1070 RNA_def_property_float_sdna(prop, nullptr, "x");
1071 RNA_def_property_array(prop, 3);
1072 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1073}
1074
1076{
1077 StructRNA *srna;
1078 PropertyRNA *prop;
1079
1080 /* Float Color Attribute */
1081 srna = RNA_def_struct(brna, "FloatColorAttribute", "Attribute");
1082 RNA_def_struct_sdna(srna, "CustomDataLayer");
1084 "Float Color Attribute",
1085 "Geometry attribute that stores RGBA colors as floating-point values "
1086 "using 32-bits per channel");
1087
1088 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1089 RNA_def_property_struct_type(prop, "FloatColorAttributeValue");
1092 "rna_Attribute_data_begin",
1093 "rna_iterator_array_next",
1094 "rna_iterator_array_end",
1095 "rna_iterator_array_get",
1096 "rna_Attribute_data_length",
1097 nullptr,
1098 nullptr,
1099 nullptr);
1100 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1101
1102 /* Float Color Attribute Value */
1103 srna = RNA_def_struct(brna, "FloatColorAttributeValue", nullptr);
1104 RNA_def_struct_sdna(srna, "MPropCol");
1105 RNA_def_struct_ui_text(srna, "Float Color Attribute Value", "Color value in geometry attribute");
1106
1107 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1108 RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space");
1109 RNA_def_property_float_sdna(prop, nullptr, "color");
1110 RNA_def_property_array(prop, 4);
1111 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1112
1113 prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR);
1114 RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space");
1115 RNA_def_property_float_sdna(prop, nullptr, "color");
1116 RNA_def_property_array(prop, 4);
1118 "rna_FloatColorAttributeValue_color_srgb_get",
1119 "rna_FloatColorAttributeValue_color_srgb_set",
1120 nullptr);
1121 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1122}
1123
1125{
1126 StructRNA *srna;
1127 PropertyRNA *prop;
1128
1129 /* Byte Color Attribute */
1130 srna = RNA_def_struct(brna, "ByteColorAttribute", "Attribute");
1131 RNA_def_struct_sdna(srna, "CustomDataLayer");
1133 "Byte Color Attribute",
1134 "Geometry attribute that stores RGBA colors as positive integer values "
1135 "using 8-bits per channel");
1136
1137 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1138 RNA_def_property_struct_type(prop, "ByteColorAttributeValue");
1141 "rna_Attribute_data_begin",
1142 "rna_iterator_array_next",
1143 "rna_iterator_array_end",
1144 "rna_iterator_array_get",
1145 "rna_Attribute_data_length",
1146 nullptr,
1147 nullptr,
1148 nullptr);
1149 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1150
1151 /* Byte Color Attribute Value */
1152 srna = RNA_def_struct(brna, "ByteColorAttributeValue", nullptr);
1153 RNA_def_struct_sdna(srna, "MLoopCol");
1154 RNA_def_struct_ui_text(srna, "Byte Color Attribute Value", "Color value in geometry attribute");
1155
1156 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1157 RNA_def_property_array(prop, 4);
1158 RNA_def_property_range(prop, 0.0f, 1.0f);
1160 "rna_ByteColorAttributeValue_color_get",
1161 "rna_ByteColorAttributeValue_color_set",
1162 nullptr);
1163 RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space");
1164 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1165
1166 prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR);
1167 RNA_def_property_array(prop, 4);
1168 RNA_def_property_range(prop, 0.0f, 1.0f);
1170 "rna_ByteColorAttributeValue_color_srgb_get",
1171 "rna_ByteColorAttributeValue_color_srgb_set",
1172 nullptr);
1173 RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space");
1174 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1175}
1176
1178{
1179 StructRNA *srna;
1180 PropertyRNA *prop;
1181
1182 srna = RNA_def_struct(brna, "IntAttribute", "Attribute");
1183 RNA_def_struct_sdna(srna, "CustomDataLayer");
1185 srna, "Integer Attribute", "Geometry attribute that stores integer values");
1186
1187 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1188 RNA_def_property_struct_type(prop, "IntAttributeValue");
1191 "rna_Attribute_data_begin",
1192 "rna_iterator_array_next",
1193 "rna_iterator_array_end",
1194 "rna_iterator_array_get",
1195 "rna_Attribute_data_length",
1196 nullptr,
1197 nullptr,
1198 nullptr);
1199 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1200
1201 srna = RNA_def_struct(brna, "IntAttributeValue", nullptr);
1202 RNA_def_struct_sdna(srna, "MIntProperty");
1203 RNA_def_struct_ui_text(srna, "Integer Attribute Value", "Integer value in geometry attribute");
1204 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1205 RNA_def_property_int_sdna(prop, nullptr, "i");
1206 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1207}
1208
1210{
1211 StructRNA *srna;
1212 PropertyRNA *prop;
1213
1214 srna = RNA_def_struct(brna, "StringAttribute", "Attribute");
1215 RNA_def_struct_sdna(srna, "CustomDataLayer");
1216 RNA_def_struct_ui_text(srna, "String Attribute", "Geometry attribute that stores strings");
1217
1218 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1219 RNA_def_property_struct_type(prop, "StringAttributeValue");
1222 "rna_Attribute_data_begin",
1223 "rna_iterator_array_next",
1224 "rna_iterator_array_end",
1225 "rna_iterator_array_get",
1226 "rna_Attribute_data_length",
1227 nullptr,
1228 nullptr,
1229 nullptr);
1230 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1231
1232 srna = RNA_def_struct(brna, "StringAttributeValue", nullptr);
1233 RNA_def_struct_sdna(srna, "MStringProperty");
1234 RNA_def_struct_ui_text(srna, "String Attribute Value", "String value in geometry attribute");
1235 prop = RNA_def_property(srna, "value", PROP_STRING, PROP_BYTESTRING);
1236 RNA_def_property_string_sdna(prop, nullptr, "s");
1238 "rna_StringAttributeValue_s_get",
1239 "rna_StringAttributeValue_s_length",
1240 "rna_StringAttributeValue_s_set");
1241 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1242}
1243
1245{
1246 StructRNA *srna;
1247 PropertyRNA *prop;
1248
1249 srna = RNA_def_struct(brna, "BoolAttribute", "Attribute");
1250 RNA_def_struct_sdna(srna, "CustomDataLayer");
1251 RNA_def_struct_ui_text(srna, "Bool Attribute", "Geometry attribute that stores booleans");
1252
1253 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1254 RNA_def_property_struct_type(prop, "BoolAttributeValue");
1257 "rna_Attribute_data_begin",
1258 "rna_iterator_array_next",
1259 "rna_iterator_array_end",
1260 "rna_iterator_array_get",
1261 "rna_Attribute_data_length",
1262 nullptr,
1263 nullptr,
1264 nullptr);
1265 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1266
1267 srna = RNA_def_struct(brna, "BoolAttributeValue", nullptr);
1268 RNA_def_struct_sdna(srna, "MBoolProperty");
1269 RNA_def_struct_ui_text(srna, "Bool Attribute Value", "Bool value in geometry attribute");
1270 prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
1271 RNA_def_property_boolean_sdna(prop, nullptr, "b", 0);
1272}
1273
1275{
1276 StructRNA *srna;
1277 PropertyRNA *prop;
1278
1279 srna = RNA_def_struct(brna, "ByteIntAttribute", "Attribute");
1280 RNA_def_struct_sdna(srna, "CustomDataLayer");
1282 srna, "8-bit Integer Attribute", "Geometry attribute that stores 8-bit integers");
1283
1284 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1285 RNA_def_property_struct_type(prop, "ByteIntAttributeValue");
1288 "rna_Attribute_data_begin",
1289 "rna_iterator_array_next",
1290 "rna_iterator_array_end",
1291 "rna_iterator_array_get",
1292 "rna_Attribute_data_length",
1293 nullptr,
1294 nullptr,
1295 nullptr);
1296 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1297
1298 srna = RNA_def_struct(brna, "ByteIntAttributeValue", nullptr);
1299 RNA_def_struct_sdna(srna, "MInt8Property");
1301 srna, "8-bit Integer Attribute Value", "8-bit value in geometry attribute");
1302 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1303 RNA_def_property_int_sdna(prop, nullptr, "i");
1304}
1305
1307{
1308 StructRNA *srna;
1309 PropertyRNA *prop;
1310
1311 srna = RNA_def_struct(brna, "Short2Attribute", "Attribute");
1312 RNA_def_struct_sdna(srna, "CustomDataLayer");
1314 "2D 16-Bit Integer Vector Attribute",
1315 "Geometry attribute that stores 2D integer vectors");
1316
1317 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1318 RNA_def_property_struct_type(prop, "Short2AttributeValue");
1321 "rna_Attribute_data_begin",
1322 "rna_iterator_array_next",
1323 "rna_iterator_array_end",
1324 "rna_iterator_array_get",
1325 "rna_Attribute_data_length",
1326 nullptr,
1327 nullptr,
1328 nullptr);
1329 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1330
1331 srna = RNA_def_struct(brna, "Short2AttributeValue", nullptr);
1332 RNA_def_struct_sdna(srna, "vec2s");
1334 srna, "2D 16-Bit Integer Vector Attribute Value", "2D value in geometry attribute");
1335
1336 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1337 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1338 RNA_def_property_int_sdna(prop, nullptr, "x");
1339 RNA_def_property_array(prop, 2);
1340 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1341}
1342
1344{
1345 StructRNA *srna;
1346 PropertyRNA *prop;
1347
1348 srna = RNA_def_struct(brna, "Int2Attribute", "Attribute");
1349 RNA_def_struct_sdna(srna, "CustomDataLayer");
1351 srna, "2D Integer Vector Attribute", "Geometry attribute that stores 2D integer vectors");
1352
1353 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1354 RNA_def_property_struct_type(prop, "Int2AttributeValue");
1357 "rna_Attribute_data_begin",
1358 "rna_iterator_array_next",
1359 "rna_iterator_array_end",
1360 "rna_iterator_array_get",
1361 "rna_Attribute_data_length",
1362 nullptr,
1363 nullptr,
1364 nullptr);
1365 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1366
1367 srna = RNA_def_struct(brna, "Int2AttributeValue", nullptr);
1368 RNA_def_struct_sdna(srna, "vec2i");
1370 srna, "2D Integer Vector Attribute Value", "2D value in geometry attribute");
1371
1372 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1373 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1374 RNA_def_property_int_sdna(prop, nullptr, "x");
1375 RNA_def_property_array(prop, 2);
1376 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1377}
1378
1380{
1381 StructRNA *srna;
1382 PropertyRNA *prop;
1383
1384 srna = RNA_def_struct(brna, "QuaternionAttribute", "Attribute");
1385 RNA_def_struct_sdna(srna, "CustomDataLayer");
1386 RNA_def_struct_ui_text(srna, "Quaternion Attribute", "Geometry attribute that stores rotation");
1387
1388 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1389 RNA_def_property_struct_type(prop, "QuaternionAttributeValue");
1392 "rna_Attribute_data_begin",
1393 "rna_iterator_array_next",
1394 "rna_iterator_array_end",
1395 "rna_iterator_array_get",
1396 "rna_Attribute_data_length",
1397 nullptr,
1398 nullptr,
1399 nullptr);
1400 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1401
1402 srna = RNA_def_struct(brna, "QuaternionAttributeValue", nullptr);
1403 RNA_def_struct_sdna(srna, "vec4f");
1405 srna, "Quaternion Attribute Value", "Rotation value in geometry attribute");
1406
1407 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
1408 RNA_def_property_ui_text(prop, "Value", "Quaternion");
1409 RNA_def_property_float_sdna(prop, nullptr, "x");
1410 RNA_def_property_array(prop, 4);
1411 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1412}
1413
1415{
1416 StructRNA *srna;
1417 PropertyRNA *prop;
1418
1419 srna = RNA_def_struct(brna, "Float4x4Attribute", "Attribute");
1420 RNA_def_struct_sdna(srna, "CustomDataLayer");
1422 srna, "4x4 Matrix Attribute", "Geometry attribute that stores a 4 by 4 float matrix");
1423
1424 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1425 RNA_def_property_struct_type(prop, "Float4x4AttributeValue");
1428 "rna_Attribute_data_begin",
1429 "rna_iterator_array_next",
1430 "rna_iterator_array_end",
1431 "rna_iterator_array_get",
1432 "rna_Attribute_data_length",
1433 nullptr,
1434 nullptr,
1435 nullptr);
1436 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1437
1438 srna = RNA_def_struct(brna, "Float4x4AttributeValue", nullptr);
1439 RNA_def_struct_sdna(srna, "mat4x4f");
1440 RNA_def_struct_ui_text(srna, "Matrix Attribute Value", "Matrix value in geometry attribute");
1441
1442 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_MATRIX);
1443 RNA_def_property_ui_text(prop, "Value", "Matrix");
1444 RNA_def_property_float_sdna(prop, nullptr, "value");
1446 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1447}
1448
1450{
1451 StructRNA *srna;
1452 PropertyRNA *prop;
1453
1454 /* Float2 Attribute */
1455 srna = RNA_def_struct(brna, "Float2Attribute", "Attribute");
1456 RNA_def_struct_sdna(srna, "CustomDataLayer");
1458 srna, "Float2 Attribute", "Geometry attribute that stores floating-point 2D vectors");
1459
1460 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1461 RNA_def_property_struct_type(prop, "Float2AttributeValue");
1464 "rna_Attribute_data_begin",
1465 "rna_iterator_array_next",
1466 "rna_iterator_array_end",
1467 "rna_iterator_array_get",
1468 "rna_Attribute_data_length",
1469 nullptr,
1470 nullptr,
1471 nullptr);
1472 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1473
1474 /* Float2 Attribute Value */
1475 srna = RNA_def_struct(brna, "Float2AttributeValue", nullptr);
1476 RNA_def_struct_sdna(srna, "vec2f");
1477 RNA_def_struct_ui_text(srna, "Float2 Attribute Value", "2D Vector value in geometry attribute");
1478
1479 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1480 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1481 RNA_def_property_float_sdna(prop, nullptr, "x");
1482 RNA_def_property_array(prop, 2);
1483 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1484}
1485
1487{
1488 PropertyRNA *prop;
1489 StructRNA *srna;
1490
1491 srna = RNA_def_struct(brna, "Attribute", nullptr);
1492 RNA_def_struct_sdna(srna, "CustomDataLayer");
1493 RNA_def_struct_ui_text(srna, "Attribute", "Geometry attribute");
1494 RNA_def_struct_path_func(srna, "rna_Attribute_path");
1495 RNA_def_struct_refine_func(srna, "rna_Attribute_refine");
1496
1497 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1498 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Attribute_name_set");
1499 RNA_def_property_editable_func(prop, "rna_Attribute_name_editable");
1500 RNA_def_property_ui_text(prop, "Name", "Name of the Attribute");
1501 RNA_def_struct_name_property(srna, prop);
1502
1503 prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
1504 RNA_def_property_enum_sdna(prop, nullptr, "type");
1506 RNA_def_property_enum_funcs(prop, "rna_Attribute_type_get", nullptr, nullptr);
1507 RNA_def_property_ui_text(prop, "Data Type", "Type of data stored in attribute");
1509
1510 prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE);
1513 prop, "rna_Attribute_domain_get", nullptr, "rna_Attribute_domain_itemf");
1514 RNA_def_property_ui_text(prop, "Domain", "Domain of the Attribute");
1516
1517 prop = RNA_def_property(srna, "is_internal", PROP_BOOLEAN, PROP_NONE);
1518 RNA_def_property_boolean_funcs(prop, "rna_Attribute_is_internal_get", nullptr);
1520 prop, "Is Internal", "The attribute is meant for internal use by Blender");
1522
1523 prop = RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE);
1524 RNA_def_property_boolean_funcs(prop, "rna_Attribute_is_required_get", nullptr);
1525 RNA_def_property_ui_text(prop, "Is Required", "Whether the attribute can be removed or renamed");
1527
1528 /* types */
1542}
1543
1545{
1546 PropertyRNA *prop;
1547 FunctionRNA *func;
1548 PropertyRNA *parm;
1549
1550 /* API */
1551 func = RNA_def_function(srna, "new", "rna_AttributeGroupID_new");
1552 RNA_def_function_ui_description(func, "Add attribute to geometry");
1554 parm = RNA_def_string(func, "name", "Attribute", 0, "Name", "Name of geometry attribute");
1556
1557 parm = RNA_def_enum(
1558 func, "type", rna_enum_attribute_type_items, CD_PROP_FLOAT, "Type", "Attribute type");
1560
1561 parm = RNA_def_enum(func,
1562 "domain",
1564 int(AttrDomain::Point),
1565 "Domain",
1566 "Type of element that attribute is stored on");
1568
1569 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
1571 RNA_def_function_return(func, parm);
1572
1573 func = RNA_def_function(srna, "remove", "rna_AttributeGroupID_remove");
1574 RNA_def_function_ui_description(func, "Remove attribute from geometry");
1576 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "Geometry Attribute");
1579
1580 /* Active */
1581 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1582 RNA_def_property_struct_type(prop, "Attribute");
1583 RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
1585 "rna_AttributeGroupID_active_get",
1586 "rna_AttributeGroupID_active_set",
1587 nullptr,
1588 nullptr);
1590 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1591
1592 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
1594 prop, "Active Attribute Index", "Active attribute index or -1 when none are active");
1595 RNA_def_property_range(prop, -1, INT_MAX);
1598 "rna_AttributeGroupID_active_index_get",
1599 "rna_AttributeGroupID_active_index_set",
1600 "rna_AttributeGroupID_active_index_range");
1601 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1602
1603 /* Domain Size */
1604 func = RNA_def_function(srna, "domain_size", "rna_AttributeGroupID_domain_size");
1605 RNA_def_function_ui_description(func, "Get the size of a given domain");
1606 parm = RNA_def_enum(func,
1607 "domain",
1609 int(AttrDomain::Point),
1610 "Domain",
1611 "Type of element that attribute is stored on");
1613 parm = RNA_def_int(func, "size", 0, 0, INT_MAX, "Size", "Size of the domain", 0, INT_MAX);
1614 RNA_def_function_return(func, parm);
1615}
1616
1618{
1619 StructRNA *srna;
1620 PropertyRNA *prop;
1621
1622 srna = RNA_def_struct(brna, "AttributeGroupMesh", nullptr);
1623 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1624 /* Define `AttributeGroupMesh` to be of type `ID` so we can reuse the generic ID `AttributeGroup`
1625 * functions. */
1626 RNA_def_struct_sdna(srna, "ID");
1627
1629
1630 prop = RNA_def_property(srna, "active_color", PROP_POINTER, PROP_NONE);
1631 RNA_def_property_struct_type(prop, "Attribute");
1632 RNA_def_property_ui_text(prop, "Active Color", "Active color attribute for display and editing");
1634 "rna_AttributeGroupMesh_active_color_get",
1635 "rna_AttributeGroupMesh_active_color_set",
1636 nullptr,
1637 nullptr);
1639 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
1640
1641 prop = RNA_def_property(srna, "active_color_index", PROP_INT, PROP_NONE);
1642 RNA_def_property_ui_text(prop, "Active Color Index", "Active color attribute index");
1645 "rna_AttributeGroupMesh_active_color_index_get",
1646 "rna_AttributeGroupMesh_active_color_index_set",
1647 "rna_AttributeGroupMesh_active_color_index_range");
1648 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
1649
1650 prop = RNA_def_property(srna, "render_color_index", PROP_INT, PROP_NONE);
1652 "Active Render Color Index",
1653 "The index of the color attribute used as a fallback for rendering");
1656 "rna_AttributeGroupMesh_render_color_index_get",
1657 "rna_AttributeGroupMesh_render_color_index_set",
1658 "rna_AttributeGroupMesh_render_color_index_range");
1659 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
1660
1661 prop = RNA_def_property(srna, "default_color_name", PROP_STRING, PROP_NONE);
1664 "rna_AttributeGroupMesh_default_color_name_get",
1665 "rna_AttributeGroupMesh_default_color_name_length",
1666 "rna_AttributeGroupMesh_default_color_name_set");
1668 prop,
1669 "Default Color Attribute",
1670 "The name of the default color attribute used as a fallback for rendering");
1671
1672 prop = RNA_def_property(srna, "active_color_name", PROP_STRING, PROP_NONE);
1675 "rna_AttributeGroupMesh_active_color_name_get",
1676 "rna_AttributeGroupMesh_active_color_name_length",
1677 "rna_AttributeGroupMesh_active_color_name_set");
1679 "Active Color Attribute",
1680 "The name of the active color attribute for display and editing");
1681}
1682
1684{
1685 StructRNA *srna;
1686
1687 srna = RNA_def_struct(brna, "AttributeGroupPointCloud", nullptr);
1688 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1689 RNA_def_struct_sdna(srna, "ID");
1690
1692}
1693
1695{
1696 StructRNA *srna;
1697
1698 srna = RNA_def_struct(brna, "AttributeGroupCurves", nullptr);
1699 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1700 RNA_def_struct_sdna(srna, "ID");
1701
1703}
1704
1706{
1707 StructRNA *srna;
1708
1709 srna = RNA_def_struct(brna, "AttributeGroupGreasePencil", nullptr);
1710 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1711 RNA_def_struct_sdna(srna, "ID");
1712
1714}
1715
1717{
1718 PropertyRNA *prop;
1719 FunctionRNA *func;
1720 PropertyRNA *parm;
1721 StructRNA *srna;
1722
1723 srna = RNA_def_struct(brna, "AttributeGroupGreasePencilDrawing", nullptr);
1724 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1725 RNA_def_struct_sdna(srna, "GreasePencilDrawing");
1726
1727 /* API */
1728 func = RNA_def_function(srna, "new", "rna_AttributeGroupGreasePencilDrawing_new");
1729 RNA_def_function_ui_description(func, "Add attribute to geometry");
1731 parm = RNA_def_string(func, "name", "Attribute", 0, "Name", "Name of geometry attribute");
1733
1734 parm = RNA_def_enum(
1735 func, "type", rna_enum_attribute_type_items, CD_PROP_FLOAT, "Type", "Attribute type");
1737
1738 parm = RNA_def_enum(func,
1739 "domain",
1741 int(AttrDomain::Point),
1742 "Domain",
1743 "Type of element that attribute is stored on");
1745
1746 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
1748 RNA_def_function_return(func, parm);
1749
1750 func = RNA_def_function(srna, "remove", "rna_AttributeGroupGreasePencilDrawing_remove");
1751 RNA_def_function_ui_description(func, "Remove attribute from geometry");
1753 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "Geometry Attribute");
1756
1757 /* Active */
1758 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1759 RNA_def_property_struct_type(prop, "Attribute");
1760 RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
1762 "rna_AttributeGroupGreasePencilDrawing_active_get",
1763 "rna_AttributeGroupGreasePencilDrawing_active_set",
1764 nullptr,
1765 "rna_AttributeGroupGreasePencilDrawing_active_poll");
1767 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1768
1769 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
1771 prop, "Active Attribute Index", "Active attribute index or -1 when none are active");
1772 RNA_def_property_range(prop, -1, INT_MAX);
1775 "rna_AttributeGroupGreasePencilDrawing_active_index_get",
1776 "rna_AttributeGroupGreasePencilDrawing_active_index_set",
1777 "rna_AttributeGroupGreasePencilDrawing_active_index_range");
1778 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1779
1780 /* Domain Size */
1781 func = RNA_def_function(
1782 srna, "domain_size", "rna_AttributeGroupGreasePencilDrawing_domain_size");
1783 RNA_def_function_ui_description(func, "Get the size of a given domain");
1784 parm = RNA_def_enum(func,
1785 "domain",
1787 int(AttrDomain::Point),
1788 "Domain",
1789 "Type of element that attribute is stored on");
1791 parm = RNA_def_int(func, "size", 0, 0, INT_MAX, "Size", "Size of the domain", 0, INT_MAX);
1792 RNA_def_function_return(func, parm);
1793}
1794
1796{
1797 PropertyRNA *prop;
1798
1799 /* Attributes */
1800 prop = RNA_def_property(srna, "attributes", PROP_COLLECTION, PROP_NONE);
1802 "rna_AttributeGroup_iterator_begin",
1803 "rna_AttributeGroup_iterator_next",
1804 "rna_iterator_array_end",
1805 "rna_AttributeGroup_iterator_get",
1806 "rna_AttributeGroup_length",
1807 nullptr,
1808 "rna_AttributeGroup_lookup_string",
1809 nullptr);
1810 RNA_def_property_struct_type(prop, "Attribute");
1811 RNA_def_property_ui_text(prop, "Attributes", "Geometry attributes");
1812 switch (type) {
1814 RNA_def_property_srna(prop, "AttributeGroupMesh");
1815 break;
1817 RNA_def_property_srna(prop, "AttributeGroupPointCloud");
1818 break;
1820 RNA_def_property_srna(prop, "AttributeGroupCurves");
1821 break;
1823 RNA_def_property_srna(prop, "AttributeGroupGreasePencil");
1824 break;
1826 RNA_def_property_srna(prop, "AttributeGroupGreasePencilDrawing");
1827 break;
1828 }
1829
1830 prop = RNA_def_property(srna, "color_attributes", PROP_COLLECTION, PROP_NONE);
1832 "rna_AttributeGroup_color_iterator_begin",
1833 "rna_AttributeGroup_color_iterator_next",
1834 "rna_iterator_array_end",
1835 "rna_AttributeGroup_color_iterator_get",
1836 "rna_AttributeGroup_color_length",
1837 nullptr,
1838 nullptr,
1839 nullptr);
1840 RNA_def_property_struct_type(prop, "Attribute");
1841 RNA_def_property_ui_text(prop, "Color Attributes", "Geometry color attributes");
1842 switch (type) {
1844 RNA_def_property_srna(prop, "AttributeGroupMesh");
1845 break;
1847 RNA_def_property_srna(prop, "AttributeGroupPointCloud");
1848 break;
1850 RNA_def_property_srna(prop, "AttributeGroupCurves");
1851 break;
1853 RNA_def_property_srna(prop, "AttributeGroupGreasePencil");
1854 break;
1856 RNA_def_property_srna(prop, "AttributeGroupGreasePencilDrawing");
1857 break;
1858 }
1859}
1860
1870#endif
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< blender::StringRef > name)
struct CustomDataLayer * BKE_attribute_new(AttributeOwner &owner, blender::StringRef name, eCustomDataType type, blender::bke::AttrDomain domain, struct ReportList *reports)
Definition attribute.cc:391
std::optional< blender::StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
Definition attribute.cc:802
int BKE_attribute_to_index(const AttributeOwner &owner, const CustomDataLayer *layer, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:932
struct CustomDataLayer * BKE_attribute_search_for_write(AttributeOwner &owner, blender::StringRef name, eCustomDataMask type, AttrDomainMask domain_mask)
Definition attribute.cc:690
blender::bke::AttrDomain BKE_attribute_domain(const AttributeOwner &owner, const struct CustomDataLayer *layer)
CustomData * BKE_attributes_iterator_next_domain(AttributeOwner &owner, struct CustomDataLayer *layers)
Definition attribute.cc:875
int BKE_attribute_domain_size(const AttributeOwner &owner, int domain)
Definition attribute.cc:751
std::optional< blender::StringRef > BKE_id_attributes_default_color_name(const struct ID *id)
CustomDataLayer * BKE_attribute_from_index(AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:899
bool BKE_attribute_remove(AttributeOwner &owner, blender::StringRef name, struct ReportList *reports)
Definition attribute.cc:523
void BKE_attributes_active_set(AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:838
@ ATTR_DOMAIN_MASK_ALL
const struct CustomDataLayer * BKE_attribute_search(const AttributeOwner &owner, blender::StringRef name, eCustomDataMask type, AttrDomainMask domain_mask)
Definition attribute.cc:657
const struct CustomDataLayer * BKE_id_attributes_color_find(const struct ID *id, blender::StringRef name)
int * BKE_attributes_active_index_p(AttributeOwner &owner)
Definition attribute.cc:853
AttributeOwnerType
void BKE_id_attributes_active_color_clear(struct ID *id)
bool BKE_attribute_required(const AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:785
int BKE_attribute_data_length(AttributeOwner &owner, struct CustomDataLayer *layer)
Definition attribute.cc:757
std::optional< blender::StringRef > BKE_id_attributes_active_color_name(const struct ID *id)
#define ATTR_DOMAIN_MASK_COLOR
#define ATTR_DOMAIN_AS_MASK(domain)
bool BKE_attribute_rename(AttributeOwner &owner, blender::StringRef old_name, blender::StringRef new_name, struct ReportList *reports)
Definition attribute.cc:267
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask)
Definition attribute.cc:711
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
Definition attribute.cc:986
void BKE_attributes_active_clear(AttributeOwner &owner)
Definition attribute.cc:848
CustomData interface, see also DNA_customdata_types.h.
void CustomData_ensure_data_is_mutable(CustomDataLayer *layer, int totelem)
size_t CustomData_get_elem_size(const CustomDataLayer *layer)
#define CD_TYPE_AS_MASK(_type)
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition string.cc:923
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define ELEM(...)
#define STREQ(a, b)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:982
@ ID_ME
@ ID_GP
@ CD_PROP_BYTE_COLOR
@ CD_PROP_FLOAT
@ CD_PROP_FLOAT3
@ CD_PROP_INT32_2D
@ CD_PROP_COLOR
@ CD_PROP_QUATERNION
@ CD_PROP_INT32
@ CD_PROP_FLOAT2
@ CD_PROP_INT16_2D
@ CD_PROP_STRING
@ CD_PROP_FLOAT4X4
@ CD_AUTO_FROM_NAME
@ CD_FLAG_TEMPORARY
const EnumPropertyItem * rna_enum_attribute_domain_itemf(const AttributeOwner &owner, bool include_instances, bool *r_free)
ParameterFlag
Definition RNA_types.hh:510
@ PARM_RNAPTR
Definition RNA_types.hh:513
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:792
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:489
PropertyFlag
Definition RNA_types.hh:286
@ PROP_THICK_WRAP
Definition RNA_types.hh:397
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_NEVER_UNLINK
Definition RNA_types.hh:358
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_NEVER_NULL
Definition RNA_types.hh:351
@ PROP_MATRIX
Definition RNA_types.hh:253
@ PROP_DIRECTION
Definition RNA_types.hh:250
@ PROP_BYTESTRING
Definition RNA_types.hh:228
@ PROP_COLOR
Definition RNA_types.hh:248
@ PROP_NONE
Definition RNA_types.hh:221
#define NC_GEOM
Definition WM_types.hh:390
#define ND_DATA
Definition WM_types.hh:506
ReportList * reports
Definition WM_types.hh:1025
BMesh const char void * data
AttributeOwnerType type() const
Definition attribute.cc:62
static AttributeOwner from_id(ID *id)
Definition attribute.cc:43
bool is_valid() const
Definition attribute.cc:67
GreasePencilDrawing * get_grease_pencil_drawing() const
Definition attribute.cc:100
void copy_unsafe(char *dst) const
constexpr int64_t size() const
uint col
float length(VecOp< float, D >) RET
#define MEM_SAFE_FREE(v)
#define CD_MASK_PROP_ALL
#define CD_MASK_COLOR_ALL
#define GS(a)
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
bool allow_procedural_attribute_access(StringRef attribute_name)
uint32_t struct_size(Span< shader::ShaderCreateInfo::PushConst > push_constants)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
const PointerRNA PointerRNA_NULL
void * rna_iterator_array_get(CollectionPropertyIterator *iter)
void rna_iterator_array_next(CollectionPropertyIterator *iter)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
static void rna_def_attribute_float4x4(BlenderRNA *brna)
static void rna_def_attribute_group_id_common(StructRNA *srna)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_items[]
static void rna_def_attribute_short2(BlenderRNA *brna)
static void rna_def_attribute_int8(BlenderRNA *brna)
const EnumPropertyItem rna_enum_color_attribute_domain_items[]
static void rna_def_attribute_bool(BlenderRNA *brna)
static void rna_def_attribute(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_domain_with_auto_items[]
static void rna_def_attribute_quaternion(BlenderRNA *brna)
static void rna_def_attribute_group_grease_pencil(BlenderRNA *brna)
static void rna_def_attribute_group_mesh(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_corner_items[]
static void rna_def_attribute_int2(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_domain_point_edge_face_curve_items[]
const EnumPropertyItem rna_enum_attribute_domain_edge_face_items[]
const EnumPropertyItem rna_enum_attribute_curves_domain_items[]
const EnumPropertyItem rna_enum_attribute_domain_point_face_curve_items[]
static void rna_def_attribute_float_vector(BlenderRNA *brna)
static void rna_def_attribute_group_grease_pencil_drawing(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_edge_items[]
static void rna_def_attribute_float_color(BlenderRNA *brna)
static void rna_def_attribute_float(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_domain_items[]
static void rna_def_attribute_int(BlenderRNA *brna)
static void rna_def_attribute_byte_color(BlenderRNA *brna)
void RNA_def_attribute(BlenderRNA *brna)
static void rna_def_attribute_float2(BlenderRNA *brna)
void rna_def_attributes_common(StructRNA *srna, const AttributeOwnerType type)
const EnumPropertyItem rna_enum_attribute_domain_without_corner_items[]
static void rna_def_attribute_group_pointcloud(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_type_items[]
static void rna_def_attribute_group_curves(BlenderRNA *brna)
const EnumPropertyItem rna_enum_attribute_type_with_auto_items[]
const EnumPropertyItem rna_enum_color_attribute_type_items[]
static void rna_def_attribute_string(BlenderRNA *brna)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
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 RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
const int rna_matrix_dimsize_4x4[]
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
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)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void rna_AttributeGroup_iterator_next(CollectionPropertyIterator *iter)
void rna_AttributeGroup_color_iterator_next(CollectionPropertyIterator *iter)
int rna_AttributeGroup_length(PointerRNA *ptr)
int rna_AttributeGroup_color_length(PointerRNA *ptr)
bool rna_AttributeGroup_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
PointerRNA rna_AttributeGroup_color_iterator_get(CollectionPropertyIterator *iter)
void rna_AttributeGroup_iterator_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
void rna_AttributeGroup_color_iterator_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
PointerRNA rna_AttributeGroup_iterator_get(CollectionPropertyIterator *iter)
#define min(a, b)
Definition sort.cc:36
union CollectionPropertyIterator::@251313231040372062304153161337117373343066046335 internal
CustomData point_data
CustomData curve_data
CustomDataLayer * layers
Definition DNA_ID.h:404
int us
Definition DNA_ID.h:425
char name[66]
Definition DNA_ID.h:415
char * default_color_attribute
char * active_color_attribute
ID * owner_id
Definition RNA_types.hh:51
void invalidate()
Definition RNA_types.hh:110
void * data
Definition RNA_types.hh:53
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251
uint len
#define N_(msgid)
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4227