From 85de07e64c967e7d80e57d3df2db08fdec16794a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 11 Apr 2020 17:12:56 +0200 Subject: Sanitize and cleanup a bit depsgraph relations building in some modifiers. This commit mainly: * Removes some uneeded dependencies to geometry of other objects (since we only use positions of those objects...). * Ensures `DEG_add_modifier_to_transform_relation` is only called once per modifier (in one case at least it could be called twice). * For modifiers using texture mask, only add dependencies to object used to generate texture coordinates when there is actually a texture set. No behavior change expected from this commit... --- source/blender/modifiers/intern/MOD_displace.c | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source/blender/modifiers/intern/MOD_displace.c') diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index b074e398ab6..19a4e855153 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -134,19 +134,28 @@ static bool isDisabled(const struct Scene *UNUSED(scene), static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { DisplaceModifierData *dmd = (DisplaceModifierData *)md; - if (dmd->map_object != NULL && dmd->texmapping == MOD_DISP_MAP_OBJECT) { - MOD_depsgraph_update_object_bone_relation( - ctx->node, dmd->map_object, dmd->map_bone, "Displace Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier"); - } - if (dmd->texmapping == MOD_DISP_MAP_GLOBAL || - (ELEM( - dmd->direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ) && - dmd->space == MOD_DISP_SPACE_GLOBAL)) { - DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier"); + bool need_transform_relation = false; + + if (dmd->space == MOD_DISP_SPACE_GLOBAL && + ELEM(dmd->direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ)) { + need_transform_relation = true; } + if (dmd->texture != NULL) { DEG_add_generic_id_relation(ctx->node, &dmd->texture->id, "Displace Modifier"); + + if (dmd->map_object != NULL && dmd->texmapping == MOD_DISP_MAP_OBJECT) { + MOD_depsgraph_update_object_bone_relation( + ctx->node, dmd->map_object, dmd->map_bone, "Displace Modifier"); + need_transform_relation = true; + } + if (dmd->texmapping == MOD_DISP_MAP_GLOBAL) { + need_transform_relation = true; + } + } + + if (need_transform_relation) { + DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier"); } } -- cgit v1.2.3