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:
authorPeter Klimenko <peterklimk@outlook.com>2020-07-31 11:45:15 +0300
committerPeter Klimenko <peterklimk@outlook.com>2020-07-31 11:45:15 +0300
commit97a4a8d0fb7fd9ac34f9f5d4d5a0689c01235e14 (patch)
treefc9746d2210eda08be9d44ae67d5e58d64b48b40 /source/blender/depsgraph/intern/builder/deg_builder_rna.cc
parent4a7c203e9ecc7c5b0370afc0fdd6bcc183dc00df (diff)
parentf3e8326453ae856d7914e45e832a2ed80aa9a9b9 (diff)
merge
Diffstat (limited to 'source/blender/depsgraph/intern/builder/deg_builder_rna.cc')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_rna.cc41
1 files changed, 35 insertions, 6 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index fbd53bf46f8..e3b667427a2 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -48,7 +48,8 @@
#include "intern/node/deg_node_id.h"
#include "intern/node/deg_node_operation.h"
-namespace DEG {
+namespace blender {
+namespace deg {
/* ********************************* ID Data ******************************** */
@@ -148,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)
@@ -282,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;
@@ -365,8 +393,9 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
RNANodeQueryIDData *RNANodeQuery::ensure_id_data(const ID *id)
{
unique_ptr<RNANodeQueryIDData> &id_data = id_data_map_.lookup_or_add_cb(
- id, [&]() { return blender::make_unique<RNANodeQueryIDData>(id); });
+ id, [&]() { return std::make_unique<RNANodeQueryIDData>(id); });
return id_data.get();
}
-} // namespace DEG
+} // namespace deg
+} // namespace blender