Blender V4.3
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
9#include <cstdlib>
10
11#include "RNA_access.hh"
12#include "RNA_define.hh"
13#include "RNA_enum_types.hh"
14
15#include "rna_internal.hh"
16
17#include "DNA_curves_types.h"
20#include "DNA_mesh_types.h"
21#include "DNA_meshdata_types.h"
23
24#include "BLI_math_color.h"
25
26#include "BKE_attribute.hh"
27#include "BKE_customdata.hh"
28
29#include "BLT_translation.hh"
30
31#include "WM_types.hh"
32
34
36 {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
37 {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
38 {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
39 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with 32-bit floating-point values"},
41 "BYTE_COLOR",
42 0,
43 "Byte Color",
44 "RGBA color with 8-bit positive integer values"},
45 {CD_PROP_STRING, "STRING", 0, "String", "Text string"},
46 {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
47 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
48 {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"},
49 {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
50 {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
51 {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
52 {0, nullptr, 0, nullptr, nullptr},
53};
54
56 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color 32-bit floating-point values"},
58 "BYTE_COLOR",
59 0,
60 "Byte Color",
61 "RGBA color with 8-bit positive integer values"},
62 {0, nullptr, 0, nullptr, nullptr}};
63
65 {CD_AUTO_FROM_NAME, "AUTO", 0, "Auto", ""},
66 {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
67 {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
68 {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
69 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with 32-bit floating-point values"},
71 "BYTE_COLOR",
72 0,
73 "Byte Color",
74 "RGBA color with 8-bit positive integer values"},
75 {CD_PROP_STRING, "STRING", 0, "String", "Text string"},
76 {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
77 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
78 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
79 {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
80 {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
81 {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
82 {0, nullptr, 0, nullptr, nullptr},
83};
84
86 /* Not implement yet */
87 // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"},
88 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
89 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
90 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
91 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
92 /* Not implement yet */
93 // {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"},
94 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
95 {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"},
96 {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
97 {0, nullptr, 0, nullptr, nullptr},
98};
99
101 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
102 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
103 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
104 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
105 {0, nullptr, 0, nullptr, nullptr},
106};
107
109 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
110 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
111 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
112 {0, nullptr, 0, nullptr, nullptr},
113};
114
116 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
117 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
118 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
119 {0, nullptr, 0, nullptr, nullptr},
120};
121
123 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
124 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
125 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
126 {0, nullptr, 0, nullptr, nullptr},
127};
128
130 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
131 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
132 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
133 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
134 {0, nullptr, 0, nullptr, nullptr},
135};
136
138 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
139 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
140 {0, nullptr, 0, nullptr, nullptr},
141};
142
144 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
145 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
146 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
147 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
148 {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"},
149 {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
150 {0, nullptr, 0, nullptr, nullptr},
151};
152
154 {int(AttrDomain::Auto), "AUTO", 0, "Auto", ""},
155 {int(AttrDomain::Point), "POINT", 0, "Point", "Attribute on point"},
156 {int(AttrDomain::Edge), "EDGE", 0, "Edge", "Attribute on mesh edge"},
157 {int(AttrDomain::Face), "FACE", 0, "Face", "Attribute on mesh faces"},
158 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
159 {int(AttrDomain::Curve), "CURVE", 0, "Spline", "Attribute on spline"},
160 {int(AttrDomain::Instance), "INSTANCE", 0, "Instance", "Attribute on instance"},
161 {int(AttrDomain::Layer), "LAYER", 0, "Layer", "Attribute on Grease Pencil layer"},
162 {0, nullptr, 0, nullptr, nullptr},
163};
164
166 {int(AttrDomain::Point), "POINT", 0, "Vertex", ""},
167 {int(AttrDomain::Corner), "CORNER", 0, "Face Corner", ""},
168 {0, nullptr, 0, nullptr, nullptr}};
169
171 {int(AttrDomain::Point), "POINT", 0, "Control Point", ""},
172 {int(AttrDomain::Curve), "CURVE", 0, "Curve", ""},
173 {0, nullptr, 0, nullptr, nullptr}};
174
175#ifdef RNA_RUNTIME
176
177# include <fmt/format.h>
178
179# include "DEG_depsgraph.hh"
180
181# include "BLT_translation.hh"
182
183# include "WM_api.hh"
184
185/* Attribute */
186
187static AttributeOwner owner_from_attribute_pointer_rna(PointerRNA *ptr)
188{
189 ID *owner_id = ptr->owner_id;
190 const CustomDataLayer *layer = static_cast<const CustomDataLayer *>(ptr->data);
191 /* TODO: Because we don't know the path to the `ptr`, we need to look though all possible
192 * candidates and search for the `layer` currently. This should be just a simple lookup. */
193 if (GS(owner_id->name) == ID_GP) {
194 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(owner_id);
195 /* First check the layer attributes. */
196 CustomData *layers_data = &grease_pencil->layers_data;
197 for (int i = 0; i < layers_data->totlayer; i++) {
198 if (&layers_data->layers[i] == layer) {
200 }
201 }
202 /* Now check all the drawings. */
203 for (GreasePencilDrawingBase *base : grease_pencil->drawings()) {
204 if (base->type == GP_DRAWING) {
205 GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(base);
206 CustomData *curve_data = &drawing->geometry.curve_data;
207 for (int i = 0; i < curve_data->totlayer; i++) {
208 if (&curve_data->layers[i] == layer) {
210 }
211 }
212 CustomData *point_data = &drawing->geometry.point_data;
213 for (int i = 0; i < point_data->totlayer; i++) {
214 if (&point_data->layers[i] == layer) {
216 }
217 }
218 }
219 }
220 }
221 return AttributeOwner::from_id(owner_id);
222}
223
224static AttributeOwner owner_from_pointer_rna(PointerRNA *ptr)
225{
226 /* For non-ID attribute owners, check the `ptr->type` to derive the `AttributeOwnerType`
227 * and construct an `AttributeOwner` from that type and `ptr->data`. */
228 if (ptr->type == &RNA_GreasePencilDrawing) {
230 }
232}
233
234static std::optional<std::string> rna_Attribute_path(const PointerRNA *ptr)
235{
236 const CustomDataLayer *layer = static_cast<const CustomDataLayer *>(ptr->data);
237 char layer_name_esc[sizeof(layer->name) * 2];
238 BLI_str_escape(layer_name_esc, layer->name, sizeof(layer_name_esc));
239 return fmt::format("attributes[\"{}\"]", layer_name_esc);
240}
241
242static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type)
243{
244 switch (type) {
245 case CD_PROP_FLOAT:
246 return &RNA_FloatAttribute;
247 case CD_PROP_INT32:
248 return &RNA_IntAttribute;
249 case CD_PROP_FLOAT3:
250 return &RNA_FloatVectorAttribute;
251 case CD_PROP_COLOR:
252 return &RNA_FloatColorAttribute;
254 return &RNA_ByteColorAttribute;
255 case CD_PROP_STRING:
256 return &RNA_StringAttribute;
257 case CD_PROP_BOOL:
258 return &RNA_BoolAttribute;
259 case CD_PROP_FLOAT2:
260 return &RNA_Float2Attribute;
261 case CD_PROP_INT8:
262 return &RNA_ByteIntAttribute;
263 case CD_PROP_INT32_2D:
264 return &RNA_Int2Attribute;
266 return &RNA_QuaternionAttribute;
267 case CD_PROP_FLOAT4X4:
268 return &RNA_Float4x4Attribute;
269 default:
270 return nullptr;
271 }
272}
273
274static StructRNA *rna_Attribute_refine(PointerRNA *ptr)
275{
276 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
277 return srna_by_custom_data_layer_type(eCustomDataType(layer->type));
278}
279
280static void rna_Attribute_name_set(PointerRNA *ptr, const char *value)
281{
282 const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
283 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
284 BKE_attribute_rename(owner, layer->name, value, nullptr);
285}
286
287static int rna_Attribute_name_editable(const PointerRNA *ptr, const char **r_info)
288{
289 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
290 AttributeOwner owner = owner_from_attribute_pointer_rna(const_cast<PointerRNA *>(ptr));
291 if (BKE_attribute_required(owner, layer->name)) {
292 *r_info = N_("Cannot modify name of required geometry attribute");
293 return false;
294 }
295
296 return true;
297}
298
299static int rna_Attribute_type_get(PointerRNA *ptr)
300{
301 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
302 return layer->type;
303}
304
306 bool include_instances,
307 bool *r_free)
308{
309 EnumPropertyItem *item = nullptr;
310 const EnumPropertyItem *domain_item = nullptr;
311 int totitem = 0, a;
312
313 static EnumPropertyItem mesh_vertex_domain_item = {
314 int(AttrDomain::Point), "POINT", 0, N_("Vertex"), N_("Attribute per point/vertex")};
315
316 for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) {
317 domain_item = &rna_enum_attribute_domain_items[a];
318
319 if (owner.type() == AttributeOwnerType::PointCloud &&
320 !ELEM(domain_item->value, int(AttrDomain::Point)))
321 {
322 continue;
323 }
324 if (owner.type() == AttributeOwnerType::Curves &&
325 !ELEM(domain_item->value, int(AttrDomain::Point), int(AttrDomain::Curve)))
326 {
327 continue;
328 }
329 if (owner.type() == AttributeOwnerType::Mesh &&
330 ELEM(domain_item->value, int(AttrDomain::Curve)))
331 {
332 continue;
333 }
334 if (owner.type() == AttributeOwnerType::GreasePencil &&
335 !ELEM(domain_item->value, int(AttrDomain::Layer)))
336 {
337 continue;
338 }
339 if (!include_instances && domain_item->value == int(AttrDomain::Instance)) {
340 continue;
341 }
342
343 if (domain_item->value == int(AttrDomain::Point) && owner.type() == AttributeOwnerType::Mesh) {
344 RNA_enum_item_add(&item, &totitem, &mesh_vertex_domain_item);
345 }
346 else {
347 RNA_enum_item_add(&item, &totitem, domain_item);
348 }
349 }
350 RNA_enum_item_end(&item, &totitem);
351
352 *r_free = true;
353 return item;
354}
355
356static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext * /*C*/,
358 PropertyRNA * /*prop*/,
359 bool *r_free)
360{
361 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
362 return rna_enum_attribute_domain_itemf(owner, true, r_free);
363}
364
365static int rna_Attribute_domain_get(PointerRNA *ptr)
366{
367 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
368 return int(BKE_attribute_domain(owner, static_cast<const CustomDataLayer *>(ptr->data)));
369}
370
371static bool rna_Attribute_is_internal_get(PointerRNA *ptr)
372{
373 const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
375}
376
377static bool rna_Attribute_is_required_get(PointerRNA *ptr)
378{
379 const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data;
380 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
381 return BKE_attribute_required(owner, layer->name);
382}
383
384static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
385{
386 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
388 if (!(CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL)) {
389 iter->valid = false;
390 }
391
392 const int length = BKE_attribute_data_length(owner, layer);
393 const size_t struct_size = CustomData_get_elem_size(layer);
395
396 rna_iterator_array_begin(iter, layer->data, struct_size, length, 0, nullptr);
397}
398
399static int rna_Attribute_data_length(PointerRNA *ptr)
400{
401 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
403 return BKE_attribute_data_length(owner, layer);
404}
405
406static void rna_Attribute_update_data(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
407{
408 ID *id = ptr->owner_id;
409
410 /* cheating way for importers to avoid slow updates */
411 if (id->us > 0) {
412 DEG_id_tag_update(id, 0);
414 }
415}
416
417/* Color Attribute */
418
419static void rna_ByteColorAttributeValue_color_get(PointerRNA *ptr, float *values)
420{
421 MLoopCol *mlcol = (MLoopCol *)ptr->data;
422 srgb_to_linearrgb_uchar4(values, &mlcol->r);
423}
424
425static void rna_ByteColorAttributeValue_color_set(PointerRNA *ptr, const float *values)
426{
427 MLoopCol *mlcol = (MLoopCol *)ptr->data;
428 linearrgb_to_srgb_uchar4(&mlcol->r, values);
429}
430
431static void rna_ByteColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values)
432{
434 values[0] = col->r / 255.0f;
435 values[1] = col->g / 255.0f;
436 values[2] = col->b / 255.0f;
437 values[3] = col->a / 255.0f;
438}
439
440static void rna_ByteColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values)
441{
443 col->r = round_fl_to_uchar_clamp(values[0] * 255.0f);
444 col->g = round_fl_to_uchar_clamp(values[1] * 255.0f);
445 col->b = round_fl_to_uchar_clamp(values[2] * 255.0f);
446 col->a = round_fl_to_uchar_clamp(values[3] * 255.0f);
447}
448
449static void rna_FloatColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values)
450{
452 linearrgb_to_srgb_v4(values, col->color);
453}
454
455static void rna_FloatColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values)
456{
458 srgb_to_linearrgb_v4(col->color, values);
459}
460
461/* String Attribute */
462
463static void rna_StringAttributeValue_s_get(PointerRNA *ptr, char *value)
464{
465 const MStringProperty *mstring = static_cast<const MStringProperty *>(ptr->data);
466 const int len = std::min<int>(mstring->s_len, sizeof(mstring->s) - 1);
467 memcpy(value, mstring->s, len);
468 /* RNA accessors require this. */
469 value[len] = '\0';
470}
471
472static int rna_StringAttributeValue_s_length(PointerRNA *ptr)
473{
474 const MStringProperty *mstring = static_cast<const MStringProperty *>(ptr->data);
475 const int len = std::min<int>(mstring->s_len, sizeof(mstring->s) - 1);
476 return len;
477}
478
479static void rna_StringAttributeValue_s_set(PointerRNA *ptr, const char *value)
480{
481 /* NOTE: RNA does not support byte-strings which contain null bytes.
482 * If `PROP_BYTESTRING` supported this then a value & length could be passed in
483 * and `MStringProperty` could be set with values to include null bytes. */
484 MStringProperty *mstring = static_cast<MStringProperty *>(ptr->data);
485 mstring->s_len = BLI_strnlen(value, sizeof(MStringProperty::s));
486 memcpy(mstring->s, value, mstring->s_len);
487}
488
489/* Attribute Group */
490
491static PointerRNA rna_AttributeGroupID_new(
492 ID *id, ReportList *reports, const char *name, const int type, const int domain)
493{
496 owner, name, eCustomDataType(type), AttrDomain(domain), reports);
497
498 if (!layer) {
499 return PointerRNA_NULL;
500 }
501
502 if ((GS(id->name) == ID_ME) && ELEM(layer->type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) {
503 Mesh *mesh = (Mesh *)id;
504 if (!mesh->active_color_attribute) {
505 mesh->active_color_attribute = BLI_strdup(layer->name);
506 }
507 if (!mesh->default_color_attribute) {
508 mesh->default_color_attribute = BLI_strdup(layer->name);
509 }
510 }
511
514
515 PointerRNA ptr = RNA_pointer_create(id, &RNA_Attribute, layer);
516 return ptr;
517}
518
519static void rna_AttributeGroupID_remove(ID *id, ReportList *reports, PointerRNA *attribute_ptr)
520{
522 const CustomDataLayer *layer = (const CustomDataLayer *)attribute_ptr->data;
523 BKE_attribute_remove(owner, layer->name, reports);
524 RNA_POINTER_INVALIDATE(attribute_ptr);
525
528}
529
530static bool rna_Attributes_layer_skip(CollectionPropertyIterator * /*iter*/, void *data)
531{
532 CustomDataLayer *layer = (CustomDataLayer *)data;
533 return !(CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL);
534}
535
536static bool rna_Attributes_noncolor_layer_skip(CollectionPropertyIterator *iter, void *data)
537{
538 CustomDataLayer *layer = (CustomDataLayer *)data;
539
540 /* Check valid domain here, too, keep in line with rna_AttributeGroup_color_length(). */
542 const AttrDomain domain = BKE_attribute_domain(owner, layer);
544 return true;
545 }
546
547 return !(CD_TYPE_AS_MASK(layer->type) & CD_MASK_COLOR_ALL) || (layer->flag & CD_FLAG_TEMPORARY);
548}
549
550/* Attributes are spread over multiple domains in separate CustomData, we use repeated
551 * array iterators to loop over all. */
552static void rna_AttributeGroup_next_domain(AttributeOwner &owner,
554 bool(skip)(CollectionPropertyIterator *iter,
555 void *data))
556{
557 do {
558 CustomDataLayer *prev_layers = (iter->internal.array.endptr == nullptr) ?
559 nullptr :
560 (CustomDataLayer *)iter->internal.array.endptr -
561 iter->internal.array.length;
562 CustomData *customdata = BKE_attributes_iterator_next_domain(owner, prev_layers);
563 if (customdata == nullptr) {
564 return;
565 }
567 iter, customdata->layers, sizeof(CustomDataLayer), customdata->totlayer, false, skip);
568 } while (!iter->valid);
569}
570
572{
573 memset(&iter->internal.array, 0, sizeof(iter->internal.array));
574 AttributeOwner owner = owner_from_pointer_rna(ptr);
575 rna_AttributeGroup_next_domain(owner, iter, rna_Attributes_layer_skip);
576}
577
579{
581
582 if (!iter->valid) {
583 AttributeOwner owner = owner_from_pointer_rna(&iter->parent);
584 rna_AttributeGroup_next_domain(owner, iter, rna_Attributes_layer_skip);
585 }
586}
587
589{
590 /* Refine to the proper type. */
591 CustomDataLayer *layer = static_cast<CustomDataLayer *>(rna_iterator_array_get(iter));
592 StructRNA *type = srna_by_custom_data_layer_type(eCustomDataType(layer->type));
593 if (type == nullptr) {
594 return PointerRNA_NULL;
595 }
596 return rna_pointer_inherit_refine(&iter->parent, type, layer);
597}
598
600{
601 memset(&iter->internal.array, 0, sizeof(iter->internal.array));
602 AttributeOwner owner = owner_from_pointer_rna(ptr);
603 rna_AttributeGroup_next_domain(owner, iter, rna_Attributes_noncolor_layer_skip);
604}
605
607{
609
610 if (!iter->valid) {
611 AttributeOwner owner = owner_from_pointer_rna(&iter->parent);
612 rna_AttributeGroup_next_domain(owner, iter, rna_Attributes_noncolor_layer_skip);
613 }
614}
615
617{
618 /* Refine to the proper type. */
619 CustomDataLayer *layer = static_cast<CustomDataLayer *>(rna_iterator_array_get(iter));
620 StructRNA *type = srna_by_custom_data_layer_type(eCustomDataType(layer->type));
621 if (type == nullptr) {
622 return PointerRNA_NULL;
623 }
624 return rna_pointer_inherit_refine(&iter->parent, type, layer);
625}
626
628{
629 AttributeOwner owner = owner_from_pointer_rna(ptr);
631}
632
634{
635 AttributeOwner owner = owner_from_pointer_rna(ptr);
637}
638
639static int rna_AttributeGroupID_active_index_get(PointerRNA *ptr)
640{
642 return *BKE_attributes_active_index_p(owner);
643}
644
645static PointerRNA rna_AttributeGroupID_active_get(PointerRNA *ptr)
646{
649
650 PointerRNA attribute_ptr = RNA_pointer_create(ptr->owner_id, &RNA_Attribute, layer);
651 return attribute_ptr;
652}
653
654static void rna_AttributeGroupID_active_set(PointerRNA *ptr,
655 PointerRNA attribute_ptr,
656 ReportList * /*reports*/)
657{
659 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
660 if (layer) {
661 BKE_attributes_active_set(owner, layer->name);
662 }
663 else {
665 }
666}
667
668static void rna_AttributeGroupID_active_index_set(PointerRNA *ptr, int value)
669{
671 *BKE_attributes_active_index_p(owner) = std::max(-1, value);
672}
673
674static void rna_AttributeGroupID_active_index_range(
675 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
676{
678 *min = -1;
680
681 *softmin = *min;
682 *softmax = *max;
683}
684
685static void rna_AttributeGroup_update_active(Main *bmain, Scene *scene, PointerRNA *ptr)
686{
687 rna_Attribute_update_data(bmain, scene, ptr);
688}
689
690static void rna_AttributeGroup_update_active_color(Main * /*bmain*/,
691 Scene * /*scene*/,
693{
694 ID *id = ptr->owner_id;
695
696 /* Cheating way for importers to avoid slow updates. */
697 if (id->us > 0) {
698 DEG_id_tag_update(id, 0);
700 }
701}
702
703static int rna_AttributeGroupID_domain_size(ID *id, const int domain)
704{
706 return BKE_attribute_domain_size(owner, domain);
707}
708
709static PointerRNA rna_AttributeGroupMesh_active_color_get(PointerRNA *ptr)
710{
713 owner,
717
718 PointerRNA attribute_ptr = RNA_pointer_create(ptr->owner_id, &RNA_Attribute, layer);
719 return attribute_ptr;
720}
721
722static void rna_AttributeGroupMesh_active_color_set(PointerRNA *ptr,
723 PointerRNA attribute_ptr,
724 ReportList * /*reports*/)
725{
726 ID *id = ptr->owner_id;
727 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
728 if (layer) {
729 BKE_id_attributes_active_color_set(id, layer->name);
730 }
731 else {
733 }
734}
735
736static int rna_AttributeGroupMesh_active_color_index_get(PointerRNA *ptr)
737{
740 owner,
744
746}
747
748static void rna_AttributeGroupMesh_active_color_index_set(PointerRNA *ptr, int value)
749{
753
754 if (!layer) {
755 fprintf(stderr, "%s: error setting active color index to %d\n", __func__, value);
756 return;
757 }
758
760}
761
762static void rna_AttributeGroupMesh_active_color_index_range(
763 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
764{
766 *min = 0;
768
769 *softmin = *min;
770 *softmax = *max;
771}
772
773static int rna_AttributeGroupMesh_render_color_index_get(PointerRNA *ptr)
774{
778
780}
781
782static void rna_AttributeGroupMesh_render_color_index_set(PointerRNA *ptr, int value)
783{
787
788 if (!layer) {
789 fprintf(stderr, "%s: error setting render color index to %d\n", __func__, value);
790 return;
791 }
792
794}
795
796static void rna_AttributeGroupMesh_render_color_index_range(
797 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
798{
800 *min = 0;
802
803 *softmin = *min;
804 *softmax = *max;
805}
806
807static void rna_AttributeGroupMesh_default_color_name_get(PointerRNA *ptr, char *value)
808{
809 const ID *id = ptr->owner_id;
810 const char *name = BKE_id_attributes_default_color_name(id);
811 if (!name) {
812 value[0] = '\0';
813 return;
814 }
815 strcpy(value, name);
816}
817
818static int rna_AttributeGroupMesh_default_color_name_length(PointerRNA *ptr)
819{
820 const ID *id = ptr->owner_id;
821 const char *name = BKE_id_attributes_default_color_name(id);
822 return name ? strlen(name) : 0;
823}
824
825static void rna_AttributeGroupMesh_default_color_name_set(PointerRNA *ptr, const char *value)
826{
827 ID *id = ptr->owner_id;
828 if (GS(id->name) == ID_ME) {
829 Mesh *mesh = (Mesh *)id;
830 MEM_SAFE_FREE(mesh->default_color_attribute);
831 if (value[0]) {
832 mesh->default_color_attribute = BLI_strdup(value);
833 }
834 }
835}
836
837static void rna_AttributeGroupMesh_active_color_name_get(PointerRNA *ptr, char *value)
838{
839 const ID *id = ptr->owner_id;
840 const char *name = BKE_id_attributes_active_color_name(id);
841 if (!name) {
842 value[0] = '\0';
843 return;
844 }
845 strcpy(value, name);
846}
847
848static int rna_AttributeGroupMesh_active_color_name_length(PointerRNA *ptr)
849{
850 const ID *id = ptr->owner_id;
851 const char *name = BKE_id_attributes_active_color_name(id);
852 return name ? strlen(name) : 0;
853}
854
855static void rna_AttributeGroupMesh_active_color_name_set(PointerRNA *ptr, const char *value)
856{
857 ID *id = ptr->owner_id;
858 if (GS(id->name) == ID_ME) {
859 Mesh *mesh = (Mesh *)id;
860 MEM_SAFE_FREE(mesh->active_color_attribute);
861 if (value[0]) {
862 mesh->active_color_attribute = BLI_strdup(value);
863 }
864 }
865}
866
867static PointerRNA rna_AttributeGroupGreasePencilDrawing_new(ID *grease_pencil_id,
868 GreasePencilDrawing *drawing,
869 ReportList *reports,
870 const char *name,
871 const int type,
872 const int domain)
873{
876 owner, name, eCustomDataType(type), AttrDomain(domain), reports);
877
878 if (!layer) {
879 return PointerRNA_NULL;
880 }
881
882 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
883 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
884
885 PointerRNA ptr = RNA_pointer_create(grease_pencil_id, &RNA_Attribute, layer);
886 return ptr;
887}
888
889static void rna_AttributeGroupGreasePencilDrawing_remove(ID *grease_pencil_id,
890 GreasePencilDrawing *drawing,
891 ReportList *reports,
892 PointerRNA *attribute_ptr)
893{
895 const CustomDataLayer *layer = (const CustomDataLayer *)attribute_ptr->data;
896 BKE_attribute_remove(owner, layer->name, reports);
897 RNA_POINTER_INVALIDATE(attribute_ptr);
898
899 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
900 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
901}
902
903static PointerRNA rna_AttributeGroupGreasePencilDrawing_active_get(PointerRNA *ptr)
904{
905 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
908
909 PointerRNA attribute_ptr = RNA_pointer_create(ptr->owner_id, &RNA_Attribute, layer);
910 return attribute_ptr;
911}
912
913static void rna_AttributeGroupGreasePencilDrawing_active_set(PointerRNA *ptr,
914 PointerRNA attribute_ptr,
915 ReportList * /*reports*/)
916{
917 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
919 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
920 if (layer) {
921 BKE_attributes_active_set(owner, layer->name);
922 }
923 else {
925 }
926}
927
928static bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA *ptr,
929 const PointerRNA value)
930{
931 AttributeOwner owner = owner_from_attribute_pointer_rna(const_cast<PointerRNA *>(&value));
932 return owner.is_valid() && owner.type() == AttributeOwnerType::GreasePencilDrawing &&
933 owner.get_grease_pencil_drawing() == static_cast<GreasePencilDrawing *>(ptr->data);
934}
935
936static int rna_AttributeGroupGreasePencilDrawing_active_index_get(PointerRNA *ptr)
937{
938 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
940 return *BKE_attributes_active_index_p(owner);
941}
942
943static void rna_AttributeGroupGreasePencilDrawing_active_index_set(PointerRNA *ptr, int value)
944{
945 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
947 *BKE_attributes_active_index_p(owner) = std::max(-1, value);
948}
949
950static void rna_AttributeGroupGreasePencilDrawing_active_index_range(
951 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
952{
953 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
955 *min = -1;
957
958 *softmin = *min;
959 *softmax = *max;
960}
961
962static int rna_AttributeGroupGreasePencilDrawing_domain_size(GreasePencilDrawing *drawing,
963 const int domain)
964{
966 return BKE_attribute_domain_size(owner, domain);
967}
968
969#else
970
972{
973 StructRNA *srna;
974 PropertyRNA *prop;
975
976 srna = RNA_def_struct(brna, "FloatAttribute", "Attribute");
977 RNA_def_struct_sdna(srna, "CustomDataLayer");
979 srna, "Float Attribute", "Geometry attribute that stores floating-point values");
980
981 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
982 RNA_def_property_struct_type(prop, "FloatAttributeValue");
985 "rna_Attribute_data_begin",
986 "rna_iterator_array_next",
987 "rna_iterator_array_end",
988 "rna_iterator_array_get",
989 "rna_Attribute_data_length",
990 nullptr,
991 nullptr,
992 nullptr);
993 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
994
995 srna = RNA_def_struct(brna, "FloatAttributeValue", nullptr);
996 RNA_def_struct_sdna(srna, "MFloatProperty");
998 srna, "Float Attribute Value", "Floating-point value in geometry attribute");
999 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
1000 RNA_def_property_float_sdna(prop, nullptr, "f");
1001 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1002}
1003
1005{
1006 StructRNA *srna;
1007 PropertyRNA *prop;
1008
1009 /* Float Vector Attribute */
1010 srna = RNA_def_struct(brna, "FloatVectorAttribute", "Attribute");
1011 RNA_def_struct_sdna(srna, "CustomDataLayer");
1013 srna, "Float Vector Attribute", "Geometry attribute that stores floating-point 3D vectors");
1014
1015 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1016 RNA_def_property_struct_type(prop, "FloatVectorAttributeValue");
1019 "rna_Attribute_data_begin",
1020 "rna_iterator_array_next",
1021 "rna_iterator_array_end",
1022 "rna_iterator_array_get",
1023 "rna_Attribute_data_length",
1024 nullptr,
1025 nullptr,
1026 nullptr);
1027 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1028
1029 /* Float Vector Attribute Value */
1030 srna = RNA_def_struct(brna, "FloatVectorAttributeValue", nullptr);
1031 RNA_def_struct_sdna(srna, "vec3f");
1033 srna, "Float Vector Attribute Value", "Vector value in geometry attribute");
1034
1035 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1036 RNA_def_property_ui_text(prop, "Vector", "3D vector");
1037 RNA_def_property_float_sdna(prop, nullptr, "x");
1038 RNA_def_property_array(prop, 3);
1039 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1040}
1041
1043{
1044 StructRNA *srna;
1045 PropertyRNA *prop;
1046
1047 /* Float Color Attribute */
1048 srna = RNA_def_struct(brna, "FloatColorAttribute", "Attribute");
1049 RNA_def_struct_sdna(srna, "CustomDataLayer");
1051 "Float Color Attribute",
1052 "Geometry attribute that stores RGBA colors as floating-point values "
1053 "using 32-bits per channel");
1054
1055 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1056 RNA_def_property_struct_type(prop, "FloatColorAttributeValue");
1059 "rna_Attribute_data_begin",
1060 "rna_iterator_array_next",
1061 "rna_iterator_array_end",
1062 "rna_iterator_array_get",
1063 "rna_Attribute_data_length",
1064 nullptr,
1065 nullptr,
1066 nullptr);
1067 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1068
1069 /* Float Color Attribute Value */
1070 srna = RNA_def_struct(brna, "FloatColorAttributeValue", nullptr);
1071 RNA_def_struct_sdna(srna, "MPropCol");
1072 RNA_def_struct_ui_text(srna, "Float Color Attribute Value", "Color value in geometry attribute");
1073
1074 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1075 RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space");
1076 RNA_def_property_float_sdna(prop, nullptr, "color");
1077 RNA_def_property_array(prop, 4);
1078 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1079
1080 prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR);
1081 RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space");
1082 RNA_def_property_float_sdna(prop, nullptr, "color");
1083 RNA_def_property_array(prop, 4);
1085 "rna_FloatColorAttributeValue_color_srgb_get",
1086 "rna_FloatColorAttributeValue_color_srgb_set",
1087 nullptr);
1088 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1089}
1090
1092{
1093 StructRNA *srna;
1094 PropertyRNA *prop;
1095
1096 /* Byte Color Attribute */
1097 srna = RNA_def_struct(brna, "ByteColorAttribute", "Attribute");
1098 RNA_def_struct_sdna(srna, "CustomDataLayer");
1100 "Byte Color Attribute",
1101 "Geometry attribute that stores RGBA colors as positive integer values "
1102 "using 8-bits per channel");
1103
1104 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1105 RNA_def_property_struct_type(prop, "ByteColorAttributeValue");
1108 "rna_Attribute_data_begin",
1109 "rna_iterator_array_next",
1110 "rna_iterator_array_end",
1111 "rna_iterator_array_get",
1112 "rna_Attribute_data_length",
1113 nullptr,
1114 nullptr,
1115 nullptr);
1116 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1117
1118 /* Byte Color Attribute Value */
1119 srna = RNA_def_struct(brna, "ByteColorAttributeValue", nullptr);
1120 RNA_def_struct_sdna(srna, "MLoopCol");
1121 RNA_def_struct_ui_text(srna, "Byte Color Attribute Value", "Color value in geometry attribute");
1122
1123 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1124 RNA_def_property_array(prop, 4);
1125 RNA_def_property_range(prop, 0.0f, 1.0f);
1127 "rna_ByteColorAttributeValue_color_get",
1128 "rna_ByteColorAttributeValue_color_set",
1129 nullptr);
1130 RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space");
1131 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1132
1133 prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR);
1134 RNA_def_property_array(prop, 4);
1135 RNA_def_property_range(prop, 0.0f, 1.0f);
1137 "rna_ByteColorAttributeValue_color_srgb_get",
1138 "rna_ByteColorAttributeValue_color_srgb_set",
1139 nullptr);
1140 RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space");
1141 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1142}
1143
1145{
1146 StructRNA *srna;
1147 PropertyRNA *prop;
1148
1149 srna = RNA_def_struct(brna, "IntAttribute", "Attribute");
1150 RNA_def_struct_sdna(srna, "CustomDataLayer");
1152 srna, "Integer Attribute", "Geometry attribute that stores integer values");
1153
1154 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1155 RNA_def_property_struct_type(prop, "IntAttributeValue");
1158 "rna_Attribute_data_begin",
1159 "rna_iterator_array_next",
1160 "rna_iterator_array_end",
1161 "rna_iterator_array_get",
1162 "rna_Attribute_data_length",
1163 nullptr,
1164 nullptr,
1165 nullptr);
1166 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1167
1168 srna = RNA_def_struct(brna, "IntAttributeValue", nullptr);
1169 RNA_def_struct_sdna(srna, "MIntProperty");
1170 RNA_def_struct_ui_text(srna, "Integer Attribute Value", "Integer value in geometry attribute");
1171 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1172 RNA_def_property_int_sdna(prop, nullptr, "i");
1173 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1174}
1175
1177{
1178 StructRNA *srna;
1179 PropertyRNA *prop;
1180
1181 srna = RNA_def_struct(brna, "StringAttribute", "Attribute");
1182 RNA_def_struct_sdna(srna, "CustomDataLayer");
1183 RNA_def_struct_ui_text(srna, "String Attribute", "Geometry attribute that stores strings");
1184
1185 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1186 RNA_def_property_struct_type(prop, "StringAttributeValue");
1189 "rna_Attribute_data_begin",
1190 "rna_iterator_array_next",
1191 "rna_iterator_array_end",
1192 "rna_iterator_array_get",
1193 "rna_Attribute_data_length",
1194 nullptr,
1195 nullptr,
1196 nullptr);
1197 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1198
1199 srna = RNA_def_struct(brna, "StringAttributeValue", nullptr);
1200 RNA_def_struct_sdna(srna, "MStringProperty");
1201 RNA_def_struct_ui_text(srna, "String Attribute Value", "String value in geometry attribute");
1202 prop = RNA_def_property(srna, "value", PROP_STRING, PROP_BYTESTRING);
1203 RNA_def_property_string_sdna(prop, nullptr, "s");
1205 "rna_StringAttributeValue_s_get",
1206 "rna_StringAttributeValue_s_length",
1207 "rna_StringAttributeValue_s_set");
1208 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1209}
1210
1212{
1213 StructRNA *srna;
1214 PropertyRNA *prop;
1215
1216 srna = RNA_def_struct(brna, "BoolAttribute", "Attribute");
1217 RNA_def_struct_sdna(srna, "CustomDataLayer");
1218 RNA_def_struct_ui_text(srna, "Bool Attribute", "Geometry attribute that stores booleans");
1219
1220 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1221 RNA_def_property_struct_type(prop, "BoolAttributeValue");
1224 "rna_Attribute_data_begin",
1225 "rna_iterator_array_next",
1226 "rna_iterator_array_end",
1227 "rna_iterator_array_get",
1228 "rna_Attribute_data_length",
1229 nullptr,
1230 nullptr,
1231 nullptr);
1232 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1233
1234 srna = RNA_def_struct(brna, "BoolAttributeValue", nullptr);
1235 RNA_def_struct_sdna(srna, "MBoolProperty");
1236 RNA_def_struct_ui_text(srna, "Bool Attribute Value", "Bool value in geometry attribute");
1237 prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
1238 RNA_def_property_boolean_sdna(prop, nullptr, "b", 0);
1239}
1240
1242{
1243 StructRNA *srna;
1244 PropertyRNA *prop;
1245
1246 srna = RNA_def_struct(brna, "ByteIntAttribute", "Attribute");
1247 RNA_def_struct_sdna(srna, "CustomDataLayer");
1249 srna, "8-bit Integer Attribute", "Geometry attribute that stores 8-bit integers");
1250
1251 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1252 RNA_def_property_struct_type(prop, "ByteIntAttributeValue");
1255 "rna_Attribute_data_begin",
1256 "rna_iterator_array_next",
1257 "rna_iterator_array_end",
1258 "rna_iterator_array_get",
1259 "rna_Attribute_data_length",
1260 nullptr,
1261 nullptr,
1262 nullptr);
1263 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1264
1265 srna = RNA_def_struct(brna, "ByteIntAttributeValue", nullptr);
1266 RNA_def_struct_sdna(srna, "MInt8Property");
1268 srna, "8-bit Integer Attribute Value", "8-bit value in geometry attribute");
1269 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1270 RNA_def_property_int_sdna(prop, nullptr, "i");
1271}
1272
1274{
1275 StructRNA *srna;
1276 PropertyRNA *prop;
1277
1278 srna = RNA_def_struct(brna, "Int2Attribute", "Attribute");
1279 RNA_def_struct_sdna(srna, "CustomDataLayer");
1281 srna, "2D Integer Vector Attribute", "Geometry attribute that stores 2D integer vectors");
1282
1283 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1284 RNA_def_property_struct_type(prop, "Int2AttributeValue");
1287 "rna_Attribute_data_begin",
1288 "rna_iterator_array_next",
1289 "rna_iterator_array_end",
1290 "rna_iterator_array_get",
1291 "rna_Attribute_data_length",
1292 nullptr,
1293 nullptr,
1294 nullptr);
1295 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1296
1297 srna = RNA_def_struct(brna, "Int2AttributeValue", nullptr);
1298 RNA_def_struct_sdna(srna, "vec2i");
1300 srna, "2D Integer Vector Attribute Value", "2D value in geometry attribute");
1301
1302 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1303 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1304 RNA_def_property_int_sdna(prop, nullptr, "x");
1305 RNA_def_property_array(prop, 2);
1306 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1307}
1308
1310{
1311 StructRNA *srna;
1312 PropertyRNA *prop;
1313
1314 srna = RNA_def_struct(brna, "QuaternionAttribute", "Attribute");
1315 RNA_def_struct_sdna(srna, "CustomDataLayer");
1316 RNA_def_struct_ui_text(srna, "Quaternion Attribute", "Geometry attribute that stores rotation");
1317
1318 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1319 RNA_def_property_struct_type(prop, "QuaternionAttributeValue");
1322 "rna_Attribute_data_begin",
1323 "rna_iterator_array_next",
1324 "rna_iterator_array_end",
1325 "rna_iterator_array_get",
1326 "rna_Attribute_data_length",
1327 nullptr,
1328 nullptr,
1329 nullptr);
1330 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1331
1332 srna = RNA_def_struct(brna, "QuaternionAttributeValue", nullptr);
1333 RNA_def_struct_sdna(srna, "vec4f");
1335 srna, "Quaternion Attribute Value", "Rotation value in geometry attribute");
1336
1337 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
1338 RNA_def_property_ui_text(prop, "Value", "Quaternion");
1339 RNA_def_property_float_sdna(prop, nullptr, "x");
1340 RNA_def_property_array(prop, 4);
1341 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1342}
1343
1345{
1346 StructRNA *srna;
1347 PropertyRNA *prop;
1348
1349 srna = RNA_def_struct(brna, "Float4x4Attribute", "Attribute");
1350 RNA_def_struct_sdna(srna, "CustomDataLayer");
1352 srna, "4x4 Matrix Attribute", "Geometry attribute that stores a 4 by 4 float matrix");
1353
1354 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1355 RNA_def_property_struct_type(prop, "Float4x4AttributeValue");
1358 "rna_Attribute_data_begin",
1359 "rna_iterator_array_next",
1360 "rna_iterator_array_end",
1361 "rna_iterator_array_get",
1362 "rna_Attribute_data_length",
1363 nullptr,
1364 nullptr,
1365 nullptr);
1366 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1367
1368 srna = RNA_def_struct(brna, "Float4x4AttributeValue", nullptr);
1369 RNA_def_struct_sdna(srna, "mat4x4f");
1370 RNA_def_struct_ui_text(srna, "Matrix Attribute Value", "Matrix value in geometry attribute");
1371
1372 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_MATRIX);
1373 RNA_def_property_ui_text(prop, "Value", "Matrix");
1374 RNA_def_property_float_sdna(prop, nullptr, "value");
1376 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1377}
1378
1380{
1381 StructRNA *srna;
1382 PropertyRNA *prop;
1383
1384 /* Float2 Attribute */
1385 srna = RNA_def_struct(brna, "Float2Attribute", "Attribute");
1386 RNA_def_struct_sdna(srna, "CustomDataLayer");
1388 srna, "Float2 Attribute", "Geometry attribute that stores floating-point 2D vectors");
1389
1390 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1391 RNA_def_property_struct_type(prop, "Float2AttributeValue");
1394 "rna_Attribute_data_begin",
1395 "rna_iterator_array_next",
1396 "rna_iterator_array_end",
1397 "rna_iterator_array_get",
1398 "rna_Attribute_data_length",
1399 nullptr,
1400 nullptr,
1401 nullptr);
1402 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1403
1404 /* Float2 Attribute Value */
1405 srna = RNA_def_struct(brna, "Float2AttributeValue", nullptr);
1406 RNA_def_struct_sdna(srna, "vec2f");
1407 RNA_def_struct_ui_text(srna, "Float2 Attribute Value", "2D Vector value in geometry attribute");
1408
1409 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1410 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1411 RNA_def_property_float_sdna(prop, nullptr, "x");
1412 RNA_def_property_array(prop, 2);
1413 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1414}
1415
1417{
1418 PropertyRNA *prop;
1419 StructRNA *srna;
1420
1421 srna = RNA_def_struct(brna, "Attribute", nullptr);
1422 RNA_def_struct_sdna(srna, "CustomDataLayer");
1423 RNA_def_struct_ui_text(srna, "Attribute", "Geometry attribute");
1424 RNA_def_struct_path_func(srna, "rna_Attribute_path");
1425 RNA_def_struct_refine_func(srna, "rna_Attribute_refine");
1426
1427 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1428 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Attribute_name_set");
1429 RNA_def_property_editable_func(prop, "rna_Attribute_name_editable");
1430 RNA_def_property_ui_text(prop, "Name", "Name of the Attribute");
1431 RNA_def_struct_name_property(srna, prop);
1432
1433 prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
1434 RNA_def_property_enum_sdna(prop, nullptr, "type");
1436 RNA_def_property_enum_funcs(prop, "rna_Attribute_type_get", nullptr, nullptr);
1437 RNA_def_property_ui_text(prop, "Data Type", "Type of data stored in attribute");
1439
1440 prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE);
1443 prop, "rna_Attribute_domain_get", nullptr, "rna_Attribute_domain_itemf");
1444 RNA_def_property_ui_text(prop, "Domain", "Domain of the Attribute");
1446
1447 prop = RNA_def_property(srna, "is_internal", PROP_BOOLEAN, PROP_NONE);
1448 RNA_def_property_boolean_funcs(prop, "rna_Attribute_is_internal_get", nullptr);
1450 prop, "Is Internal", "The attribute is meant for internal use by Blender");
1452
1453 prop = RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE);
1454 RNA_def_property_boolean_funcs(prop, "rna_Attribute_is_required_get", nullptr);
1455 RNA_def_property_ui_text(prop, "Is Required", "Whether the attribute can be removed or renamed");
1457
1458 /* types */
1471}
1472
1474{
1475 PropertyRNA *prop;
1476 FunctionRNA *func;
1477 PropertyRNA *parm;
1478
1479 /* API */
1480 func = RNA_def_function(srna, "new", "rna_AttributeGroupID_new");
1481 RNA_def_function_ui_description(func, "Add attribute to geometry");
1483 parm = RNA_def_string(func, "name", "Attribute", 0, "Name", "Name of geometry attribute");
1485
1486 parm = RNA_def_enum(
1487 func, "type", rna_enum_attribute_type_items, CD_PROP_FLOAT, "Type", "Attribute type");
1489
1490 parm = RNA_def_enum(func,
1491 "domain",
1493 int(AttrDomain::Point),
1494 "Domain",
1495 "Type of element that attribute is stored on");
1497
1498 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
1500 RNA_def_function_return(func, parm);
1501
1502 func = RNA_def_function(srna, "remove", "rna_AttributeGroupID_remove");
1503 RNA_def_function_ui_description(func, "Remove attribute from geometry");
1505 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "Geometry Attribute");
1508
1509 /* Active */
1510 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1511 RNA_def_property_struct_type(prop, "Attribute");
1512 RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
1514 "rna_AttributeGroupID_active_get",
1515 "rna_AttributeGroupID_active_set",
1516 nullptr,
1517 nullptr);
1519 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1520
1521 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
1523 prop, "Active Attribute Index", "Active attribute index or -1 when none are active");
1524 RNA_def_property_range(prop, -1, INT_MAX);
1527 "rna_AttributeGroupID_active_index_get",
1528 "rna_AttributeGroupID_active_index_set",
1529 "rna_AttributeGroupID_active_index_range");
1530 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1531
1532 /* Domain Size */
1533 func = RNA_def_function(srna, "domain_size", "rna_AttributeGroupID_domain_size");
1534 RNA_def_function_ui_description(func, "Get the size of a given domain");
1535 parm = RNA_def_enum(func,
1536 "domain",
1538 int(AttrDomain::Point),
1539 "Domain",
1540 "Type of element that attribute is stored on");
1542 parm = RNA_def_int(func, "size", 0, 0, INT_MAX, "Size", "Size of the domain", 0, INT_MAX);
1543 RNA_def_function_return(func, parm);
1544}
1545
1547{
1548 StructRNA *srna;
1549 PropertyRNA *prop;
1550
1551 srna = RNA_def_struct(brna, "AttributeGroupMesh", nullptr);
1552 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1553 /* Define `AttributeGroupMesh` to be of type `ID` so we can reuse the generic ID `AttributeGroup`
1554 * functions. */
1555 RNA_def_struct_sdna(srna, "ID");
1556
1558
1559 prop = RNA_def_property(srna, "active_color", PROP_POINTER, PROP_NONE);
1560 RNA_def_property_struct_type(prop, "Attribute");
1561 RNA_def_property_ui_text(prop, "Active Color", "Active color attribute for display and editing");
1563 "rna_AttributeGroupMesh_active_color_get",
1564 "rna_AttributeGroupMesh_active_color_set",
1565 nullptr,
1566 nullptr);
1568 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
1569
1570 prop = RNA_def_property(srna, "active_color_index", PROP_INT, PROP_NONE);
1571 RNA_def_property_ui_text(prop, "Active Color Index", "Active color attribute index");
1574 "rna_AttributeGroupMesh_active_color_index_get",
1575 "rna_AttributeGroupMesh_active_color_index_set",
1576 "rna_AttributeGroupMesh_active_color_index_range");
1577 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
1578
1579 prop = RNA_def_property(srna, "render_color_index", PROP_INT, PROP_NONE);
1581 "Active Render Color Index",
1582 "The index of the color attribute used as a fallback for rendering");
1585 "rna_AttributeGroupMesh_render_color_index_get",
1586 "rna_AttributeGroupMesh_render_color_index_set",
1587 "rna_AttributeGroupMesh_render_color_index_range");
1588 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
1589
1590 prop = RNA_def_property(srna, "default_color_name", PROP_STRING, PROP_NONE);
1593 "rna_AttributeGroupMesh_default_color_name_get",
1594 "rna_AttributeGroupMesh_default_color_name_length",
1595 "rna_AttributeGroupMesh_default_color_name_set");
1597 prop,
1598 "Default Color Attribute",
1599 "The name of the default color attribute used as a fallback for rendering");
1600
1601 prop = RNA_def_property(srna, "active_color_name", PROP_STRING, PROP_NONE);
1604 "rna_AttributeGroupMesh_active_color_name_get",
1605 "rna_AttributeGroupMesh_active_color_name_length",
1606 "rna_AttributeGroupMesh_active_color_name_set");
1608 "Active Color Attribute",
1609 "The name of the active color attribute for display and editing");
1610}
1611
1613{
1614 StructRNA *srna;
1615
1616 srna = RNA_def_struct(brna, "AttributeGroupPointCloud", nullptr);
1617 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1618 RNA_def_struct_sdna(srna, "ID");
1619
1621}
1622
1624{
1625 StructRNA *srna;
1626
1627 srna = RNA_def_struct(brna, "AttributeGroupCurves", nullptr);
1628 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1629 RNA_def_struct_sdna(srna, "ID");
1630
1632}
1633
1635{
1636 StructRNA *srna;
1637
1638 srna = RNA_def_struct(brna, "AttributeGroupGreasePencil", nullptr);
1639 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1640 RNA_def_struct_sdna(srna, "ID");
1641
1643}
1644
1646{
1647 PropertyRNA *prop;
1648 FunctionRNA *func;
1649 PropertyRNA *parm;
1650 StructRNA *srna;
1651
1652 srna = RNA_def_struct(brna, "AttributeGroupGreasePencilDrawing", nullptr);
1653 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
1654 RNA_def_struct_sdna(srna, "GreasePencilDrawing");
1655
1656 /* API */
1657 func = RNA_def_function(srna, "new", "rna_AttributeGroupGreasePencilDrawing_new");
1658 RNA_def_function_ui_description(func, "Add attribute to geometry");
1660 parm = RNA_def_string(func, "name", "Attribute", 0, "Name", "Name of geometry attribute");
1662
1663 parm = RNA_def_enum(
1664 func, "type", rna_enum_attribute_type_items, CD_PROP_FLOAT, "Type", "Attribute type");
1666
1667 parm = RNA_def_enum(func,
1668 "domain",
1670 int(AttrDomain::Point),
1671 "Domain",
1672 "Type of element that attribute is stored on");
1674
1675 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
1677 RNA_def_function_return(func, parm);
1678
1679 func = RNA_def_function(srna, "remove", "rna_AttributeGroupGreasePencilDrawing_remove");
1680 RNA_def_function_ui_description(func, "Remove attribute from geometry");
1682 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "Geometry Attribute");
1685
1686 /* Active */
1687 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1688 RNA_def_property_struct_type(prop, "Attribute");
1689 RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
1691 "rna_AttributeGroupGreasePencilDrawing_active_get",
1692 "rna_AttributeGroupGreasePencilDrawing_active_set",
1693 nullptr,
1694 "rna_AttributeGroupGreasePencilDrawing_active_poll");
1696 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1697
1698 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
1700 prop, "Active Attribute Index", "Active attribute index or -1 when none are active");
1701 RNA_def_property_range(prop, -1, INT_MAX);
1704 "rna_AttributeGroupGreasePencilDrawing_active_index_get",
1705 "rna_AttributeGroupGreasePencilDrawing_active_index_set",
1706 "rna_AttributeGroupGreasePencilDrawing_active_index_range");
1707 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
1708
1709 /* Domain Size */
1710 func = RNA_def_function(
1711 srna, "domain_size", "rna_AttributeGroupGreasePencilDrawing_domain_size");
1712 RNA_def_function_ui_description(func, "Get the size of a given domain");
1713 parm = RNA_def_enum(func,
1714 "domain",
1716 int(AttrDomain::Point),
1717 "Domain",
1718 "Type of element that attribute is stored on");
1720 parm = RNA_def_int(func, "size", 0, 0, INT_MAX, "Size", "Size of the domain", 0, INT_MAX);
1721 RNA_def_function_return(func, parm);
1722}
1723
1725{
1726 PropertyRNA *prop;
1727
1728 /* Attributes */
1729 prop = RNA_def_property(srna, "attributes", PROP_COLLECTION, PROP_NONE);
1731 "rna_AttributeGroup_iterator_begin",
1732 "rna_AttributeGroup_iterator_next",
1733 "rna_iterator_array_end",
1734 "rna_AttributeGroup_iterator_get",
1735 "rna_AttributeGroup_length",
1736 nullptr,
1737 nullptr,
1738 nullptr);
1739 RNA_def_property_struct_type(prop, "Attribute");
1740 RNA_def_property_ui_text(prop, "Attributes", "Geometry attributes");
1741 switch (type) {
1743 RNA_def_property_srna(prop, "AttributeGroupMesh");
1744 break;
1746 RNA_def_property_srna(prop, "AttributeGroupPointCloud");
1747 break;
1749 RNA_def_property_srna(prop, "AttributeGroupCurves");
1750 break;
1752 RNA_def_property_srna(prop, "AttributeGroupGreasePencil");
1753 break;
1755 RNA_def_property_srna(prop, "AttributeGroupGreasePencilDrawing");
1756 break;
1757 }
1758
1759 prop = RNA_def_property(srna, "color_attributes", PROP_COLLECTION, PROP_NONE);
1761 "rna_AttributeGroup_color_iterator_begin",
1762 "rna_AttributeGroup_color_iterator_next",
1763 "rna_iterator_array_end",
1764 "rna_AttributeGroup_color_iterator_get",
1765 "rna_AttributeGroup_color_length",
1766 nullptr,
1767 nullptr,
1768 nullptr);
1769 RNA_def_property_struct_type(prop, "Attribute");
1770 RNA_def_property_ui_text(prop, "Color Attributes", "Geometry color attributes");
1771 switch (type) {
1773 RNA_def_property_srna(prop, "AttributeGroupMesh");
1774 break;
1776 RNA_def_property_srna(prop, "AttributeGroupPointCloud");
1777 break;
1779 RNA_def_property_srna(prop, "AttributeGroupCurves");
1780 break;
1782 RNA_def_property_srna(prop, "AttributeGroupGreasePencil");
1783 break;
1785 RNA_def_property_srna(prop, "AttributeGroupGreasePencilDrawing");
1786 break;
1787 }
1788}
1789
1799#endif
const char * BKE_id_attributes_default_color_name(const struct ID *id)
struct CustomDataLayer * BKE_attribute_search_for_write(AttributeOwner &owner, const char *name, eCustomDataMask type, AttrDomainMask domain_mask)
Definition attribute.cc:669
int BKE_attribute_to_index(const AttributeOwner &owner, const CustomDataLayer *layer, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:911
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)
Definition attribute.cc:994
void BKE_id_attributes_active_color_set(struct ID *id, const char *name)
Definition attribute.cc:965
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)
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:854
int BKE_attribute_domain_size(const AttributeOwner &owner, int domain)
Definition attribute.cc:730
CustomDataLayer * BKE_attribute_from_index(AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:878
@ ATTR_DOMAIN_MASK_ALL
int * BKE_attributes_active_index_p(AttributeOwner &owner)
Definition attribute.cc:832
AttributeOwnerType
void BKE_id_attributes_active_color_clear(struct ID *id)
Definition attribute.cc:981
bool BKE_attribute_rename(AttributeOwner &owner, const char *old_name, const char *new_name, struct ReportList *reports)
Definition attribute.cc:253
int BKE_attribute_data_length(AttributeOwner &owner, struct CustomDataLayer *layer)
Definition attribute.cc:736
bool BKE_attribute_remove(AttributeOwner &owner, const char *name, struct ReportList *reports)
Definition attribute.cc:501
void BKE_attributes_active_set(AttributeOwner &owner, const char *name)
Definition attribute.cc:817
#define ATTR_DOMAIN_MASK_COLOR
#define ATTR_DOMAIN_AS_MASK(domain)
struct CustomDataLayer * BKE_attributes_active_get(AttributeOwner &owner)
Definition attribute.cc:781
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask)
Definition attribute.cc:690
bool BKE_attribute_required(const AttributeOwner &owner, const char *name)
Definition attribute.cc:764
void BKE_attributes_active_clear(AttributeOwner &owner)
Definition attribute.cc:827
const struct CustomDataLayer * BKE_attribute_search(const AttributeOwner &owner, const char *name, eCustomDataMask type, AttrDomainMask domain_mask)
Definition attribute.cc:636
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.c:40
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.c:909
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ ID_ME
@ ID_GP
#define CD_MASK_PROP_ALL
@ CD_FLAG_TEMPORARY
#define CD_MASK_COLOR_ALL
@ 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_STRING
@ CD_PROP_FLOAT4X4
@ CD_AUTO_FROM_NAME
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
#define MEM_SAFE_FREE(v)
#define RNA_POINTER_INVALIDATE(ptr)
const EnumPropertyItem * rna_enum_attribute_domain_itemf(const AttributeOwner &owner, bool include_instances, bool *r_free)
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:375
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_NEVER_UNLINK
Definition RNA_types.hh:273
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_DIRECTION
Definition RNA_types.hh:165
@ PROP_BYTESTRING
Definition RNA_types.hh:143
@ PROP_COLOR
Definition RNA_types.hh:163
@ PROP_NONE
Definition RNA_types.hh:136
constexpr PointerRNA PointerRNA_NULL
Definition RNA_types.hh:45
#define NC_GEOM
Definition WM_types.hh:360
#define ND_DATA
Definition WM_types.hh:475
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
int len
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
uint col
#define GS(x)
Definition iris.cc:202
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, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
void * rna_iterator_array_get(CollectionPropertyIterator *iter)
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
void rna_iterator_array_next(CollectionPropertyIterator *iter)
PointerRNA RNA_pointer_create(ID *id, 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_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_group_point_cloud(BlenderRNA *brna)
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[]
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_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_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
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)
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.c:32
union CollectionPropertyIterator::@1329 internal
CustomData point_data
CustomData curve_data
CustomDataLayer * layers
const char * identifier
Definition RNA_types.hh:506
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
char * active_color_attribute
ID * owner_id
Definition RNA_types.hh:40
StructRNA * type
Definition RNA_types.hh:41
void * data
Definition RNA_types.hh:42
float max
#define N_(msgid)
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126