diff options
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder_rna.cc')
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_rna.cc | 33 |
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; |