 |
Blender
V2.93
|
Go to the documentation of this file.
26 #define DEFINE_CUSTOMDATA_LAYER_COLLECTION(collection_name, customdata_type, layer_type) \
28 static int rna_##collection_name##_check(CollectionPropertyIterator *UNUSED(iter), void *data) \
30 CustomDataLayer *layer = (CustomDataLayer *)data; \
31 return (layer->type != layer_type); \
34 static void rna_Mesh_##collection_name##s_begin(CollectionPropertyIterator *iter, \
37 CustomData *data = rna_mesh_##customdata_type(ptr); \
39 rna_iterator_array_begin(iter, \
40 (void *)data->layers, \
41 sizeof(CustomDataLayer), \
44 rna_##collection_name##_check); \
47 rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL); \
51 static int rna_Mesh_##collection_name##s_length(PointerRNA *ptr) \
53 CustomData *data = rna_mesh_##customdata_type(ptr); \
54 return data ? CustomData_number_of_layers(data, layer_type) : 0; \
57 static void rna_Mesh_##collection_name##_index_range( \
58 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) \
60 CustomData *data = rna_mesh_##customdata_type(ptr); \
62 *max = data ? CustomData_number_of_layers(data, layer_type) - 1 : 0; \
63 *max = MAX2(0, *max); \
68 #define DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM( \
69 collection_name, customdata_type, layer_type, active_type, layer_rna_type) \
71 static PointerRNA rna_Mesh_##collection_name##_##active_type##_get(PointerRNA *ptr) \
73 CustomData *data = rna_mesh_##customdata_type(ptr); \
74 CustomDataLayer *layer; \
76 int index = CustomData_get_##active_type##_layer_index(data, layer_type); \
77 layer = (index == -1) ? NULL : &data->layers[index]; \
82 return rna_pointer_inherit_refine(ptr, &RNA_##layer_rna_type, layer); \
85 static void rna_Mesh_##collection_name##_##active_type##_set( \
86 PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) \
88 Mesh *me = rna_mesh(ptr); \
89 CustomData *data = rna_mesh_##customdata_type(ptr); \
92 CustomDataLayer *layer; \
93 int layer_index = CustomData_get_layer_index(data, layer_type); \
94 for (layer = data->layers + layer_index, a = 0; layer_index + a < data->totlayer; \
96 if (value.data == layer) { \
97 CustomData_set_layer_##active_type(data, layer_type, a); \
98 BKE_mesh_update_customdata_pointers(me, true); \
105 static int rna_Mesh_##collection_name##_##active_type##_index_get(PointerRNA *ptr) \
107 CustomData *data = rna_mesh_##customdata_type(ptr); \
109 return CustomData_get_##active_type##_layer(data, layer_type); \
116 static void rna_Mesh_##collection_name##_##active_type##_index_set(PointerRNA *ptr, int value) \
118 Mesh *me = rna_mesh(ptr); \
119 CustomData *data = rna_mesh_##customdata_type(ptr); \
121 CustomData_set_layer_##active_type(data, layer_type, value); \
122 BKE_mesh_update_customdata_pointers(me, true); \