summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorRicardo Buring <ricardo.buring@gmail.com>2024-08-07 16:20:21 +0200
committerRicardo Buring <ricardo.buring@gmail.com>2024-09-21 21:19:45 +0200
commit0333648cea0483edce0131722789b54d4daa7d5a (patch)
treeedf63916f4ca196d097c66c52d04432e4a94bc44 /main
parente4e024ab88efe74677769395886bc1b09eccbac7 (diff)
downloadredot-engine-0333648cea0483edce0131722789b54d4daa7d5a.tar.gz
Move Godot Physics 3D into a module; add dummy 3D physics server
If the module is enabled (default), 3D physics works as it did before. If the module is disabled and no other 3D physics server is registered (via a module or GDExtension), then we fall back to a dummy implementation which effectively disables 3D physics functionality (and a warning is printed). The dummy 3D physics server can also be selected explicitly, in which case no warning is printed.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp
index fa50a3039f..439cd385c0 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -83,6 +83,7 @@
#ifndef _3D_DISABLED
#include "servers/physics_server_3d.h"
+#include "servers/physics_server_3d_dummy.h"
#include "servers/xr_server.h"
#endif // _3D_DISABLED
@@ -320,7 +321,15 @@ void initialize_physics() {
// Physics server not found, Use the default physics
physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server();
}
- ERR_FAIL_NULL(physics_server_3d);
+
+ // Fall back to dummy if no default server has been registered.
+ if (!physics_server_3d) {
+ WARN_PRINT(vformat("Falling back to dummy PhysicsServer3D; 3D physics functionality will be disabled. If this is intended, set the %s project setting to Dummy.", PhysicsServer3DManager::setting_property_name));
+ physics_server_3d = memnew(PhysicsServer3DDummy);
+ }
+
+ // Should be impossible, but make sure it's not null.
+ ERR_FAIL_NULL_MSG(physics_server_3d, "Failed to initialize PhysicsServer3D.");
physics_server_3d->init();
#endif // _3D_DISABLED