/* property_utils.cpp */ #include "property_utils.h" #include "core/core_string_names.h" #include "core/config/engine.h" #include "core/containers/local_vector.h" #include "scene/resources/packed_scene.h" bool PropertyUtils::is_property_value_different(const Variant &p_a, const Variant &p_b) { if (p_a.get_type() == Variant::REAL && p_b.get_type() == Variant::REAL) { //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 { // 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; return !a.deep_equal(b); } } Variant PropertyUtils::get_property_default_value(const Object *p_object, const StringName &p_property, bool *r_is_valid, const Vector *p_states_stack_cache, bool p_update_exports, const Node *p_owner, bool *r_is_class_default) { // This function obeys the way property values are set when an object is instantiated, // which is the following (the latter wins): // 1. Default value from builtin class // 2. Default value from script exported variable (from the topmost script) // 3. Value overrides from the instantiation/inheritance stack if (r_is_class_default) { *r_is_class_default = false; } if (r_is_valid) { *r_is_valid = false; } Ref