summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp22
-rw-r--r--main/tests/test_math.cpp5
-rw-r--r--main/tests/test_oa_hash_map.cpp83
-rw-r--r--main/tests/test_physics_3d.cpp16
-rw-r--r--main/tests/test_render.cpp6
5 files changed, 112 insertions, 20 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 68016a5cef..94dd895a26 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1645,7 +1645,11 @@ bool Main::start() {
print_line("Loading docs...");
for (int i = 0; i < _doc_data_class_path_count; i++) {
- String path = doc_tool.plus_file(_doc_data_class_paths[i].path);
+ // Custom modules are always located by absolute path.
+ String path = _doc_data_class_paths[i].path;
+ if (path.is_rel_path()) {
+ path = doc_tool.plus_file(path);
+ }
String name = _doc_data_class_paths[i].name;
doc_data_classes[name] = path;
if (!checked_paths.has(path)) {
@@ -1958,6 +1962,16 @@ bool Main::start() {
ProjectSettings::get_singleton()->set_custom_property_info("rendering/canvas_textures/default_texture_repeat", PropertyInfo(Variant::INT, "rendering/canvas_textures/default_texture_repeat", PROPERTY_HINT_ENUM, "Disable,Enable,Mirror"));
}
+#ifdef TOOLS_ENABLED
+ if (editor) {
+ bool editor_embed_subwindows = EditorSettings::get_singleton()->get_setting("interface/editor/single_window_mode");
+
+ if (editor_embed_subwindows) {
+ sml->get_root()->set_embed_subwindows_hint(true);
+ }
+ }
+#endif
+
String local_game_path;
if (game_path != "" && !project_manager) {
local_game_path = game_path.replace("\\", "/");
@@ -1991,12 +2005,6 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (editor) {
- bool editor_embed_subwindows = EditorSettings::get_singleton()->get_setting("interface/editor/single_window_mode");
-
- if (editor_embed_subwindows) {
- sml->get_root()->set_embed_subwindows_hint(true);
- }
-
if (game_path != GLOBAL_GET("application/run/main_scene") || !editor_node->has_scenes_in_session()) {
Error serr = editor_node->load_scene(local_game_path);
if (serr != OK) {
diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp
index 11aa164709..5f84bad4e9 100644
--- a/main/tests/test_math.cpp
+++ b/main/tests/test_math.cpp
@@ -33,6 +33,7 @@
#include "core/math/basis.h"
#include "core/math/camera_matrix.h"
#include "core/math/delaunay_3d.h"
+#include "core/math/geometry_2d.h"
#include "core/math/math_funcs.h"
#include "core/math/transform.h"
#include "core/method_ptrcall.h"
@@ -482,7 +483,7 @@ MainLoop *test() {
float gb = (rgbe >> 9) & 0x1ff;
float bb = (rgbe >> 18) & 0x1ff;
float eb = (rgbe >> 27);
- float mb = Math::pow(2, eb - 15.0 - 9.0);
+ float mb = Math::pow(2.0, eb - 15.0 - 9.0);
float rd = rb * mb;
float gd = gb * mb;
float bd = bb * mb;
@@ -635,7 +636,7 @@ MainLoop *test() {
b["44"] = 4;
}
- print_line("inters: " + rtos(Geometry::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0)));
+ print_line("inters: " + rtos(Geometry2D::segment_intersects_circle(Vector2(-5, 0), Vector2(-2, 0), Vector2(), 1.0)));
print_line("cross: " + Vector3(1, 2, 3).cross(Vector3(4, 5, 7)));
print_line("dot: " + rtos(Vector3(1, 2, 3).dot(Vector3(4, 5, 7))));
diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp
index 719817baf4..9182f66b61 100644
--- a/main/tests/test_oa_hash_map.cpp
+++ b/main/tests/test_oa_hash_map.cpp
@@ -210,6 +210,89 @@ MainLoop *test() {
}
}
+ // Test map with 0 capacity.
+ {
+ OAHashMap<int, String> original_map(0);
+ original_map.set(1, "1");
+ OS::get_singleton()->print("OAHashMap 0 capacity initialization passed.\n");
+ }
+
+ // Test copy constructor.
+ {
+ OAHashMap<int, String> original_map;
+ original_map.set(1, "1");
+ original_map.set(2, "2");
+ original_map.set(3, "3");
+ original_map.set(4, "4");
+ original_map.set(5, "5");
+
+ OAHashMap<int, String> map_copy(original_map);
+
+ bool pass = true;
+ for (
+ OAHashMap<int, String>::Iterator it = original_map.iter();
+ it.valid;
+ it = original_map.next_iter(it)) {
+ if (map_copy.lookup_ptr(*it.key) == nullptr) {
+ pass = false;
+ }
+ if (*it.value != *map_copy.lookup_ptr(*it.key)) {
+ pass = false;
+ }
+ }
+ if (pass) {
+ OS::get_singleton()->print("OAHashMap copy constructor test passed.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap copy constructor test FAILED.\n");
+ }
+
+ map_copy.set(1, "Random String");
+ if (*map_copy.lookup_ptr(1) == *original_map.lookup_ptr(1)) {
+ OS::get_singleton()->print("OAHashMap copy constructor, atomic copy test FAILED.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap copy constructor, atomic copy test passed.\n");
+ }
+ }
+
+ // Test assign operator.
+ {
+ OAHashMap<int, String> original_map;
+ original_map.set(1, "1");
+ original_map.set(2, "2");
+ original_map.set(3, "3");
+ original_map.set(4, "4");
+ original_map.set(5, "5");
+
+ OAHashMap<int, String> map_copy(100000);
+ map_copy.set(1, "Just a string.");
+ map_copy = original_map;
+
+ bool pass = true;
+ for (
+ OAHashMap<int, String>::Iterator it = map_copy.iter();
+ it.valid;
+ it = map_copy.next_iter(it)) {
+ if (original_map.lookup_ptr(*it.key) == nullptr) {
+ pass = false;
+ }
+ if (*it.value != *original_map.lookup_ptr(*it.key)) {
+ pass = false;
+ }
+ }
+ if (pass) {
+ OS::get_singleton()->print("OAHashMap assign operation test passed.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap assign operation test FAILED.\n");
+ }
+
+ map_copy.set(1, "Random String");
+ if (*map_copy.lookup_ptr(1) == *original_map.lookup_ptr(1)) {
+ OS::get_singleton()->print("OAHashMap assign operation atomic copy test FAILED.\n");
+ } else {
+ OS::get_singleton()->print("OAHashMap assign operation atomic copy test passed.\n");
+ }
+ }
+
return nullptr;
}
diff --git a/main/tests/test_physics_3d.cpp b/main/tests/test_physics_3d.cpp
index fe54ece98e..dfe2e946cf 100644
--- a/main/tests/test_physics_3d.cpp
+++ b/main/tests/test_physics_3d.cpp
@@ -136,9 +136,9 @@ protected:
/* BOX SHAPE */
- Vector<Plane> box_planes = Geometry::build_box_planes(Vector3(0.5, 0.5, 0.5));
+ Vector<Plane> box_planes = Geometry3D::build_box_planes(Vector3(0.5, 0.5, 0.5));
RID box_mesh = vs->mesh_create();
- Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
+ Geometry3D::MeshData box_data = Geometry3D::build_convex_mesh(box_planes);
vs->mesh_add_surface_from_mesh_data(box_mesh, box_data);
type_mesh_map[PhysicsServer3D::SHAPE_BOX] = box_mesh;
@@ -148,10 +148,10 @@ protected:
/* CAPSULE SHAPE */
- Vector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5, 0.7, 12, Vector3::AXIS_Z);
+ Vector<Plane> capsule_planes = Geometry3D::build_capsule_planes(0.5, 0.7, 12, Vector3::AXIS_Z);
RID capsule_mesh = vs->mesh_create();
- Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
+ Geometry3D::MeshData capsule_data = Geometry3D::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data);
type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh;
@@ -165,10 +165,10 @@ protected:
/* CONVEX SHAPE */
- Vector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5, 0.7, 5, Vector3::AXIS_Z);
+ Vector<Plane> convex_planes = Geometry3D::build_cylinder_planes(0.5, 0.7, 5, Vector3::AXIS_Z);
RID convex_mesh = vs->mesh_create();
- Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
+ Geometry3D::MeshData convex_data = Geometry3D::build_convex_mesh(convex_planes);
QuickHull::build(convex_data.vertices, convex_data);
vs->mesh_add_surface_from_mesh_data(convex_mesh, convex_data);
@@ -341,10 +341,10 @@ public:
RenderingServer *vs = RenderingServer::get_singleton();
PhysicsServer3D *ps = PhysicsServer3D::get_singleton();
- Vector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5, 1, 12, 5, Vector3::AXIS_Y);
+ Vector<Plane> capsule_planes = Geometry3D::build_capsule_planes(0.5, 1, 12, 5, Vector3::AXIS_Y);
RID capsule_mesh = vs->mesh_create();
- Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
+ Geometry3D::MeshData capsule_data = Geometry3D::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data);
type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh;
diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp
index afc09374b9..d936dd72e7 100644
--- a/main/tests/test_render.cpp
+++ b/main/tests/test_render.cpp
@@ -79,8 +79,8 @@ public:
Vector<Vector3> vts;
/*
- Vector<Plane> sp = Geometry::build_sphere_planes(2,5,5);
- Geometry::MeshData md2 = Geometry::build_convex_mesh(sp);
+ Vector<Plane> sp = Geometry3D::build_sphere_planes(2,5,5);
+ Geometry3D::MeshData md2 = Geometry3D::build_convex_mesh(sp);
vts=md2.vertices;
*/
/*
@@ -118,7 +118,7 @@ public:
vts.push_back(Vector3(-1, 1, -1));
vts.push_back(Vector3(-1, -1, -1));
- Geometry::MeshData md;
+ Geometry3D::MeshData md;
Error err = QuickHull::build(vts, md);
print_line("ERR: " + itos(err));
test_cube = vs->mesh_create();