1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Implemented physics plug

Moved init_physics

Implemented physics 2D plug

Fix clang

Fix clang

Fix static check

Fix clang

Fix static check

Moved physics server initialization

Moved physics server settings initialization
This commit is contained in:
AndreaCatania
2017-10-21 13:02:06 +02:00
parent f52ab8d864
commit 7a9ca08f16
28 changed files with 286 additions and 152 deletions

View File

@@ -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);