[Bf-blender-cvs] [95f8f321b6f] master: Refactor: libquery: Add Material foreach_id support.

Bastien Montagne noreply at git.blender.org
Thu May 7 17:32:39 CEST 2020


Commit: 95f8f321b6f5225febbfdd8846f37e2049e55fa2
Author: Bastien Montagne
Date:   Thu May 7 16:48:43 2020 +0200
Branches: master
https://developer.blender.org/rB95f8f321b6f5225febbfdd8846f37e2049e55fa2

Refactor: libquery: Add Material foreach_id support.

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

M	source/blender/blenkernel/intern/lib_query.c
M	source/blender/blenkernel/intern/material.c

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

diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 9ebcc80092e..27667b1e110 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -976,18 +976,7 @@ static void library_foreach_ID_link(Main *bmain,
       }
 
       case ID_MA: {
-        Material *material = (Material *)id;
-        if (material->nodetree) {
-          /* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
-          BKE_library_foreach_ID_embedded(&data, (ID **)&material->nodetree);
-        }
-        if (material->texpaintslot != NULL) {
-          CALLBACK_INVOKE(material->texpaintslot->ima, IDWALK_CB_NOP);
-        }
-        if (material->gp_style != NULL) {
-          CALLBACK_INVOKE(material->gp_style->sima, IDWALK_CB_USER);
-          CALLBACK_INVOKE(material->gp_style->ima, IDWALK_CB_USER);
-        }
+        BLI_assert(0);
         break;
       }
 
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 440f46f4f7c..d4de04a9e98 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -64,6 +64,7 @@
 #include "BKE_idtype.h"
 #include "BKE_image.h"
 #include "BKE_lib_id.h"
+#include "BKE_lib_query.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
@@ -143,6 +144,22 @@ static void material_free_data(ID *id)
   BKE_previewimg_free(&material->preview);
 }
 
+static void material_foreach_id(ID *id, LibraryForeachIDData *data)
+{
+  Material *material = (Material *)id;
+  /* Nodetrees **are owned by IDs**, treat them as mere sub-data and not real ID! */
+  if (!BKE_library_foreach_ID_embedded(data, (ID **)&material->nodetree)) {
+    return;
+  }
+  if (material->texpaintslot != NULL) {
+    BKE_LIB_FOREACHID_PROCESS(data, material->texpaintslot->ima, IDWALK_CB_NOP);
+  }
+  if (material->gp_style != NULL) {
+    BKE_LIB_FOREACHID_PROCESS(data, material->gp_style->sima, IDWALK_CB_USER);
+    BKE_LIB_FOREACHID_PROCESS(data, material->gp_style->ima, IDWALK_CB_USER);
+  }
+}
+
 IDTypeInfo IDType_ID_MA = {
     .id_code = ID_MA,
     .id_filter = FILTER_ID_MA,
@@ -157,6 +174,7 @@ IDTypeInfo IDType_ID_MA = {
     .copy_data = material_copy_data,
     .free_data = material_free_data,
     .make_local = NULL,
+    .foreach_id = material_foreach_id,
 };
 
 void BKE_gpencil_material_attr_init(Material *ma)



More information about the Bf-blender-cvs mailing list