Fix: Skip anonymous CustomData layers for the python API #104783

Merged
Martijn Versteegh merged 5 commits from Baardaap/blender:skipanonymousuvlayers into main 2023-02-15 23:55:01 +01:00
2 changed files with 2 additions and 42 deletions
Showing only changes of commit 65bf552140 - Show all commits

View File

@ -964,7 +964,7 @@ static void rna_MPoly_freestyle_face_mark_set(PointerRNA *ptr, bool value)
/* uv_layers */
DEFINE_CUSTOMDATA_LAYER_COLLECTION_SKIP_ANONYMOUS(uv_layer, ldata, CD_PROP_FLOAT2)
DEFINE_CUSTOMDATA_LAYER_COLLECTION(uv_layer, ldata, CD_PROP_FLOAT2)
Review

Looking at all the uses of DEFINE_CUSTOMDATA_LAYER_COLLECTION, I think it would be fine to just modify it instead of adding a new macro

Looking at all the uses of `DEFINE_CUSTOMDATA_LAYER_COLLECTION`, I think it would be fine to just modify it instead of adding a new macro

Are we sure there's no place where an anonymous layer needs to be exposed to python? Probably not indeed. I'll take a look at all uses of that macro.

Are we sure there's no place where an anonymous layer needs to be exposed to python? Probably not indeed. I'll take a look at all uses of that macro.
DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(
uv_layer, ldata, CD_PROP_FLOAT2, active, MeshUVLoopLayer)
DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(

View File

@ -8,49 +8,9 @@
/* Macros to help reduce code clutter in rna_mesh.c */
/* Define the accessors for a basic CustomDataLayer collection */
#define DEFINE_CUSTOMDATA_LAYER_COLLECTION(collection_name, customdata_type, layer_type) \
/* check */ \
static int rna_##collection_name##_check(CollectionPropertyIterator *UNUSED(iter), void *data) \
{ \
CustomDataLayer *layer = (CustomDataLayer *)data; \
return (layer->type != layer_type); \
} \
/* begin */ \
static void rna_Mesh_##collection_name##s_begin(CollectionPropertyIterator *iter, \
PointerRNA *ptr) \
{ \
CustomData *data = rna_mesh_##customdata_type(ptr); \
if (data) { \
rna_iterator_array_begin(iter, \
(void *)data->layers, \
sizeof(CustomDataLayer), \
data->totlayer, \
0, \
rna_##collection_name##_check); \
} \
else { \
rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL); \
} \
} \
/* length */ \
static int rna_Mesh_##collection_name##s_length(PointerRNA *ptr) \
{ \
CustomData *data = rna_mesh_##customdata_type(ptr); \
return data ? CustomData_number_of_layers(data, layer_type) : 0; \
} \
/* index range */ \
static void rna_Mesh_##collection_name##_index_range( \
PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) \
{ \
CustomData *data = rna_mesh_##customdata_type(ptr); \
*min = 0; \
*max = data ? CustomData_number_of_layers(data, layer_type) - 1 : 0; \
*max = MAX2(0, *max); \
}
/* Define the accessors for a basic CustomDataLayer collection, skipping anonymous layers */
#define DEFINE_CUSTOMDATA_LAYER_COLLECTION_SKIP_ANONYMOUS(collection_name, customdata_type, layer_type) \
#define DEFINE_CUSTOMDATA_LAYER_COLLECTION(collection_name, customdata_type, layer_type) \
/* check */ \
static int rna_##collection_name##_check(CollectionPropertyIterator *UNUSED(iter), void *data) \
{ \