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...
This commit is contained in:
2020-04-11 17:12:56 +02:00
parent 5cc7036aa3
commit 85de07e64c
6 changed files with 95 additions and 48 deletions

View File

@@ -98,18 +98,28 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
WaveModifierData *wmd = (WaveModifierData *)md;
bool need_transform_relation = false;
if (wmd->objectcenter != NULL) {
DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
}
MOD_depsgraph_update_object_bone_relation(
ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier");
if (wmd->objectcenter != NULL || wmd->map_object != NULL) {
DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier");
need_transform_relation = true;
}
if (wmd->texture != NULL) {
DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier");
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) {
MOD_depsgraph_update_object_bone_relation(
ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier");
need_transform_relation = true;
}
else if (wmd->texmapping == MOD_DISP_MAP_GLOBAL) {
need_transform_relation = true;
}
}
if (need_transform_relation) {
DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier");
}
}