diff options
author | Bastien Montagne <bastien@blender.org> | 2020-04-11 18:12:56 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-04-11 18:16:58 +0300 |
commit | 85de07e64c967e7d80e57d3df2db08fdec16794a (patch) | |
tree | 37497e1e0ee9924e947c1c93332eaf0b7dae3c8d /source/blender/modifiers/intern/MOD_displace.c | |
parent | 5cc7036aa39506f3af3608ad450f1fdf6b2f3347 (diff) |
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...
Diffstat (limited to 'source/blender/modifiers/intern/MOD_displace.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_displace.c | 29 |
1 files changed, 19 insertions, 10 deletions
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"); } } |