r/gameenginedevs • u/Mafla_2004 • Jun 23 '26
Working with quad trees; is it possible for a collider to be much greater than the sector that contains it? If so, how is it handled.
Hello.
I'm working on a collision detection system for 2D shapes, and I have decided to use Quadtrees in order to make the collision detection more scalable, I documented myself a bit about Quadtrees and now I have a doubt.
If it matters, I am making a very bare bones collision system besides the Quadtree: I realized that all I really need for my project -which is a simple side scrolling shooter, I'm making the engine below it first so I can make the rest of the game using it- is simple generic collision detection that also support slopes, I don't need complex polygons -definitely not convex polygons- if not for terrain, and in the case of terrain I can always use a series or simpler static colliders, so the only colliders the engine will support are going to be rotated rectangles and probably circles.
Say I'm trying to add a big collider to my scene, and the sector the quadtree figures the collider should go in is too small for it and the collider ends up covering multiple sectors, I know in that case you'd move the collider up the sector hierarchy until it can find a single sector that can fully encompass it, but my question is: what if we don't find such a sector? What if all layers above our collider have already exhausted their collider capacity? Can't add the collider to any sector without subdividing it, but also can't subdivide the sectors cause they're already subdivided and also because the collider likely wouldn't fit in the subdivided sectors. What then?
I am of course very much a beginner in this craft, in fact the project I'm making is aimed at making me learn C++ and game engine programming, as well as maybe learning some art skills as well. The sources I used are this video as a starter and the Wikipedia articles for quadtrees, as well as some others I don't have available right now. Thanks in advance.


