Static Override: Move 'auto' flag into override struct, expose it to RNA.

This commit is contained in:
Bastien Montagne 2018-05-02 16:14:33 +02:00
parent 40771a0e9e
commit ce7575c823
4 changed files with 15 additions and 5 deletions

View File

@ -163,7 +163,7 @@ static ID *override_static_create_from(Main *bmain, ID *reference_id)
id_us_min(local_id);
BKE_override_static_init(local_id, reference_id);
local_id->flag |= LIB_OVERRIDE_STATIC_AUTO;
local_id->flag |= STATICOVERRIDE_AUTO;
return local_id;
}
@ -534,7 +534,7 @@ bool BKE_override_static_operations_create(ID *local, const bool force_auto)
const bool is_template = (local->override_static->reference == NULL);
bool ret = false;
if (!is_template && (force_auto || local->flag & LIB_OVERRIDE_STATIC_AUTO)) {
if (!is_template && (force_auto || local->override_static->flag & STATICOVERRIDE_AUTO)) {
PointerRNA rnaptr_local, rnaptr_reference;
RNA_id_pointer_create(local, &rnaptr_local);
RNA_id_pointer_create(local->override_static->reference, &rnaptr_reference);

View File

@ -2332,7 +2332,7 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
}
else {
/* Disable auto-override tags for non-active objects, will help with performaces... */
new_ob->id.flag &= ~LIB_OVERRIDE_STATIC_AUTO;
new_ob->id.override_static->flag &= ~STATICOVERRIDE_AUTO;
}
/* We still want to store all objects' current override status (i.e. change of parent). */
BKE_override_static_operations_create(&new_ob->id, true);

View File

@ -181,12 +181,18 @@ typedef struct IDOverrideStatic {
struct ID *reference; /* Reference linked ID which this one overrides. */
ListBase properties; /* List of IDOverrideProperty structs. */
short flag;
short pad[3];
/* Read/write data. */
/* Temp ID storing extra override data (used for differential operations only currently).
* Always NULL outside of read/write context. */
struct ID *storage;
} IDOverrideStatic;
enum eStaticOverride_Flag {
STATICOVERRIDE_AUTO = 1 << 0, /* Allow automatic generation of overriding rules. */
};
/* watch it: Sequence has identical beginning. */
/**
@ -389,7 +395,7 @@ typedef enum ID_Type {
#define ID_IS_STATIC_OVERRIDE_AUTO(_id) (!ID_IS_LINKED((_id)) && \
ID_IS_STATIC_OVERRIDE((_id)) && \
(((ID *)(_id))->flag & LIB_OVERRIDE_STATIC_AUTO))
(((ID *)(_id))->override_static->flag & STATICOVERRIDE_AUTO))
#ifdef GS
# undef GS
@ -402,7 +408,6 @@ typedef enum ID_Type {
/* id->flag (persitent). */
enum {
LIB_OVERRIDE_STATIC_AUTO = 1 << 0, /* Allow automatic generation of overriding rules. */
LIB_FAKEUSER = 1 << 9,
};

View File

@ -1106,12 +1106,17 @@ static void rna_def_ID_override_static_property(BlenderRNA *brna)
static void rna_def_ID_override_static(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "IDOverrideStatic", NULL);
RNA_def_struct_ui_text(srna, "ID Static Override", "Struct gathering all data needed by statically overridden IDs");
RNA_def_pointer(srna, "reference", "ID", "Reference ID", "Linked ID used as reference by this override");
prop = RNA_def_boolean(srna, "auto_generate", true, "Auto Generate Override",
"Automatically generate overriding operations by detecting changes in properties");
RNA_def_property_boolean_sdna(prop, NULL, "flag", STATICOVERRIDE_AUTO);
RNA_def_collection(srna, "properties", "IDOverrideStaticProperty", "Properties",
"List of overridden properties");