summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp52
-rw-r--r--main/main.h1
-rw-r--r--main/performance.cpp76
-rw-r--r--main/performance.h22
-rw-r--r--main/tests/test_basis.cpp325
-rw-r--r--main/tests/test_basis.h40
-rw-r--r--main/tests/test_main.cpp6
-rw-r--r--main/tests/test_string.cpp2
8 files changed, 492 insertions, 32 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 94dd895a26..76175780a3 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -856,7 +856,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (I->get() == "--allow_focus_steal_pid") { // not exposed to user
if (I->next()) {
- allow_focus_steal_pid = I->next()->get().to_int64();
+ allow_focus_steal_pid = I->next()->get().to_int();
N = I->next()->next();
} else {
OS::get_singleton()->print("Missing editor PID argument, aborting.\n");
@@ -930,6 +930,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#endif
}
+ // Initialize user data dir.
+ OS::get_singleton()->ensure_user_data_dir();
+
GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60);
ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/multithreaded_server/rid_pool_prealloc", PropertyInfo(Variant::INT, "memory/limits/multithreaded_server/rid_pool_prealloc", PROPERTY_HINT_RANGE, "0,500,1")); // No negative and limit to 500 due to crashes
GLOBAL_DEF("network/limits/debugger/max_chars_per_second", 32768);
@@ -948,7 +951,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
packed_data->set_disabled(true);
globals->set_disable_feature_overrides(true);
}
-
#endif
GLOBAL_DEF("logging/file_logging/enable_file_logging", false);
@@ -1266,10 +1268,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Thread::_main_thread_id = p_main_tid_override;
}
- /* Initialize user data dir */
-
- OS::get_singleton()->ensure_user_data_dir();
-
/* Initialize Input */
input = memnew(Input);
@@ -1312,6 +1310,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
}
rendering_server->init();
+ rendering_server->set_render_loop_enabled(!disable_render_loop);
OS::get_singleton()->initialize_joypads();
@@ -1621,7 +1620,7 @@ bool Main::start() {
{
DirAccessRef da = DirAccess::open(doc_tool);
- ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a base Godot build directory.");
+ ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");
}
#ifndef MODULE_MONO_ENABLED
@@ -1634,6 +1633,8 @@ bool Main::start() {
GLOBAL_DEF("mono/profiler/args", "log:calls,alloc,sample,output=output.mlpd");
GLOBAL_DEF("mono/profiler/enabled", false);
GLOBAL_DEF("mono/unhandled_exception_policy", 0);
+ // From editor/csharp_project.cpp.
+ GLOBAL_DEF("mono/project/auto_update_project", true);
#endif
DocData doc;
@@ -1919,7 +1920,14 @@ bool Main::start() {
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
String appname = ProjectSettings::get_singleton()->get("application/config/name");
appname = TranslationServer::get_singleton()->translate(appname);
+#ifdef DEBUG_ENABLED
+ // Append a suffix to the window title to denote that the project is running
+ // from a debug build (including the editor). Since this results in lower performance,
+ // this should be clearly presented to the user.
+ DisplayServer::get_singleton()->window_set_title(vformat("%s (DEBUG)", appname));
+#else
DisplayServer::get_singleton()->window_set_title(appname);
+#endif
int shadow_atlas_size = GLOBAL_GET("rendering/quality/shadow_atlas/size");
int shadow_atlas_q0_subdiv = GLOBAL_GET("rendering/quality/shadow_atlas/quadrant_0_subdiv");
@@ -2107,7 +2115,6 @@ bool Main::start() {
*/
uint64_t Main::last_ticks = 0;
-uint64_t Main::target_ticks = 0;
uint32_t Main::frames = 0;
uint32_t Main::frame = 0;
bool Main::force_redraw_requested = false;
@@ -2203,7 +2210,7 @@ bool Main::iteration() {
RenderingServer::get_singleton()->sync(); //sync if still drawing from previous frames.
- if (DisplayServer::get_singleton()->can_any_window_draw() && !disable_render_loop) {
+ if (DisplayServer::get_singleton()->can_any_window_draw() && RenderingServer::get_singleton()->is_render_loop_enabled()) {
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) {
if (RenderingServer::get_singleton()->has_changed()) {
RenderingServer::get_singleton()->draw(true, scaled_step); // flush visual commands
@@ -2258,26 +2265,7 @@ bool Main::iteration() {
return exit;
}
- if (OS::get_singleton()->is_in_low_processor_usage_mode() || !DisplayServer::get_singleton()->can_any_window_draw()) {
- OS::get_singleton()->delay_usec(OS::get_singleton()->get_low_processor_usage_mode_sleep_usec()); //apply some delay to force idle time
- } else {
- uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
- if (frame_delay) {
- OS::get_singleton()->delay_usec(Engine::get_singleton()->get_frame_delay() * 1000);
- }
- }
-
- int target_fps = Engine::get_singleton()->get_target_fps();
- if (target_fps > 0 && !Engine::get_singleton()->is_editor_hint()) {
- uint64_t time_step = 1000000L / target_fps;
- target_ticks += time_step;
- uint64_t current_ticks = OS::get_singleton()->get_ticks_usec();
- if (current_ticks < target_ticks) {
- OS::get_singleton()->delay_usec(target_ticks - current_ticks);
- }
- current_ticks = OS::get_singleton()->get_ticks_usec();
- target_ticks = MIN(MAX(target_ticks, current_ticks - time_step), current_ticks + time_step);
- }
+ OS::get_singleton()->add_frame_delay(DisplayServer::get_singleton()->window_can_draw());
#ifdef TOOLS_ENABLED
if (auto_build_solutions) {
@@ -2313,8 +2301,8 @@ void Main::cleanup() {
ResourceLoader::remove_custom_loaders();
ResourceSaver::remove_custom_savers();
+ // Flush before uninitializing the scene, but delete the MessageQueue as late as possible.
message_queue->flush();
- memdelete(message_queue);
OS::get_singleton()->delete_main_loop();
@@ -2400,6 +2388,10 @@ void Main::cleanup() {
OS::get_singleton()->set_restart_on_exit(false, List<String>()); //clear list (uses memory)
}
+ // Now should be safe to delete MessageQueue (famous last words).
+ message_queue->flush();
+ memdelete(message_queue);
+
unregister_core_driver_types();
unregister_core_types();
diff --git a/main/main.h b/main/main.h
index ab6917a65c..308128735c 100644
--- a/main/main.h
+++ b/main/main.h
@@ -38,7 +38,6 @@
class Main {
static void print_help(const char *p_binary);
static uint64_t last_ticks;
- static uint64_t target_ticks;
static uint32_t frames;
static uint32_t frame;
static bool force_redraw_requested;
diff --git a/main/performance.cpp b/main/performance.cpp
index 7e6b9fca64..7234511aeb 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -43,6 +43,12 @@ Performance *Performance::singleton = nullptr;
void Performance::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_monitor", "monitor"), &Performance::get_monitor);
+ ClassDB::bind_method(D_METHOD("add_custom_monitor", "id", "callable", "arguments"), &Performance::add_custom_monitor, DEFVAL(Array()));
+ ClassDB::bind_method(D_METHOD("remove_custom_monitor", "id"), &Performance::remove_custom_monitor);
+ ClassDB::bind_method(D_METHOD("has_custom_monitor", "id"), &Performance::has_custom_monitor);
+ ClassDB::bind_method(D_METHOD("get_custom_monitor", "id"), &Performance::get_custom_monitor);
+ ClassDB::bind_method(D_METHOD("get_monitor_modification_time"), &Performance::get_monitor_modification_time);
+ ClassDB::bind_method(D_METHOD("get_custom_monitor_names"), &Performance::get_custom_monitor_names);
BIND_ENUM_CONSTANT(TIME_FPS);
BIND_ENUM_CONSTANT(TIME_PROCESS);
@@ -231,8 +237,78 @@ void Performance::set_physics_process_time(float p_pt) {
_physics_process_time = p_pt;
}
+void Performance::add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args) {
+ ERR_FAIL_COND_MSG(has_custom_monitor(p_id), "Custom monitor with id '" + String(p_id) + "' already exists.");
+ _monitor_map.insert(p_id, MonitorCall(p_callable, p_args));
+ _monitor_modification_time = OS::get_singleton()->get_ticks_usec();
+}
+
+void Performance::remove_custom_monitor(const StringName &p_id) {
+ ERR_FAIL_COND_MSG(!has_custom_monitor(p_id), "Custom monitor with id '" + String(p_id) + "' doesn't exists.");
+ _monitor_map.erase(p_id);
+ _monitor_modification_time = OS::get_singleton()->get_ticks_usec();
+}
+
+bool Performance::has_custom_monitor(const StringName &p_id) {
+ return _monitor_map.has(p_id);
+}
+
+Variant Performance::get_custom_monitor(const StringName &p_id) {
+ ERR_FAIL_COND_V_MSG(!has_custom_monitor(p_id), Variant(), "Custom monitor with id '" + String(p_id) + "' doesn't exists.");
+ bool error;
+ String error_message;
+ Variant return_value = _monitor_map[p_id].call(error, error_message);
+ ERR_FAIL_COND_V_MSG(error, return_value, "Error calling from custom monitor '" + String(p_id) + "' to callable: " + error_message);
+ return return_value;
+}
+
+Array Performance::get_custom_monitor_names() {
+ if (!_monitor_map.size()) {
+ return Array();
+ }
+ Array return_array;
+ return_array.resize(_monitor_map.size());
+ int index = 0;
+ for (OrderedHashMap<StringName, MonitorCall>::Element i = _monitor_map.front(); i; i = i.next()) {
+ return_array.set(index, i.key());
+ index++;
+ }
+ return return_array;
+}
+
+uint64_t Performance::get_monitor_modification_time() {
+ return _monitor_modification_time;
+}
+
Performance::Performance() {
_process_time = 0;
_physics_process_time = 0;
+ _monitor_modification_time = 0;
singleton = this;
}
+
+Performance::MonitorCall::MonitorCall(Callable p_callable, Vector<Variant> p_arguments) {
+ _callable = p_callable;
+ _arguments = p_arguments;
+}
+
+Performance::MonitorCall::MonitorCall() {
+}
+
+Variant Performance::MonitorCall::call(bool &r_error, String &r_error_message) {
+ Vector<const Variant *> arguments_mem;
+ arguments_mem.resize(_arguments.size());
+ for (int i = 0; i < _arguments.size(); i++) {
+ arguments_mem.write[i] = &_arguments[i];
+ }
+ const Variant **args = (const Variant **)arguments_mem.ptr();
+ int argc = _arguments.size();
+ Variant return_value;
+ Callable::CallError error;
+ _callable.call(args, argc, return_value, error);
+ r_error = (error.error != Callable::CallError::CALL_OK);
+ if (r_error) {
+ r_error_message = Variant::get_callable_error_text(_callable, args, argc, error);
+ }
+ return return_value;
+}
diff --git a/main/performance.h b/main/performance.h
index ddbe45fa00..5f88a24c0f 100644
--- a/main/performance.h
+++ b/main/performance.h
@@ -32,6 +32,7 @@
#define PERFORMANCE_H
#include "core/object.h"
+#include "core/ordered_hash_map.h"
#define PERF_WARN_OFFLINE_FUNCTION
#define PERF_WARN_PROCESS_SYNC
@@ -47,6 +48,19 @@ class Performance : public Object {
float _process_time;
float _physics_process_time;
+ class MonitorCall {
+ Callable _callable;
+ Vector<Variant> _arguments;
+
+ public:
+ MonitorCall(Callable p_callable, Vector<Variant> p_arguments);
+ MonitorCall();
+ Variant call(bool &r_error, String &r_error_message);
+ };
+
+ OrderedHashMap<StringName, MonitorCall> _monitor_map;
+ uint64_t _monitor_modification_time;
+
public:
enum Monitor {
@@ -95,6 +109,14 @@ public:
void set_process_time(float p_pt);
void set_physics_process_time(float p_pt);
+ void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args);
+ void remove_custom_monitor(const StringName &p_id);
+ bool has_custom_monitor(const StringName &p_id);
+ Variant get_custom_monitor(const StringName &p_id);
+ Array get_custom_monitor_names();
+
+ uint64_t get_monitor_modification_time();
+
static Performance *get_singleton() { return singleton; }
Performance();
diff --git a/main/tests/test_basis.cpp b/main/tests/test_basis.cpp
new file mode 100644
index 0000000000..5904fc386a
--- /dev/null
+++ b/main/tests/test_basis.cpp
@@ -0,0 +1,325 @@
+/*************************************************************************/
+/* test_basis.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 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. */
+/*************************************************************************/
+
+#include "test_basis.h"
+
+#include "core/math/random_number_generator.h"
+#include "core/os/os.h"
+#include "core/ustring.h"
+
+namespace TestBasis {
+
+enum RotOrder {
+ EulerXYZ,
+ EulerXZY,
+ EulerYZX,
+ EulerYXZ,
+ EulerZXY,
+ EulerZYX
+};
+
+Vector3 deg2rad(const Vector3 &p_rotation) {
+ return p_rotation / 180.0 * Math_PI;
+}
+
+Vector3 rad2deg(const Vector3 &p_rotation) {
+ return p_rotation / Math_PI * 180.0;
+}
+
+Basis EulerToBasis(RotOrder mode, const Vector3 &p_rotation) {
+ Basis ret;
+ switch (mode) {
+ case EulerXYZ:
+ ret.set_euler_xyz(p_rotation);
+ break;
+
+ case EulerXZY:
+ ret.set_euler_xzy(p_rotation);
+ break;
+
+ case EulerYZX:
+ ret.set_euler_yzx(p_rotation);
+ break;
+
+ case EulerYXZ:
+ ret.set_euler_yxz(p_rotation);
+ break;
+
+ case EulerZXY:
+ ret.set_euler_zxy(p_rotation);
+ break;
+
+ case EulerZYX:
+ ret.set_euler_zyx(p_rotation);
+ break;
+
+ default:
+ // If you land here, Please integrate all rotation orders.
+ CRASH_NOW_MSG("This is not unreachable.");
+ }
+
+ return ret;
+}
+
+Vector3 BasisToEuler(RotOrder mode, const Basis &p_rotation) {
+ switch (mode) {
+ case EulerXYZ:
+ return p_rotation.get_euler_xyz();
+
+ case EulerXZY:
+ return p_rotation.get_euler_xzy();
+
+ case EulerYZX:
+ return p_rotation.get_euler_yzx();
+
+ case EulerYXZ:
+ return p_rotation.get_euler_yxz();
+
+ case EulerZXY:
+ return p_rotation.get_euler_zxy();
+
+ case EulerZYX:
+ return p_rotation.get_euler_zyx();
+
+ default:
+ // If you land here, Please integrate all rotation orders.
+ CRASH_NOW_MSG("This is not unreachable.");
+ return Vector3();
+ }
+}
+
+String get_rot_order_name(RotOrder ro) {
+ switch (ro) {
+ case EulerXYZ:
+ return "XYZ";
+ case EulerXZY:
+ return "XZY";
+ case EulerYZX:
+ return "YZX";
+ case EulerYXZ:
+ return "YXZ";
+ case EulerZXY:
+ return "ZXY";
+ case EulerZYX:
+ return "ZYX";
+ default:
+ return "[Not supported]";
+ }
+}
+
+bool test_rotation(Vector3 deg_original_euler, RotOrder rot_order) {
+ // This test:
+ // 1. Converts the rotation vector from deg to rad.
+ // 2. Converts euler to basis.
+ // 3. Converts the above basis back into euler.
+ // 4. Converts the above euler into basis again.
+ // 5. Compares the basis obtained in step 2 with the basis of step 4
+ //
+ // The conversion "basis to euler", done in the step 3, may be different from
+ // the original euler, even if the final rotation are the same.
+ // This happens because there are more ways to represents the same rotation,
+ // both valid, using eulers.
+ // For this reason is necessary to convert that euler back to basis and finally
+ // compares it.
+ //
+ // In this way we can assert that both functions: basis to euler / euler to basis
+ // are correct.
+
+ bool pass = true;
+
+ // Euler to rotation
+ const Vector3 original_euler = deg2rad(deg_original_euler);
+ const Basis to_rotation = EulerToBasis(rot_order, original_euler);
+
+ // Euler from rotation
+ const Vector3 euler_from_rotation = BasisToEuler(rot_order, to_rotation);
+ const Basis rotation_from_computed_euler = EulerToBasis(rot_order, euler_from_rotation);
+
+ Basis res = to_rotation.inverse() * rotation_from_computed_euler;
+
+ if ((res.get_axis(0) - Vector3(1.0, 0.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Fail due to X %ls\n", String(res.get_axis(0)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(1) - Vector3(0.0, 1.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Fail due to Y %ls\n", String(res.get_axis(1)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(2) - Vector3(0.0, 0.0, 1.0)).length() > 0.1) {
+ OS::get_singleton()->print("Fail due to Z %ls\n", String(res.get_axis(2)).c_str());
+ pass = false;
+ }
+
+ if (pass) {
+ // Double check `to_rotation` decomposing with XYZ rotation order.
+ const Vector3 euler_xyz_from_rotation = to_rotation.get_euler_xyz();
+ Basis rotation_from_xyz_computed_euler;
+ rotation_from_xyz_computed_euler.set_euler_xyz(euler_xyz_from_rotation);
+
+ res = to_rotation.inverse() * rotation_from_xyz_computed_euler;
+
+ if ((res.get_axis(0) - Vector3(1.0, 0.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Double check with XYZ rot order failed, due to X %ls\n", String(res.get_axis(0)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(1) - Vector3(0.0, 1.0, 0.0)).length() > 0.1) {
+ OS::get_singleton()->print("Double check with XYZ rot order failed, due to Y %ls\n", String(res.get_axis(1)).c_str());
+ pass = false;
+ }
+ if ((res.get_axis(2) - Vector3(0.0, 0.0, 1.0)).length() > 0.1) {
+ OS::get_singleton()->print("Double check with XYZ rot order failed, due to Z %ls\n", String(res.get_axis(2)).c_str());
+ pass = false;
+ }
+ }
+
+ if (pass == false) {
+ // Print phase only if not pass.
+ OS *os = OS::get_singleton();
+ os->print("Rotation order: %ls\n.", get_rot_order_name(rot_order).c_str());
+ os->print("Original Rotation: %ls\n", String(deg_original_euler).c_str());
+ os->print("Quaternion to rotation order: %ls\n", String(rad2deg(euler_from_rotation)).c_str());
+ }
+
+ return pass;
+}
+
+void test_euler_conversion() {
+ Vector<RotOrder> rotorder_to_test;
+ rotorder_to_test.push_back(EulerXYZ);
+ rotorder_to_test.push_back(EulerXZY);
+ rotorder_to_test.push_back(EulerYZX);
+ rotorder_to_test.push_back(EulerYXZ);
+ rotorder_to_test.push_back(EulerZXY);
+ rotorder_to_test.push_back(EulerZYX);
+
+ Vector<Vector3> vectors_to_test;
+
+ // Test the special cases.
+ vectors_to_test.push_back(Vector3(0.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.5, 0.5, 0.5));
+ vectors_to_test.push_back(Vector3(-0.5, -0.5, -0.5));
+ vectors_to_test.push_back(Vector3(40.0, 40.0, 40.0));
+ vectors_to_test.push_back(Vector3(-40.0, -40.0, -40.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, -90.0));
+ vectors_to_test.push_back(Vector3(0.0, -90.0, 0.0));
+ vectors_to_test.push_back(Vector3(-90.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, 90.0));
+ vectors_to_test.push_back(Vector3(0.0, 90.0, 0.0));
+ vectors_to_test.push_back(Vector3(90.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, -30.0));
+ vectors_to_test.push_back(Vector3(0.0, -30.0, 0.0));
+ vectors_to_test.push_back(Vector3(-30.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.0, 0.0, 30.0));
+ vectors_to_test.push_back(Vector3(0.0, 30.0, 0.0));
+ vectors_to_test.push_back(Vector3(30.0, 0.0, 0.0));
+ vectors_to_test.push_back(Vector3(0.5, 50.0, 20.0));
+ vectors_to_test.push_back(Vector3(-0.5, -50.0, -20.0));
+ vectors_to_test.push_back(Vector3(0.5, 0.0, 90.0));
+ vectors_to_test.push_back(Vector3(0.5, 0.0, -90.0));
+ vectors_to_test.push_back(Vector3(360.0, 360.0, 360.0));
+ vectors_to_test.push_back(Vector3(-360.0, -360.0, -360.0));
+ vectors_to_test.push_back(Vector3(-90.0, 60.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, 60.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, -60.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, -60.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, 60.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, 60.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, -60.0, 90.0));
+ vectors_to_test.push_back(Vector3(-90.0, -60.0, 90.0));
+ vectors_to_test.push_back(Vector3(60.0, 90.0, -40.0));
+ vectors_to_test.push_back(Vector3(60.0, -90.0, -40.0));
+ vectors_to_test.push_back(Vector3(-60.0, -90.0, -40.0));
+ vectors_to_test.push_back(Vector3(-60.0, 90.0, 40.0));
+ vectors_to_test.push_back(Vector3(60.0, 90.0, 40.0));
+ vectors_to_test.push_back(Vector3(60.0, -90.0, 40.0));
+ vectors_to_test.push_back(Vector3(-60.0, -90.0, 40.0));
+ vectors_to_test.push_back(Vector3(-90.0, 90.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, 90.0, -90.0));
+ vectors_to_test.push_back(Vector3(90.0, -90.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, -90.0, -90.0));
+ vectors_to_test.push_back(Vector3(-90.0, 90.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, 90.0, 90.0));
+ vectors_to_test.push_back(Vector3(90.0, -90.0, 90.0));
+ vectors_to_test.push_back(Vector3(20.0, 150.0, 30.0));
+ vectors_to_test.push_back(Vector3(20.0, -150.0, 30.0));
+ vectors_to_test.push_back(Vector3(-120.0, -150.0, 30.0));
+ vectors_to_test.push_back(Vector3(-120.0, -150.0, -130.0));
+ vectors_to_test.push_back(Vector3(120.0, -150.0, -130.0));
+ vectors_to_test.push_back(Vector3(120.0, 150.0, -130.0));
+ vectors_to_test.push_back(Vector3(120.0, 150.0, 130.0));
+
+ // Add 1000 random vectors with weirds numbers.
+ RandomNumberGenerator rng;
+ for (int _ = 0; _ < 1000; _ += 1) {
+ vectors_to_test.push_back(Vector3(
+ rng.randf_range(-1800, 1800),
+ rng.randf_range(-1800, 1800),
+ rng.randf_range(-1800, 1800)));
+ }
+
+ bool success = true;
+ for (int h = 0; h < rotorder_to_test.size(); h += 1) {
+ int passed = 0;
+ int failed = 0;
+ for (int i = 0; i < vectors_to_test.size(); i += 1) {
+ if (test_rotation(vectors_to_test[i], rotorder_to_test[h])) {
+ //OS::get_singleton()->print("Success. \n\n");
+ passed += 1;
+ } else {
+ OS::get_singleton()->print("FAILED FAILED FAILED. \n\n");
+ OS::get_singleton()->print("------------>\n");
+ OS::get_singleton()->print("------------>\n");
+ failed += 1;
+ success = false;
+ }
+ }
+
+ if (failed == 0) {
+ OS::get_singleton()->print("%i passed tests for rotation order: %ls.\n", passed, get_rot_order_name(rotorder_to_test[h]).c_str());
+ } else {
+ OS::get_singleton()->print("%i FAILED tests for rotation order: %ls.\n", failed, get_rot_order_name(rotorder_to_test[h]).c_str());
+ }
+ }
+
+ if (success) {
+ OS::get_singleton()->print("Euler conversion checks passed.\n");
+ } else {
+ OS::get_singleton()->print("Euler conversion checks FAILED.\n");
+ }
+}
+
+MainLoop *test() {
+ OS::get_singleton()->print("Start euler conversion checks.\n");
+ test_euler_conversion();
+
+ return NULL;
+}
+
+} // namespace TestBasis
diff --git a/main/tests/test_basis.h b/main/tests/test_basis.h
new file mode 100644
index 0000000000..63297bd3b8
--- /dev/null
+++ b/main/tests/test_basis.h
@@ -0,0 +1,40 @@
+/*************************************************************************/
+/* test_basis.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 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 TEST_BASIS_H
+#define TEST_BASIS_H
+
+#include "core/os/main_loop.h"
+
+namespace TestBasis {
+MainLoop *test();
+}
+
+#endif
diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp
index 0bb8367240..5ebdaf1741 100644
--- a/main/tests/test_main.cpp
+++ b/main/tests/test_main.cpp
@@ -35,6 +35,7 @@
#ifdef DEBUG_ENABLED
#include "test_astar.h"
+#include "test_basis.h"
#include "test_class_db.h"
#include "test_gdscript.h"
#include "test_gui.h"
@@ -51,6 +52,7 @@ const char **tests_get_names() {
static const char *test_names[] = {
"string",
"math",
+ "basis",
"physics_2d",
"physics_3d",
"render",
@@ -79,6 +81,10 @@ MainLoop *test_main(String p_test, const List<String> &p_args) {
return TestMath::test();
}
+ if (p_test == "basis") {
+ return TestBasis::test();
+ }
+
if (p_test == "physics_2d") {
return TestPhysics2D::test();
}
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index 775c039282..5a14492be5 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -370,7 +370,7 @@ bool test_22() {
static const int num[4] = { 1237461283, -22, 0, -1123412 };
for (int i = 0; i < 4; i++) {
- OS::get_singleton()->print("\tString: \"%s\" as Int is %i\n", nums[i], String(nums[i]).to_int());
+ OS::get_singleton()->print("\tString: \"%s\" as Int is %lli\n", nums[i], (long long)(String(nums[i]).to_int()));
if (String(nums[i]).to_int() != num[i]) {
return false;