[Bf-blender-cvs] [11c19c24bd6] master: Cleanup/Update comments in liboverride code.

Bastien Montagne noreply at git.blender.org
Tue Nov 10 15:31:10 CET 2020


Commit: 11c19c24bd67e5adf14dc34f18e4b27141878fb2
Author: Bastien Montagne
Date:   Tue Nov 10 15:30:36 2020 +0100
Branches: master
https://developer.blender.org/rB11c19c24bd67e5adf14dc34f18e4b27141878fb2

Cleanup/Update comments in liboverride code.

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

M	source/blender/blenkernel/intern/lib_override.c

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

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index aa5e28b35bf..c9776b1a6a5 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -129,8 +129,8 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f
     BKE_lib_override_library_init(dst_id, NULL);
   }
 
-  /* Source is already overriding data, we copy it but reuse its reference for dest ID.
-   * otherwise, source is only an override template, it then becomes reference of dest ID. */
+  /* If source is already overriding data, we copy it but reuse its reference for dest ID.
+   * Otherwise, source is only an override template, it then becomes reference of dest ID. */
   dst_id->override_library->reference = src_id->override_library->reference ?
                                             src_id->override_library->reference :
                                             (ID *)src_id;
@@ -232,7 +232,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
     FOREACH_MAIN_ID_BEGIN (bmain, other_id) {
       if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib == NULL) {
         /* Note that using ID_REMAP_SKIP_INDIRECT_USAGE below is superfluous, as we only remap
-         * local IDs usages anyway... */
+         * local IDs usages anyway. */
         BKE_libblock_relink_ex(bmain,
                                other_id,
                                reference_id,
@@ -256,7 +256,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
 /**
  * Create overridden local copies of all tagged data-blocks in given Main.
  *
- * \note Set id->newid of overridden libs with newly created overrides,
+ * \note Set `id->newid` of overridden libs with newly created overrides,
  * caller is responsible to clean those pointers before/after usage as needed.
  *
  * \note By default, it will only remap newly created local overriding data-blocks between
@@ -289,13 +289,14 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain)
   for (todo_id_iter = todo_ids.first; todo_id_iter != NULL; todo_id_iter = todo_id_iter->next) {
     reference_id = todo_id_iter->data;
     if (reference_id->newid == NULL) {
-      /* If newid is already set, assume it has been handled by calling code.
+      /* If `newid` is already set, assume it has been handled by calling code.
        * Only current use case: re-using proxy ID when converting to liboverride. */
       if ((reference_id->newid = lib_override_library_create_from(bmain, reference_id)) == NULL) {
         success = false;
         break;
       }
-    } /* We also tag the new IDs so that in next step we can remap their pointers too. */
+    }
+    /* We also tag the new IDs so that in next step we can remap their pointers too. */
     reference_id->newid->tag |= LIB_TAG_DOIT;
 
     Key *reference_key;
@@ -333,7 +334,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain)
       FOREACH_MAIN_ID_BEGIN (bmain, other_id) {
         if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib == NULL) {
           /* Note that using ID_REMAP_SKIP_INDIRECT_USAGE below is superfluous, as we only remap
-           * local IDs usages anyway... */
+           * local IDs usages anyway. */
           BKE_libblock_relink_ex(bmain,
                                  other_id,
                                  reference_id,
@@ -381,7 +382,7 @@ static bool lib_override_hierarchy_recursive_tag(Main *bmain,
     id->tag |= tag;
   }
 
-  /* This way we won't process again that ID should we encounter it again through another
+  /* This way we won't process again that ID, should we encounter it again through another
    * relationship hierarchy.
    * Note that this does not free any memory from relations, so we can still use the entries.
    */
@@ -436,7 +437,7 @@ void BKE_lib_override_library_dependencies_tag(Main *bmain,
 
 /**
  * Tag all IDs in given \a bmain that are part of the same \a id_root liboverride ID group.
- * That is, all other liboverrides IDs (in)directly used by \a is_root one, sharing the same
+ * That is, all other liboverride IDs (in)directly used by \a is_root one, and sharing the same
  * library for their reference IDs.
  *
  * \param id_root: The root of the hierarchy of liboverride dependencies to be tagged.
@@ -481,8 +482,7 @@ static int lib_override_library_make_tag_ids_cb(LibraryIDLinkCallbackData *cb_da
   BLI_assert(id_owner->lib == library_root);
 
   if (id->tag & LIB_TAG_DOIT) {
-    /* Already processed, but maybe not with the same chain of dependency, so we need to check that
-     * one nonetheless. */
+    /* Already processed and tagged, nothing else to do here. */
     return IDWALK_RET_STOP_RECURSION;
   }
 
@@ -492,7 +492,7 @@ static int lib_override_library_make_tag_ids_cb(LibraryIDLinkCallbackData *cb_da
   }
 
   /* We tag all collections and objects for override. And we also tag all other data-blocks which
-   * would user one of those. */
+   * would use one of those. */
   if (ELEM(GS(id->name), ID_OB, ID_GR)) {
     id->tag |= LIB_TAG_DOIT;
   }
@@ -502,12 +502,12 @@ static int lib_override_library_make_tag_ids_cb(LibraryIDLinkCallbackData *cb_da
 
 static bool lib_override_library_create_do(Main *bmain, ID *id_root)
 {
-  /* Tag all collections and objects, as well as other IDs using them. */
   id_root->tag |= LIB_TAG_DOIT;
 
   BKE_main_relations_create(bmain, 0);
 
   if (ELEM(GS(id_root->name), ID_OB, ID_GR)) {
+    /* Tag all collections and objects. */
     BKE_library_foreach_ID_link(bmain,
                                 id_root,
                                 lib_override_library_make_tag_ids_cb,
@@ -515,7 +515,7 @@ static bool lib_override_library_create_do(Main *bmain, ID *id_root)
                                 IDWALK_READONLY | IDWALK_RECURSE);
 
     /* Then, we remove (untag) bone shape objects, you shall never want to override those
-     * (hopefully)... */
+     * (hopefully). */
     LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
       if (ob->type == OB_ARMATURE && ob->pose != NULL && (ob->id.tag & LIB_TAG_DOIT)) {
         for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
@@ -527,6 +527,10 @@ static bool lib_override_library_create_do(Main *bmain, ID *id_root)
     }
   }
 
+  /* Now tag all non-object/collection IDs 'in-between' two tagged ones, as those are part of an
+   * override chain and therefore alos need to be overridden.
+   * One very common cases are e.g. drivers on geometry or materials of an overridden object, that
+   * are using another overridden object as parameter. */
   /* Note that this call will also free the main relations data we created above. */
   BKE_lib_override_library_dependencies_tag(bmain, id_root, LIB_TAG_DOIT, false);
 
@@ -636,16 +640,13 @@ static void lib_override_library_create_post_process(
  * \note Currently it only does special things if given \a id_root is an object of collection, more
  * specific behaviors may be added in the future for other ID types.
  *
- * \note It will overrides all IDs tagged with \a LIB_TAG_DOIT, and it does not clear that tag at
+ * \note It will override all IDs tagged with \a LIB_TAG_DOIT, and it does not clear that tag at
  * its beginning, so caller code can add extra data-blocks to be overridden as well.
  *
- * \note In the future that same function may be extended to support 'refresh' of overrides
- * (rebuilding overrides from linked data, trying to preserve local overrides already defined).
- *
  * \param id_root: The root ID to create an override from.
  * \param id_reference: Some reference ID used to do some post-processing after overrides have been
- * created, may be NULL. Typically, the Empty object instantiating the linked
- * collection we override, currently.
+ * created, may be NULL. Typically, the Empty object instantiating the linked collection we
+ * override, currently.
  * \return true if override was successfully created.
  */
 bool BKE_lib_override_library_create(
@@ -667,10 +668,10 @@ bool BKE_lib_override_library_create(
 }
 
 /**
- * Converts a given proxy object into a library override.
+ * Convert a given proxy object into a library override.
  *
- * \note This is actually a thin wrapper around \a BKE_lib_override_library_create, only extra work
- * is to actually convert the proxy itself into an override first.
+ * \note This is a thin wrapper around \a BKE_lib_override_library_create, only extra work is to
+ * actually convert the proxy itself into an override first.
  *
  * \return true if override was successfully created.
  */
@@ -679,7 +680,7 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
                                             ViewLayer *view_layer,
                                             Object *ob_proxy)
 {
-  /* proxy_group, if defined, is the empty instantiating the collection from which the proxy is
+  /* `proxy_group`, if defined, is the empty instantiating the collection from which the proxy is
    * coming. */
   Object *ob_proxy_group = ob_proxy->proxy_group;
   const bool is_override_instancing_object = ob_proxy_group != NULL;
@@ -688,7 +689,8 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
   ID *id_reference = is_override_instancing_object ? &ob_proxy_group->id : &ob_proxy->id;
 
   /* We manually convert the proxy object into a library override, further override handling will
-   * then be handled by BKE_lib_override_library_create() just as for a regular override creation.
+   * then be handled by `BKE_lib_override_library_create()` just as for a regular override
+   * creation.
    */
   ob_proxy->proxy->id.tag |= LIB_TAG_DOIT;
   ob_proxy->proxy->id.newid = &ob_proxy->id;
@@ -728,7 +730,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_
     if (id->tag & LIB_TAG_DOIT && ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
       /* While this should not happen in typical cases (and won't be properly supported here), user
        * is free to do all kind of very bad things, including having different local overrides of a
-       * same linked ID in a same hierarchy... */
+       * same linked ID in a same

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list