summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-11-03 23:39:44 -0300
committerGitHub <noreply@github.com>2017-11-03 23:39:44 -0300
commit7715a261d5f387b7769bb8149735e4131ea97757 (patch)
tree41a3bfe4c655470a3e7b9b5e162e48853ca561d2 /main/main.cpp
parent25c38c75425e3ccfcaed53ebd38fc588d6f35764 (diff)
parent7a9ca08f16c500aa0caccc21a8e42564f962971a (diff)
Merge pull request #12262 from AndreaCatania/pplug
Physics server plug
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp
index deffb3a632..5e8e52d3e5 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -47,6 +47,8 @@
#include "scene/main/scene_tree.h"
#include "servers/arvr_server.h"
#include "servers/audio_server.h"
+#include "servers/physics_2d_server.h"
+#include "servers/physics_server.h"
#include "io/resource_loader.h"
#include "script_language.h"
@@ -84,6 +86,8 @@ static bool _start_success = false;
static ScriptDebugger *script_debugger = NULL;
AudioServer *audio_server = NULL;
ARVRServer *arvr_server = NULL;
+PhysicsServer *physics_server = NULL;
+Physics2DServer *physics_2d_server = NULL;
static MessageQueue *message_queue = NULL;
static Performance *performance = NULL;
@@ -120,6 +124,35 @@ static int fixed_fps = -1;
static OS::ProcessID allow_focus_steal_pid = 0;
+void initialize_physics() {
+
+ /// 3D Physics Server
+ physics_server = PhysicsServerManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServerManager::setting_property_name));
+ if (!physics_server) {
+ // Physics server not found, Use the default physics
+ physics_server = PhysicsServerManager::new_default_server();
+ }
+ ERR_FAIL_COND(!physics_server);
+ physics_server->init();
+
+ /// 2D Physics server
+ physics_2d_server = Physics2DServerManager::new_server(ProjectSettings::get_singleton()->get(Physics2DServerManager::setting_property_name));
+ if (!physics_2d_server) {
+ // Physics server not found, Use the default physics
+ physics_2d_server = Physics2DServerManager::new_default_server();
+ }
+ ERR_FAIL_COND(!physics_2d_server);
+ physics_2d_server->init();
+}
+
+void finalize_physics() {
+ physics_server->finish();
+ memdelete(physics_server);
+
+ physics_2d_server->finish();
+ memdelete(physics_2d_server);
+}
+
static String unescape_cmdline(const String &p_str) {
return p_str.replace("%20", " ");
@@ -1072,9 +1105,13 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid);
}
- MAIN_PRINT("Main: Load Scripts, Modules, Drivers");
+ MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts");
register_module_types();
+
+ initialize_physics();
+ register_server_singletons();
+
register_driver_types();
ScriptServer::init_languages();
@@ -1791,6 +1828,7 @@ void Main::cleanup() {
unregister_server_types();
OS::get_singleton()->finalize();
+ finalize_physics();
if (packed_data)
memdelete(packed_data);