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

Does Rapier 3d Implement Spatial Partitioning? #507

Closed
The-DevBlog opened this issue May 13, 2024 · 1 comment
Closed

Does Rapier 3d Implement Spatial Partitioning? #507

The-DevBlog opened this issue May 13, 2024 · 1 comment

Comments

@The-DevBlog
Copy link

The-DevBlog commented May 13, 2024

Scenario

I have a simple program that employs 1000 units on screen. Each unit has its own dynamic rigidbody, as well as a collider. On startup, these units are spaced far enough apart that they are not colliding. My program runs at a very slow 15 FPS, and when the units actually start colliding, it drops to below 5 FPS.

From my understanding, collision happens in two phases, the Broadphase & Narrowphase. The Broadphase checks to see if there are any collisions or intersections, while the narrowphase uses the data from the broadphase to actually compute the contact points required for actual collision.

Because of the exponentially bad performance as I increase the amount of units on screen, I would assume that spatial Partitioning is not implemented.

Questions

  • Is the broadphase checking for collisions on a collider which every other collider on screen? If this is this case, with 1000 units, that means there are 1000000 calculations being made every frame?
  • If this^^ is the case, is there a way to implement spatial awareness so that the broadphase is only checking for intersections in a certain proximity to a collider?
@The-DevBlog The-DevBlog changed the title Does Rapier 3d Implement Spatial Awareness? Does Rapier 3d Implement Spatial Partitioning? May 13, 2024
@Vrixyz
Copy link
Contributor

Vrixyz commented May 20, 2024

Short answer: yes, rapier3d has space partitionning.

Slightly longer response is that the broadphase setups the space partitioning and the narrowphase does the finer detection. On top of that there is an IslandManager to be able to parallelize these 2 steps better.

This repository is focused on bevy integration though, and I feel like your question is more oriented towards "lower level" performance: Consider looking into the lower level crates such as rapier or Parry.

If you have a particular performance issue, double check you're running in release mode (or your dependency is), as mentioned in the documentation.

If you still have a problem, please reopen an issue! Minimal reproducible examples are appreciated :)

@Vrixyz Vrixyz closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants