resolve numerical error when comparing instancing an inheritance to avoid saving changed properties when they didn't, closes 4759
(cherry picked from commit f0abda999e
)
This commit is contained in:
parent
6525e0017c
commit
b075525e84
|
@ -545,9 +545,19 @@ https://github.com/godotengine/godot/issues/3127
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) {
|
if (exists) {
|
||||||
//exists and did not change
|
|
||||||
|
//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)
|
||||||
continue;
|
continue;
|
||||||
|
} else if (bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists && isdefault) {
|
if (!exists && isdefault) {
|
||||||
|
|
|
@ -1885,6 +1885,13 @@ bool PropertyEditor::_is_property_different(const Variant& p_current, const Vari
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p_current.get_type()==Variant::REAL && p_orig.get_type()==Variant::REAL) {
|
||||||
|
float a = p_current;
|
||||||
|
float b = p_orig;
|
||||||
|
|
||||||
|
return 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));
|
return bool(Variant::evaluate(Variant::OP_NOT_EQUAL,p_current,p_orig));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2149,6 +2156,7 @@ void PropertyEditor::_check_reload_status(const String&p_name, TreeItem* item) {
|
||||||
if (_get_instanced_node_original_property(p_name,vorig) || usage) {
|
if (_get_instanced_node_original_property(p_name,vorig) || usage) {
|
||||||
Variant v = obj->get(p_name);
|
Variant v = obj->get(p_name);
|
||||||
|
|
||||||
|
|
||||||
bool changed = _is_property_different(v,vorig,usage);
|
bool changed = _is_property_different(v,vorig,usage);
|
||||||
|
|
||||||
//if ((found!=-1 && !is_disabled)!=changed) {
|
//if ((found!=-1 && !is_disabled)!=changed) {
|
||||||
|
|
Loading…
Reference in New Issue