diff options
-rw-r--r-- | source/blender/blenkernel/BKE_library_override.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_override.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/undo_system.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 36 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 26 | ||||
-rw-r--r-- | source/creator/creator_args.c | 12 |
10 files changed, 96 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_library_override.h b/source/blender/blenkernel/BKE_library_override.h index 4792d203d23..b6642bfa726 100644 --- a/source/blender/blenkernel/BKE_library_override.h +++ b/source/blender/blenkernel/BKE_library_override.h @@ -38,6 +38,9 @@ struct IDOverrideStaticProperty; struct IDOverrideStaticPropertyOperation; struct Main; +void BKE_override_static_enable(const bool do_enable); +bool BKE_override_static_is_enabled(void); + struct IDOverrideStatic *BKE_override_static_init(struct ID *local_id, struct ID *reference_id); void BKE_override_static_copy(struct ID *dst_id, const struct ID *src_id); void BKE_override_static_clear(struct IDOverrideStatic *override); diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c index 35437c1c9b9..714730b2f52 100644 --- a/source/blender/blenkernel/intern/library_override.c +++ b/source/blender/blenkernel/intern/library_override.c @@ -59,6 +59,19 @@ static void bke_override_property_operation_copy(IDOverrideStaticPropertyOperati static void bke_override_property_clear(IDOverrideStaticProperty *op); static void bke_override_property_operation_clear(IDOverrideStaticPropertyOperation *opop); +/* Temp, for until static override is ready and tested enough to go 'public', we hide it by default in UI and such. */ +static bool _override_static_enabled = false; + +void BKE_override_static_enable(const bool do_enable) +{ + _override_static_enabled = do_enable; +} + +bool BKE_override_static_is_enabled() +{ + return _override_static_enabled; +} + /** Initialize empty overriding of \a reference_id by \a local_id. */ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id) { diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index 0eb209cabeb..ae98a765124 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -425,7 +425,9 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char /* Might not be final place for this to be called - probably only want to call it from some * undo handlers, not all of them? */ - BKE_main_override_static_operations_create(G.main, false); + if (BKE_override_static_is_enabled()) { + BKE_main_override_static_operations_create(G.main, false); + } /* Remove all undos after (also when 'ustack->step_active == NULL'). */ while (ustack->steps.last != ustack->step_active) { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 70e9a33aeae..c61a8f95ee6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -463,7 +463,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) case UI_ID_LOCAL: if (id) { Main *bmain = CTX_data_main(C); - if (CTX_wm_window(C)->eventstate->shift) { + if (BKE_override_static_is_enabled() && CTX_wm_window(C)->eventstate->shift) { ID *override_id = BKE_override_static_create_from_id(bmain, id); if (override_id != NULL) { BKE_main_id_clear_newpoins(bmain); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 5d9b6a2d13e..d239b1f25dc 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2404,7 +2404,8 @@ static bool make_override_static_poll(bContext *C) Object *obact = CTX_data_active_object(C); /* Object must be directly linked to be overridable. */ - return (ED_operator_objectmode(C) && obact != NULL && + return (BKE_override_static_is_enabled() && + ED_operator_objectmode(C) && obact != NULL && ((ID_IS_LINKED(obact) && obact->id.tag & LIB_TAG_EXTERN) || (!ID_IS_LINKED(obact) && obact->dup_group != NULL && ID_IS_LINKED(obact->dup_group)))); } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 2f84340e34e..b66622536e9 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -1076,8 +1076,8 @@ typedef enum eOutlinerIdOpTypes { static const EnumPropertyItem prop_id_op_types[] = { {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""}, {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""}, - {OUTLINER_IDOP_STATIC_OVERRIDE, "STATIC_OVERRIDE", - 0, "Add Static Override", "Add a local static override of this data-block"}, + {OUTLINER_IDOP_STATIC_OVERRIDE, "STATIC_OVERRIDE", 0, "Add Static Override", + "Add a local static override of this data-block"}, {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, {OUTLINER_IDOP_DELETE, "DELETE", 0, "Delete", "WARNING: no undo"}, {OUTLINER_IDOP_REMAP, "REMAP", 0, "Remap Users", @@ -1090,6 +1090,29 @@ static const EnumPropertyItem prop_id_op_types[] = { {0, NULL, 0, NULL, NULL} }; +static const EnumPropertyItem *outliner_id_operation_itemf( + bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + if (BKE_override_static_is_enabled()) { + *r_free = false; + return prop_id_op_types; + } + + EnumPropertyItem *items = NULL; + int totitem = 0; + + for (const EnumPropertyItem *it = prop_id_op_types; it->identifier != NULL; it++) { + if (it->value == OUTLINER_IDOP_STATIC_OVERRIDE) { + continue; + } + RNA_enum_item_add(&items, &totitem, it); + } + RNA_enum_item_end(&items, &totitem); + *r_free = true; + + return items; +} + static int outliner_id_operation_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -1163,9 +1186,11 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) } case OUTLINER_IDOP_STATIC_OVERRIDE: { - /* make local */ - outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_static_override_cb, NULL); - ED_undo_push(C, "Overridden Data"); + if (BKE_override_static_is_enabled()) { + /* make local */ + outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_static_override_cb, NULL); + ED_undo_push(C, "Overridden Data"); + } break; } case OUTLINER_IDOP_SINGLE: @@ -1270,6 +1295,7 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) ot->flag = 0; ot->prop = RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); + RNA_def_enum_funcs(ot->prop, outliner_id_operation_itemf); } /* **************************************** */ diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 921a7e3561a..463214fd4fd 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -355,7 +355,7 @@ static ID *rna_ID_copy(ID *id, Main *bmain) static ID *rna_ID_override_create(ID *id, Main *bmain) { - if (id->lib == NULL) { + if (!BKE_override_static_is_enabled() || id->lib == NULL) { return NULL; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a105e205a2e..b05a6bd6c1d 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -7976,6 +7976,10 @@ eRNAOverrideStatus RNA_property_static_override_status(PointerRNA *ptr, Property { int override_status = 0; + if (!BKE_override_static_is_enabled()) { + return override_status; + } + if (!ptr || !prop || !ptr->id.data || !((ID *)ptr->id.data)->override_static) { return override_status; } diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 3aad4dcde34..d8c74bdf565 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -55,6 +55,7 @@ #include "BKE_appdir.h" #include "BKE_blender_version.h" #include "BKE_global.h" +#include "BKE_library_override.h" #include "DNA_ID.h" @@ -358,6 +359,29 @@ static PyObject *bpy_app_autoexec_fail_message_get(PyObject *UNUSED(self), void } +PyDoc_STRVAR(bpy_app_use_static_override_doc, +"Boolean, whether static override is exposed in UI or not." +); +static PyObject *bpy_app_use_static_override_get(PyObject *UNUSED(self), void *UNUSED(closure)) +{ + return PyBool_FromLong((long)BKE_override_static_is_enabled()); +} + +static int bpy_app_use_static_override_set(PyObject *UNUSED(self), PyObject *value, void *UNUSED(closure)) +{ + const int param = PyC_Long_AsBool(value); + + if (param == -1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "bpy.app.use_static_override must be a boolean"); + return -1; + } + + BKE_override_static_enable((const bool)param); + + return 0; +} + + static PyGetSetDef bpy_app_getsets[] = { {(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG}, {(char *)"debug_ffmpeg", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_FFMPEG}, @@ -376,6 +400,8 @@ static PyGetSetDef bpy_app_getsets[] = { {(char *)"debug_gpumem", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_GPU_MEM}, {(char *)"debug_io", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_IO}, + {(char *)"use_static_override", bpy_app_use_static_override_get, bpy_app_use_static_override_set, (char *)bpy_app_use_static_override_doc, NULL}, + {(char *)"binary_path_python", bpy_app_binary_path_python_get, NULL, (char *)bpy_app_binary_path_python_doc, NULL}, {(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL}, diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index b276a1d884a..86eafc1de09 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -54,6 +54,7 @@ #include "BKE_global.h" #include "BKE_library.h" +#include "BKE_library_override.h" #include "BKE_main.h" #include "BKE_scene.h" #include "BKE_report.h" @@ -568,6 +569,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo printf("Misc Options:\n"); BLI_argsPrintArgDoc(ba, "--app-template"); BLI_argsPrintArgDoc(ba, "--factory-startup"); + BLI_argsPrintArgDoc(ba, "--enable-static-override"); printf("\n"); BLI_argsPrintArgDoc(ba, "--env-system-datafiles"); BLI_argsPrintArgDoc(ba, "--env-system-scripts"); @@ -1001,6 +1003,15 @@ static int arg_handle_factory_startup_set(int UNUSED(argc), const char **UNUSED( return 0; } +static const char arg_handle_enable_static_override_doc[] = +"\n\tEnable Static Override features in the UI." +; +static int arg_handle_enable_static_override(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) +{ + BKE_override_static_enable(true); + return 0; +} + static const char arg_handle_env_system_set_doc_datafiles[] = "\n\tSet the "STRINGIFY_ARG (BLENDER_SYSTEM_DATAFILES)" environment variable."; static const char arg_handle_env_system_set_doc_scripts[] = @@ -1927,6 +1938,7 @@ void main_args_setup(bContext *C, bArgs *ba) BLI_argsAdd(ba, 1, NULL, "--app-template", CB(arg_handle_app_template), NULL); BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL); + BLI_argsAdd(ba, 1, NULL, "--enable-static-override", CB(arg_handle_enable_static_override), NULL); /* TODO, add user env vars? */ BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), NULL); |