[Bf-blender-cvs] [26e08cbeb88] blender-v2.93-release: Depsgraph: fix spurious cycles with identically named idprops on bones.
Alexander Gavrilov
noreply at git.blender.org
Fri Dec 2 12:06:27 CET 2022
Commit: 26e08cbeb885a51c8222b7df32b6e04567c88d48
Author: Alexander Gavrilov
Date: Tue Jan 4 14:28:37 2022 +0300
Branches: blender-v2.93-release
https://developer.blender.org/rB26e08cbeb885a51c8222b7df32b6e04567c88d48
Depsgraph: fix spurious cycles with identically named idprops on bones.
If multiple bones have a custom property with the same name,
depsgraph didn't distinguish between them, potentially leading
to spurious cycles.
This patch moves ID_PROPERTY operation nodes for bone custom
properties from the parameters component to individual bone
components, thus decoupling them.
Differential Revision: https://developer.blender.org/D13729
===================================================================
M source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M source/blender/depsgraph/intern/builder/deg_builder_rna.cc
===================================================================
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 930db0403ff..a33e6257d7b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -251,6 +251,21 @@ OperationNode *DepsgraphNodeBuilder::add_operation_node(ID *id,
return add_operation_node(id, comp_type, "", opcode, op, name, name_tag);
}
+OperationNode *DepsgraphNodeBuilder::ensure_operation_node(ID *id,
+ NodeType comp_type,
+ const char *comp_name,
+ OperationCode opcode,
+ const DepsEvalOperationCb &op,
+ const char *name,
+ int name_tag)
+{
+ OperationNode *operation = find_operation_node(id, comp_type, comp_name, opcode, name, name_tag);
+ if (operation != nullptr) {
+ return operation;
+ }
+ return add_operation_node(id, comp_type, comp_name, opcode, op, name, name_tag);
+}
+
OperationNode *DepsgraphNodeBuilder::ensure_operation_node(ID *id,
NodeType comp_type,
OperationCode opcode,
@@ -1081,8 +1096,16 @@ void DepsgraphNodeBuilder::build_driver_id_property(ID *id, const char *rna_path
return;
}
const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop);
- ensure_operation_node(
- id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, nullptr, prop_identifier);
+ /* Custom properties of bones are placed in their components to improve granularity. */
+ if (RNA_struct_is_a(ptr.type, &RNA_PoseBone)) {
+ const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr.data);
+ ensure_operation_node(
+ id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, nullptr, prop_identifier);
+ }
+ else {
+ ensure_operation_node(
+ id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, nullptr, prop_identifier);
+ }
}
void DepsgraphNodeBuilder::build_parameters(ID *id)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 7bbe130e8ff..3483a1856fa 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -126,6 +126,13 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
const char *name = "",
int name_tag = -1);
+ OperationNode *ensure_operation_node(ID *id,
+ NodeType comp_type,
+ const char *comp_name,
+ OperationCode opcode,
+ const DepsEvalOperationCb &op = nullptr,
+ const char *name = "",
+ int name_tag = -1);
OperationNode *ensure_operation_node(ID *id,
NodeType comp_type,
OperationCode opcode,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 48143aef09b..1f296a03f8f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1715,8 +1715,17 @@ void DepsgraphRelationBuilder::build_driver_id_property(ID *id, const char *rna_
return;
}
const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop);
- OperationKey id_property_key(
- id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, prop_identifier);
+ /* Custom properties of bones are placed in their components to improve granularity. */
+ OperationKey id_property_key;
+ if (RNA_struct_is_a(ptr.type, &RNA_PoseBone)) {
+ const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr.data);
+ id_property_key = OperationKey(
+ id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, prop_identifier);
+ }
+ else {
+ id_property_key = OperationKey(
+ id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, prop_identifier);
+ }
OperationKey parameters_exit_key(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
add_relation(
id_property_key, parameters_exit_key, "ID Property -> Done", RELATION_CHECK_BEFORE_ADD);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 54c51adec66..95a57b0388f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -181,7 +181,15 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
node_identifier.operation_name_tag = -1;
/* Handling of commonly known scenarios. */
if (prop != nullptr && RNA_property_is_idprop(prop)) {
- node_identifier.type = NodeType::PARAMETERS;
+ /* Custom properties of bones are placed in their components to improve granularity. */
+ if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
+ const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr->data);
+ node_identifier.type = NodeType::BONE;
+ node_identifier.component_name = pchan->name;
+ }
+ else {
+ node_identifier.type = NodeType::PARAMETERS;
+ }
node_identifier.operation_code = OperationCode::ID_PROPERTY;
node_identifier.operation_name = RNA_property_identifier(
reinterpret_cast<const PropertyRNA *>(prop));
More information about the Bf-blender-cvs
mailing list