Blender V5.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
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.h"
19#include "BKE_attribute.hh"
20#include "BKE_grease_pencil.hh"
21
22#include "BLT_translation.hh"
23
24#include "WM_types.hh"
25
26#include "UI_resources.hh"
27
28namespace blender {
29
30using bke::AttrDomain;
31
33 {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
34 {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
35 {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
36 {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
37 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with 32-bit floating-point values"},
38 {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
39 {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
40 {CD_PROP_STRING, "STRING", 0, "String", "Text string"},
41 {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"},
42 {CD_PROP_INT16_2D, "INT16_2D", 0, "2D 16-Bit Integer Vector", "16-bit signed integer vector"},
43 {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
44 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
45 {CD_PROP_FLOAT4, "FLOAT4", 0, "4D Vector", "4D vector with floating-point values"},
47 "BYTE_COLOR",
48 0,
49 "Byte Color",
50 "RGBA color with 8-bit positive integer values"},
51 {0, nullptr, 0, nullptr, nullptr},
52};
53
55 {int(bke::AttrType::Float), "FLOAT", 0, "Float", "Floating-point value"},
56 {int(bke::AttrType::Int32), "INT", 0, "Integer", "32-bit integer"},
57 {int(bke::AttrType::Bool), "BOOLEAN", 0, "Boolean", "True or false"},
59 "FLOAT_VECTOR",
60 0,
61 "Vector",
62 "3D vector with floating-point values"},
64 "FLOAT_COLOR",
65 0,
66 "Color",
67 "RGBA color with 32-bit floating-point values"},
69 "QUATERNION",
70 0,
71 "Quaternion",
72 "Floating point quaternion rotation"},
73 {int(bke::AttrType::Float4x4), "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
74 {int(bke::AttrType::String), "STRING", 0, "String", "Text string"},
76 "INT8",
77 0,
78 "8-Bit Integer",
79 "Smaller integer with a range from -128 to 127"},
81 "INT16_2D",
82 0,
83 "2D 16-Bit Integer Vector",
84 "16-bit signed integer vector"},
86 "INT32_2D",
87 0,
88 "2D Integer Vector",
89 "32-bit signed integer vector"},
90 {int(bke::AttrType::Float2), "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
91 {int(bke::AttrType::Float4), "FLOAT4", 0, "4D Vector", "4D vector with floating-point values"},
93 "BYTE_COLOR",
94 0,
95 "Byte Color",
96 "RGBA color with 8-bit positive integer values"},
97 {0, nullptr, 0, nullptr, nullptr},
98};
99
101 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color 32-bit floating-point values"},
103 "BYTE_COLOR",
104 0,
105 "Byte Color",
106 "RGBA color with 8-bit positive integer values"},
107 {0, nullptr, 0, nullptr, nullptr}};
108
110 {CD_AUTO_FROM_NAME, "AUTO", 0, "Auto", ""},
111 {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
112 {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
113 {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
114 {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
115 {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with 32-bit floating-point values"},
116 {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
117 {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"},
118 {CD_PROP_STRING, "STRING", 0, "String", "Text string"},
119 {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"},
120 {CD_PROP_INT16_2D, "INT16_2D", 0, "2D 16-Bit Integer Vector", "16-bit signed integer vector"},
121 {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
122 {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
123 {CD_PROP_FLOAT4, "FLOAT4", 0, "4D Vector", "4D vector with floating-point values"},
125 "BYTE_COLOR",
126 0,
127 "Byte Color",
128 "RGBA color with 8-bit positive integer values"},
129 {0, nullptr, 0, nullptr, nullptr},
130};
131
133 {int(bke::AttrStorageType::Array), "ARRAY", 0, "Array", "Store a value for every element"},
135 "SINGLE",
136 0,
137 "Single",
138 "Store a single value for the entire domain"},
139 {0, nullptr, 0, nullptr, nullptr},
140};
141
143 int(bke::AttrDomainSelection::Auto), "AUTO", 0, "Auto", ""};
145 int(AttrDomain::Point), "POINT", ICON_VERTEXSEL, "Point", "Vertex or point"};
147 int(AttrDomain::Edge), "EDGE", ICON_EDGESEL, "Edge", "Mesh edge"};
149 int(AttrDomain::Face), "FACE", ICON_FACESEL, "Face", "Mesh face"};
151 int(AttrDomain::Corner), "CORNER", ICON_FACE_CORNER, "Face Corner", "Mesh face corner"};
153 int(AttrDomain::Curve), "CURVE", ICON_CURVE_DATA, "Spline", ""};
155 int(AttrDomain::Instance), "INSTANCE", ICON_EMPTY_AXIS, "Instance", ""};
157 int(AttrDomain::Layer), "LAYER", ICON_OUTLINER_DATA_GP_LAYER, "Layer", "Grease Pencil layer"};
158
169
177
184
191
198
206
212
222
234
240
246
247} // namespace blender
248
249#ifdef RNA_RUNTIME
250
251# include <fmt/format.h>
252
253# include "DNA_customdata_types.h"
255# include "DNA_mesh_types.h"
256# include "DNA_meshdata_types.h"
257# include "DNA_pointcloud_types.h"
258
259# include "BLI_math_color_c.hh"
260# include "BLI_string.hh"
261
264# include "BKE_curves.hh"
265# include "BKE_customdata.hh"
266# include "BKE_editmesh.hh"
267# include "BKE_mesh_types.hh"
268# include "BKE_report.hh"
269
270# include "DEG_depsgraph.hh"
271
272# include "BLT_translation.hh"
273
274# include "IMB_colormanagement.hh"
275
276# include "WM_api.hh"
277
278namespace blender {
279
280/* Attribute */
281
282static bool find_attr_with_pointer(const bke::AttributeStorage &storage,
283 const bke::Attribute &attr)
284{
285 return std::any_of(storage.begin(), storage.end(), [&](const bke::Attribute &attr_iter) {
286 return &attr_iter == &attr;
287 });
288}
289
290static AttributeOwner owner_from_attribute_pointer_rna(PointerRNA *ptr)
291{
292 ID *owner_id = ptr->owner_id;
293 /* TODO: Because we don't know the path to the `ptr`, we need to look though all possible
294 * candidates and search for the `layer` currently. This should be just a simple lookup. */
295 if (GS(owner_id->name) == ID_GP) {
296 bke::Attribute *attr = static_cast<bke::Attribute *>(ptr->data);
297 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(owner_id);
298
299 /* First check the layer attributes. */
300 if (find_attr_with_pointer(grease_pencil->attribute_storage.wrap(), *attr)) {
302 }
303
304 /* Now check all the drawings. */
305 for (GreasePencilDrawingBase *base : grease_pencil->drawings()) {
306 if (base->type == GP_DRAWING) {
307 GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(base);
308 const bke::CurvesGeometry &curves = drawing->geometry.wrap();
309 if (find_attr_with_pointer(curves.attribute_storage.wrap(), *attr)) {
311 }
312 }
313 }
314 }
315 return AttributeOwner::from_id(owner_id);
316}
317
318static AttributeOwner owner_from_pointer_rna(const PointerRNA *ptr)
319{
320 /* For non-ID attribute owners, check the `ptr->type` to derive the `AttributeOwnerType`
321 * and construct an `AttributeOwner` from that type and `ptr->data`. */
322 if (ptr->type == RNA_GreasePencilDrawing) {
324 }
325 return AttributeOwner::from_id(ptr->owner_id);
326}
327
328static std::optional<std::string> rna_Attribute_path(const PointerRNA *ptr)
329{
330 return fmt::format("attributes[\"{}\"]", BLI_str_escape(rna_Attribute_name_get(*ptr)));
331}
332
333static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type)
334{
335 switch (type) {
336 case CD_PROP_FLOAT:
337 return RNA_FloatAttribute;
338 case CD_PROP_INT32:
339 return RNA_IntAttribute;
340 case CD_PROP_FLOAT3:
341 return RNA_FloatVectorAttribute;
342 case CD_PROP_FLOAT4:
343 return RNA_Float4Attribute;
344 case CD_PROP_COLOR:
345 return RNA_FloatColorAttribute;
347 return RNA_ByteColorAttribute;
348 case CD_PROP_STRING:
349 return RNA_StringAttribute;
350 case CD_PROP_BOOL:
351 return RNA_BoolAttribute;
352 case CD_PROP_FLOAT2:
353 return RNA_Float2Attribute;
354 case CD_PROP_INT8:
355 return RNA_ByteIntAttribute;
356 case CD_PROP_INT16_2D:
357 return RNA_Short2Attribute;
358 case CD_PROP_INT32_2D:
359 return RNA_Int2Attribute;
361 return RNA_QuaternionAttribute;
362 case CD_PROP_FLOAT4X4:
363 return RNA_Float4x4Attribute;
364 default:
365 return nullptr;
366 }
367}
368
369static StructRNA *srna_value_by_custom_data_layer_type(const eCustomDataType type)
370{
371 switch (type) {
372 case CD_PROP_FLOAT:
373 return RNA_FloatAttributeValue;
374 case CD_PROP_INT32:
375 return RNA_IntAttributeValue;
376 case CD_PROP_FLOAT3:
377 return RNA_FloatVectorAttributeValue;
378 case CD_PROP_COLOR:
379 return RNA_FloatColorAttributeValue;
381 return RNA_ByteColorAttributeValue;
382 case CD_PROP_STRING:
383 return RNA_StringAttributeValue;
384 case CD_PROP_BOOL:
385 return RNA_BoolAttributeValue;
386 case CD_PROP_FLOAT2:
387 return RNA_Float2AttributeValue;
388 case CD_PROP_INT8:
389 return RNA_ByteIntAttributeValue;
390 case CD_PROP_INT16_2D:
391 return RNA_Short2AttributeValue;
392 case CD_PROP_INT32_2D:
393 return RNA_Int2AttributeValue;
395 return RNA_QuaternionAttributeValue;
396 case CD_PROP_FLOAT4X4:
397 return RNA_Float4x4AttributeValue;
398 case CD_PROP_FLOAT4:
399 return RNA_Float4AttributeValue;
400 default:
401 return nullptr;
402 }
403}
404
405static StructRNA *rna_Attribute_refine(PointerRNA *ptr)
406{
407 if (GS(ptr->owner_id->name) == ID_ME) {
408 const Mesh *mesh = blender::id_cast<const Mesh *>(ptr->owner_id);
409 if (mesh->runtime->edit_mesh) {
410 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
411 return srna_by_custom_data_layer_type(eCustomDataType(layer->type));
412 }
413 }
414 bke::Attribute *attr = ptr->data_as<bke::Attribute>();
415 const eCustomDataType data_type = *bke::attr_type_to_custom_data_type(attr->data_type());
416 return srna_by_custom_data_layer_type(data_type);
417}
418
420{
421 if (!ptr) {
422 return "";
423 }
424 ID *owner_id = ptr.owner_id;
425 const AttributeOwner owner = AttributeOwner::from_id(owner_id);
426 if (owner.type() == AttributeOwnerType::Mesh) {
427 const Mesh *mesh = owner.get_mesh();
428 if (mesh->runtime->edit_mesh) {
429 const CustomDataLayer *layer = ptr.data_as<CustomDataLayer>();
430 return layer->name;
431 }
432 }
433 const bke::Attribute *attr = ptr.data_as<bke::Attribute>();
434 return attr->name();
435}
436
437void rna_Attribute_name_get(PointerRNA *ptr, char *value)
438{
440}
441
443{
444 return rna_Attribute_name_get(*ptr).size();
445}
446
447void rna_Attribute_name_set(PointerRNA *ptr, const char *value)
448{
449 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
450 if (owner.type() == AttributeOwnerType::Mesh) {
451 const Mesh *mesh = owner.get_mesh();
452 if (mesh->runtime->edit_mesh) {
453 const CustomDataLayer *layer = static_cast<const CustomDataLayer *>(ptr->data);
454 BKE_attribute_rename(owner, layer->name, value, nullptr);
455 return;
456 }
457 }
458
459 const bke::Attribute *attr = ptr->data_as<bke::Attribute>();
460 BKE_attribute_rename(owner, attr->name(), value, nullptr);
461}
462
463static int rna_Attribute_name_editable(const PointerRNA *ptr, const char **r_info)
464{
465 AttributeOwner owner = owner_from_attribute_pointer_rna(const_cast<PointerRNA *>(ptr));
466 if (owner.type() == AttributeOwnerType::Mesh) {
467 const Mesh *mesh = owner.get_mesh();
468 if (mesh->runtime->edit_mesh) {
469 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
470 if (BKE_attribute_required(owner, layer->name)) {
471 *r_info = N_("Cannot modify name of required geometry attribute");
472 return false;
473 }
474 return true;
475 }
476 }
477
478 bke::Attribute *attr = ptr->data_as<bke::Attribute>();
479 if (BKE_attribute_required(owner, attr->name())) {
480 *r_info = N_("Cannot modify name of required geometry attribute");
481 return false;
482 }
483 return true;
484}
485
486static int rna_Attribute_type_get(PointerRNA *ptr)
487{
488 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
489 if (owner.type() == AttributeOwnerType::Mesh) {
490 const Mesh *mesh = owner.get_mesh();
491 if (mesh->runtime->edit_mesh) {
492 CustomDataLayer *layer = static_cast<CustomDataLayer *>(ptr->data);
493 return layer->type;
494 }
495 }
496 const bke::Attribute *attr = static_cast<const bke::Attribute *>(ptr->data);
497 return *bke::attr_type_to_custom_data_type(attr->data_type());
498}
499
500static int rna_Attribute_storage_type_get(PointerRNA *ptr)
501{
502 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
503 if (owner.type() == AttributeOwnerType::Mesh) {
504 const Mesh *mesh = owner.get_mesh();
505 if (mesh->runtime->edit_mesh) {
506 return int(bke::AttrStorageType::Array);
507 }
508 }
509 const bke::Attribute *attr = static_cast<const bke::Attribute *>(ptr->data);
510 return int(attr->storage_type());
511}
512
514 bool include_instances,
515 bool *r_free)
516{
517 EnumPropertyItem *item = nullptr;
518 const EnumPropertyItem *domain_item = nullptr;
519 int totitem = 0, a;
520
521 static EnumPropertyItem mesh_vertex_domain_item = {int(AttrDomain::Point),
522 "POINT",
523 ICON_VERTEXSEL,
524 N_("Vertex"),
525 N_("Attribute per point/vertex")};
526
527 for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) {
528 domain_item = &rna_enum_attribute_domain_items[a];
529
530 if (owner.type() == AttributeOwnerType::PointCloud &&
531 !ELEM(domain_item->value, int(AttrDomain::Point)))
532 {
533 continue;
534 }
535 if (owner.type() == AttributeOwnerType::Curves &&
536 !ELEM(domain_item->value, int(AttrDomain::Point), int(AttrDomain::Curve)))
537 {
538 continue;
539 }
540 if (owner.type() == AttributeOwnerType::Mesh && !ELEM(domain_item->value,
541 int(AttrDomain::Point),
542 int(AttrDomain::Edge),
543 int(AttrDomain::Face),
544 int(AttrDomain::Corner)))
545 {
546 continue;
547 }
548 if (owner.type() == AttributeOwnerType::GreasePencil &&
549 !ELEM(domain_item->value, int(AttrDomain::Layer)))
550 {
551 continue;
552 }
553 if (!include_instances && domain_item->value == int(AttrDomain::Instance)) {
554 continue;
555 }
556
557 if (domain_item->value == int(AttrDomain::Point) && owner.type() == AttributeOwnerType::Mesh) {
558 RNA_enum_item_add(&item, &totitem, &mesh_vertex_domain_item);
559 }
560 else {
561 RNA_enum_item_add(&item, &totitem, domain_item);
562 }
563 }
564 RNA_enum_item_end(&item, &totitem);
565
566 *r_free = true;
567 return item;
568}
569
570static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext * /*C*/,
571 PointerRNA *ptr,
572 PropertyRNA * /*prop*/,
573 bool *r_free)
574{
575 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
576 return rna_enum_attribute_domain_itemf(owner, true, r_free);
577}
578
579static int rna_Attribute_domain_get(PointerRNA *ptr)
580{
581 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
582 if (owner.type() == AttributeOwnerType::Mesh) {
583 const Mesh *mesh = owner.get_mesh();
584 if (const BMesh *bm = BKE_editmesh_bmesh_get(mesh)) {
585 return int(
586 BKE_attribute_domain(*mesh, *bm, static_cast<const CustomDataLayer *>(ptr->data)));
587 }
588 }
589 const bke::Attribute *attr = static_cast<const bke::Attribute *>(ptr->data);
590 return int(attr->domain());
591}
592
593static bool rna_Attribute_is_internal_get(PointerRNA *ptr)
594{
596}
597
598static bool rna_Attribute_is_required_get(PointerRNA *ptr)
599{
600 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
602}
603
605{
606 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
607 if (owner.type() == AttributeOwnerType::Mesh) {
608 const Mesh *mesh = owner.get_mesh();
609 if (mesh->runtime->edit_mesh) {
610 iter->valid = false;
611 return;
612 }
613 }
614
615 bke::MutableAttributeAccessor accessor = *owner.get_accessor();
616
617 bke::Attribute *attr = ptr->data_as<bke::Attribute>();
618 const int domain_size = accessor.domain_size(attr->domain());
619 const CPPType &type = bke::attribute_type_to_cpp_type(attr->data_type());
620
621 auto begin_array = [&]() {
622 const auto &data = std::get<bke::Attribute::ArrayData>(attr->data_for_write());
623 rna_iterator_array_begin(iter, ptr, data.data, type.size, domain_size, false, nullptr);
624 };
625 switch (attr->storage_type()) {
627 begin_array();
628 break;
629 }
631 /* Convert storage to array data until single-value access API is developed. */
632 const auto &data = std::get<bke::Attribute::SingleData>(attr->data());
633 const GPointer value(type, data.value);
634 attr->assign_data(bke::Attribute::ArrayData::from_value(value, domain_size));
635 begin_array();
636 break;
637 }
638 }
639}
640
642{
643 if (!*ptr) {
644 return 0;
645 }
646 AttributeOwner owner = owner_from_attribute_pointer_rna(ptr);
647 if (owner.type() == AttributeOwnerType::Mesh) {
648 const Mesh *mesh = owner.get_mesh();
649 if (mesh->runtime->edit_mesh) {
650 return 0;
651 }
652 }
653
654 const bke::Attribute *attr = ptr->data_as<bke::Attribute>();
655 const bke::AttributeAccessor accessor = *owner.get_accessor();
656 return accessor.domain_size(attr->domain());
657}
658
660{
662 rna_Attribute_data_begin(&iter, ptr);
663 if (!iter.valid) {
664 *r_ptr = {};
665 return false;
666 }
667
668 ArrayIterator *internal = &iter.internal.array;
669 if (index < 0 || index >= internal->length) {
670 *r_ptr = {};
671 return false;
672 }
673
674 internal->ptr += internal->itemsize * index;
675
676 const bke::Attribute &attr = *ptr->data_as<bke::Attribute>();
677 const eCustomDataType data_type = *bke::attr_type_to_custom_data_type(attr.data_type());
678 StructRNA *type = srna_value_by_custom_data_layer_type(data_type);
679 *r_ptr = RNA_pointer_create_with_parent(iter.parent, type, rna_iterator_array_get(&iter));
681 return true;
682}
683
688static void tag_any_attribute_changed(ID *id)
689{
690 switch (GS(id->name)) {
691 case ID_CV: {
692 Curves *curves = id_cast<Curves *>(id);
693 curves->geometry.wrap().tag_topology_changed();
694 break;
695 }
696 case ID_ME: {
697 Mesh *mesh = id_cast<Mesh *>(id);
698 mesh->tag_topology_changed();
699 break;
700 }
701 case ID_PT: {
702 PointCloud *pointcloud = id_cast<PointCloud *>(id);
703 pointcloud->tag_positions_changed();
704 pointcloud->tag_radii_changed();
705 break;
706 }
707 case ID_GP: {
708 GreasePencil *grease_pencil = id_cast<GreasePencil *>(id);
709 for (GreasePencilDrawingBase *drawing_base : grease_pencil->drawings()) {
710 if (drawing_base->type == GP_DRAWING) {
712 reinterpret_cast<GreasePencilDrawing *>(drawing_base)->wrap();
713 drawing.tag_topology_changed();
714 }
715 }
716 break;
717 }
718 default: {
719 break;
720 }
721 }
722}
723
724static void rna_Attribute_update_data(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
725{
726 ID *id = ptr->owner_id;
727
728 /* cheating way for importers to avoid slow updates */
729 if (id->us > 0) {
730 tag_any_attribute_changed(id);
731 DEG_id_tag_update(id, 0);
733 }
734}
735
736/* Color Attribute */
737
738static void rna_ByteColorAttributeValue_color_get(PointerRNA *ptr, float *values)
739{
740 MLoopCol *mlcol = static_cast<MLoopCol *>(ptr->data);
741 srgb_to_linearrgb_uchar4(values, &mlcol->r);
743}
744
745static void rna_ByteColorAttributeValue_color_set(PointerRNA *ptr, const float *values)
746{
747 MLoopCol *mlcol = static_cast<MLoopCol *>(ptr->data);
748 float rec709[4];
750 rec709[3] = values[3];
751 linearrgb_to_srgb_uchar4(&mlcol->r, values);
752}
753
754static void rna_ByteColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values)
755{
756 MLoopCol *col = static_cast<MLoopCol *>(ptr->data);
757 values[0] = col->r / 255.0f;
758 values[1] = col->g / 255.0f;
759 values[2] = col->b / 255.0f;
760 values[3] = col->a / 255.0f;
761}
762
763static void rna_ByteColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values)
764{
765 MLoopCol *col = static_cast<MLoopCol *>(ptr->data);
766 col->r = round_fl_to_uchar_clamp(values[0] * 255.0f);
767 col->g = round_fl_to_uchar_clamp(values[1] * 255.0f);
768 col->b = round_fl_to_uchar_clamp(values[2] * 255.0f);
769 col->a = round_fl_to_uchar_clamp(values[3] * 255.0f);
770}
771
772static void rna_FloatColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values)
773{
774 MPropCol *col = static_cast<MPropCol *>(ptr->data);
776 values[3] = col->color[3];
777}
778
779static void rna_FloatColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values)
780{
781 MPropCol *col = static_cast<MPropCol *>(ptr->data);
783 col->color[3] = values[3];
784}
785
786/* String Attribute */
787
788static void rna_StringAttributeValue_s_get(PointerRNA *ptr, char *value)
789{
790 const MStringProperty *mstring = static_cast<const MStringProperty *>(ptr->data);
791 const int len = std::min<int>(mstring->s_len, sizeof(mstring->s) - 1);
792 memcpy(value, mstring->s, len);
793 /* RNA accessors require this. */
794 value[len] = '\0';
795}
796
797static int rna_StringAttributeValue_s_length(PointerRNA *ptr)
798{
799 const MStringProperty *mstring = static_cast<const MStringProperty *>(ptr->data);
800 const int len = std::min<int>(mstring->s_len, sizeof(mstring->s) - 1);
801 return len;
802}
803
804static void rna_StringAttributeValue_s_set(PointerRNA *ptr, const char *value)
805{
806 /* NOTE: RNA does not support byte-strings which contain null bytes.
807 * If `PROP_BYTESTRING` supported this then a value & length could be passed in
808 * and `MStringProperty` could be set with values to include null bytes. */
809 MStringProperty *mstring = static_cast<MStringProperty *>(ptr->data);
810 mstring->s_len = BLI_strnlen(value, sizeof(MStringProperty::s));
811 memcpy(mstring->s, value, mstring->s_len);
812}
813
814/* Attribute Group */
815
816static PointerRNA rna_AttributeGroupID_new(
817 ID *id, ReportList *reports, const char *name, const int type, const int domain)
818{
820 if (owner.type() == AttributeOwnerType::Mesh) {
821 Mesh *mesh = owner.get_mesh();
824 *mesh, *bm, name, eCustomDataType(type), AttrDomain(domain), reports);
825 if (!layer) {
826 return {};
827 }
828
829 if ((GS(id->name) == ID_ME)) {
830 Mesh *mesh = id_cast<Mesh *>(id);
832 if (!mesh->active_color_attribute) {
833 mesh->active_color_attribute = BLI_strdup(layer->name);
834 }
835 if (!mesh->default_color_attribute) {
836 mesh->default_color_attribute = BLI_strdup(layer->name);
837 }
838 }
839 if (ELEM(layer->type, CD_PROP_FLOAT2)) {
840 if (mesh->active_uv_map_name().is_empty()) {
841 mesh->uv_maps_active_set(layer->name);
842 }
843 if (mesh->default_uv_map_name().is_empty()) {
844 mesh->uv_maps_default_set(layer->name);
845 }
846 }
847 }
848
851
852 PointerRNA ptr = RNA_pointer_create_discrete(id, RNA_Attribute, layer);
853 return ptr;
854 }
855 }
856
857 const bke::AttributeAccessor accessor = *owner.get_accessor();
858 if (!accessor.domain_supported(AttrDomain(domain))) {
859 BKE_report(reports, RPT_ERROR, "Attribute domain not supported by this geometry type");
860 return {};
861 }
862 const int domain_size = accessor.domain_size(AttrDomain(domain));
863
864 bke::AttributeStorage &attributes = *owner.get_storage();
866 bke::Attribute &attr = attributes.add(
868 AttrDomain(domain),
870 bke::Attribute::ArrayData::from_default_value(cpp_type, domain_size));
871
872 if (owner.type() == AttributeOwnerType::Mesh) {
873 Mesh *mesh = owner.get_mesh();
875 if (!mesh->active_color_attribute) {
876 BKE_id_attributes_active_color_set(id, attr.name());
877 }
878 if (!mesh->default_color_attribute) {
880 }
881 }
882 if (ELEM(attr.data_type(), bke::AttrType::Float2)) {
883 if (mesh->active_uv_map_name().is_empty()) {
884 mesh->uv_maps_active_set(attr.name());
885 }
886 if (mesh->default_uv_map_name().is_empty()) {
887 mesh->uv_maps_default_set(attr.name());
888 }
889 }
890 }
891
894
895 return RNA_pointer_create_discrete(id, RNA_Attribute, &attr);
896}
897
898static void rna_AttributeGroupID_remove(ID *id, ReportList *reports, PointerRNA *attribute_ptr)
899{
901 if (owner.type() == AttributeOwnerType::Mesh) {
902 const Mesh *mesh = owner.get_mesh();
903 if (mesh->runtime->edit_mesh) {
904 const CustomDataLayer *layer = static_cast<const CustomDataLayer *>(attribute_ptr->data);
905 BKE_attribute_remove(owner, layer->name, reports);
906 attribute_ptr->invalidate();
907
910 return;
911 }
912 }
913
914 const bke::Attribute *attr = static_cast<const bke::Attribute *>(attribute_ptr->data);
915 if (BKE_attribute_required(owner, attr->name())) {
916 BKE_report(reports, RPT_ERROR, "Attribute is required and cannot be removed");
917 return;
918 }
919
920 bke::MutableAttributeAccessor accessor = *owner.get_accessor();
921 accessor.remove(attr->name());
922 attribute_ptr->invalidate();
923
926}
927
929 PointerRNA *ptr,
930 const AttrDomainMask domain_mask,
931 const eCustomDataMask cd_type_mask,
932 const bool include_anonymous)
933{
934 memset(&iter->internal.array, 0, sizeof(iter->internal.array));
935 AttributeOwner owner = owner_from_pointer_rna(ptr);
936 if (owner.type() == AttributeOwnerType::Mesh) {
937 Mesh *mesh = owner.get_mesh();
938 if (BMesh *bm = const_cast<BMesh *>(BKE_editmesh_bmesh_get(mesh))) {
940 const auto add_layers = [&](CustomData &data) {
941 for (CustomDataLayer &layer : MutableSpan(data.layers, data.totlayer)) {
942 if (!(CD_TYPE_AS_MASK(eCustomDataType(layer.type)) & cd_type_mask)) {
943 continue;
944 }
945 if (!include_anonymous && bke::attribute_name_is_anonymous(layer.name)) {
946 continue;
947 }
948 layers.append(&layer);
949 }
950 };
951 if (domain_mask & ATTR_DOMAIN_MASK_POINT) {
952 add_layers(bm->vdata);
953 }
954 if (domain_mask & ATTR_DOMAIN_MASK_EDGE) {
955 add_layers(bm->edata);
956 }
957 if (domain_mask & ATTR_DOMAIN_MASK_FACE) {
958 add_layers(bm->pdata);
959 }
960 if (domain_mask & ATTR_DOMAIN_MASK_CORNER) {
961 add_layers(bm->ldata);
962 }
963 VectorData data = layers.release();
965 iter, ptr, data.data, sizeof(CustomDataLayer *), data.size, true, nullptr);
966 return;
967 }
968 }
969
970 bke::AttributeStorage &storage = *owner.get_storage();
972 for (bke::Attribute &attr : storage) {
973 if (!(ATTR_DOMAIN_AS_MASK(attr.domain()) & domain_mask)) {
974 continue;
975 }
976 if (!(CD_TYPE_AS_MASK(*bke::attr_type_to_custom_data_type(attr.data_type())) & cd_type_mask)) {
977 continue;
978 }
979 if (!include_anonymous && bke::attribute_name_is_anonymous(attr.name())) {
980 continue;
981 }
982 attributes.append(&attr);
983 }
984 VectorData data = attributes.release();
986 iter, ptr, data.data, sizeof(bke::Attribute *), data.size, true, nullptr);
987}
988
990{
992}
993
995{
996 AttributeOwner owner = owner_from_pointer_rna(&iter->parent);
997 if (owner.type() == AttributeOwnerType::Mesh) {
998 Mesh *mesh = owner.get_mesh();
999 if (mesh->runtime->edit_mesh) {
1001 StructRNA *type = srna_by_custom_data_layer_type(eCustomDataType(layer->type));
1002 if (type == nullptr) {
1003 return {};
1004 }
1005 return RNA_pointer_create_with_parent(iter->parent, type, layer);
1006 }
1007 }
1008
1009 bke::Attribute *attr = *static_cast<bke::Attribute **>(rna_iterator_array_get(iter));
1010 const eCustomDataType data_type = *bke::attr_type_to_custom_data_type(attr->data_type());
1011 StructRNA *type = srna_by_custom_data_layer_type(data_type);
1012 return RNA_pointer_create_with_parent(iter->parent, type, attr);
1013}
1014
1016{
1018}
1019
1021{
1022 AttributeOwner owner = owner_from_pointer_rna(ptr);
1024}
1025
1027{
1028 AttributeOwner owner = owner_from_pointer_rna(ptr);
1030}
1031
1033 const StringRef key,
1034 AttrDomainMask domain_mask,
1035 eCustomDataMask cd_type_mask)
1036{
1037 AttributeOwner owner = owner_from_pointer_rna(&ptr);
1038 if (owner.type() == AttributeOwnerType::Mesh) {
1039 const Mesh *mesh = owner.get_mesh();
1040 if (const BMesh *bm = BKE_editmesh_bmesh_get(mesh)) {
1041 const BMDataLayerLookup attr = BM_data_layer_lookup(*bm, key);
1042 if (!attr) {
1043 return {};
1044 }
1045 if (!(CD_TYPE_AS_MASK(*bke::attr_type_to_custom_data_type(attr.type)) & cd_type_mask)) {
1046 return {};
1047 }
1048 if (!(ATTR_DOMAIN_AS_MASK(attr.domain) & domain_mask)) {
1049 return {};
1050 }
1053 ptr, RNA_Attribute, const_cast<CustomDataLayer *>(attr.layer), result);
1054 return result;
1055 }
1056 }
1057
1058 bke::AttributeStorage &storage = *owner.get_storage();
1059 bke::Attribute *attr = storage.lookup(key);
1060 if (!attr) {
1061 return {};
1062 }
1063 if (!(ATTR_DOMAIN_AS_MASK(attr->domain()) & domain_mask)) {
1064 return {};
1065 }
1066 if (!(CD_TYPE_AS_MASK(*bke::attr_type_to_custom_data_type(attr->data_type())) & cd_type_mask)) {
1067 return {};
1068 }
1070 rna_pointer_create_with_ancestors(ptr, RNA_Attribute, attr, result);
1071 return result;
1072}
1073
1074bool rna_AttributeGroup_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
1075{
1077 return *r_ptr;
1078}
1079
1080static int rna_AttributeGroupID_active_index_get(PointerRNA *ptr)
1081{
1082 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1083 return *BKE_attributes_active_index_p(owner);
1084}
1085
1086static PointerRNA rna_AttributeGroupID_active_get(PointerRNA *ptr)
1087{
1088 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1089 const std::optional<StringRef> name = BKE_attributes_active_name_get(owner);
1090 if (!name) {
1091 return {};
1092 }
1094}
1095
1096static void rna_AttributeGroupID_active_set(PointerRNA *ptr,
1097 PointerRNA attribute_ptr,
1098 ReportList * /*reports*/)
1099{
1100 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1101 if (owner.type() == AttributeOwnerType::Mesh) {
1102 const Mesh *mesh = owner.get_mesh();
1103 if (mesh->runtime->edit_mesh) {
1104 CustomDataLayer *layer = static_cast<CustomDataLayer *>(attribute_ptr.data);
1105 if (layer) {
1106 BKE_attributes_active_set(owner, layer->name);
1107 }
1108 else {
1110 }
1111 return;
1112 }
1113 }
1114
1115 bke::Attribute *attr = attribute_ptr.data_as<bke::Attribute>();
1116 if (!attr) {
1118 return;
1119 }
1120
1121 BKE_attributes_active_set(owner, attr->name());
1122}
1123
1124static void rna_AttributeGroupID_active_index_set(PointerRNA *ptr, int value)
1125{
1126 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1127 *BKE_attributes_active_index_p(owner) = std::max(-1, value);
1128}
1129
1130static void rna_AttributeGroupID_active_index_range(
1131 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1132{
1133 *min = -1;
1135
1136 *softmin = *min;
1137 *softmax = *max;
1138}
1139
1140static void rna_AttributeGroup_update_active(Main *bmain, Scene *scene, PointerRNA *ptr)
1141{
1142 rna_Attribute_update_data(bmain, scene, ptr);
1143}
1144
1145static void rna_AttributeGroup_update_active_color(Main * /*bmain*/,
1146 Scene * /*scene*/,
1147 PointerRNA *ptr)
1148{
1149 ID *id = ptr->owner_id;
1150
1151 /* Cheating way for importers to avoid slow updates. */
1152 if (id->us > 0) {
1153 DEG_id_tag_update(id, 0);
1155 }
1156}
1157
1158static int rna_AttributeGroupID_domain_size(ID *id, const int domain)
1159{
1161 if (owner.type() == AttributeOwnerType::Mesh) {
1162 const Mesh *mesh = owner.get_mesh();
1163 if (mesh->runtime->edit_mesh) {
1164 return BKE_attribute_domain_size(owner, domain);
1165 }
1166 }
1167
1168 bke::AttributeAccessor attributes = *owner.get_accessor();
1169 return attributes.domain_size(bke::AttrDomain(domain));
1170}
1171
1172static PointerRNA rna_AttributeGroupMesh_active_color_get(PointerRNA *ptr)
1173{
1175 *ptr,
1176 BKE_id_attributes_active_color_name(ptr->owner_id).value_or(""),
1179}
1180
1181static void rna_AttributeGroupMesh_active_color_set(PointerRNA *ptr,
1182 PointerRNA attribute_ptr,
1183 ReportList * /*reports*/)
1184{
1185 if (!attribute_ptr) {
1187 return;
1188 }
1189 BKE_id_attributes_active_color_set(ptr->owner_id, rna_Attribute_name_get(attribute_ptr));
1190}
1191
1192static int rna_AttributeGroupMesh_active_color_index_get(PointerRNA *ptr)
1193{
1194 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1195 return BKE_attribute_to_index(owner,
1196 BKE_id_attributes_active_color_name(ptr->owner_id).value_or(""),
1199}
1200
1201static void rna_AttributeGroupMesh_active_color_index_set(PointerRNA *ptr, int value)
1202{
1203 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1204 const std::optional<StringRef> name = BKE_attribute_from_index(
1206 if (!name) {
1207 fprintf(stderr, "%s: error setting active color index to %d\n", __func__, value);
1208 return;
1209 }
1210 BKE_id_attributes_active_color_set(ptr->owner_id, name);
1211}
1212
1213static void rna_AttributeGroupMesh_active_color_index_range(
1214 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1215{
1216 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1217 *min = 0;
1219
1220 *softmin = *min;
1221 *softmax = *max;
1222}
1223
1224static int rna_AttributeGroupMesh_render_color_index_get(PointerRNA *ptr)
1225{
1226 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1227 return BKE_attribute_to_index(owner,
1228 BKE_id_attributes_default_color_name(ptr->owner_id).value_or(""),
1231}
1232
1233static void rna_AttributeGroupMesh_render_color_index_set(PointerRNA *ptr, int value)
1234{
1235 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1236 const std::optional<StringRef> name = BKE_attribute_from_index(
1238 if (!name) {
1239 fprintf(stderr, "%s: error setting render color index to %d\n", __func__, value);
1240 return;
1241 }
1242 BKE_id_attributes_default_color_set(ptr->owner_id, name);
1243}
1244
1245static void rna_AttributeGroupMesh_render_color_index_range(
1246 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1247{
1248 AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id);
1249 *min = 0;
1251
1252 *softmin = *min;
1253 *softmax = *max;
1254}
1255
1256static void rna_AttributeGroupMesh_default_color_name_get(PointerRNA *ptr, char *value)
1257{
1258 const ID *id = ptr->owner_id;
1259 const StringRef name = BKE_id_attributes_default_color_name(id).value_or("");
1260 name.copy_unsafe(value);
1261}
1262
1263static int rna_AttributeGroupMesh_default_color_name_length(PointerRNA *ptr)
1264{
1265 const ID *id = ptr->owner_id;
1266 const StringRef name = BKE_id_attributes_default_color_name(id).value_or("");
1267 return name.size();
1268}
1269
1270static void rna_AttributeGroupMesh_default_color_name_set(PointerRNA *ptr, const char *value)
1271{
1272 ID *id = ptr->owner_id;
1273 if (GS(id->name) == ID_ME) {
1274 Mesh *mesh = id_cast<Mesh *>(id);
1275 MEM_SAFE_DELETE(mesh->default_color_attribute);
1276 if (value[0]) {
1277 mesh->default_color_attribute = BLI_strdup(value);
1278 }
1279 }
1280}
1281
1282static void rna_AttributeGroupMesh_active_color_name_get(PointerRNA *ptr, char *value)
1283{
1284 const ID *id = ptr->owner_id;
1285 const StringRef name = BKE_id_attributes_active_color_name(id).value_or("");
1286 name.copy_unsafe(value);
1287}
1288
1289static int rna_AttributeGroupMesh_active_color_name_length(PointerRNA *ptr)
1290{
1291 const ID *id = ptr->owner_id;
1292 const StringRef name = BKE_id_attributes_active_color_name(id).value_or("");
1293 return name.size();
1294}
1295
1296static void rna_AttributeGroupMesh_active_color_name_set(PointerRNA *ptr, const char *value)
1297{
1298 ID *id = ptr->owner_id;
1299 if (GS(id->name) == ID_ME) {
1300 Mesh *mesh = id_cast<Mesh *>(id);
1301 MEM_SAFE_DELETE(mesh->active_color_attribute);
1302 if (value[0]) {
1303 mesh->active_color_attribute = BLI_strdup(value);
1304 }
1305 }
1306}
1307
1308static PointerRNA rna_AttributeGroupGreasePencilDrawing_new(ID *grease_pencil_id,
1309 GreasePencilDrawing *drawing,
1310 ReportList *reports,
1311 const char *name,
1312 const int type,
1313 const int domain)
1314{
1316 const bke::AttributeAccessor accessor = *owner.get_accessor();
1317 if (!accessor.domain_supported(AttrDomain(domain))) {
1318 BKE_report(reports, RPT_ERROR, "Attribute domain not supported by this geometry type");
1319 return {};
1320 }
1321 const int domain_size = accessor.domain_size(AttrDomain(domain));
1322
1323 bke::AttributeStorage &attributes = *owner.get_storage();
1325 bke::Attribute &attr = attributes.add(
1326 attributes.unique_name_calc(name),
1327 AttrDomain(domain),
1329 bke::Attribute::ArrayData::from_default_value(cpp_type, domain_size));
1330
1331 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
1332 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
1333
1334 return RNA_pointer_create_discrete(grease_pencil_id, RNA_Attribute, &attr);
1335}
1336
1337static void rna_AttributeGroupGreasePencilDrawing_remove(ID *grease_pencil_id,
1338 GreasePencilDrawing *drawing,
1339 ReportList *reports,
1340 PointerRNA *attribute_ptr)
1341{
1343 const bke::Attribute *attr = static_cast<const bke::Attribute *>(attribute_ptr->data);
1344 if (BKE_attribute_required(owner, attr->name())) {
1345 BKE_report(reports, RPT_ERROR, "Attribute is required and cannot be removed");
1346 return;
1347 }
1348
1349 bke::MutableAttributeAccessor accessor = *owner.get_accessor();
1350 accessor.remove(attr->name());
1351 attribute_ptr->invalidate();
1352
1353 DEG_id_tag_update(grease_pencil_id, ID_RECALC_GEOMETRY);
1354 WM_main_add_notifier(NC_GEOM | ND_DATA, grease_pencil_id);
1355}
1356
1357static PointerRNA rna_AttributeGroupGreasePencilDrawing_active_get(PointerRNA *ptr)
1358{
1359 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
1361 const std::optional<StringRef> name = BKE_attributes_active_name_get(owner);
1362 if (!name) {
1363 return {};
1364 }
1365 bke::AttributeStorage &storage = *owner.get_storage();
1366 bke::Attribute *attr = storage.lookup(*name);
1367 return RNA_pointer_create_discrete(ptr->owner_id, RNA_Attribute, attr);
1368}
1369
1370static void rna_AttributeGroupGreasePencilDrawing_active_set(PointerRNA *ptr,
1371 PointerRNA attribute_ptr,
1372 ReportList * /*reports*/)
1373{
1374 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
1376 if (!attribute_ptr) {
1378 return;
1379 }
1381}
1382
1383static bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA *ptr,
1384 const PointerRNA value)
1385{
1386 AttributeOwner owner = owner_from_attribute_pointer_rna(const_cast<PointerRNA *>(&value));
1387 return owner.is_valid() && owner.type() == AttributeOwnerType::GreasePencilDrawing &&
1388 owner.get_grease_pencil_drawing() == static_cast<GreasePencilDrawing *>(ptr->data);
1389}
1390
1391static int rna_AttributeGroupGreasePencilDrawing_active_index_get(PointerRNA *ptr)
1392{
1393 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
1395 return *BKE_attributes_active_index_p(owner);
1396}
1397
1398static void rna_AttributeGroupGreasePencilDrawing_active_index_set(PointerRNA *ptr, int value)
1399{
1400 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
1402 *BKE_attributes_active_index_p(owner) = std::max(-1, value);
1403}
1404
1405static void rna_AttributeGroupGreasePencilDrawing_active_index_range(
1406 PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
1407{
1408 GreasePencilDrawing *drawing = static_cast<GreasePencilDrawing *>(ptr->data);
1410 *min = -1;
1411 *max = owner.get_storage()->count();
1412
1413 *softmin = *min;
1414 *softmax = *max;
1415}
1416
1417static int rna_AttributeGroupGreasePencilDrawing_domain_size(GreasePencilDrawing *drawing,
1418 const int domain)
1419{
1421 return owner.get_accessor()->domain_size(bke::AttrDomain(domain));
1422}
1423
1424} // namespace blender
1425
1426#else
1427
1428namespace blender {
1429
1431{
1432 StructRNA *srna;
1433 PropertyRNA *prop;
1434
1435 srna = RNA_def_struct(brna, "FloatAttribute", "Attribute");
1437 srna, "Float Attribute", "Geometry attribute that stores floating-point values");
1438
1439 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1440 RNA_def_property_struct_type(prop, "FloatAttributeValue");
1443 "rna_Attribute_data_begin",
1444 "rna_iterator_array_next",
1445 "rna_iterator_array_end",
1446 "rna_iterator_array_get",
1447 "rna_Attribute_data_length",
1448 "rna_Attribute_data_lookup_int",
1449 nullptr,
1450 nullptr);
1451 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1452
1453 srna = RNA_def_struct(brna, "FloatAttributeValue", nullptr);
1454 RNA_def_struct_sdna(srna, "MFloatProperty");
1456 srna, "Float Attribute Value", "Floating-point value in geometry attribute");
1457 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
1458 RNA_def_property_float_sdna(prop, nullptr, "f");
1459 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1460}
1461
1463{
1464 StructRNA *srna;
1465 PropertyRNA *prop;
1466
1467 /* Float Vector Attribute */
1468 srna = RNA_def_struct(brna, "FloatVectorAttribute", "Attribute");
1470 srna, "Float Vector Attribute", "Geometry attribute that stores floating-point 3D vectors");
1471
1472 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1473 RNA_def_property_struct_type(prop, "FloatVectorAttributeValue");
1476 "rna_Attribute_data_begin",
1477 "rna_iterator_array_next",
1478 "rna_iterator_array_end",
1479 "rna_iterator_array_get",
1480 "rna_Attribute_data_length",
1481 "rna_Attribute_data_lookup_int",
1482 nullptr,
1483 nullptr);
1484 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1485
1486 /* Float Vector Attribute Value */
1487 srna = RNA_def_struct(brna, "FloatVectorAttributeValue", nullptr);
1488 RNA_def_struct_sdna(srna, "vec3f");
1490 srna, "Float Vector Attribute Value", "Vector value in geometry attribute");
1491
1492 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1493 RNA_def_property_ui_text(prop, "Vector", "3D vector");
1494 RNA_def_property_float_sdna(prop, nullptr, "x");
1495 RNA_def_property_array(prop, 3);
1496 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1497}
1498
1500{
1501 StructRNA *srna;
1502 PropertyRNA *prop;
1503
1504 /* Float Color Attribute */
1505 srna = RNA_def_struct(brna, "FloatColorAttribute", "Attribute");
1507 "Float Color Attribute",
1508 "Geometry attribute that stores RGBA colors as floating-point values "
1509 "using 32-bits per channel");
1510
1511 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1512 RNA_def_property_struct_type(prop, "FloatColorAttributeValue");
1515 "rna_Attribute_data_begin",
1516 "rna_iterator_array_next",
1517 "rna_iterator_array_end",
1518 "rna_iterator_array_get",
1519 "rna_Attribute_data_length",
1520 "rna_Attribute_data_lookup_int",
1521 nullptr,
1522 nullptr);
1523 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1524
1525 /* Float Color Attribute Value */
1526 srna = RNA_def_struct(brna, "FloatColorAttributeValue", nullptr);
1527 RNA_def_struct_sdna(srna, "MPropCol");
1528 RNA_def_struct_ui_text(srna, "Float Color Attribute Value", "Color value in geometry attribute");
1529
1530 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1531 RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space");
1532 RNA_def_property_float_sdna(prop, nullptr, "color");
1533 RNA_def_property_array(prop, 4);
1534 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1535
1536 prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR);
1537 RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space");
1538 RNA_def_property_float_sdna(prop, nullptr, "color");
1539 RNA_def_property_array(prop, 4);
1541 "rna_FloatColorAttributeValue_color_srgb_get",
1542 "rna_FloatColorAttributeValue_color_srgb_set",
1543 nullptr);
1544 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1545}
1546
1548{
1549 StructRNA *srna;
1550 PropertyRNA *prop;
1551
1552 /* Byte Color Attribute */
1553 srna = RNA_def_struct(brna, "ByteColorAttribute", "Attribute");
1555 "Byte Color Attribute",
1556 "Geometry attribute that stores RGBA colors as positive integer values "
1557 "using 8-bits per channel");
1558
1559 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1560 RNA_def_property_struct_type(prop, "ByteColorAttributeValue");
1563 "rna_Attribute_data_begin",
1564 "rna_iterator_array_next",
1565 "rna_iterator_array_end",
1566 "rna_iterator_array_get",
1567 "rna_Attribute_data_length",
1568 "rna_Attribute_data_lookup_int",
1569 nullptr,
1570 nullptr);
1571 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1572
1573 /* Byte Color Attribute Value */
1574 srna = RNA_def_struct(brna, "ByteColorAttributeValue", nullptr);
1575 RNA_def_struct_sdna(srna, "MLoopCol");
1576 RNA_def_struct_ui_text(srna, "Byte Color Attribute Value", "Color value in geometry attribute");
1577
1578 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1579 RNA_def_property_array(prop, 4);
1580 RNA_def_property_range(prop, 0.0f, 1.0f);
1582 "rna_ByteColorAttributeValue_color_get",
1583 "rna_ByteColorAttributeValue_color_set",
1584 nullptr);
1585 RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space");
1586 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1587
1588 prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR);
1589 RNA_def_property_array(prop, 4);
1590 RNA_def_property_range(prop, 0.0f, 1.0f);
1592 "rna_ByteColorAttributeValue_color_srgb_get",
1593 "rna_ByteColorAttributeValue_color_srgb_set",
1594 nullptr);
1595 RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space");
1596 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1597}
1598
1600{
1601 StructRNA *srna;
1602 PropertyRNA *prop;
1603
1604 srna = RNA_def_struct(brna, "IntAttribute", "Attribute");
1606 srna, "Integer Attribute", "Geometry attribute that stores integer values");
1607
1608 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1609 RNA_def_property_struct_type(prop, "IntAttributeValue");
1612 "rna_Attribute_data_begin",
1613 "rna_iterator_array_next",
1614 "rna_iterator_array_end",
1615 "rna_iterator_array_get",
1616 "rna_Attribute_data_length",
1617 "rna_Attribute_data_lookup_int",
1618 nullptr,
1619 nullptr);
1620 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1621
1622 srna = RNA_def_struct(brna, "IntAttributeValue", nullptr);
1623 RNA_def_struct_sdna(srna, "MIntProperty");
1624 RNA_def_struct_ui_text(srna, "Integer Attribute Value", "Integer value in geometry attribute");
1625 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1626 RNA_def_property_int_sdna(prop, nullptr, "i");
1627 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1628}
1629
1631{
1632 StructRNA *srna;
1633 PropertyRNA *prop;
1634
1635 srna = RNA_def_struct(brna, "StringAttribute", "Attribute");
1636 RNA_def_struct_ui_text(srna, "String Attribute", "Geometry attribute that stores strings");
1637
1638 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1639 RNA_def_property_struct_type(prop, "StringAttributeValue");
1642 "rna_Attribute_data_begin",
1643 "rna_iterator_array_next",
1644 "rna_iterator_array_end",
1645 "rna_iterator_array_get",
1646 "rna_Attribute_data_length",
1647 "rna_Attribute_data_lookup_int",
1648 nullptr,
1649 nullptr);
1650 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1651
1652 srna = RNA_def_struct(brna, "StringAttributeValue", nullptr);
1653 RNA_def_struct_sdna(srna, "MStringProperty");
1654 RNA_def_struct_ui_text(srna, "String Attribute Value", "String value in geometry attribute");
1655 prop = RNA_def_property(srna, "value", PROP_STRING, PROP_BYTESTRING);
1656 RNA_def_property_string_sdna(prop, nullptr, "s");
1658 "rna_StringAttributeValue_s_get",
1659 "rna_StringAttributeValue_s_length",
1660 "rna_StringAttributeValue_s_set");
1661 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1662}
1663
1665{
1666 StructRNA *srna;
1667 PropertyRNA *prop;
1668
1669 srna = RNA_def_struct(brna, "BoolAttribute", "Attribute");
1670 RNA_def_struct_ui_text(srna, "Bool Attribute", "Geometry attribute that stores booleans");
1671
1672 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1673 RNA_def_property_struct_type(prop, "BoolAttributeValue");
1676 "rna_Attribute_data_begin",
1677 "rna_iterator_array_next",
1678 "rna_iterator_array_end",
1679 "rna_iterator_array_get",
1680 "rna_Attribute_data_length",
1681 "rna_Attribute_data_lookup_int",
1682 nullptr,
1683 nullptr);
1684 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1685
1686 srna = RNA_def_struct(brna, "BoolAttributeValue", nullptr);
1687 RNA_def_struct_sdna(srna, "MBoolProperty");
1688 RNA_def_struct_ui_text(srna, "Bool Attribute Value", "Bool value in geometry attribute");
1689 prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
1690 RNA_def_property_boolean_sdna(prop, nullptr, "b", 0);
1691 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1692}
1693
1695{
1696 StructRNA *srna;
1697 PropertyRNA *prop;
1698
1699 srna = RNA_def_struct(brna, "ByteIntAttribute", "Attribute");
1701 srna, "8-bit Integer Attribute", "Geometry attribute that stores 8-bit integers");
1702
1703 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1704 RNA_def_property_struct_type(prop, "ByteIntAttributeValue");
1707 "rna_Attribute_data_begin",
1708 "rna_iterator_array_next",
1709 "rna_iterator_array_end",
1710 "rna_iterator_array_get",
1711 "rna_Attribute_data_length",
1712 "rna_Attribute_data_lookup_int",
1713 nullptr,
1714 nullptr);
1715 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1716
1717 srna = RNA_def_struct(brna, "ByteIntAttributeValue", nullptr);
1718 RNA_def_struct_sdna(srna, "MInt8Property");
1720 srna, "8-bit Integer Attribute Value", "8-bit value in geometry attribute");
1721 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1722 RNA_def_property_int_sdna(prop, nullptr, "i");
1723 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1724}
1725
1727{
1728 StructRNA *srna;
1729 PropertyRNA *prop;
1730
1731 srna = RNA_def_struct(brna, "Short2Attribute", "Attribute");
1733 "2D 16-Bit Integer Vector Attribute",
1734 "Geometry attribute that stores 2D integer vectors");
1735
1736 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1737 RNA_def_property_struct_type(prop, "Short2AttributeValue");
1740 "rna_Attribute_data_begin",
1741 "rna_iterator_array_next",
1742 "rna_iterator_array_end",
1743 "rna_iterator_array_get",
1744 "rna_Attribute_data_length",
1745 "rna_Attribute_data_lookup_int",
1746 nullptr,
1747 nullptr);
1748 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1749
1750 srna = RNA_def_struct(brna, "Short2AttributeValue", nullptr);
1751 RNA_def_struct_sdna(srna, "vec2s");
1753 srna, "2D 16-Bit Integer Vector Attribute Value", "2D value in geometry attribute");
1754
1755 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1756 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1757 RNA_def_property_int_sdna(prop, nullptr, "x");
1758 RNA_def_property_array(prop, 2);
1759 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1760}
1761
1763{
1764 StructRNA *srna;
1765 PropertyRNA *prop;
1766
1767 srna = RNA_def_struct(brna, "Int2Attribute", "Attribute");
1769 srna, "2D Integer Vector Attribute", "Geometry attribute that stores 2D integer vectors");
1770
1771 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1772 RNA_def_property_struct_type(prop, "Int2AttributeValue");
1775 "rna_Attribute_data_begin",
1776 "rna_iterator_array_next",
1777 "rna_iterator_array_end",
1778 "rna_iterator_array_get",
1779 "rna_Attribute_data_length",
1780 "rna_Attribute_data_lookup_int",
1781 nullptr,
1782 nullptr);
1783 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1784
1785 srna = RNA_def_struct(brna, "Int2AttributeValue", nullptr);
1786 RNA_def_struct_sdna(srna, "vec2i");
1788 srna, "2D Integer Vector Attribute Value", "2D value in geometry attribute");
1789
1790 prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
1791 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1792 RNA_def_property_int_sdna(prop, nullptr, "x");
1793 RNA_def_property_array(prop, 2);
1794 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1795}
1796
1798{
1799 StructRNA *srna;
1800 PropertyRNA *prop;
1801
1802 srna = RNA_def_struct(brna, "QuaternionAttribute", "Attribute");
1803 RNA_def_struct_ui_text(srna, "Quaternion Attribute", "Geometry attribute that stores rotation");
1804
1805 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1806 RNA_def_property_struct_type(prop, "QuaternionAttributeValue");
1809 "rna_Attribute_data_begin",
1810 "rna_iterator_array_next",
1811 "rna_iterator_array_end",
1812 "rna_iterator_array_get",
1813 "rna_Attribute_data_length",
1814 "rna_Attribute_data_lookup_int",
1815 nullptr,
1816 nullptr);
1817 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1818
1819 srna = RNA_def_struct(brna, "QuaternionAttributeValue", nullptr);
1820 RNA_def_struct_sdna(srna, "vec4f");
1822 srna, "Quaternion Attribute Value", "Rotation value in geometry attribute");
1823
1824 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
1825 RNA_def_property_ui_text(prop, "Value", "Quaternion");
1826 RNA_def_property_float_sdna(prop, nullptr, "x");
1827 RNA_def_property_array(prop, 4);
1828 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1829}
1830
1832{
1833 StructRNA *srna;
1834 PropertyRNA *prop;
1835
1836 srna = RNA_def_struct(brna, "Float4x4Attribute", "Attribute");
1838 srna, "4x4 Matrix Attribute", "Geometry attribute that stores a 4 by 4 float matrix");
1839
1840 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1841 RNA_def_property_struct_type(prop, "Float4x4AttributeValue");
1844 "rna_Attribute_data_begin",
1845 "rna_iterator_array_next",
1846 "rna_iterator_array_end",
1847 "rna_iterator_array_get",
1848 "rna_Attribute_data_length",
1849 "rna_Attribute_data_lookup_int",
1850 nullptr,
1851 nullptr);
1852 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1853
1854 srna = RNA_def_struct(brna, "Float4x4AttributeValue", nullptr);
1855 RNA_def_struct_sdna(srna, "mat4x4f");
1856 RNA_def_struct_ui_text(srna, "Matrix Attribute Value", "Matrix value in geometry attribute");
1857
1858 prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_MATRIX);
1859 RNA_def_property_ui_text(prop, "Value", "Matrix");
1860 RNA_def_property_float_sdna(prop, nullptr, "value");
1862 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1863}
1864
1866{
1867 StructRNA *srna;
1868 PropertyRNA *prop;
1869
1870 /* Float2 Attribute */
1871 srna = RNA_def_struct(brna, "Float2Attribute", "Attribute");
1873 srna, "Float2 Attribute", "Geometry attribute that stores floating-point 2D vectors");
1874
1875 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1876 RNA_def_property_struct_type(prop, "Float2AttributeValue");
1879 "rna_Attribute_data_begin",
1880 "rna_iterator_array_next",
1881 "rna_iterator_array_end",
1882 "rna_iterator_array_get",
1883 "rna_Attribute_data_length",
1884 "rna_Attribute_data_lookup_int",
1885 nullptr,
1886 nullptr);
1887 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1888
1889 /* Float2 Attribute Value */
1890 srna = RNA_def_struct(brna, "Float2AttributeValue", nullptr);
1891 RNA_def_struct_sdna(srna, "vec2f");
1892 RNA_def_struct_ui_text(srna, "Float2 Attribute Value", "2D Vector value in geometry attribute");
1893
1894 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1895 RNA_def_property_ui_text(prop, "Vector", "2D vector");
1896 RNA_def_property_float_sdna(prop, nullptr, "x");
1897 RNA_def_property_array(prop, 2);
1898 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1899}
1900
1902{
1903 StructRNA *srna;
1904 PropertyRNA *prop;
1905
1906 /* Float4 Attribute */
1907 srna = RNA_def_struct(brna, "Float4Attribute", "Attribute");
1909 srna, "Float4 Attribute", "Geometry attribute that stores floating-point 4D vectors");
1910
1911 prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
1912 RNA_def_property_struct_type(prop, "Float4AttributeValue");
1915 "rna_Attribute_data_begin",
1916 "rna_iterator_array_next",
1917 "rna_iterator_array_end",
1918 "rna_iterator_array_get",
1919 "rna_Attribute_data_length",
1920 "rna_Attribute_data_lookup_int",
1921 nullptr,
1922 nullptr);
1923 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1924
1925 /* Float4 Attribute Value */
1926 srna = RNA_def_struct(brna, "Float4AttributeValue", nullptr);
1927 RNA_def_struct_sdna(srna, "vec4f");
1928 RNA_def_struct_ui_text(srna, "Float4 Attribute Value", "4D Vector value in geometry attribute");
1929
1930 prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION);
1931 RNA_def_property_ui_text(prop, "Vector", "4D vector");
1932 RNA_def_property_float_sdna(prop, nullptr, "x");
1933 RNA_def_property_array(prop, 4);
1934 RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
1935}
1936
1938{
1939 PropertyRNA *prop;
1940 StructRNA *srna;
1941
1942 srna = RNA_def_struct(brna, "Attribute", nullptr);
1943 RNA_def_struct_ui_text(srna, "Attribute", "Geometry attribute");
1944 RNA_def_struct_path_func(srna, "rna_Attribute_path");
1945 RNA_def_struct_refine_func(srna, "rna_Attribute_refine");
1946
1947 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1949 prop, "rna_Attribute_name_get", "rna_Attribute_name_length", "rna_Attribute_name_set");
1950 RNA_def_property_editable_func(prop, "rna_Attribute_name_editable");
1951 RNA_def_property_ui_text(prop, "Name", "Name of the Attribute");
1952 RNA_def_struct_name_property(srna, prop);
1953
1954 prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
1956 RNA_def_property_enum_funcs(prop, "rna_Attribute_type_get", nullptr, nullptr);
1957 RNA_def_property_ui_text(prop, "Data Type", "Type of data stored in attribute");
1959
1960 prop = RNA_def_property(srna, "storage_type", PROP_ENUM, PROP_NONE);
1962 RNA_def_property_enum_funcs(prop, "rna_Attribute_storage_type_get", nullptr, nullptr);
1963 RNA_def_property_ui_text(prop, "Storage Type", "Method used to store the data");
1966
1967 prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE);
1970 prop, "rna_Attribute_domain_get", nullptr, "rna_Attribute_domain_itemf");
1971 RNA_def_property_ui_text(prop, "Domain", "Domain of the Attribute");
1973
1974 prop = RNA_def_property(srna, "is_internal", PROP_BOOLEAN, PROP_NONE);
1975 RNA_def_property_boolean_funcs(prop, "rna_Attribute_is_internal_get", nullptr);
1977 prop, "Is Internal", "The attribute is meant for internal use by Blender");
1979
1980 prop = RNA_def_property(srna, "is_required", PROP_BOOLEAN, PROP_NONE);
1981 RNA_def_property_boolean_funcs(prop, "rna_Attribute_is_required_get", nullptr);
1982 RNA_def_property_ui_text(prop, "Is Required", "Whether the attribute can be removed or renamed");
1984
1985 /* types */
2000}
2001
2003{
2004 PropertyRNA *prop;
2005 FunctionRNA *func;
2006 PropertyRNA *parm;
2007
2008 /* API */
2009 func = RNA_def_function(srna, "new", "rna_AttributeGroupID_new");
2010 RNA_def_function_ui_description(func, "Add attribute to geometry");
2012 parm = RNA_def_string(func, "name", "Attribute", 0, "Name", "Name of geometry attribute");
2014
2015 parm = RNA_def_enum(
2016 func, "type", rna_enum_attribute_type_items, CD_PROP_FLOAT, "Type", "Attribute type");
2018
2019 parm = RNA_def_enum(func,
2020 "domain",
2022 int(AttrDomain::Point),
2023 "Domain",
2024 "Type of element that attribute is stored on");
2026
2027 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
2029 RNA_def_function_return(func, parm);
2030
2031 func = RNA_def_function(srna, "remove", "rna_AttributeGroupID_remove");
2032 RNA_def_function_ui_description(func, "Remove attribute from geometry");
2034 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "Geometry Attribute");
2037
2038 /* Active */
2039 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2040 RNA_def_property_struct_type(prop, "Attribute");
2041 RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
2043 "rna_AttributeGroupID_active_get",
2044 "rna_AttributeGroupID_active_set",
2045 nullptr,
2046 nullptr);
2048 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
2049
2050 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
2052 prop, "Active Attribute Index", "Active attribute index or -1 when none are active");
2056 "rna_AttributeGroupID_active_index_get",
2057 "rna_AttributeGroupID_active_index_set",
2058 "rna_AttributeGroupID_active_index_range");
2059 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
2060
2061 /* Domain Size */
2062 func = RNA_def_function(srna, "domain_size", "rna_AttributeGroupID_domain_size");
2063 RNA_def_function_ui_description(func, "Get the size of a given domain");
2064 parm = RNA_def_enum(func,
2065 "domain",
2067 int(AttrDomain::Point),
2068 "Domain",
2069 "Type of element that attribute is stored on");
2071 parm = RNA_def_int(func, "size", 0, 0, INT_MAX, "Size", "Size of the domain", 0, INT_MAX);
2072 RNA_def_function_return(func, parm);
2073}
2074
2076{
2077 StructRNA *srna;
2078 PropertyRNA *prop;
2079
2080 srna = RNA_def_struct(brna, "AttributeGroupMesh", nullptr);
2081 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
2082 /* Define `AttributeGroupMesh` to be of type `ID` so we can reuse the generic ID `AttributeGroup`
2083 * functions. */
2084 RNA_def_struct_sdna(srna, "ID");
2085
2087
2088 prop = RNA_def_property(srna, "active_color", PROP_POINTER, PROP_NONE);
2089 RNA_def_property_struct_type(prop, "Attribute");
2090 RNA_def_property_ui_text(prop, "Active Color", "Active color attribute for display and editing");
2092 "rna_AttributeGroupMesh_active_color_get",
2093 "rna_AttributeGroupMesh_active_color_set",
2094 nullptr,
2095 nullptr);
2097 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
2098
2099 prop = RNA_def_property(srna, "active_color_index", PROP_INT, PROP_NONE);
2100 RNA_def_property_ui_text(prop, "Active Color Index", "Active color attribute index");
2103 "rna_AttributeGroupMesh_active_color_index_get",
2104 "rna_AttributeGroupMesh_active_color_index_set",
2105 "rna_AttributeGroupMesh_active_color_index_range");
2106 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
2107
2108 prop = RNA_def_property(srna, "render_color_index", PROP_INT, PROP_NONE);
2110 "Active Render Color Index",
2111 "The index of the color attribute used as a fallback for rendering");
2114 "rna_AttributeGroupMesh_render_color_index_get",
2115 "rna_AttributeGroupMesh_render_color_index_set",
2116 "rna_AttributeGroupMesh_render_color_index_range");
2117 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active_color");
2118
2119 prop = RNA_def_property(srna, "default_color_name", PROP_STRING, PROP_NONE);
2122 "rna_AttributeGroupMesh_default_color_name_get",
2123 "rna_AttributeGroupMesh_default_color_name_length",
2124 "rna_AttributeGroupMesh_default_color_name_set");
2126 prop,
2127 "Default Color Attribute",
2128 "The name of the default color attribute used as a fallback for rendering");
2129
2130 prop = RNA_def_property(srna, "active_color_name", PROP_STRING, PROP_NONE);
2133 "rna_AttributeGroupMesh_active_color_name_get",
2134 "rna_AttributeGroupMesh_active_color_name_length",
2135 "rna_AttributeGroupMesh_active_color_name_set");
2137 "Active Color Attribute",
2138 "The name of the active color attribute for display and editing");
2139}
2140
2142{
2143 StructRNA *srna;
2144
2145 srna = RNA_def_struct(brna, "AttributeGroupPointCloud", nullptr);
2146 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
2147 RNA_def_struct_sdna(srna, "ID");
2148
2150}
2151
2153{
2154 StructRNA *srna;
2155
2156 srna = RNA_def_struct(brna, "AttributeGroupCurves", nullptr);
2157 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
2158 RNA_def_struct_sdna(srna, "ID");
2159
2161}
2162
2164{
2165 StructRNA *srna;
2166
2167 srna = RNA_def_struct(brna, "AttributeGroupGreasePencil", nullptr);
2168 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
2169 RNA_def_struct_sdna(srna, "ID");
2170
2172}
2173
2175{
2176 PropertyRNA *prop;
2177 FunctionRNA *func;
2178 PropertyRNA *parm;
2179 StructRNA *srna;
2180
2181 srna = RNA_def_struct(brna, "AttributeGroupGreasePencilDrawing", nullptr);
2182 RNA_def_struct_ui_text(srna, "Attribute Group", "Group of geometry attributes");
2183 RNA_def_struct_sdna(srna, "GreasePencilDrawing");
2184
2185 /* API */
2186 func = RNA_def_function(srna, "new", "rna_AttributeGroupGreasePencilDrawing_new");
2187 RNA_def_function_ui_description(func, "Add attribute to geometry");
2189 parm = RNA_def_string(func, "name", "Attribute", 0, "Name", "Name of geometry attribute");
2191
2192 parm = RNA_def_enum(
2193 func, "type", rna_enum_attribute_type_items, CD_PROP_FLOAT, "Type", "Attribute type");
2195
2196 parm = RNA_def_enum(func,
2197 "domain",
2199 int(AttrDomain::Point),
2200 "Domain",
2201 "Type of element that attribute is stored on");
2203
2204 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
2206 RNA_def_function_return(func, parm);
2207
2208 func = RNA_def_function(srna, "remove", "rna_AttributeGroupGreasePencilDrawing_remove");
2209 RNA_def_function_ui_description(func, "Remove attribute from geometry");
2211 parm = RNA_def_pointer(func, "attribute", "Attribute", "", "Geometry Attribute");
2214
2215 /* Active */
2216 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2217 RNA_def_property_struct_type(prop, "Attribute");
2218 RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
2220 "rna_AttributeGroupGreasePencilDrawing_active_get",
2221 "rna_AttributeGroupGreasePencilDrawing_active_set",
2222 nullptr,
2223 "rna_AttributeGroupGreasePencilDrawing_active_poll");
2225 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
2226
2227 prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE);
2229 prop, "Active Attribute Index", "Active attribute index or -1 when none are active");
2233 "rna_AttributeGroupGreasePencilDrawing_active_index_get",
2234 "rna_AttributeGroupGreasePencilDrawing_active_index_set",
2235 "rna_AttributeGroupGreasePencilDrawing_active_index_range");
2236 RNA_def_property_update(prop, 0, "rna_AttributeGroup_update_active");
2237
2238 /* Domain Size */
2239 func = RNA_def_function(
2240 srna, "domain_size", "rna_AttributeGroupGreasePencilDrawing_domain_size");
2241 RNA_def_function_ui_description(func, "Get the size of a given domain");
2242 parm = RNA_def_enum(func,
2243 "domain",
2245 int(AttrDomain::Point),
2246 "Domain",
2247 "Type of element that attribute is stored on");
2249 parm = RNA_def_int(func, "size", 0, 0, INT_MAX, "Size", "Size of the domain", 0, INT_MAX);
2250 RNA_def_function_return(func, parm);
2251}
2252
2254{
2255 PropertyRNA *prop;
2256
2257 /* Attributes */
2258 prop = RNA_def_property(srna, "attributes", PROP_COLLECTION, PROP_NONE);
2260 "rna_AttributeGroup_iterator_begin",
2261 "rna_iterator_array_next",
2262 "rna_iterator_array_end",
2263 "rna_AttributeGroup_iterator_get",
2264 "rna_AttributeGroup_length",
2265 nullptr,
2266 "rna_AttributeGroup_lookup_string",
2267 nullptr);
2268 RNA_def_property_struct_type(prop, "Attribute");
2269 RNA_def_property_ui_text(prop, "Attributes", "Geometry attributes");
2270 switch (type) {
2272 RNA_def_property_srna(prop, "AttributeGroupMesh");
2273 break;
2275 RNA_def_property_srna(prop, "AttributeGroupPointCloud");
2276 break;
2278 RNA_def_property_srna(prop, "AttributeGroupCurves");
2279 break;
2281 RNA_def_property_srna(prop, "AttributeGroupGreasePencil");
2282 break;
2284 RNA_def_property_srna(prop, "AttributeGroupGreasePencilDrawing");
2285 break;
2286 }
2287
2288 prop = RNA_def_property(srna, "color_attributes", PROP_COLLECTION, PROP_NONE);
2290 "rna_AttributeGroup_color_iterator_begin",
2291 "rna_iterator_array_next",
2292 "rna_iterator_array_end",
2293 "rna_AttributeGroup_iterator_get",
2294 "rna_AttributeGroup_color_length",
2295 nullptr,
2296 nullptr,
2297 nullptr);
2298 RNA_def_property_struct_type(prop, "Attribute");
2299 RNA_def_property_ui_text(prop, "Color Attributes", "Geometry color attributes");
2300 switch (type) {
2302 RNA_def_property_srna(prop, "AttributeGroupMesh");
2303 break;
2305 RNA_def_property_srna(prop, "AttributeGroupPointCloud");
2306 break;
2308 RNA_def_property_srna(prop, "AttributeGroupCurves");
2309 break;
2311 RNA_def_property_srna(prop, "AttributeGroupGreasePencil");
2312 break;
2314 RNA_def_property_srna(prop, "AttributeGroupGreasePencilDrawing");
2315 break;
2316 }
2317}
2318
2328} // namespace blender
2329
2330#endif
Generic geometry attributes built on CustomData.
#define ATTR_DOMAIN_MASK_COLOR
#define ATTR_DOMAIN_AS_MASK(domain)
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
Low-level operations for grease pencil.
#define BLT_I18NCONTEXT_AMOUNT
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define ELEM(...)
#define CD_MASK_PROP_ALL
#define CD_MASK_COLOR_ALL
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
btScalar max
static AttributeOwner from_id(ID *id)
constexpr MutableSpan()=default
int domain_size(const AttrDomain domain) const
constexpr int64_t size() const
void copy_unsafe(char *dst) const
#define INT_MAX
#define storage(slot, qualifiers)
#define layer
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
std::optional< eCustomDataType > attr_type_to_custom_data_type(AttrType attr_type)
bool attribute_name_is_anonymous(const StringRef name)
const CPPType * custom_data_type_to_cpp_type(eCustomDataType type)
bool allow_procedural_attribute_access(StringRef attribute_name)
std::optional< AttrType > custom_data_type_to_attr_type(eCustomDataType data_type)
const CPPType & attribute_type_to_cpp_type(AttrType type)
BLI_INLINE Texture * wrap(MTLTexture *texture)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
std::optional< StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
static void rna_def_attribute_float4x4(BlenderRNA *brna)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
int rna_AttributeGroup_color_length(PointerRNA *ptr)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
const EnumPropertyItem rna_enum_attribute_curves_domain_items[]
void rna_AttributeGroup_color_iterator_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
static EnumPropertyItem domain_item_edge
const EnumPropertyItem rna_enum_attribute_domain_edge_face_items[]
int * BKE_attributes_active_index_p(AttributeOwner &owner)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
bool BKE_attribute_remove(AttributeOwner &owner, StringRef name, struct ReportList *reports)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
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)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_edge_items[]
static void rna_def_attribute_float2(BlenderRNA *brna)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
void BKE_id_attributes_active_color_clear(struct ID *id)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
Definition editmesh.cc:79
std::optional< StringRef > BKE_id_attributes_default_color_name(const struct ID *id)
const EnumPropertyItem rna_enum_attribute_type_with_auto_items[]
void rna_iterator_array_end(CollectionPropertyIterator *iter)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void rna_Attribute_name_set(PointerRNA *ptr, const char *value)
static EnumPropertyItem domain_item_auto
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
static EnumPropertyItem domain_item_layer
static EnumPropertyItem domain_item_corner
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
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[])
std::optional< StringRef > BKE_id_attributes_active_color_name(const struct ID *id)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
static void rna_def_attribute_string(BlenderRNA *brna)
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
StringRefNull rna_Attribute_name_get(const PointerRNA &ptr)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
static void rna_def_attribute_int2(BlenderRNA *brna)
void rna_pointer_create_with_ancestors(const PointerRNA &parent, StructRNA *type, void *data, PointerRNA &r_ptr)
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask, bool include_anonymous=true)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void BKE_attributes_active_set(AttributeOwner &owner, StringRef name)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_items[]
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name)
const EnumPropertyItem rna_enum_attribute_domain_only_mesh_no_corner_items[]
static void rna_def_attribute_group_mesh(BlenderRNA *brna)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
static EnumPropertyItem domain_item_face
bool BKE_attribute_rename(AttributeOwner &owner, StringRef old_name, StringRef new_name, struct ReportList *reports)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:609
void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
static void rna_def_attribute_float4(BlenderRNA *brna)
static EnumPropertyItem domain_item_point
uint64_t eCustomDataMask
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
static void rna_def_attribute_group_id_common(StructRNA *srna)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
const EnumPropertyItem rna_enum_attribute_domain_without_corner_items[]
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
@ PROP_COLLECTION
Definition RNA_types.hh:216
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_attribute(BlenderRNA *brna)
BLI_INLINE void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3], const float rec709[3])
static void rna_def_attribute_int8(BlenderRNA *brna)
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_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
static void rna_def_attribute_short2(BlenderRNA *brna)
void DEG_id_tag_update(ID *id, unsigned int flags)
static void rna_def_attribute_group_curves(BlenderRNA *brna)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
const EnumPropertyItem rna_enum_attribute_domain_point_edge_face_curve_items[]
const EnumPropertyItem rna_enum_attribute_domain_with_auto_items[]
static void rna_def_attribute_group_grease_pencil(BlenderRNA *brna)
int rna_Attribute_data_length(PointerRNA *ptr)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
static void rna_def_attribute(BlenderRNA *brna)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
const EnumPropertyItem rna_enum_attr_storage_type_items[]
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
const EnumPropertyItem rna_enum_attribute_type_items[]
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE void IMB_colormanagement_scene_linear_to_rec709(float rec709[3], const float scene_linear[3])
static void rna_def_attribute_quaternion(BlenderRNA *brna)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
BMDataLayerLookup BM_data_layer_lookup(const BMesh &bm, const StringRef name)
eCustomDataMask CD_TYPE_AS_MASK(eCustomDataType type)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
int rna_AttributeGroup_length(PointerRNA *ptr)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
std::optional< StringRef > BKE_attribute_from_index(AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask, bool include_anonymous=true)
bool BKE_attribute_required(const AttributeOwner &owner, StringRef name)
void * rna_iterator_array_get(CollectionPropertyIterator *iter)
static void rna_def_attribute_group_pointcloud(BlenderRNA *brna)
PointerRNA rna_AttributeGroup_iterator_get(CollectionPropertyIterator *iter)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
bke::AttrDomain BKE_attribute_domain(const Mesh &mesh, const BMesh &bm, const struct CustomDataLayer *layer)
int BKE_attribute_domain_size(const AttributeOwner &owner, int domain)
void rna_AttributeGroup_iterator_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, AttrDomainMask domain_mask, eCustomDataMask cd_type_mask, bool include_anonymous)
static void rna_def_attribute_bool(BlenderRNA *brna)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static void rna_def_attribute_group_grease_pencil_drawing(BlenderRNA *brna)
@ ATTR_DOMAIN_MASK_CORNER
@ ATTR_DOMAIN_MASK_POINT
@ ATTR_DOMAIN_MASK_ALL
@ ATTR_DOMAIN_MASK_FACE
@ ATTR_DOMAIN_MASK_EDGE
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
int BKE_attribute_to_index(const AttributeOwner &owner, const StringRef name, AttrDomainMask domain_mask, eCustomDataMask layer_mask, bool include_anonymous=true)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_THICK_WRAP
Definition RNA_types.hh:493
@ PROP_NEVER_UNLINK
Definition RNA_types.hh:454
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
const EnumPropertyItem rna_enum_color_attribute_domain_items[]
static EnumPropertyItem domain_item_curve
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
Definition editmesh.cc:65
MINLINE unsigned char round_fl_to_uchar_clamp(float a)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_attrtype_items[]
int rna_Attribute_name_length(PointerRNA *ptr)
bool rna_Attribute_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
static void rna_def_attribute_float_color(BlenderRNA *brna)
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
const EnumPropertyItem * rna_enum_attribute_domain_itemf(const AttributeOwner &owner, bool include_instances, bool *r_free)
static EnumPropertyItem domain_item_instance
void BKE_attributes_active_clear(AttributeOwner &owner)
const EnumPropertyItem rna_enum_attribute_domain_point_face_curve_items[]
@ PROP_MATRIX
Definition RNA_types.hh:322
@ PROP_BYTESTRING
Definition RNA_types.hh:295
@ PROP_DIRECTION
Definition RNA_types.hh:319
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
@ PARM_REQUIRED
Definition RNA_types.hh:631
@ PARM_RNAPTR
Definition RNA_types.hh:633
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
static void rna_def_attribute_float_vector(BlenderRNA *brna)
static void rna_def_attribute_byte_color(BlenderRNA *brna)
void RNA_def_property_array(PropertyRNA *prop, int length)
const int rna_matrix_dimsize_4x4[]
PointerRNA rna_AttributeGroup_lookup_string(const PointerRNA &ptr, const StringRef key, AttrDomainMask domain_mask, eCustomDataMask cd_type_mask)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, size_t itemsize, int64_t length, bool free_ptr, IteratorSkipFunc skip)
const EnumPropertyItem rna_enum_attribute_domain_items[]
const EnumPropertyItem rna_enum_color_attribute_type_items[]
static void rna_def_attribute_int(BlenderRNA *brna)
struct CustomDataLayer * BKE_attribute_new(Mesh &mesh, BMesh &bm, StringRef name, eCustomDataType type, bke::AttrDomain domain, struct ReportList *reports)
void rna_def_attributes_common(StructRNA *srna, const AttributeOwnerType type)
static void rna_def_attribute_float(BlenderRNA *brna)
#define min(a, b)
Definition sort.cc:38
static ArrayData from_default_value(const CPPType &type, int64_t domain_size)
static ArrayData from_value(const GPointer &value, int64_t domain_size)
#define N_(msgid)