 |
Blender V5.0
|
Go to the documentation of this file.
16#define DEFINE_CUSTOMDATA_LAYER_COLLECTION(collection_name, customdata_type, layer_type) \
18 [[maybe_unused]] static bool rna_##collection_name##_check(CollectionPropertyIterator *, \
21 CustomDataLayer *layer = (CustomDataLayer *)data; \
22 return (blender::bke::attribute_name_is_anonymous(layer->name) || layer->type != layer_type); \
25 [[maybe_unused]] static void rna_Mesh_##collection_name##s_begin( \
26 CollectionPropertyIterator *iter, PointerRNA *ptr) \
28 CustomData *data = rna_mesh_##customdata_type(ptr); \
30 rna_iterator_array_begin(iter, \
32 (void *)data->layers, \
33 sizeof(CustomDataLayer), \
36 rna_##collection_name##_check); \
39 rna_iterator_array_begin(iter, ptr, NULL, 0, 0, 0, NULL); \
43 [[maybe_unused]] static int rna_Mesh_##collection_name##s_length(PointerRNA *ptr) \
45 CustomData *data = rna_mesh_##customdata_type(ptr); \
46 return data ? CustomData_number_of_layers(data, layer_type) - \
47 CustomData_number_of_anonymous_layers(data, layer_type) : \
51 [[maybe_unused]] static void rna_Mesh_##collection_name##_index_range( \
52 PointerRNA *ptr, int *min, int *max, int *, int *) \
54 CustomData *data = rna_mesh_##customdata_type(ptr); \
56 *max = data ? CustomData_number_of_layers(data, layer_type) - \
57 CustomData_number_of_anonymous_layers(data, layer_type) - 1 : \
59 *max = std::max(0, *max); \
64#define DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM( \
65 collection_name, customdata_type, layer_type, active_type, layer_rna_type) \
67 [[maybe_unused]] static PointerRNA rna_Mesh_##collection_name##_##active_type##_get( \
70 CustomData *data = rna_mesh_##customdata_type(ptr); \
71 CustomDataLayer *layer; \
73 int index = CustomData_get_##active_type##_layer_index(data, layer_type); \
74 layer = (index == -1) ? NULL : &data->layers[index]; \
79 return RNA_pointer_create_with_parent(*ptr, &RNA_##layer_rna_type, layer); \
82 [[maybe_unused]] static void rna_Mesh_##collection_name##_##active_type##_set( \
83 PointerRNA *ptr, PointerRNA value, ReportList *) \
85 Mesh *mesh = rna_mesh(ptr); \
86 CustomData *data = rna_mesh_##customdata_type(ptr); \
89 CustomDataLayer *layer; \
90 int layer_index = CustomData_get_layer_index(data, layer_type); \
91 for (layer = data->layers + layer_index, a = 0; layer_index + a < data->totlayer; \
94 if (value.data == layer) { \
95 CustomData_set_layer_##active_type(data, layer_type, a); \
96 BKE_mesh_tessface_clear(mesh); \
103 [[maybe_unused]] static int rna_Mesh_##collection_name##_##active_type##_index_get( \
106 CustomData *data = rna_mesh_##customdata_type(ptr); \
108 return CustomData_get_##active_type##_layer(data, layer_type); \
115 [[maybe_unused]] static void rna_Mesh_##collection_name##_##active_type##_index_set( \
116 PointerRNA *ptr, int value) \
118 Mesh *mesh = rna_mesh(ptr); \
119 CustomData *data = rna_mesh_##customdata_type(ptr); \
121 if (UNLIKELY(value < 0)) { \
124 else if (value > 0) { \
125 value = min_ii(value, CustomData_number_of_layers(data, layer_type) - 1); \
127 CustomData_set_layer_##active_type(data, layer_type, value); \
128 BKE_mesh_tessface_clear(mesh); \