Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-12-30 14:48:51 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-01-11 12:13:10 +0300
commit6bd924c748ace7fac87b33f46bb0467f3ea2701a (patch)
tree8c407f8ff172dfca143987c203b35ebb00d33af7
parente8a8e953b3d11bf99f4835b082fec9e2bf2be468 (diff)
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.
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c15
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h2
2 files changed, 11 insertions, 6 deletions
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,