Depsgraph: Fix for fake dependency cycle being created for shape key drivers
One thing i'm not fully happy with is all this is_same_* functions. Need to get rid of this by probably adding explicit entry/init/whatever nodes and maybe making node criteria aware of whether key will be used as "from" or as "to" node.
This commit is contained in:
parent
5d4ffb42a3
commit
46204f843b
|
@ -1178,7 +1178,8 @@ void DepsgraphRelationBuilder::build_driver_variables(ID *id, FCurve *fcu)
|
|||
continue;
|
||||
}
|
||||
if (is_same_bone_dependency(variable_key, self_key) ||
|
||||
is_nodetree_node_dependency(variable_key, self_key))
|
||||
is_same_nodetree_node_dependency(variable_key, self_key) ||
|
||||
is_same_shapekey_dependency(variable_key, self_key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -276,6 +276,8 @@ protected:
|
|||
DepsNodeHandle create_node_handle(const KeyType& key,
|
||||
const char *default_name = "");
|
||||
|
||||
/* TODO(sergey): All those is_same* functions are to be generalized. */
|
||||
|
||||
/* Check whether two keys correponds to the same bone from same armature.
|
||||
*
|
||||
* This is used by drivers relations builder to avoid possible fake
|
||||
|
@ -289,7 +291,14 @@ protected:
|
|||
* the same node tree as a driver variable.
|
||||
*/
|
||||
template <typename KeyFrom, typename KeyTo>
|
||||
bool is_nodetree_node_dependency(const KeyFrom& key_from,
|
||||
bool is_same_nodetree_node_dependency(const KeyFrom& key_from,
|
||||
const KeyTo& key_to);
|
||||
|
||||
/* Similar to above, but used to check whether driver is using key from
|
||||
* the same key datablock as a driver variable.
|
||||
*/
|
||||
template <typename KeyFrom, typename KeyTo>
|
||||
bool is_same_shapekey_dependency(const KeyFrom& key_from,
|
||||
const KeyTo& key_to);
|
||||
|
||||
private:
|
||||
|
|
|
@ -164,7 +164,7 @@ bool DepsgraphRelationBuilder::is_same_bone_dependency(const KeyFrom& key_from,
|
|||
}
|
||||
|
||||
template <typename KeyFrom, typename KeyTo>
|
||||
bool DepsgraphRelationBuilder::is_nodetree_node_dependency(
|
||||
bool DepsgraphRelationBuilder::is_same_nodetree_node_dependency(
|
||||
const KeyFrom& key_from,
|
||||
const KeyTo& key_to)
|
||||
{
|
||||
|
@ -196,4 +196,31 @@ bool DepsgraphRelationBuilder::is_nodetree_node_dependency(
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename KeyFrom, typename KeyTo>
|
||||
bool DepsgraphRelationBuilder::is_same_shapekey_dependency(
|
||||
const KeyFrom& key_from,
|
||||
const KeyTo& key_to)
|
||||
{
|
||||
/* Get operations for requested keys. */
|
||||
DepsNode *node_from = get_node(key_from);
|
||||
DepsNode *node_to = get_node(key_to);
|
||||
if (node_from == NULL || node_to == NULL) {
|
||||
return false;
|
||||
}
|
||||
OperationDepsNode *op_from = node_from->get_exit_operation();
|
||||
OperationDepsNode *op_to = node_to->get_entry_operation();
|
||||
if (op_from == NULL || op_to == NULL) {
|
||||
return false;
|
||||
}
|
||||
/* Check if this is actually a shape key datablock. */
|
||||
if (GS(op_from->owner->owner->id->name) != ID_KE) {
|
||||
return false;
|
||||
}
|
||||
/* Different key data blocks. */
|
||||
if (op_from->owner->owner != op_to->owner->owner) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace DEG
|
||||
|
|
|
@ -468,6 +468,7 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx,
|
|||
deg_debug_fprintf(ctx, "[");
|
||||
/* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
|
||||
deg_debug_fprintf(ctx, "id=\"%s\"", rel->name);
|
||||
deg_debug_fprintf(ctx, "label=\"%s\"", rel->name);
|
||||
deg_debug_fprintf(ctx, ",color="); deg_debug_graphviz_relation_color(ctx, rel);
|
||||
deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
|
||||
/* NOTE: edge from node to own cluster is not possible and gives graphviz
|
||||
|
|
|
@ -192,11 +192,7 @@ static bool pointer_to_component_node_criteria(
|
|||
}
|
||||
}
|
||||
else if (ptr->type == &RNA_ShapeKey) {
|
||||
Key *key = (Key *)ptr->id.data;
|
||||
/* ShapeKeys are currently handled as geometry on the geometry that
|
||||
* owns it.
|
||||
*/
|
||||
*id = key->from;
|
||||
*id = (ID *)ptr->id.data;
|
||||
*type = DEG_NODE_TYPE_GEOMETRY;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue