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

Ridiculous Physics CPU Spike with multiple CharacterBody3D colliding with each other #78895

Closed
MagickPanda opened this issue Jul 1, 2023 · 6 comments

Comments

@MagickPanda
Copy link

Godot version

4.1 rc2

System information

Godot v4.1.rc2 - Windows 10.0.19043 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.1694) - AMD Ryzen 7 1700 Eight-Core Processor (16 Threads)

Issue description

I found this problem when testing the possiblity of using CharacterBody3D directly as my game object's physics.

I was attempting to make 4 objects with 'CharacterBody3D' as root and a simple convex collision3d shape generated from in-game model preview(view-> generate simple convex blahblah) convex generation function, I made them all move towards to a fixed Vector3 point in game space, after a few seconds of moving, they finally run into each other and begin to collide, then the physics frame uses up all CPU time and take like 300-500ms per process, which is ridiculous with only 4 objects.

Also I tried with a simple CharacterBody3D and the terrain as convex Static3D object, it randomly spikes too, but it's not as 100% reproducible as the one with 4 CharacterBody3D objects I just posted. So I only posted this one.

Here is a video recording the problem and the profiler view:
https://github.com/godotengine/godot/assets/35385424/cfed1528-5b35-41ed-88a5-10e7eff5e96f

Tried changing the CharacterBody3D's inspector setting from Grounded to Floating, and tried to turn on the 'Run Physics on a separated thread' option, but neither worked, it will end up like 1-2FPS with 500ms physics time eventually upon collisions.

Tried searching a bit but didn't find a similiar issue, lemme know if this is already reported, and please close this one if it's known issue/being fixed.
Thanks.

Steps to reproduce

Just run the minimal project in the attachment and click 'Run' button.

Check Debugger->Profiler->Start to see the physics frame time sky-rocket ing from 10ms to 500ms -.-

Minimal reproduction project

physics-spike.zip

@Zireael07
Copy link
Contributor

Zireael07 commented Jul 1, 2023

Convex shapes generated by that function are NOT simple, can have thousands of vertices! Use a sphere or a box instead

EDIT TO ADD: duplicate of my own issue but I can't find the number now

@AThousandShips

This comment was marked as outdated.

@AThousandShips AThousandShips closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2023
@AThousandShips
Copy link
Member

My bad, looked through your code and saw ridiculously large collision shapes but running the project those weren't used, reopening

@AThousandShips
Copy link
Member

Since you tested with simpler shapes as well I assume this is actually related to using move_and_slide like this, I'm not sure how safe it is to have multiple bodies do this against each other constantly, might just be something that is very non-performant to do

@Calinou
Copy link
Member

Calinou commented Jul 1, 2023

This is still a duplicate of #48587, as the underlying cause is the same (see the linked duplicate issues on that issue). The other issue's title should be changed as it doesn't just affect complex convex shapes, but any convex shape really.

@AThousandShips
Copy link
Member

Gotcha! Didn't see any mention of this simple shapes (28 points) on that one

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