@todo FIXME: Could maybe be moved to have less code in main.cpp.
| 364 | |
| 365 | /// @todo FIXME: Could maybe be moved to have less code in main.cpp. |
| 366 | void initialize_physics() { |
| 367 | #ifndef PHYSICS_3D_DISABLED |
| 368 | /// 3D Physics Server |
| 369 | physics_server_3d = PhysicsServer3DManager::get_singleton()->new_server( |
| 370 | GLOBAL_GET(PhysicsServer3DManager::setting_property_name)); |
| 371 | if (!physics_server_3d) { |
| 372 | // Physics server not found, Use the default physics |
| 373 | physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server(); |
| 374 | } |
| 375 | |
| 376 | // Fall back to dummy if no default server has been registered. |
| 377 | if (!physics_server_3d) { |
| 378 | 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)); |
| 379 | physics_server_3d = memnew(PhysicsServer3DDummy); |
| 380 | } |
| 381 | |
| 382 | // Should be impossible, but make sure it's not null. |
| 383 | ERR_FAIL_NULL_MSG(physics_server_3d, "Failed to initialize PhysicsServer3D."); |
| 384 | physics_server_3d->init(); |
| 385 | #endif // PHYSICS_3D_DISABLED |
| 386 | |
| 387 | #ifndef PHYSICS_2D_DISABLED |
| 388 | // 2D Physics server |
| 389 | physics_server_2d = PhysicsServer2DManager::get_singleton()->new_server( |
| 390 | GLOBAL_GET(PhysicsServer2DManager::get_singleton()->setting_property_name)); |
| 391 | if (!physics_server_2d) { |
| 392 | // Physics server not found, Use the default physics |
| 393 | physics_server_2d = PhysicsServer2DManager::get_singleton()->new_default_server(); |
| 394 | } |
| 395 | |
| 396 | // Fall back to dummy if no default server has been registered. |
| 397 | if (!physics_server_2d) { |
| 398 | WARN_PRINT(vformat("Falling back to dummy PhysicsServer2D; 2D physics functionality will be disabled. If this is intended, set the %s project setting to Dummy.", PhysicsServer2DManager::setting_property_name)); |
| 399 | physics_server_2d = memnew(PhysicsServer2DDummy); |
| 400 | } |
| 401 | |
| 402 | // Should be impossible, but make sure it's not null. |
| 403 | ERR_FAIL_NULL_MSG(physics_server_2d, "Failed to initialize PhysicsServer2D."); |
| 404 | physics_server_2d->init(); |
| 405 | #endif // PHYSICS_2D_DISABLED |
| 406 | } |
| 407 | |
| 408 | void finalize_physics() { |
| 409 | #ifndef PHYSICS_3D_DISABLED |
no test coverage detected