summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp59
1 files changed, 48 insertions, 11 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 650a680d87..00ce8c6f7b 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -66,6 +66,8 @@
#include "servers/arvr_server.h"
#include "servers/audio_server.h"
#include "servers/camera_server.h"
+#include "servers/navigation_2d_server.h"
+#include "servers/navigation_server.h"
#include "servers/physics_2d_server.h"
#include "servers/physics_server.h"
#include "servers/register_server_types.h"
@@ -103,6 +105,8 @@ static CameraServer *camera_server = NULL;
static ARVRServer *arvr_server = NULL;
static PhysicsServer *physics_server = NULL;
static Physics2DServer *physics_2d_server = NULL;
+static NavigationServer *navigation_server = NULL;
+static Navigation2DServer *navigation_2d_server = NULL;
// We error out if setup2() doesn't turn this true
static bool _start_success = false;
@@ -197,6 +201,19 @@ void finalize_physics() {
memdelete(physics_2d_server);
}
+void initialize_navigation_server() {
+ ERR_FAIL_COND(navigation_server != NULL);
+ navigation_server = NavigationServerManager::new_default_server();
+ navigation_2d_server = memnew(Navigation2DServer);
+}
+
+void finalize_navigation_server() {
+ memdelete(navigation_server);
+ navigation_server = NULL;
+ memdelete(navigation_2d_server);
+ navigation_2d_server = NULL;
+}
+
//#define DEBUG_INIT
#ifdef DEBUG_INIT
#define MAIN_PRINT(m_txt) print_line(m_txt)
@@ -269,6 +286,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n");
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
+ OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
OS::get_singleton()->print(" --remote-debug <address> Remote debug (<host/IP>:<port> address).\n");
#if defined(DEBUG_ENABLED) && !defined(SERVER_ENABLED)
OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n");
@@ -335,7 +353,6 @@ void Main::print_help(const char *p_binary) {
*/
Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
- RID_OwnerBase::init_rid();
OS::get_singleton()->initialize_core();
@@ -532,6 +549,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-w" || I->get() == "--windowed") { // force windowed window
init_windowed = true;
+ } else if (I->get() == "--gpu-abort") { // force windowed window
+
+ Engine::singleton->abort_on_gpu_errors = true;
} else if (I->get() == "-t" || I->get() == "--always-on-top") { // force always-on-top window
init_always_on_top = true;
@@ -669,7 +689,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
editor = true;
#ifdef DEBUG_METHODS_ENABLED
} else if (I->get() == "--gdnative-generate-json-api") {
- // Register as an editor instance to use the GLES2 fallback automatically on hardware that doesn't support the GLES3 backend
+ // Register as an editor instance to use low-end fallback if relevant.
editor = true;
// We still pass it to the main arguments since the argument handling itself is not done in this function
@@ -974,14 +994,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->set_cmdline(execpath, main_args);
- GLOBAL_DEF("rendering/quality/driver/driver_name", "GLES3");
- ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_name", PROPERTY_HINT_ENUM, "GLES2,GLES3"));
+ GLOBAL_DEF("rendering/quality/driver/driver_name", "Vulkan");
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_name", PROPERTY_HINT_ENUM, "Vulkan,GLES2"));
if (video_driver == "") {
video_driver = GLOBAL_GET("rendering/quality/driver/driver_name");
}
- GLOBAL_DEF("rendering/quality/driver/fallback_to_gles2", false);
-
// Assigning here even though it's GLES2-specific, to be sure that it appears in docs
GLOBAL_DEF("rendering/quality/2d/gles2_use_nvidia_rect_flicker_workaround", false);
@@ -1191,6 +1209,9 @@ error:
Error Main::setup2(Thread::ID p_main_tid_override) {
+ preregister_module_types();
+ preregister_server_types();
+
// Print engine name and version
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
@@ -1334,7 +1355,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
if (String(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) {
- Ref<Texture> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image"));
+ Ref<Texture2D> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot);
@@ -1356,6 +1377,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
camera_server = CameraServer::create();
initialize_physics();
+ initialize_navigation_server();
register_server_singletons();
register_driver_types();
@@ -1733,6 +1755,12 @@ bool Main::start() {
}
#endif
+ {
+
+ int directional_atlas_size = GLOBAL_GET("rendering/quality/directional_shadow/size");
+ VisualServer::get_singleton()->directional_shadow_atlas_set_size(directional_atlas_size);
+ }
+
if (!editor && !project_manager) {
//standard helpers that can be changed from main config
@@ -1776,8 +1804,6 @@ bool Main::start() {
sml->get_root()->set_shadow_atlas_quadrant_subdiv(1, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q1_subdiv));
sml->get_root()->set_shadow_atlas_quadrant_subdiv(2, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q2_subdiv));
sml->get_root()->set_shadow_atlas_quadrant_subdiv(3, Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q3_subdiv));
- Viewport::Usage usage = Viewport::Usage(int(GLOBAL_GET("rendering/quality/intended_usage/framebuffer_allocation")));
- sml->get_root()->set_usage(usage);
bool snap_controls = GLOBAL_DEF("gui/common/snap_controls_to_pixels", true);
sml->get_root()->set_snap_controls_to_pixels(snap_controls);
@@ -1785,6 +1811,11 @@ bool Main::start() {
bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true);
sml->set_use_font_oversampling(font_oversampling);
+ int texture_filter = GLOBAL_DEF("rendering/canvas_textures/default_texture_filter", 1);
+ int texture_repeat = GLOBAL_DEF("rendering/canvas_textures/default_texture_repeat", 0);
+ sml->get_root()->set_default_canvas_item_texture_filter(Viewport::DefaultCanvasItemTextureFilter(texture_filter));
+ sml->get_root()->set_default_canvas_item_texture_repeat(Viewport::DefaultCanvasItemTextureRepeat(texture_repeat));
+
} else {
GLOBAL_DEF("display/window/stretch/mode", "disabled");
@@ -1797,6 +1828,11 @@ bool Main::start() {
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
GLOBAL_DEF("gui/common/snap_controls_to_pixels", true);
GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true);
+
+ GLOBAL_DEF("rendering/canvas_textures/default_texture_filter", 1);
+ ProjectSettings::get_singleton()->set_custom_property_info("rendering/canvas_textures/default_texture_filter", PropertyInfo(Variant::INT, "rendering/canvas_textures/default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,MipmapLinear,MipmapNearest"));
+ GLOBAL_DEF("rendering/canvas_textures/default_texture_repeat", 0);
+ 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"));
}
String local_game_path;
@@ -1900,8 +1936,6 @@ bool Main::start() {
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);
sml->get_root()->add_child(pmanager);
- // Speed up rendering slightly by disabling 3D features while in the project manager.
- sml->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING);
OS::get_singleton()->set_context(OS::CONTEXT_PROJECTMAN);
project_manager = true;
}
@@ -2011,6 +2045,8 @@ bool Main::iteration() {
message_queue->flush();
+ NavigationServer::get_singleton_mut()->step(frame_slice * time_scale);
+
PhysicsServer::get_singleton()->step(frame_slice * time_scale);
Physics2DServer::get_singleton()->end_sync();
@@ -2202,6 +2238,7 @@ void Main::cleanup() {
OS::get_singleton()->finalize();
finalize_physics();
+ finalize_navigation_server();
if (packed_data)
memdelete(packed_data);