diff --git a/source/blender/makesrna/RNA_define.hh b/source/blender/makesrna/RNA_define.hh index 0cacc962616..20e611b10ee 100644 --- a/source/blender/makesrna/RNA_define.hh +++ b/source/blender/makesrna/RNA_define.hh @@ -357,14 +357,38 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont, int type, int subtype); +/** + * Define a boolean property controlling one or more bitflags in the DNA member. + * + * \note This can be combined to a call to #RNA_def_property_array on the same property, in case + * the wrapped DNA member is an array of integers. Do not confuse it with defining a RNA boolean + * array property using a single DNA member as a bitset (use + * #RNA_def_property_boolean_bitset_array_sdna for this). + */ void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, - int64_t bit); + int64_t booleanbit); void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, - int64_t bit); + int64_t booleanbit); +/** + * Used to define an array of boolean values using a single int/char/etc. member of a DNA struct + * (aka 'bitset array'). + * + * The #booleanbit value should strictly have a single bit enabled (so typically come from a + * bit-shift expression like `1 << 0`), and be strictly positive (i.e. the left-most bit in the + * valid range should not be used). Multi-bit values are not valid. It will be used as first bit + * for the `0`-indexed item of the array. + * + * The maximum #len depends on the type of the DNA member, and the #booleanbit value. The left-most + * bit is not usable (because bitshift operations over signed negative values are typically + * 'arithmetic', and not 'bitwise', in C++). So e.g. `31` for an `int32_t` with a `booleanbit` + * value of `1 << 0`, and so on. + */ +void RNA_def_property_boolean_bitset_array_sdna( + PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit, int len); void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname); void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname); void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname); diff --git a/source/blender/makesrna/intern/rna_armature.cc b/source/blender/makesrna/intern/rna_armature.cc index 5f77b387701..ccdeef100bb 100644 --- a/source/blender/makesrna/intern/rna_armature.cc +++ b/source/blender/makesrna/intern/rna_armature.cc @@ -1587,8 +1587,8 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) "Start Handle Scale", "Multiply B-Bone Scale In channels by the local scale values of the start handle. " "This is done after the Scale Easing option and isn't affected by it."); - RNA_def_property_boolean_sdna(prop, nullptr, "bbone_prev_flag", BBONE_HANDLE_SCALE_X); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna( + prop, nullptr, "bbone_prev_flag", BBONE_HANDLE_SCALE_X, 3); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); prop = RNA_def_property(srna, "bbone_handle_use_ease_start", PROP_BOOLEAN, PROP_NONE); @@ -1632,8 +1632,8 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) "End Handle Scale", "Multiply B-Bone Scale Out channels by the local scale values of the end handle. " "This is done after the Scale Easing option and isn't affected by it."); - RNA_def_property_boolean_sdna(prop, nullptr, "bbone_next_flag", BBONE_HANDLE_SCALE_X); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna( + prop, nullptr, "bbone_next_flag", BBONE_HANDLE_SCALE_X, 3); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); prop = RNA_def_property(srna, "bbone_handle_use_ease_end", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_collection.cc b/source/blender/makesrna/intern/rna_collection.cc index f5ba95677ce..dcff16779f5 100644 --- a/source/blender/makesrna/intern/rna_collection.cc +++ b/source/blender/makesrna/intern/rna_collection.cc @@ -789,8 +789,8 @@ void RNA_def_collections(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE, nullptr); prop = RNA_def_property(srna, "lineart_intersection_mask", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "lineart_intersection_mask", 1); - RNA_def_property_array(prop, 8); + RNA_def_property_boolean_bitset_array_sdna( + prop, nullptr, "lineart_intersection_mask", 1 << 0, 8); RNA_def_property_ui_text( prop, "Masks", "Intersection generated by this collection will have this mask value"); RNA_def_property_update(prop, NC_SCENE, nullptr); diff --git a/source/blender/makesrna/intern/rna_define.cc b/source/blender/makesrna/intern/rna_define.cc index d2a571a8a6d..c43a76a941a 100644 --- a/source/blender/makesrna/intern/rna_define.cc +++ b/source/blender/makesrna/intern/rna_define.cc @@ -24,6 +24,7 @@ #include "BLI_asan.h" #include "BLI_ghash.h" #include "BLI_listbase.h" +#include "BLI_math_bits.h" #include "BLT_translation.hh" @@ -48,6 +49,15 @@ static CLG_LogRef LOG = {"rna.define"}; # define ASSERT_SOFT_HARD_LIMITS (void)0 #endif +/* Several types cannot use all their bytes to store a bitset (bitshift operations on negative + * numbers are 'arithmetic', i.e. preserve the sign, i.e. are not 'pure' binary shifting). + * + * Currently, all signed types and uint64_t cannot use their left-most bit (i.e. sign bit). */ +#define IS_DNATYPE_BOOLEAN_BITSHIFT_FULLRANGE_COMPAT(_str) \ + (strcmp(_str, "char") == 0 || strcmp(_str, "uchar") == 0 || strcmp(_str, "ushort") == 0 || \ + strcmp(_str, "uint") == 0 || strcmp(_str, "uint8_t") == 0 || strcmp(_str, "uint16_t") == 0 || \ + strcmp(_str, "uint32_t") == 0) + /* Global used during defining */ BlenderDefRNA DefRNA = { @@ -1577,6 +1587,24 @@ void RNA_def_property_array(PropertyRNA *prop, int length) return; } + /* For boolean arrays using bitflags, ensure that the DNA member is an array, and not a scalar + * value. + * + * NOTE: when using #RNA_def_property_boolean_bitset_array_sdna, #RNA_def_property_array will be + * called _before_ defining #dp->booleanbit, so this check won't be triggered. */ + if (DefRNA.preprocess && DefRNA.verify && prop->type == PROP_BOOLEAN) { + PropertyDefRNA *dp = rna_find_struct_property_def(DefRNA.laststruct, prop); + if (dp && dp->booleanbit && dp->dnaarraylength < length) { + CLOG_ERROR(&LOG, + "\"%s.%s\", cannot define a bitflags boolean array wrapping a scalar DNA member. " + "`RNA_def_property_boolean_bitset_array_sdna` should be used instead.", + srna->identifier, + prop->identifier); + DefRNA.error = true; + return; + } + } + switch (prop->type) { case PROP_BOOLEAN: case PROP_INT: @@ -2310,10 +2338,12 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, return dp; } -void RNA_def_property_boolean_sdna(PropertyRNA *prop, - const char *structname, - const char *propname, - int64_t bit) +static void rna_def_property_boolean_sdna(PropertyRNA *prop, + const char *structname, + const char *propname, + const int64_t booleanbit, + const bool booleannegative, + const int length) { PropertyDefRNA *dp; BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop; @@ -2330,75 +2360,141 @@ void RNA_def_property_boolean_sdna(PropertyRNA *prop, return; } - if ((dp = rna_def_property_sdna(prop, structname, propname))) { + BLI_assert(length > 0); - if (!DefRNA.silent) { - /* Error check to ensure floats are not wrapped as integers/booleans. */ - if (dp->dnatype && *dp->dnatype && IS_DNATYPE_BOOLEAN_COMPAT(dp->dnatype) == 0) { + /* In 'bitset array' case, ensure that the booleanbit value has a single bit enabled, and find + * its 'index'. */ + uint bit_index = 0; + if (length > 1) { + if (booleanbit <= 0) { + CLOG_ERROR(&LOG, + "%s.%s is using a null or negative 'booleanbit' value of %ld, which is invalid " + "for 'bitset arrays' boolean properties.", + srna->identifier, + prop->identifier, + booleanbit); + DefRNA.error = true; + return; + } + + bit_index = bitscan_forward_uint64(*reinterpret_cast(&booleanbit)); + if ((booleanbit & ~(1 << bit_index)) != 0) { + CLOG_ERROR(&LOG, + "%s.%s is using a multi-bit 'booleanbit' value of %ld, which is invalid for " + "'bitset arrays' boolean properties.", + srna->identifier, + prop->identifier, + booleanbit); + DefRNA.error = true; + return; + } + } + + dp = rna_def_property_sdna(prop, structname, propname); + if (!dp) { + return; + } + + if (!DefRNA.silent) { + /* Error check to ensure floats are not wrapped as integers/booleans. */ + if (dp->dnatype && *dp->dnatype && IS_DNATYPE_BOOLEAN_COMPAT(dp->dnatype) == 0) { + CLOG_ERROR(&LOG, + "%s.%s is a '%s' but wrapped as type '%s'.", + srna->identifier, + prop->identifier, + dp->dnatype, + RNA_property_typename(prop->type)); + DefRNA.error = true; + return; + } + } + + const bool is_bitset_array = (length > 1); + if (is_bitset_array) { + if (DefRNA.verify) { + const short max_length = (dp->dnasize * 8) - + (IS_DNATYPE_BOOLEAN_BITSHIFT_FULLRANGE_COMPAT(dp->dnatype) ? 0 : 1); + if ((bit_index + length) > max_length) { CLOG_ERROR(&LOG, - "%s.%s is a '%s' but wrapped as type '%s'.", + "%s.%s is a '%s' of %d bytes, but wrapped as type '%s' 'bitset array' of %d " + "items starting at bit %d.", srna->identifier, prop->identifier, dp->dnatype, - RNA_property_typename(prop->type)); + dp->dnasize, + RNA_property_typename(prop->type), + length, + bit_index); DefRNA.error = true; return; } } + RNA_def_property_array(prop, length); + } - dp->booleanbit = bit; + /* NOTE: #dp->booleanbit must be defined _after_ calling #RNA_def_property_array when defining a + * 'bitset array'. */ + dp->booleanbit = booleanbit; + dp->booleannegative = booleannegative; #ifndef RNA_RUNTIME - /* Set the default if possible. */ - if (dp->dnaoffset != -1) { - int SDNAnr = DNA_struct_find_index_wrapper(DefRNA.sdna, dp->dnastructname); - if (SDNAnr != -1) { - const void *default_data = DNA_default_table[SDNAnr]; - if (default_data) { - default_data = POINTER_OFFSET(default_data, dp->dnaoffset); - bool has_default = true; - if (prop->totarraylength > 0) { - has_default = false; - if (debugSRNA_defaults) { - fprintf(stderr, "%s default: unsupported boolean array default\n", __func__); - } + /* Set the default if possible. */ + if (dp->dnaoffset != -1) { + int SDNAnr = DNA_struct_find_index_wrapper(DefRNA.sdna, dp->dnastructname); + if (SDNAnr != -1) { + const void *default_data = DNA_default_table[SDNAnr]; + if (default_data) { + default_data = POINTER_OFFSET(default_data, dp->dnaoffset); + bool has_default = true; + if (prop->totarraylength > 0) { + has_default = false; + if (debugSRNA_defaults) { + fprintf(stderr, "%s default: unsupported boolean array default\n", __func__); + } + } + else { + if (STREQ(dp->dnatype, "char")) { + bprop->defaultvalue = *(const char *)default_data & booleanbit; + } + else if (STREQ(dp->dnatype, "short")) { + bprop->defaultvalue = *(const short *)default_data & booleanbit; + } + else if (STREQ(dp->dnatype, "int")) { + bprop->defaultvalue = *(const int *)default_data & booleanbit; } else { - if (STREQ(dp->dnatype, "char")) { - bprop->defaultvalue = *(const char *)default_data & bit; + has_default = false; + if (debugSRNA_defaults) { + fprintf( + stderr, "%s default: unsupported boolean type (%s)\n", __func__, dp->dnatype); } - else if (STREQ(dp->dnatype, "short")) { - bprop->defaultvalue = *(const short *)default_data & bit; - } - else if (STREQ(dp->dnatype, "int")) { - bprop->defaultvalue = *(const int *)default_data & bit; - } - else { - has_default = false; - if (debugSRNA_defaults) { - fprintf( - stderr, "%s default: unsupported boolean type (%s)\n", __func__, dp->dnatype); - } + } + + if (has_default) { + if (dp->booleannegative) { + bprop->defaultvalue = !bprop->defaultvalue; } - if (has_default) { - if (dp->booleannegative) { - bprop->defaultvalue = !bprop->defaultvalue; - } - - if (debugSRNA_defaults) { - fprintf(stderr, "value=%d, ", bprop->defaultvalue); - print_default_info(dp); - } + if (debugSRNA_defaults) { + fprintf(stderr, "value=%d, ", bprop->defaultvalue); + print_default_info(dp); } } } } } -#else - UNUSED_VARS(bprop); -#endif } +#else + UNUSED_VARS(bprop); +#endif +} + +void RNA_def_property_boolean_sdna(PropertyRNA *prop, + const char *structname, + const char *propname, + int64_t booleanbit) +{ + rna_def_property_boolean_sdna(prop, structname, propname, booleanbit, false, 1); } void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, @@ -2406,15 +2502,16 @@ void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *propname, int64_t booleanbit) { - PropertyDefRNA *dp; + rna_def_property_boolean_sdna(prop, structname, propname, booleanbit, true, 1); +} - RNA_def_property_boolean_sdna(prop, structname, propname, booleanbit); - - dp = rna_find_struct_property_def(DefRNA.laststruct, prop); - - if (dp) { - dp->booleannegative = true; - } +void RNA_def_property_boolean_bitset_array_sdna(PropertyRNA *prop, + const char *structname, + const char *propname, + const int64_t booleanbit, + const int length) +{ + rna_def_property_boolean_sdna(prop, structname, propname, booleanbit, false, length); } void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname) diff --git a/source/blender/makesrna/intern/rna_material.cc b/source/blender/makesrna/intern/rna_material.cc index bf22394a724..3ab909fe864 100644 --- a/source/blender/makesrna/intern/rna_material.cc +++ b/source/blender/makesrna/intern/rna_material.cc @@ -780,8 +780,7 @@ static void rna_def_material_lineart(BlenderRNA *brna) prop = RNA_def_property(srna, "use_material_mask_bits", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_default(prop, false); - RNA_def_property_boolean_sdna(prop, nullptr, "material_mask_bits", 1); - RNA_def_property_array(prop, 8); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "material_mask_bits", 1 << 0, 8); RNA_def_property_ui_text(prop, "Mask", ""); RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index bb8896a217f..c88d699b9cf 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -2916,20 +2916,17 @@ static void rna_def_modifier_mirror(BlenderRNA *brna) RNA_define_lib_overridable(true); prop = RNA_def_property(srna, "use_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_MIR_AXIS_X); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "flag", MOD_MIR_AXIS_X, 3); RNA_def_property_ui_text(prop, "Mirror Axis", "Enable axis mirror"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_bisect_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_MIR_BISECT_AXIS_X); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "flag", MOD_MIR_BISECT_AXIS_X, 3); RNA_def_property_ui_text(prop, "Bisect Axis", "Cuts the mesh across the mirror plane"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_bisect_flip_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_MIR_BISECT_FLIP_AXIS_X); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "flag", MOD_MIR_BISECT_FLIP_AXIS_X, 3); RNA_def_property_ui_text(prop, "Bisect Flip Axis", "Flips the direction of the slice"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -6900,8 +6897,8 @@ static void rna_def_modifier_meshcache(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "flip_axis", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flip_axis", MOD_MESHCACHE_FLIP_AXIS_X); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna( + prop, nullptr, "flip_axis", MOD_MESHCACHE_FLIP_AXIS_X, 3); RNA_def_property_ui_text(prop, "Flip Axis", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -9132,8 +9129,7 @@ static void rna_def_modifier_grease_pencil_lineart(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_material_mask_bits", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "material_mask_bits", 1); - RNA_def_property_array(prop, 8); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "material_mask_bits", 1 << 0, 8); RNA_def_property_ui_text(prop, "Masks", "Mask bits to match from Material Line Art settings"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -9145,8 +9141,7 @@ static void rna_def_modifier_grease_pencil_lineart(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_intersection_mask", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "intersection_mask", 1); - RNA_def_property_array(prop, 8); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "intersection_mask", 1 << 0, 8); RNA_def_property_ui_text(prop, "Masks", "Mask bits to match from Collection Line Art settings"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index 5097d3dd0c4..d04ce261eed 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -3181,15 +3181,13 @@ static void rna_def_object(BlenderRNA *brna) /* transform locks */ prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); @@ -3212,8 +3210,7 @@ static void rna_def_object(BlenderRNA *brna) "Lock editing of four component rotations by components (instead of as Eulers)"); prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update"); diff --git a/source/blender/makesrna/intern/rna_pose.cc b/source/blender/makesrna/intern/rna_pose.cc index 91702ac9381..c97b3656797 100644 --- a/source/blender/makesrna/intern/rna_pose.cc +++ b/source/blender/makesrna/intern/rna_pose.cc @@ -1178,16 +1178,14 @@ static void rna_def_pose_channel(BlenderRNA *brna) /* transform locks */ prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX, 3); RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX, 3); RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); @@ -1216,8 +1214,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX); - RNA_def_property_array(prop, 3); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming"); RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); diff --git a/source/blender/makesrna/intern/rna_rigidbody.cc b/source/blender/makesrna/intern/rna_rigidbody.cc index e95bb0c4afd..b023c9de71c 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.cc +++ b/source/blender/makesrna/intern/rna_rigidbody.cc @@ -1202,8 +1202,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset"); prop = RNA_def_property(srna, "collision_collections", PROP_BOOLEAN, PROP_LAYER_MEMBER); - RNA_def_property_boolean_sdna(prop, nullptr, "col_groups", 1); - RNA_def_property_array(prop, 20); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "col_groups", 1 << 0, 20); RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyOb_collision_collections_set"); RNA_def_property_ui_text( prop, "Collision Collections", "Collision collections rigid body belongs to"); diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index db2c0eaab9e..250fb94cccf 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -4112,9 +4112,8 @@ static void rna_def_tool_settings(BlenderRNA *brna) /* Mesh */ prop = RNA_def_property(srna, "mesh_select_mode", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "selectmode", 1); + RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "selectmode", 1 << 0, 3); RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY); - RNA_def_property_array(prop, 3); RNA_def_property_boolean_funcs(prop, nullptr, "rna_Scene_editmesh_select_mode_set"); RNA_def_property_ui_text(prop, "Mesh Selection Mode", "Which mesh elements selection works on"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);