[Bf-blender-cvs] [deb01eb1991] master: LibOverride: Add concept of 'embedded'/'virtual' override.

Bastien Montagne noreply at git.blender.org
Tue Jun 30 12:19:18 CEST 2020


Commit: deb01eb1991e49fb912ede1ef036710e51b25fc5
Author: Bastien Montagne
Date:   Tue Jun 30 11:33:36 2020 +0200
Branches: master
https://developer.blender.org/rBdeb01eb1991e49fb912ede1ef036710e51b25fc5

LibOverride: Add concept of 'embedded'/'virtual' override.

IDs like embedded ones (master collections, root node trees) cannot be
linked, and thus cannot be real override themselves.

Since they are managed by their owner ID, that one will also have the
overrides for their locally edited properties.

We still need a way to mark them as overridden though, for various UI
and override-internal purposes, this is done using a new ID flag.

Note that since Shae Keys are not linkable, and their pointers are not
editable in RNA, they are also considered as embedded from override
point of view.

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

M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/makesdna/DNA_ID.h

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

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index a536b382c8f..4be0c7ce16f 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -127,6 +127,7 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f
     }
   }
   else if (src_id->override_library == NULL) {
+    /* Virtual overrides of embedded data does not require any extra work. */
     return;
   }
   else {
@@ -621,7 +622,7 @@ bool BKE_lib_override_library_property_operation_operands_validate(
  * \return true if status is OK, false otherwise. */
 bool BKE_lib_override_library_status_check_local(Main *bmain, ID *local)
 {
-  BLI_assert(ID_IS_OVERRIDE_LIBRARY(local));
+  BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(local));
 
   ID *reference = local->override_library->reference;
 
@@ -677,7 +678,7 @@ bool BKE_lib_override_library_status_check_local(Main *bmain, ID *local)
  * \return true if status is OK, false otherwise. */
 bool BKE_lib_override_library_status_check_reference(Main *bmain, ID *local)
 {
-  BLI_assert(ID_IS_OVERRIDE_LIBRARY(local));
+  BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(local));
 
   ID *reference = local->override_library->reference;
 
@@ -823,7 +824,7 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for
   TaskPool *task_pool = BLI_task_pool_create(bmain, TASK_PRIORITY_HIGH);
 
   FOREACH_MAIN_ID_BEGIN (bmain, id) {
-    if ((ID_IS_OVERRIDE_LIBRARY(id) && force_auto) ||
+    if ((ID_IS_OVERRIDE_LIBRARY_REAL(id) && force_auto) ||
         (id->tag & LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH)) {
       BLI_task_pool_push(task_pool, lib_override_library_operations_create_cb, id, false, NULL);
       id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH;
@@ -896,7 +897,7 @@ void BKE_lib_override_library_main_tag(struct Main *bmain, const short tag, cons
 /** Remove all tagged-as-unused properties and operations from that ID override data. */
 void BKE_lib_override_library_id_unused_cleanup(struct ID *local)
 {
-  if (ID_IS_OVERRIDE_LIBRARY(local)) {
+  if (ID_IS_OVERRIDE_LIBRARY_REAL(local)) {
     LISTBASE_FOREACH_MUTABLE (
         IDOverrideLibraryProperty *, op, &local->override_library->properties) {
       if (op->tag & IDOVERRIDE_LIBRARY_TAG_UNUSED) {
@@ -929,7 +930,7 @@ void BKE_lib_override_library_main_unused_cleanup(struct Main *bmain)
 /** Update given override from its reference (re-applying overridden properties). */
 void BKE_lib_override_library_update(Main *bmain, ID *local)
 {
-  if (!ID_IS_OVERRIDE_LIBRARY(local)) {
+  if (!ID_IS_OVERRIDE_LIBRARY_REAL(local)) {
     return;
   }
 
@@ -1055,12 +1056,12 @@ ID *BKE_lib_override_library_operations_store_start(Main *bmain,
                                                     OverrideLibraryStorage *override_storage,
                                                     ID *local)
 {
-  if (ID_IS_OVERRIDE_LIBRARY_TEMPLATE(local)) {
+  if (ID_IS_OVERRIDE_LIBRARY_TEMPLATE(local) || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(local)) {
     /* This is actually purely local data with an override template, nothing to do here! */
     return NULL;
   }
 
-  BLI_assert(ID_IS_OVERRIDE_LIBRARY(local));
+  BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(local));
   BLI_assert(override_storage != NULL);
 
   /* Forcefully ensure we know about all needed override operations. */
@@ -1106,7 +1107,7 @@ ID *BKE_lib_override_library_operations_store_start(Main *bmain,
 void BKE_lib_override_library_operations_store_end(
     OverrideLibraryStorage *UNUSED(override_storage), ID *local)
 {
-  BLI_assert(ID_IS_OVERRIDE_LIBRARY(local));
+  BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(local));
 
   /* Nothing else to do here really, we need to keep all temp override storage data-blocks in
    * memory until whole file is written anyway (otherwise we'd get mem pointers overlap...). */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 86e878147e5..4e0325e72fa 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -4071,7 +4071,7 @@ static bool write_file_handle(Main *mainvar,
             (id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
 
         const bool do_override = !ELEM(override_storage, NULL, bmain) &&
-                                 ID_IS_OVERRIDE_LIBRARY(id);
+                                 ID_IS_OVERRIDE_LIBRARY_REAL(id);
 
         if (do_override) {
           BKE_lib_override_library_operations_store_start(bmain, override_storage, id);
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index ed2d3671b6b..60cedfe3c8a 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -470,8 +470,15 @@ typedef enum ID_Type {
 #define ID_IS_OVERRIDABLE_LIBRARY(_id) \
   (ID_IS_LINKED(_id) && !ID_MISSING(_id) && (((const ID *)(_id))->tag & LIB_TAG_EXTERN) != 0)
 
+#define ID_IS_OVERRIDE_LIBRARY_REAL(_id) \
+  (((const ID *)(_id))->override_library != NULL && \
+   ((const ID *)(_id))->override_library->reference != NULL)
+
+#define ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id) \
+  ((((const ID *)(_id))->flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE) != 0)
+
 #define ID_IS_OVERRIDE_LIBRARY(_id) \
-  (((const ID *)(_id))->override_library != NULL && ((const ID *)(_id))->override_library->reference != NULL)
+  (ID_IS_OVERRIDE_LIBRARY_REAL(_id) || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(_id))
 
 #define ID_IS_OVERRIDE_LIBRARY_TEMPLATE(_id) \
   (((ID *)(_id))->override_library != NULL && ((ID *)(_id))->override_library->reference == NULL)
@@ -509,6 +516,11 @@ enum {
    * we want to restore if possible, and silently drop if it's missing.
    */
   LIB_INDIRECT_WEAK_LINK = 1 << 11,
+  /**
+   * The data-block is a sub-data of another one, which is an override.
+   * Note that this also applies to shapekeys, even though they are not 100% embedded data...
+   */
+  LIB_EMBEDDED_DATA_LIB_OVERRIDE = 1 << 12,
 };
 
 /**



More information about the Bf-blender-cvs mailing list