Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-07-27 09:53:32 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-07-27 09:53:32 +0300
commit9b867f2e90bd5ba9c2e37ed39cf8b1ad28e39b07 (patch)
tree0c6f5c7555e21aae410de7279a5642d4ab333252 /source/blender/depsgraph/intern/builder/deg_builder_rna.cc
parent3bcec7c1420b5401dbe87286bc3be8c5063cf1f4 (diff)
Fix T79121: Dependency cycle when driver points to prop with 'scale' in name
This makes `RNANodeQuery::construct_node_identifier()` more strict in its matching of certain property names. The downside of this approach is that it's not possible any more to use `"rotation"` and expect a match for `"rotation_euler"` and friends, so the list of strings to test against is now 3x as long. Reviewed By: sergey Maniphest Tasks: T79121 Differential Revision: https://developer.blender.org/D8375
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder_rna.cc')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 98ae653d294..e3b667427a2 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -149,6 +149,25 @@ Node *RNANodeQuery::find_node(const PointerRNA *ptr,
node_identifier.operation_name_tag);
}
+bool RNANodeQuery::contains(const char *prop_identifier, const char *rna_path_component)
+{
+ const char *substr = strstr(prop_identifier, rna_path_component);
+ if (substr == nullptr) {
+ return false;
+ }
+
+ // If substr != prop_identifier, it means that the substring is found further in prop_identifier,
+ // and that thus index -1 is a valid memory location.
+ const bool start_ok = substr == prop_identifier || substr[-1] == '.';
+ if (!start_ok) {
+ return false;
+ }
+
+ const size_t component_len = strlen(rna_path_component);
+ const bool end_ok = ELEM(substr[component_len], '\0', '.', '[');
+ return end_ok;
+}
+
RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
const PropertyRNA *prop,
RNAPointerSource source)
@@ -283,12 +302,20 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
if (prop != nullptr) {
const char *prop_identifier = RNA_property_identifier((PropertyRNA *)prop);
/* TODO(sergey): How to optimize this? */
- if (strstr(prop_identifier, "location") || strstr(prop_identifier, "rotation") ||
- strstr(prop_identifier, "scale") || strstr(prop_identifier, "matrix_")) {
+ if (contains(prop_identifier, "location") || contains(prop_identifier, "matrix_basis") ||
+ contains(prop_identifier, "matrix_channel") ||
+ contains(prop_identifier, "matrix_inverse") ||
+ contains(prop_identifier, "matrix_local") ||
+ contains(prop_identifier, "matrix_parent_inverse") ||
+ contains(prop_identifier, "matrix_world") ||
+ contains(prop_identifier, "rotation_axis_angle") ||
+ contains(prop_identifier, "rotation_euler") ||
+ contains(prop_identifier, "rotation_mode") ||
+ contains(prop_identifier, "rotation_quaternion") || contains(prop_identifier, "scale")) {
node_identifier.type = NodeType::TRANSFORM;
return node_identifier;
}
- else if (strstr(prop_identifier, "data")) {
+ else if (contains(prop_identifier, "data")) {
/* We access object.data, most likely a geometry.
* Might be a bone tho. */
node_identifier.type = NodeType::GEOMETRY;