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

Fix rigid_body_writeback performance scaling #325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shfty
Copy link

@Shfty Shfty commented Feb 7, 2023

Currently, the RigidBodyWritebackComponents query used by the rigid_body_writeback system is composed of an Entity and several Option<T> components, with no concrete by-ref / by-mut borrow to prevent it from checking every entity in the world.

This causes it to scale poorly in scenes with many entities. Consider an example scene with two RigidBody cubes and 8000 non-physics background meshes: writeback_rigid_bodies will check all 8002 objects despite only two of them being relevant, which reduces overall frame rate by ~60FPS in my local testing.

This change adds RapierRigidBodyHandle to the query as a concrete by-ref borrow, and passes its inner handle directly to the rest of the system rather than looking it up via entity2body. This prevents irrelevant entities from being queried, and fixes the aforementioned performance deficit.

@Aceeri
Copy link
Sponsor Contributor

Aceeri commented Jul 31, 2023

This should be fixed by #361 now

@Vrixyz
Copy link
Contributor

Vrixyz commented May 20, 2024

Reminder to use hide whitespace option, this change is very interesting ; I think this should get merged !

image

@Vrixyz Vrixyz added D-Easy P-High arbitrary important item A-Dynamics A-Integration very bevy specific labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics A-Integration very bevy specific D-Easy P-High arbitrary important item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants