Merge branch 'blender-v3.5-release'

This commit is contained in:
Sergey Sharybin
2023-02-21 18:41:43 +01:00
5 changed files with 93 additions and 29 deletions

View File

@@ -2198,6 +2198,13 @@ bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
return value;
}
/**
* The boolean IDProperty type isn't supported in old versions. In order to keep forward
* compatibility for a period of time (until 4.0), save boolean RNA properties as integer
* IDProperties.
*/
#define USE_INT_IDPROPS_FOR_BOOLEAN_RNA_PROP
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
{
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
@@ -2228,7 +2235,11 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
group = RNA_struct_idprops(ptr, 1);
if (group) {
#ifdef USE_INT_IDPROPS_FOR_BOOLEAN_RNA_PROP
IDP_AddToGroup(group, IDP_New(IDP_INT, &val, prop->identifier));
#else
IDP_AddToGroup(group, IDP_New(IDP_BOOLEAN, &val, prop->identifier));
#endif
}
}
}
@@ -2249,6 +2260,24 @@ static void rna_property_boolean_fill_default_array_values(
}
}
static void rna_property_boolean_fill_default_array_values_from_ints(
const int *defarr, int defarr_length, bool defvalue, int out_length, bool *r_values)
{
if (defarr && defarr_length > 0) {
defarr_length = MIN2(defarr_length, out_length);
for (int i = 0; i < defarr_length; i++) {
r_values[i] = defarr[i] != 0;
}
}
else {
defarr_length = 0;
}
for (int i = defarr_length; i < out_length; i++) {
r_values[i] = defvalue;
}
}
static void rna_property_boolean_get_default_array_values(PointerRNA *ptr,
BoolPropertyRNA *bprop,
bool *r_values)
@@ -2372,13 +2401,17 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const bo
IDProperty *group;
val.array.len = prop->totarraylength;
#ifdef USE_INT_IDPROPS_FOR_BOOLEAN_RNA_PROP
val.array.type = IDP_INT;
#else
val.array.type = IDP_BOOLEAN;
#endif
group = RNA_struct_idprops(ptr, 1);
if (group) {
idprop = IDP_New(IDP_ARRAY, &val, prop->identifier);
IDP_AddToGroup(group, idprop);
bool *values_dst = IDP_Array(idprop);
int *values_dst = IDP_Array(idprop);
for (uint i = 0; i < idprop->len; i++) {
values_dst[i] = values[i];
}
@@ -2424,10 +2457,19 @@ bool RNA_property_boolean_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop
if (prop->magic != RNA_MAGIC) {
const IDProperty *idprop = (const IDProperty *)prop;
BLI_assert(idprop->type == IDP_BOOLEAN);
if (idprop->ui_data) {
const IDPropertyUIDataBool *ui_data = (const IDPropertyUIDataBool *)idprop->ui_data;
return ui_data->default_value;
switch (IDP_ui_data_type(idprop)) {
case IDP_UI_DATA_TYPE_BOOLEAN: {
const IDPropertyUIDataBool *ui_data = (const IDPropertyUIDataBool *)idprop->ui_data;
return ui_data->default_value;
}
case IDP_UI_DATA_TYPE_INT: {
const IDPropertyUIDataInt *ui_data = (const IDPropertyUIDataInt *)idprop->ui_data;
return ui_data->default_value != 0;
}
default:
BLI_assert_unreachable();
}
}
return false;
}
@@ -2446,18 +2488,40 @@ void RNA_property_boolean_get_default_array(PointerRNA *ptr, PropertyRNA *prop,
const IDProperty *idprop = (const IDProperty *)prop;
if (idprop->ui_data) {
BLI_assert(idprop->type == IDP_ARRAY);
BLI_assert(idprop->subtype == IDP_BOOLEAN);
const IDPropertyUIDataBool *ui_data = (const IDPropertyUIDataBool *)idprop->ui_data;
if (ui_data->default_array) {
rna_property_boolean_fill_default_array_values((bool *)ui_data->default_array,
ui_data->default_array_len,
ui_data->default_value,
idprop->len,
values);
}
else {
rna_property_boolean_fill_default_array_values(
NULL, 0, ui_data->default_value, idprop->len, values);
switch (IDP_ui_data_type(idprop)) {
case IDP_UI_DATA_TYPE_BOOLEAN: {
const IDPropertyUIDataBool *ui_data = (const IDPropertyUIDataBool *)idprop->ui_data;
if (ui_data->default_array) {
rna_property_boolean_fill_default_array_values((const bool *)ui_data->default_array,
ui_data->default_array_len,
ui_data->default_value,
idprop->len,
values);
}
else {
rna_property_boolean_fill_default_array_values(
NULL, 0, ui_data->default_value, idprop->len, values);
}
break;
}
case IDP_UI_DATA_TYPE_INT: {
const IDPropertyUIDataInt *ui_data = (const IDPropertyUIDataInt *)idprop->ui_data;
if (ui_data->default_array) {
rna_property_boolean_fill_default_array_values_from_ints(ui_data->default_array,
ui_data->default_array_len,
ui_data->default_value,
idprop->len,
values);
}
else {
rna_property_boolean_fill_default_array_values(
NULL, 0, ui_data->default_value, idprop->len, values);
}
break;
}
default:
BLI_assert_unreachable();
break;
}
}
}

View File

@@ -430,12 +430,12 @@ def main() -> None:
# Directories:
# This is an exception, it has it's own CMake files we do not maintain.
"./extern",
"./release/scripts/addons_contrib",
"./scripts/addons_contrib",
# Just data.
"./doc/python_api/examples",
"./release/scripts/addons/presets",
"./release/scripts/presets",
"./release/scripts/templates_py",
"./scripts/addons/presets",
"./scripts/presets",
"./scripts/templates_py",
),
),
)

View File

@@ -14,11 +14,11 @@ PATHS: Tuple[str, ...] = (
"doc",
"release/datafiles",
"release/lts",
"release/scripts/freestyle",
"release/scripts/modules",
"release/scripts/presets",
"release/scripts/startup",
"release/scripts/templates_py",
"scripts/freestyle",
"scripts/modules",
"scripts/presets",
"scripts/startup",
"scripts/templates_py",
"source/blender",
"tools",
"tests",
@@ -39,7 +39,7 @@ PATHS_EXCLUDE: Set[str] = set(
"tools/svn_rev_map/sha1_to_rev.py",
"tools/svn_rev_map/rev_to_sha1.py",
"tools/svn_rev_map/rev_to_sha1.py",
"release/scripts/modules/rna_manual_reference.py",
"scripts/modules/rna_manual_reference.py",
)
)

View File

@@ -37,7 +37,7 @@ extensions = (
)
ignore_files = {
"release/scripts/modules/rna_manual_reference.py", # Large generated file, don't format.
"scripts/modules/rna_manual_reference.py", # Large generated file, don't format.
}

View File

@@ -10,8 +10,8 @@ PATHS = (
"intern/ghost",
"intern/guardedalloc",
"intern/memutil",
"release/scripts/modules",
"release/scripts",
"scripts/modules",
"scripts",
"source",
"tests",