Skip to content
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

CharacterBody3D exhibits very poor performance against certain concave colliders. #50300

Closed
Tracked by #45333
SaracenOne opened this issue Jul 8, 2021 · 4 comments
Closed
Tracked by #45333

Comments

@SaracenOne
Copy link
Member

Godot version

14cc1df

System information

Windows 10, Vulkan, Intel® Core™ i7-8700K, Nvidia GTX 1080 (471.11)

Issue description

When using CharacterBody3D, certain arrangements of concave colliders can result in severe performance drops. I do not have a consistent example of what arrangements specifically cause the performance dips, but I have included minimum reproduction project demonstrating it.

I have artificially increased the project's FPS to 240 since there is so little else going on in this scene for the performance dip to be noticable. You can set it back to 60 FPS though. This was also tested on the debug build, not release_debug, so compiling with optimisation will likely mitigate this, but discussions have prior does indiciate that this is likely legitimate bug in how the physics engine is processing things.
devenv_xvhWcpxXM9

Steps to reproduce

Simply open the example project, and use the WSAD keys to walk forward into the corner. You can use either a C++ profiler or Godot's own profiling tools to observe just how much of the frame gets spent processing physics when walking into this corner. This has so far only been tested with a debug symbols build. I have also included the .blend file for this scene.

Minimal reproduction project

collision_perf.zip

@pouleyKetchoupp
Copy link
Contributor

I haven't investigated the exact cause of the performance issue within the physics system, but as a workaround it seems that increasing the collision safe margin on the character helps. You can set it to something like 0.05 and the fps doesn't drop anymore. It's a little margin on collision detection, so increasing it makes things slightly less accurate, but it will be probably not noticeable.

With the default value which is very low, it might cause the system to do extra collision tests each frame which lead to the drop in performance. That still needs to be investigated.

@Calinou
Copy link
Member

Calinou commented Nov 8, 2021

@SaracenOne Does increasing the collision safe margin as described above improve the performance?

@reduz
Copy link
Member

reduz commented Dec 22, 2022

I ported this to master and I can no longer reproduce the problem, would help checking/verification.
collision_perf.zip

@SaracenOne
Copy link
Member Author

I tested it again and didn't notice the same perf drops. There were issues with stuttering and the capsule being pushed down, but the perf at least doesn't seem to be an issue in this specific case at least so I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants