 |
Blender
V3.3
|
Go to the documentation of this file.
12 #define DEFINE_CUSTOMDATA_LAYER_COLLECTION(collection_name, customdata_type, layer_type) \
14 static int rna_##collection_name##_check(CollectionPropertyIterator *UNUSED(iter), void *data) \
16 CustomDataLayer *layer = (CustomDataLayer *)data; \
17 return (layer->type != layer_type); \
20 static void rna_Mesh_##collection_name##s_begin(CollectionPropertyIterator *iter, \
23 CustomData *data = rna_mesh_##customdata_type(ptr); \
25 rna_iterator_array_begin(iter, \
26 (void *)data->layers, \
27 sizeof(CustomDataLayer), \
30 rna_##collection_name##_check); \
33 rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL); \
37 static int rna_Mesh_##collection_name##s_length(PointerRNA *ptr) \
39 CustomData *data = rna_mesh_##customdata_type(ptr); \
40 return data ? CustomData_number_of_layers(data, layer_type) : 0; \
43 static void rna_Mesh_##collection_name##_index_range( \
44 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) \
46 CustomData *data = rna_mesh_##customdata_type(ptr); \
48 *max = data ? CustomData_number_of_layers(data, layer_type) - 1 : 0; \
49 *max = MAX2(0, *max); \
54 #define DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM( \
55 collection_name, customdata_type, layer_type, active_type, layer_rna_type) \
57 static PointerRNA rna_Mesh_##collection_name##_##active_type##_get(PointerRNA *ptr) \
59 CustomData *data = rna_mesh_##customdata_type(ptr); \
60 CustomDataLayer *layer; \
62 int index = CustomData_get_##active_type##_layer_index(data, layer_type); \
63 layer = (index == -1) ? NULL : &data->layers[index]; \
68 return rna_pointer_inherit_refine(ptr, &RNA_##layer_rna_type, layer); \
71 static void rna_Mesh_##collection_name##_##active_type##_set( \
72 PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) \
74 Mesh *me = rna_mesh(ptr); \
75 CustomData *data = rna_mesh_##customdata_type(ptr); \
78 CustomDataLayer *layer; \
79 int layer_index = CustomData_get_layer_index(data, layer_type); \
80 for (layer = data->layers + layer_index, a = 0; layer_index + a < data->totlayer; \
82 if (value.data == layer) { \
83 CustomData_set_layer_##active_type(data, layer_type, a); \
84 BKE_mesh_update_customdata_pointers(me, true); \
91 static int rna_Mesh_##collection_name##_##active_type##_index_get(PointerRNA *ptr) \
93 CustomData *data = rna_mesh_##customdata_type(ptr); \
95 return CustomData_get_##active_type##_layer(data, layer_type); \
102 static void rna_Mesh_##collection_name##_##active_type##_index_set(PointerRNA *ptr, int value) \
104 Mesh *me = rna_mesh(ptr); \
105 CustomData *data = rna_mesh_##customdata_type(ptr); \
107 CustomData_set_layer_##active_type(data, layer_type, value); \
108 BKE_mesh_update_customdata_pointers(me, true); \