[Bf-blender-cvs] [6bd924c748a] blender-v3.0-release: Fix T93868: GPencil material filter does not work with instances

Antonio Vazquez noreply at git.blender.org
Tue Jan 11 10:38:38 CET 2022


Commit: 6bd924c748ace7fac87b33f46bb0467f3ea2701a
Author: Antonio Vazquez
Date:   Thu Dec 30 12:48:51 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB6bd924c748ace7fac87b33f46bb0467f3ea2701a

Fix T93868: GPencil material filter does not work with instances

When the material is used in several objects, the filter by material is not working as expected because the internal pointers are different due eval version.

Now, the original version of the material is compared to keep same address.

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

M	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 9ea146c77f2..818effc98bb 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -40,6 +40,8 @@
 #include "MOD_gpencil_modifiertypes.h"
 #include "MOD_gpencil_util.h"
 
+#include "DEG_depsgraph_query.h"
+
 void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
 {
 #define INIT_GP_TYPE(typeName) \
@@ -73,7 +75,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
 /* verify if valid layer, material and pass index */
 bool is_stroke_affected_by_modifier(Object *ob,
                                     char *mlayername,
-                                    const Material *material,
+                                    Material *material,
                                     const int mpassindex,
                                     const int gpl_passindex,
                                     const int minpoints,
@@ -84,8 +86,8 @@ bool is_stroke_affected_by_modifier(Object *ob,
                                     const bool inv3,
                                     const bool inv4)
 {
-  Material *ma = BKE_gpencil_material(ob, gps->mat_nr + 1);
-  MaterialGPencilStyle *gp_style = ma->gp_style;
+  Material *ma_gps = BKE_gpencil_material(ob, gps->mat_nr + 1);
+  MaterialGPencilStyle *gp_style = ma_gps->gp_style;
 
   /* omit if filter by layer */
   if (mlayername[0] != '\0') {
@@ -102,13 +104,16 @@ bool is_stroke_affected_by_modifier(Object *ob,
   }
   /* Omit if filter by material. */
   if (material != NULL) {
+    /* Requires to use the original material to compare the same pointer address. */
+    Material *ma_md_orig = (Material *)DEG_get_original_id(&material->id);
+    Material *ma_gps_orig = (Material *)DEG_get_original_id(&ma_gps->id);
     if (inv4 == false) {
-      if (material != ma) {
+      if (ma_md_orig != ma_gps_orig) {
         return false;
       }
     }
     else {
-      if (material == ma) {
+      if (ma_md_orig == ma_gps_orig) {
         return false;
       }
     }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
index 2878ad4c73a..30e54f44499 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
@@ -31,7 +31,7 @@ struct bGPDstroke;
 
 bool is_stroke_affected_by_modifier(struct Object *ob,
                                     char *mlayername,
-                                    const struct Material *material,
+                                    struct Material *material,
                                     const int mpassindex,
                                     const int gpl_passindex,
                                     const int minpoints,



More information about the Bf-blender-cvs mailing list