-
Notifications
You must be signed in to change notification settings - Fork 58
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
Manipulating compound shapes after body has entered tree can be slow #660
Comments
I haven't tested it but do you think something like a CSGTorus used as an expanding ring/shockwave where an Area3D has to detect it, could severely impact performance? this requires the torus to change its collision shape every frame plus an Area3D to detect it, which I read it can be slow |
A If we ignore that part, it would probably depend somewhat on the tessellation of the torus, but just changing a single shape isn't going to have a massive impact. It's usually when you start doing many shape changes per frame that it becomes a problem. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Just noting that this issue can be a big problem for construction games, where it is extremely common to have rigidbodies made of compound shapes that can be removed/added at runtime, as players construct or do damage to them (building, vehicle, ship...). Game examples include Robocraft, Starship Evo, Space Engineers, From the Depths, Scrap Mechanic... |
I been working on a character controller with a dynamic crouch and i found that manipulating the shape is the most expensive thing on the project right now. Manipulating around 16 shapes starts to affect the performance and with 32 or 64 the framerate slows down a lot. For comparison, doing this with Godot physics has no noticeable impact on the frame rate. This makes the achieving the feature parity with the old prototype using jolt is unfortunately not possible right now, as we were modifying the shape of dozens or even hundreds of collision shapes in a similar way to a bullet hell. Is there any possibility to lessen the performance impact? Maybe not hundreds, but we would like to at least maintain the crouching for 32 players. |
If it's 16 bodies all containing just a single shape that's being manipulated each once per frame I would be somewhat surprised, since a single-shaped body wouldn't be using Jolt's There's not a whole lot that can be done to improve the situation in that scenario, besides maybe checking to see whether the shape data has actually changed before invalidating/rebuilding the root shape, but that'll only be viable for the simpler shapes, which are relatively cheap to create anyway (assuming it's the only shape in the body). |
Thank you Mihe. I double checked and you are right, there is not a big difference. But updating 64 collision shapes is taking up to 8 ms now in godot physics or jolt. Which is estrange, this used to not be a problem some time at the past. |
This is a formal issue for the discrepancy with Godot Physics that's currently mentioned in
README.md
:Put simply, as soon as a
CollisionObject3D
has been added to the scene tree (and thus the physics space) any changes to the body's overall shape will force a full rebuild of the body's compound shape, which is slow/expensive. This applies when changing any property of any currently attached shape as well as when adding or removing an individual shape.The only real workaround for avoiding multiple rebuilds when dealing with multiple shape changes is to do them out-of-tree (i.e. when not in a physics space).
Here's how to reproduce it:
main.gd
and changeslow
tofalse
The text was updated successfully, but these errors were encountered: