diff options
Diffstat (limited to 'scene/property_utils.cpp')
-rw-r--r-- | scene/property_utils.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scene/property_utils.cpp b/scene/property_utils.cpp index db17f9d643..94a037bd9b 100644 --- a/scene/property_utils.cpp +++ b/scene/property_utils.cpp @@ -44,6 +44,7 @@ bool PropertyUtils::is_property_value_different(const Object *p_object, const Va // This must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error. return !Math::is_equal_approx((float)p_a, (float)p_b); } else if (p_a.get_type() == Variant::NODE_PATH && p_b.get_type() == Variant::OBJECT) { + // With properties of type Node, left side is NodePath, while right side is Node. const Node *base_node = Object::cast_to<Node>(p_object); const Node *target_node = Object::cast_to<Node>(p_b); if (base_node && target_node) { @@ -51,6 +52,23 @@ bool PropertyUtils::is_property_value_different(const Object *p_object, const Va } } + if (p_a.get_type() == Variant::ARRAY && p_b.get_type() == Variant::ARRAY) { + const Node *base_node = Object::cast_to<Node>(p_object); + Array array1 = p_a; + Array array2 = p_b; + + if (base_node && !array1.is_empty() && array2.size() == array1.size() && array1[0].get_type() == Variant::NODE_PATH && array2[0].get_type() == Variant::OBJECT) { + // Like above, but NodePaths/Nodes are inside arrays. + for (int i = 0; i < array1.size(); i++) { + const Node *target_node = Object::cast_to<Node>(array2[i]); + if (!target_node || array1[i] != base_node->get_path_to(target_node)) { + return true; + } + } + return false; + } + } + // For our purposes, treating null object as NIL is the right thing to do const Variant &a = p_a.get_type() == Variant::OBJECT && (Object *)p_a == nullptr ? Variant() : p_a; const Variant &b = p_b.get_type() == Variant::OBJECT && (Object *)p_b == nullptr ? Variant() : p_b; |