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.
This commit is contained in:
parent
52da1afbf6
commit
e0d1e66732
Notes:
blender-bot
2023-02-14 06:46:23 +01:00
Referenced by issue #94495, Geometry nodes: Split edges node leads to a crash in edit mode Referenced by issue #93868, Grease pencil hue and tint modifiers don't work with selected material Referenced by issue #93479, 3.0 Potential candidates for corrective releases
|
@ -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[])
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,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,
|
||||
|
|
Loading…
Reference in New Issue