stephengold / Libbulletjme

A JNI interface to Bullet Physics and V-HACD
https://stephengold.github.io/Libbulletjme/lbj-en/English/overview.html
Other
83 stars 9 forks source link

[ Question ] - How does this library/engine handle spatial partitioning? #30

Closed boxic closed 2 months ago

boxic commented 2 months ago

Sorry if this is an inappropriate place to ask questions rather than file reports or feature requests, but I was just curious how this library/engine handles spatial partitioning - put simpler, how does the library/engine ensure rigid bodies only check for collisions against objects near them? Purely wanting to learn how it works! is there a specific tree structure it uses?

stephengold commented 2 months ago

JMonkeyEngine's scene graph is an acyclic directed graph: a tree of spatials, with meshes at the leaves. It gives you the flexibility to organize each scene spatially, if you wish. Whatever scene-graph organization you choose, spatial culling is performed using bounding volumes, either axis-aligned bounding boxes (AABBs) or bounding spheres, at each level of the graph.

JME is a volunteer-run project with an active and welcoming community, but we don't congregate here at GitHub. This is our tracker for bugs and enhancements. If you have (further) questions about how JME works, the best forum for them would be our Discourse hub.

boxic commented 2 months ago

thank you for the response!

stephengold commented 2 months ago

Re-reading this, I just realized that boxic probably wasn't asking about JMonkeyEngine, as I hastily assumed. Oops!

boxic commented 2 months ago

Yeah I was talking about Bullet I think

stephengold commented 2 months ago

Bullet implements 2 broadphase collision algorithms:

  1. incremental 3-D sweep and prune
  2. dynamic bounding-volume hierarchy based on AABB

You basically select one or the other when the physics space is created.

I haven't studied them in detail, but I can point you to the C++ code.

boxic commented 2 months ago

Ah okay, that's much more insightful, thank you!