-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Godot Physics 3D into a module; add dummy 3D physics server #95252
Conversation
Is this module already automatically disabled with the |
4a992f6
to
3821d80
Compare
@Calinou Thanks for the suggestion, the |
3821d80
to
7bcd2ee
Compare
7f0aa42
to
0979158
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, it works as expected.
When compiling the editor with module_godot_physics_3d_enabled=no
, the project settings dialog is correctly updated to remove the mention of the GodotPhysics server:
All 3D demo projects run when no physics server is enabled (with correct visuals), although you can't move, which is expected.
Some remarks (which also apply to the 2D counterpart of this PR, I assume):
- A warning is also printed on startup of an empty project with just a Node, both in the editor stdout (not visible in the Output panel as it's too early) and in the running project:
WARNING: No PhysicsServer3D implementation was found; 3D physics functionality will be disabled.
at: initialize_physics (main/main.cpp:326)
- There should probably be a
Dummy
option you can select in the project settings for two reasons:- Silence the warning when you don't compile any physics engines. This is useful when compiling a binary with no physics engines to reduce the binary size of non-game applications, or games that write their own physics without using PhysicsServer.
- Simulate what happens when physics are disabled at build-time, without needing to compile a separate binary.
0979158
to
561a199
Compare
Great idea @Calinou. I added the option, and now a warning only appears when the dummy server is used as a fallback:
When the Dummy setting is chosen explicitly, there is no warning. The fallback warning is still not printed in the editor Output panel when the editor starts, but I guess that's fine. |
Tested a build of a web
Without:
So a 1.47% size reduction on the wasm (487 KiB), and 1.88% on the zip (148 KiB). Tested with |
561a199
to
ed034f4
Compare
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.
ed034f4
to
0333648
Compare
Thanks! |
If the module is enabled (default), 3D physics works as it did before this PR.
If the module is disabled and no other 3D physics server is registered (via a module or GDExtension), then Godot falls back to a dummy implementation which effectively disables 3D physics functionality (and a warning is printed).
To try it, compile with the SCons option
module_godot_physics_3d_enabled=no
.This is useful for games that want to use a different 3D physics server, especially in web builds where binary size matters.
Linux binary size comparison (
scons target=template_release production=yes use_llvm=yes linker=lld
):So the binary size of the Godot Physics 3D module is 935.688 KiB (958144 bytes).