Static Override: progresses towards full support for material slots.
Material slots are a real pain to get working, due to all the black magic they do to hide object vs. obdata storage of the material... Currently hitting an order problem - we need to always set 'link' (to object or obdata) property of the slot first, before we set its material... *super-sigh*
This commit is contained in:
parent
cb42ad8c75
commit
856d36e4b8
|
@ -262,7 +262,7 @@ typedef enum PropertyOverrideFlag {
|
|||
/* Only use indices to compare items in the property, never names (collections only). */
|
||||
/* Useful when nameprop of the items is generated from other data
|
||||
* (e.g. name of material slots is actually name of assigned material). */
|
||||
PROPOVERRIDE_INDEX_ONLY = (1 << 11),
|
||||
PROPOVERRIDE_NO_PROP_NAME = (1 << 11),
|
||||
} PropertyOverrideFlag;
|
||||
|
||||
/* Function parameters flags.
|
||||
|
|
|
@ -1985,7 +1985,7 @@ static void rna_def_object(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
|
||||
RNA_def_property_struct_type(prop, "MaterialSlot");
|
||||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_INDEX_ONLY);
|
||||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC | PROPOVERRIDE_NO_PROP_NAME);
|
||||
/* don't dereference pointer! */
|
||||
RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", NULL, NULL, NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
|
||||
|
@ -2002,6 +2002,7 @@ static void rna_def_object(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "actcol");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set",
|
||||
"rna_Object_active_material_index_range");
|
||||
RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
|
||||
|
|
|
@ -1121,7 +1121,7 @@ static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key
|
|||
/* Ensures it makes sense to go inside the pointers to compare their content
|
||||
* (if they are IDs, or have different names or RNA type, then this would be meaningless). */
|
||||
static bool rna_property_override_diff_propptr_validate_diffing(
|
||||
PointerRNA *propptr_a, PointerRNA *propptr_b,
|
||||
PointerRNA *propptr_a, PointerRNA *propptr_b, const bool no_prop_name,
|
||||
bool *r_is_id, bool *r_is_null, bool *r_is_type_diff,
|
||||
char **r_propname_a, char *propname_a_buff, size_t propname_a_buff_size,
|
||||
char **r_propname_b, char *propname_b_buff, size_t propname_b_buff_size)
|
||||
|
@ -1129,7 +1129,7 @@ static bool rna_property_override_diff_propptr_validate_diffing(
|
|||
BLI_assert(propptr_a != NULL);
|
||||
|
||||
bool is_valid_for_diffing = true;
|
||||
const bool do_force_name = r_propname_a != NULL;
|
||||
const bool do_force_name = !no_prop_name && r_propname_a != NULL;
|
||||
|
||||
if (do_force_name) {
|
||||
BLI_assert(r_propname_a != NULL);
|
||||
|
@ -1165,7 +1165,7 @@ static bool rna_property_override_diff_propptr_validate_diffing(
|
|||
/* We do a generic quick first comparison checking for "name" and/or "type" properties.
|
||||
* We assume that is any of those are false, then we are not handling the same data.
|
||||
* This helps a lot in static override case, especially to detect inserted items in collections. */
|
||||
if (is_valid_for_diffing || do_force_name) {
|
||||
if (!no_prop_name && (is_valid_for_diffing || do_force_name)) {
|
||||
PropertyRNA *nameprop_a = RNA_struct_name_property(propptr_a->type);
|
||||
PropertyRNA *nameprop_b = (propptr_b != NULL) ? RNA_struct_name_property(propptr_b->type) : NULL;
|
||||
|
||||
|
@ -1222,7 +1222,8 @@ static bool rna_property_override_diff_propptr_validate_diffing(
|
|||
|
||||
/* Used for both Pointer and Collection properties. */
|
||||
static int rna_property_override_diff_propptr(
|
||||
PointerRNA *propptr_a, PointerRNA *propptr_b, eRNACompareMode mode, const bool no_ownership,
|
||||
PointerRNA *propptr_a, PointerRNA *propptr_b,
|
||||
eRNACompareMode mode, const bool no_ownership, const bool no_prop_name,
|
||||
IDOverrideStatic *override, const char *rna_path, const int flags, bool *r_override_changed)
|
||||
{
|
||||
const bool do_create = override != NULL && (flags & RNA_OVERRIDE_COMPARE_CREATE) != 0 && rna_path != NULL;
|
||||
|
@ -1232,7 +1233,7 @@ static int rna_property_override_diff_propptr(
|
|||
bool is_type_diff = false;
|
||||
/* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
|
||||
bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
|
||||
propptr_a, propptr_b, &is_id, &is_null, &is_type_diff,
|
||||
propptr_a, propptr_b, no_prop_name, &is_id, &is_null, &is_type_diff,
|
||||
NULL, NULL, 0, NULL, NULL, 0);
|
||||
|
||||
if (is_id) {
|
||||
|
@ -1538,8 +1539,9 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
|
|||
PointerRNA propptr_a = RNA_property_pointer_get(ptr_a, prop_a);
|
||||
PointerRNA propptr_b = RNA_property_pointer_get(ptr_b, prop_b);
|
||||
const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0;
|
||||
const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0;
|
||||
return rna_property_override_diff_propptr(
|
||||
&propptr_a, &propptr_b, mode, no_ownership,
|
||||
&propptr_a, &propptr_b, mode, no_ownership, no_prop_name,
|
||||
override, rna_path, flags, r_override_changed);
|
||||
}
|
||||
break;
|
||||
|
@ -1550,6 +1552,7 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
|
|||
/* Note: we assume we only insert in ptr_a (i.e. we can only get new items in ptr_a),
|
||||
* and that we never remove anything. */
|
||||
const bool use_insertion = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_STATIC_INSERTION) && do_create;
|
||||
const bool no_prop_name = (RNA_property_override_flag(prop_a) & PROPOVERRIDE_NO_PROP_NAME) != 0;
|
||||
bool equals = true;
|
||||
bool abort = false;
|
||||
bool is_first_insert = true;
|
||||
|
@ -1590,16 +1593,18 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
|
|||
/* If false, it means that the whole data itself is different, so no point in going inside of it at all! */
|
||||
if (iter_b.valid) {
|
||||
is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(
|
||||
&iter_a.ptr, &iter_b.ptr, &is_id, &is_null, &is_type_diff,
|
||||
&propname_a, buff_a, sizeof(buff_a),
|
||||
&propname_b, buff_b, sizeof(buff_b));
|
||||
&iter_a.ptr, &iter_b.ptr, no_prop_name,
|
||||
&is_id, &is_null, &is_type_diff,
|
||||
&propname_a, buff_a, sizeof(buff_a),
|
||||
&propname_b, buff_b, sizeof(buff_b));
|
||||
}
|
||||
else {
|
||||
is_valid_for_diffing = false;
|
||||
if (is_valid_for_insertion) {
|
||||
/* We still need propname from 'a' item... */
|
||||
rna_property_override_diff_propptr_validate_diffing(
|
||||
&iter_a.ptr, NULL, &is_id, &is_null, &is_type_diff,
|
||||
&iter_a.ptr, NULL, no_prop_name,
|
||||
&is_id, &is_null, &is_type_diff,
|
||||
&propname_a, buff_a, sizeof(buff_a),
|
||||
&propname_b, buff_b, sizeof(buff_b));
|
||||
}
|
||||
|
@ -1685,7 +1690,7 @@ int rna_property_override_diff_default(PointerRNA *ptr_a, PointerRNA *ptr_b,
|
|||
if (equals || do_create) {
|
||||
const bool no_ownership = (RNA_property_flag(prop_a) & PROP_PTR_NO_OWNERSHIP) != 0;
|
||||
const int eq = rna_property_override_diff_propptr(
|
||||
&iter_a.ptr, &iter_b.ptr, mode, no_ownership,
|
||||
&iter_a.ptr, &iter_b.ptr, mode, no_ownership, no_prop_name,
|
||||
override, extended_rna_path, flags, r_override_changed);
|
||||
equals = equals && eq;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue