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

Merge pull request #103373 from YeldhamDev/build_remove_physics

Allow to compile templates without physics servers
This commit is contained in:
Rémi Verschelde
2025-03-28 17:30:03 +01:00
72 changed files with 951 additions and 364 deletions

View File

@@ -10,8 +10,6 @@ env.add_source_files(env.servers_sources, "camera_server.cpp")
env.add_source_files(env.servers_sources, "display_server.cpp")
env.add_source_files(env.servers_sources, "navigation_server_2d.cpp")
env.add_source_files(env.servers_sources, "navigation_server_3d.cpp")
env.add_source_files(env.servers_sources, "physics_server_2d.cpp")
env.add_source_files(env.servers_sources, "physics_server_2d_wrap_mt.cpp")
env.add_source_files(env.servers_sources, "register_server_types.cpp")
env.add_source_files(env.servers_sources, "rendering_server.cpp")
env.add_source_files(env.servers_sources, "text_server.cpp")
@@ -26,13 +24,17 @@ SConscript("navigation/SCsub")
SConscript("rendering/SCsub")
SConscript("text/SCsub")
if not env["disable_3d"]:
if not env["disable_physics_2d"]:
env.add_source_files(env.servers_sources, "physics_server_2d.cpp")
env.add_source_files(env.servers_sources, "physics_server_2d_wrap_mt.cpp")
if not env["disable_physics_3d"]:
env.add_source_files(env.servers_sources, "physics_server_3d.cpp")
env.add_source_files(env.servers_sources, "physics_server_3d_wrap_mt.cpp")
if not env["disable_xr"]:
env.add_source_files(env.servers_sources, "xr_server.cpp")
SConscript("xr/SCsub")
if not env["disable_xr"]:
env.add_source_files(env.servers_sources, "xr_server.cpp")
SConscript("xr/SCsub")
lib = env.add_library("servers", env.servers_sources)

View File

@@ -81,16 +81,19 @@
// 2D physics and navigation.
#include "navigation_server_2d.h"
#ifndef PHYSICS_2D_DISABLED
#include "physics_server_2d.h"
#include "physics_server_2d_dummy.h"
#include "servers/extensions/physics_server_2d_extension.h"
#endif // PHYSICS_2D_DISABLED
// 3D physics and navigation (3D navigation is needed for 2D).
#include "navigation_server_3d.h"
#ifndef _3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
#include "physics_server_3d.h"
#include "physics_server_3d_dummy.h"
#include "servers/extensions/physics_server_3d_extension.h"
#endif // PHYSICS_3D_DISABLED
#ifndef XR_DISABLED
#include "xr/xr_body_tracker.h"
#include "xr/xr_controller_tracker.h"
@@ -101,19 +104,20 @@
#include "xr/xr_positional_tracker.h"
#include "xr_server.h"
#endif // XR_DISABLED
#endif // _3D_DISABLED
ShaderTypes *shader_types = nullptr;
#ifndef _3D_DISABLED
static PhysicsServer3D *_create_dummy_physics_server_3d() {
return memnew(PhysicsServer3DDummy);
}
#endif // _3D_DISABLED
#ifndef PHYSICS_2D_DISABLED
static PhysicsServer2D *_create_dummy_physics_server_2d() {
return memnew(PhysicsServer2DDummy);
}
#endif // PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
static PhysicsServer3D *_create_dummy_physics_server_3d() {
return memnew(PhysicsServer3DDummy);
}
#endif // PHYSICS_3D_DISABLED
static bool has_server_feature_callback(const String &p_feature) {
if (RenderingServer::get_singleton()) {
@@ -250,6 +254,7 @@ void register_server_types() {
ServersDebugger::initialize();
#ifndef PHYSICS_2D_DISABLED
// Physics 2D
GDREGISTER_CLASS(PhysicsServer2DManager);
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2DManager", PhysicsServer2DManager::get_singleton(), "PhysicsServer2DManager"));
@@ -275,12 +280,13 @@ void register_server_types() {
GLOBAL_DEF(PropertyInfo(Variant::STRING, PhysicsServer2DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"), "DEFAULT");
PhysicsServer2DManager::get_singleton()->register_server("Dummy", callable_mp_static(_create_dummy_physics_server_2d));
#endif // PHYSICS_2D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer2D);
GDREGISTER_CLASS(NavigationPathQueryParameters2D);
GDREGISTER_CLASS(NavigationPathQueryResult2D);
#ifndef _3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
// Physics 3D
GDREGISTER_CLASS(PhysicsServer3DManager);
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3DManager", PhysicsServer3DManager::get_singleton(), "PhysicsServer3DManager"));
@@ -308,6 +314,7 @@ void register_server_types() {
GLOBAL_DEF(PropertyInfo(Variant::STRING, PhysicsServer3DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"), "DEFAULT");
PhysicsServer3DManager::get_singleton()->register_server("Dummy", callable_mp_static(_create_dummy_physics_server_3d));
#endif // PHYSICS_3D_DISABLED
#ifndef XR_DISABLED
GDREGISTER_ABSTRACT_CLASS(XRInterface);
@@ -322,7 +329,6 @@ void register_server_types() {
GDREGISTER_CLASS(XRServer);
GDREGISTER_ABSTRACT_CLASS(XRTracker);
#endif // XR_DISABLED
#endif // _3D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer3D);
GDREGISTER_CLASS(NavigationPathQueryParameters3D);
@@ -359,13 +365,15 @@ void register_server_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton(), "NavigationServer3D"));
Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton(), "RenderingServer"));
#ifndef PHYSICS_2D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton(), "PhysicsServer2D"));
#ifndef _3D_DISABLED
#endif // PHYSICS_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton(), "PhysicsServer3D"));
#endif // PHYSICS_3D_DISABLED
#ifndef XR_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton(), "XRServer"));
#endif // XR_DISABLED
#endif // _3D_DISABLED
OS::get_singleton()->benchmark_end_measure("Servers", "Register Singletons");
}