From f0abda999e179faf1577026d0369062349cb4897 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 12 Jun 2016 19:33:07 -0300 Subject: [PATCH] resolve numerical error when comparing instancing an inheritance to avoid saving changed properties when they didn't, closes 4759 --- scene/resources/packed_scene.cpp | 16 +++++++++++++--- tools/editor/property_editor.cpp | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 5df22ba8cc0..5ac79463913 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -545,9 +545,19 @@ https://github.com/godotengine/godot/issues/3127 } #endif - if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) { - //exists and did not change - continue; + if (exists) { + + //check if already exists and did not change + if (value.get_type()==Variant::REAL && original.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 + float a = value; + float b = original; + + if (Math::abs(a-b)CMP_EPSILON; //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error + } + return bool(Variant::evaluate(Variant::OP_NOT_EQUAL,p_current,p_orig)); } @@ -2232,6 +2239,7 @@ void PropertyEditor::_check_reload_status(const String&p_name, TreeItem* item) { if (_get_instanced_node_original_property(p_name,vorig) || usage) { Variant v = obj->get(p_name); + bool changed = _is_property_different(v,vorig,usage); //if ((found!=-1 && !is_disabled)!=changed) {