[Bf-blender-cvs] [aa64fd69e73] master: UI: List library overrides in the Outliner

Julian Eisel noreply at git.blender.org
Sun Dec 27 22:47:24 CET 2020


Commit: aa64fd69e733e49317101ea60299f2179830ae95
Author: Julian Eisel
Date:   Sun Dec 27 22:15:20 2020 +0100
Branches: master
https://developer.blender.org/rBaa64fd69e733e49317101ea60299f2179830ae95

UI: List library overrides in the Outliner

Having a centeral place to find a list of all library overrides should be
useful for managing production scenes where library overrides are used a lot.
This change adds the individually overridden properties of a data-block under
the data-block itself. Just how we show modifiers, constraints or pose channels
there. This way we can also expose library override operations/options better
in future.

There's also a filter option for the library overrides now, so they can be
hidden. It is only available in the View Layer display mode though, like the
other filter options.

One internal change this has to do is adding more informative return values to
undo pushes and the library override functions called by it. That way we can
send a notifier when library overrides change for the Outliner to know when to
rebuild the tree.

Differential Revision: https://developer.blender.org/D7631

Reviewed by: Andy Goralczyk, Bastien Montagne, William Reynish

===================================================================

M	release/scripts/startup/bl_ui/space_outliner.py
M	source/blender/blenkernel/BKE_lib_override.h
M	source/blender/blenkernel/BKE_undo_system.h
M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/blenkernel/intern/undo_system.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/space_outliner/outliner_dragdrop.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/undo/ed_undo.c
M	source/blender/makesdna/DNA_outliner_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/WM_types.h

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 16bbbb9566e..1500ae13462 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -410,6 +410,10 @@ class OUTLINER_PT_filter(Panel):
         row = sub.row()
         row.label(icon='EMPTY_DATA')
         row.prop(space, "use_filter_object_empty", text="Empties")
+        row = sub.row()
+        if bpy.data.libraries:
+            row.label(icon='LIBRARY_DATA_OVERRIDE')
+            row.prop(space, "use_filter_lib_override", text="Library Overrides")
 
         if (
                 bpy.data.curves or
diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h
index 13edabd4cb7..c9a9c26e222 100644
--- a/source/blender/blenkernel/BKE_lib_override.h
+++ b/source/blender/blenkernel/BKE_lib_override.h
@@ -95,6 +95,10 @@ struct IDOverrideLibraryProperty *BKE_lib_override_library_property_get(
     struct IDOverrideLibrary *override, const char *rna_path, bool *r_created);
 void BKE_lib_override_library_property_delete(struct IDOverrideLibrary *override,
                                               struct IDOverrideLibraryProperty *override_property);
+bool BKE_lib_override_rna_property_find(struct PointerRNA *idpoin,
+                                        const struct IDOverrideLibraryProperty *library_prop,
+                                        struct PointerRNA *r_override_poin,
+                                        struct PropertyRNA **r_override_prop);
 
 struct IDOverrideLibraryPropertyOperation *BKE_lib_override_library_property_operation_find(
     struct IDOverrideLibraryProperty *override_property,
@@ -131,7 +135,7 @@ bool BKE_lib_override_library_status_check_local(struct Main *bmain, struct ID *
 bool BKE_lib_override_library_status_check_reference(struct Main *bmain, struct ID *local);
 
 bool BKE_lib_override_library_operations_create(struct Main *bmain, struct ID *local);
-void BKE_lib_override_library_main_operations_create(struct Main *bmain, const bool force_auto);
+bool BKE_lib_override_library_main_operations_create(struct Main *bmain, const bool force_auto);
 
 void BKE_lib_override_library_id_reset(struct Main *bmain, struct ID *id_root);
 void BKE_lib_override_library_id_hierarchy_reset(struct Main *bmain, struct ID *id_root);
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h
index 58872d6be58..b13a0580a55 100644
--- a/source/blender/blenkernel/BKE_undo_system.h
+++ b/source/blender/blenkernel/BKE_undo_system.h
@@ -96,6 +96,12 @@ typedef struct UndoStep {
   /* Over alloc 'type->struct_size'. */
 } UndoStep;
 
+typedef enum UndoPushReturn {
+  UNDO_PUSH_RET_FAILURE = 0,
+  UNDO_PUSH_RET_SUCCESS = (1 << 0),
+  UNDO_PUSH_RET_OVERRIDE_CHANGED = (1 << 1),
+} UndoPushReturn;
+
 typedef void (*UndoTypeForEachIDRefFn)(void *user_data, struct UndoRefID *id_ref);
 
 typedef struct UndoType {
@@ -172,11 +178,11 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack,
                                                const UndoType *ut);
 UndoStep *BKE_undosys_step_push_init(UndoStack *ustack, struct bContext *C, const char *name);
 
-bool BKE_undosys_step_push_with_type(UndoStack *ustack,
-                                     struct bContext *C,
-                                     const char *name,
-                                     const UndoType *ut);
-bool BKE_undosys_step_push(UndoStack *ustack, struct bContext *C, const char *name);
+UndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack,
+                                               struct bContext *C,
+                                               const char *name,
+                                               const UndoType *ut);
+UndoPushReturn BKE_undosys_step_push(UndoStack *ustack, struct bContext *C, const char *name);
 
 UndoStep *BKE_undosys_step_find_by_name_with_type(UndoStack *ustack,
                                                   const char *name,
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index cabc80d4024..cb41a4728ef 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -57,6 +57,8 @@
 #include "RNA_access.h"
 #include "RNA_types.h"
 
+#include "atomic_ops.h"
+
 #define OVERRIDE_AUTO_CHECK_DELAY 0.2 /* 200ms between auto-override checks. */
 //#define DEBUG_OVERRIDE_TIMEIT
 
@@ -982,6 +984,23 @@ IDOverrideLibraryProperty *BKE_lib_override_library_property_get(IDOverrideLibra
   return op;
 }
 
+/**
+ * Get the RNA-property matching the \a library_prop override property. Used for UI to query
+ * additional data about the overriden property (e.g. UI name).
+ *
+ * \param idpoin: Pointer to the override ID.
+ * \param library_prop: The library override property to find the matching RNA property for.
+ */
+bool BKE_lib_override_rna_property_find(PointerRNA *idpoin,
+                                        const IDOverrideLibraryProperty *library_prop,
+                                        PointerRNA *r_override_poin,
+                                        PropertyRNA **r_override_prop)
+{
+  BLI_assert(RNA_struct_is_ID(idpoin->type) && ID_IS_OVERRIDE_LIBRARY(idpoin->data));
+  return RNA_path_resolve_property(
+      idpoin, library_prop->rna_path, r_override_poin, r_override_prop);
+}
+
 void lib_override_library_property_copy(IDOverrideLibraryProperty *op_dst,
                                         IDOverrideLibraryProperty *op_src)
 {
@@ -1370,19 +1389,20 @@ bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local)
  * since it has to go over all properties in depth (all overridable ones at least).
  * Generating differential values and applying overrides are much cheaper.
  *
- * \return true if a new overriding op was created, or some local data was reset. */
+ * \return true if any library operation was created.
+ */
 bool BKE_lib_override_library_operations_create(Main *bmain, ID *local)
 {
   BLI_assert(local->override_library != NULL);
   const bool is_template = (local->override_library->reference == NULL);
-  bool ret = false;
+  bool created = false;
 
   if (!is_template) {
     /* Do not attempt to generate overriding rules from an empty place-holder generated by link
      * code when it cannot find the actual library/ID. Much better to keep the local data-block as
      * is in the file in that case, until broken lib is fixed. */
     if (ID_MISSING(local->override_library->reference)) {
-      return ret;
+      return created;
     }
 
     if (GS(local->name) == ID_OB) {
@@ -1412,14 +1432,16 @@ bool BKE_lib_override_library_operations_create(Main *bmain, ID *local)
                                 local->override_library,
                                 RNA_OVERRIDE_COMPARE_CREATE | RNA_OVERRIDE_COMPARE_RESTORE,
                                 &report_flags);
+
     if (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) {
-      ret = true;
+      created = true;
     }
+
 #ifndef NDEBUG
     if (report_flags & RNA_OVERRIDE_MATCH_RESULT_RESTORED) {
       printf("We did restore some properties of %s from its reference.\n", local->name);
     }
-    if (ret) {
+    if (report_flags & RNA_OVERRIDE_MATCH_RESULT_CREATED) {
       printf("We did generate library override rules for %s\n", local->name);
     }
     else {
@@ -1427,19 +1449,28 @@ bool BKE_lib_override_library_operations_create(Main *bmain, ID *local)
     }
 #endif
   }
-  return ret;
+  return created;
 }
 
+struct LibOverrideOpCreateData {
+  Main *bmain;
+  bool changed;
+};
+
 static void lib_override_library_operations_create_cb(TaskPool *__restrict pool, void *taskdata)
 {
-  Main *bmain = BLI_task_pool_user_data(pool);
+  struct LibOverrideOpCreateData *create_data = BLI_task_pool_user_data(pool);
   ID *id = taskdata;
 
-  BKE_lib_override_library_operations_create(bmain, id);
+  if (BKE_lib_override_library_operations_create(create_data->bmain, id)) {
+    /* Technically no need for atomic, all jobs write the same value and we only care if one did
+     * it. But play safe and avoid implicit assumptions. */
+    atomic_fetch_and_or_uint8((uint8_t *)&create_data->changed, true);
+  }
 }
 
 /** Check all overrides from given \a bmain and create/update overriding operations as needed. */
-void BKE_lib_override_library_main_operations_create(Main *bmain, const bool force_auto)
+bool BKE_lib_override_library_main_operations_create(Main *bmain, const bool force_auto)
 {
   ID *id;
 
@@ -1464,7 +1495,8 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for
     }
   }
 
-  TaskPool *task_pool = BLI_task_pool_create(bmain, TASK_PRIORITY_HIGH);
+  struct LibOverrideOpCreateData create_pool_data = {.bmain = bmain, .changed = false};
+  TaskPool *task_pool = BLI_task_pool_create(&create_pool_data, TASK_PRIORITY_HIGH);
 
   FOREACH_MAIN_ID_BEGIN (bmain, id) {
     if (ID_IS_OVERRIDE_LIBRARY_REAL(id) &&
@@ -1503,6 +1535,8 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for
 #ifdef DEBUG_OVERRIDE_TIMEIT
   TIMEIT_END_AVERAGED(BKE_lib_override_library_main_operations_create);
 #endif
+
+  return create_pool_data.changed;
 }
 
 static bool lib_override_library_id_reset_do(Main *bmain, ID *id_root)
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index b687254fd69..078c93532d9 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -342,9 +342,10 @@ static bool undosys_stack_push_main(UndoStack *ustack, const char *name, struct
   CLOG_INFO(&LOG, 1, "'%s'", name);
   bContext *C_temp = CTX_create();
   CTX_data_main_set(C_temp, bmain);
-  bool ok = BKE_undosys_step_push_with_type(ustack, C_temp, name, BKE_UNDOSYS_TYPE_MEMFILE);
+  UndoPushReturn ret = BKE_undosys_step_push_with_type(
+      ustack, C_temp, name, BKE_UNDOSYS_TYPE_MEMFILE);
   CTX_free(C_temp);
-  return ok;
+  return (ret & UNDO_PUSH_RET_SUCCESS);
 }
 
 void BKE_undosys_stack_init_from_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list