From f483460e389727cd29fdd53e212037934a0bd767 Mon Sep 17 00:00:00 2001 From: DualMatrix Date: Sat, 22 Sep 2018 22:31:56 +0200 Subject: Removed obsoleted core/helper/value_evaluator.h and moved math_fieldwise to core/math/ Removed obsoleted core/helper/value_evaluator.h and moved math_fieldwise to core/math/ --- core/helper/SCsub | 7 -- core/helper/math_fieldwise.cpp | 181 ----------------------------------------- core/helper/math_fieldwise.h | 42 ---------- core/helper/value_evaluator.h | 46 ----------- core/math/math_fieldwise.cpp | 181 +++++++++++++++++++++++++++++++++++++++++ core/math/math_fieldwise.h | 42 ++++++++++ editor/multi_node_edit.cpp | 2 +- editor/property_editor.cpp | 57 ------------- editor/property_editor.h | 21 ----- scene/gui/tree.cpp | 40 ++------- scene/gui/tree.h | 5 -- 11 files changed, 231 insertions(+), 393 deletions(-) delete mode 100644 core/helper/SCsub delete mode 100644 core/helper/math_fieldwise.cpp delete mode 100644 core/helper/math_fieldwise.h delete mode 100644 core/helper/value_evaluator.h create mode 100644 core/math/math_fieldwise.cpp create mode 100644 core/math/math_fieldwise.h diff --git a/core/helper/SCsub b/core/helper/SCsub deleted file mode 100644 index 4efc902717..0000000000 --- a/core/helper/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.core_sources, "*.cpp") - -Export('env') diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp deleted file mode 100644 index 20b2341ab0..0000000000 --- a/core/helper/math_fieldwise.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/*************************************************************************/ -/* math_fieldwise.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifdef TOOLS_ENABLED - -#include "math_fieldwise.h" - -#define SETUP_TYPE(m_type) \ - m_type source = p_source; \ - m_type target = p_target; -#define TRY_TRANSFER_FIELD(m_name, m_member) \ - if (p_field == m_name) { \ - target.m_member = source.m_member; \ - } - -Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field) { - - ERR_FAIL_COND_V(p_target.get_type() != p_source.get_type(), p_target); - - /* clang-format makes a mess of this macro usage */ - /* clang-format off */ - - switch (p_source.get_type()) { - - case Variant::VECTOR2: { - - SETUP_TYPE(Vector2) - - /**/ TRY_TRANSFER_FIELD("x", x) - else TRY_TRANSFER_FIELD("y", y) - - return target; - } - - case Variant::RECT2: { - - SETUP_TYPE(Rect2) - - /**/ TRY_TRANSFER_FIELD("x", position.x) - else TRY_TRANSFER_FIELD("y", position.y) - else TRY_TRANSFER_FIELD("w", size.x) - else TRY_TRANSFER_FIELD("h", size.y) - - return target; - } - - case Variant::VECTOR3: { - - SETUP_TYPE(Vector3) - - /**/ TRY_TRANSFER_FIELD("x", x) - else TRY_TRANSFER_FIELD("y", y) - else TRY_TRANSFER_FIELD("z", z) - - return target; - } - - case Variant::PLANE: { - - SETUP_TYPE(Plane) - - /**/ TRY_TRANSFER_FIELD("x", normal.x) - else TRY_TRANSFER_FIELD("y", normal.y) - else TRY_TRANSFER_FIELD("z", normal.z) - else TRY_TRANSFER_FIELD("d", d) - - return target; - } - - case Variant::QUAT: { - - SETUP_TYPE(Quat) - - /**/ TRY_TRANSFER_FIELD("x", x) - else TRY_TRANSFER_FIELD("y", y) - else TRY_TRANSFER_FIELD("z", z) - else TRY_TRANSFER_FIELD("w", w) - - return target; - } - - case Variant::AABB: { - - SETUP_TYPE(AABB) - - /**/ TRY_TRANSFER_FIELD("px", position.x) - else TRY_TRANSFER_FIELD("py", position.y) - else TRY_TRANSFER_FIELD("pz", position.z) - else TRY_TRANSFER_FIELD("sx", size.x) - else TRY_TRANSFER_FIELD("sy", size.y) - else TRY_TRANSFER_FIELD("sz", size.z) - - return target; - } - - case Variant::TRANSFORM2D: { - - SETUP_TYPE(Transform2D) - - /**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) - else TRY_TRANSFER_FIELD("xy", elements[0][1]) - else TRY_TRANSFER_FIELD("yx", elements[1][0]) - else TRY_TRANSFER_FIELD("yy", elements[1][1]) - else TRY_TRANSFER_FIELD("ox", elements[2][0]) - else TRY_TRANSFER_FIELD("oy", elements[2][1]) - - return target; - } - - case Variant::BASIS: { - - SETUP_TYPE(Basis) - - /**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) - else TRY_TRANSFER_FIELD("xy", elements[0][1]) - else TRY_TRANSFER_FIELD("xz", elements[0][2]) - else TRY_TRANSFER_FIELD("yx", elements[1][0]) - else TRY_TRANSFER_FIELD("yy", elements[1][1]) - else TRY_TRANSFER_FIELD("yz", elements[1][2]) - else TRY_TRANSFER_FIELD("zx", elements[2][0]) - else TRY_TRANSFER_FIELD("zy", elements[2][1]) - else TRY_TRANSFER_FIELD("zz", elements[2][2]) - - return target; - } - - case Variant::TRANSFORM: { - - SETUP_TYPE(Transform) - - /**/ TRY_TRANSFER_FIELD("xx", basis.elements[0][0]) - else TRY_TRANSFER_FIELD("xy", basis.elements[0][1]) - else TRY_TRANSFER_FIELD("xz", basis.elements[0][2]) - else TRY_TRANSFER_FIELD("yx", basis.elements[1][0]) - else TRY_TRANSFER_FIELD("yy", basis.elements[1][1]) - else TRY_TRANSFER_FIELD("yz", basis.elements[1][2]) - else TRY_TRANSFER_FIELD("zx", basis.elements[2][0]) - else TRY_TRANSFER_FIELD("zy", basis.elements[2][1]) - else TRY_TRANSFER_FIELD("zz", basis.elements[2][2]) - else TRY_TRANSFER_FIELD("xo", origin.x) - else TRY_TRANSFER_FIELD("yo", origin.y) - else TRY_TRANSFER_FIELD("zo", origin.z) - - return target; - } - - default: { - ERR_FAIL_V(p_target); - } - } - /* clang-format on */ -} - -#endif // TOOLS_ENABLED diff --git a/core/helper/math_fieldwise.h b/core/helper/math_fieldwise.h deleted file mode 100644 index 0e7cc3ea4a..0000000000 --- a/core/helper/math_fieldwise.h +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************/ -/* math_fieldwise.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef MATH_FIELDWISE_H -#define MATH_FIELDWISE_H - -#ifdef TOOLS_ENABLED - -#include "core/variant.h" - -Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field); - -#endif // TOOLS_ENABLED - -#endif // MATH_FIELDWISE_H diff --git a/core/helper/value_evaluator.h b/core/helper/value_evaluator.h deleted file mode 100644 index 39177a7820..0000000000 --- a/core/helper/value_evaluator.h +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************/ -/* value_evaluator.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef VALUE_EVALUATOR_H -#define VALUE_EVALUATOR_H - -#include "core/object.h" - -class ValueEvaluator : public Object { - - GDCLASS(ValueEvaluator, Object); - -public: - virtual double eval(const String &p_text) { - return p_text.to_double(); - } -}; - -#endif // VALUE_EVALUATOR_H diff --git a/core/math/math_fieldwise.cpp b/core/math/math_fieldwise.cpp new file mode 100644 index 0000000000..20b2341ab0 --- /dev/null +++ b/core/math/math_fieldwise.cpp @@ -0,0 +1,181 @@ +/*************************************************************************/ +/* math_fieldwise.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifdef TOOLS_ENABLED + +#include "math_fieldwise.h" + +#define SETUP_TYPE(m_type) \ + m_type source = p_source; \ + m_type target = p_target; +#define TRY_TRANSFER_FIELD(m_name, m_member) \ + if (p_field == m_name) { \ + target.m_member = source.m_member; \ + } + +Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field) { + + ERR_FAIL_COND_V(p_target.get_type() != p_source.get_type(), p_target); + + /* clang-format makes a mess of this macro usage */ + /* clang-format off */ + + switch (p_source.get_type()) { + + case Variant::VECTOR2: { + + SETUP_TYPE(Vector2) + + /**/ TRY_TRANSFER_FIELD("x", x) + else TRY_TRANSFER_FIELD("y", y) + + return target; + } + + case Variant::RECT2: { + + SETUP_TYPE(Rect2) + + /**/ TRY_TRANSFER_FIELD("x", position.x) + else TRY_TRANSFER_FIELD("y", position.y) + else TRY_TRANSFER_FIELD("w", size.x) + else TRY_TRANSFER_FIELD("h", size.y) + + return target; + } + + case Variant::VECTOR3: { + + SETUP_TYPE(Vector3) + + /**/ TRY_TRANSFER_FIELD("x", x) + else TRY_TRANSFER_FIELD("y", y) + else TRY_TRANSFER_FIELD("z", z) + + return target; + } + + case Variant::PLANE: { + + SETUP_TYPE(Plane) + + /**/ TRY_TRANSFER_FIELD("x", normal.x) + else TRY_TRANSFER_FIELD("y", normal.y) + else TRY_TRANSFER_FIELD("z", normal.z) + else TRY_TRANSFER_FIELD("d", d) + + return target; + } + + case Variant::QUAT: { + + SETUP_TYPE(Quat) + + /**/ TRY_TRANSFER_FIELD("x", x) + else TRY_TRANSFER_FIELD("y", y) + else TRY_TRANSFER_FIELD("z", z) + else TRY_TRANSFER_FIELD("w", w) + + return target; + } + + case Variant::AABB: { + + SETUP_TYPE(AABB) + + /**/ TRY_TRANSFER_FIELD("px", position.x) + else TRY_TRANSFER_FIELD("py", position.y) + else TRY_TRANSFER_FIELD("pz", position.z) + else TRY_TRANSFER_FIELD("sx", size.x) + else TRY_TRANSFER_FIELD("sy", size.y) + else TRY_TRANSFER_FIELD("sz", size.z) + + return target; + } + + case Variant::TRANSFORM2D: { + + SETUP_TYPE(Transform2D) + + /**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) + else TRY_TRANSFER_FIELD("xy", elements[0][1]) + else TRY_TRANSFER_FIELD("yx", elements[1][0]) + else TRY_TRANSFER_FIELD("yy", elements[1][1]) + else TRY_TRANSFER_FIELD("ox", elements[2][0]) + else TRY_TRANSFER_FIELD("oy", elements[2][1]) + + return target; + } + + case Variant::BASIS: { + + SETUP_TYPE(Basis) + + /**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) + else TRY_TRANSFER_FIELD("xy", elements[0][1]) + else TRY_TRANSFER_FIELD("xz", elements[0][2]) + else TRY_TRANSFER_FIELD("yx", elements[1][0]) + else TRY_TRANSFER_FIELD("yy", elements[1][1]) + else TRY_TRANSFER_FIELD("yz", elements[1][2]) + else TRY_TRANSFER_FIELD("zx", elements[2][0]) + else TRY_TRANSFER_FIELD("zy", elements[2][1]) + else TRY_TRANSFER_FIELD("zz", elements[2][2]) + + return target; + } + + case Variant::TRANSFORM: { + + SETUP_TYPE(Transform) + + /**/ TRY_TRANSFER_FIELD("xx", basis.elements[0][0]) + else TRY_TRANSFER_FIELD("xy", basis.elements[0][1]) + else TRY_TRANSFER_FIELD("xz", basis.elements[0][2]) + else TRY_TRANSFER_FIELD("yx", basis.elements[1][0]) + else TRY_TRANSFER_FIELD("yy", basis.elements[1][1]) + else TRY_TRANSFER_FIELD("yz", basis.elements[1][2]) + else TRY_TRANSFER_FIELD("zx", basis.elements[2][0]) + else TRY_TRANSFER_FIELD("zy", basis.elements[2][1]) + else TRY_TRANSFER_FIELD("zz", basis.elements[2][2]) + else TRY_TRANSFER_FIELD("xo", origin.x) + else TRY_TRANSFER_FIELD("yo", origin.y) + else TRY_TRANSFER_FIELD("zo", origin.z) + + return target; + } + + default: { + ERR_FAIL_V(p_target); + } + } + /* clang-format on */ +} + +#endif // TOOLS_ENABLED diff --git a/core/math/math_fieldwise.h b/core/math/math_fieldwise.h new file mode 100644 index 0000000000..0e7cc3ea4a --- /dev/null +++ b/core/math/math_fieldwise.h @@ -0,0 +1,42 @@ +/*************************************************************************/ +/* math_fieldwise.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef MATH_FIELDWISE_H +#define MATH_FIELDWISE_H + +#ifdef TOOLS_ENABLED + +#include "core/variant.h" + +Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field); + +#endif // TOOLS_ENABLED + +#endif // MATH_FIELDWISE_H diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 173be01586..be4e752d55 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -30,7 +30,7 @@ #include "multi_node_edit.h" -#include "core/helper/math_fieldwise.h" +#include "core/math/math_fieldwise.h" #include "editor_node.h" bool MultiNodeEdit::_set(const StringName &p_name, const Variant &p_value) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 508db2e03f..c611327a31 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1991,60 +1991,3 @@ CustomPropertyEditor::CustomPropertyEditor() { create_dialog = NULL; property_select = NULL; } - -///////////////////////////// - -double PropertyValueEvaluator::eval(const String &p_text) { - - // If range value contains a comma replace it with dot (issue #6028) - const String &p_new_text = p_text.replace(",", "."); - - if (!obj || !script_language) - return _default_eval(p_new_text); - - Ref