r/GraphicsProgramming • u/IRateBurritos • 19d ago
Question Question about broad-phase collision detection
I'm working on a game engine and using GPU Gems as a loose guide for my physics. I really like the approach they outline for broad phase collision but I'm confused by one point. In ensuring no collision is double counted, the book says to expand each bounding sphere by sqrt(2) and then make the grid 1.5x that large. I did the math and understand where 1.5 comes from, but I'm stumped on the sqrt(2) and why we have to expand the bounding spheres themselves? Isn't the whole point of a bounding sphere that it contains the entire collider and is rotation invariant?
Also, just wanted to check if people think the book's approach is still viable. It seems solid to me but I'm still new to all this.
View all comments
Show parent comment
1
u/IRateBurritos 18d ago edited 18d ago
So, I think that's the confusion for me. Assuming the cells are arranged as
0 1 0' 1'
2 3 2' 3'
And the cell size is 1.5x the sphere radius, I don't see why the sqrt(2) scaling is necessary, especially considering they also scale the spheres by that amount. The 1.5 makes sense to me for removing the case where spheres are double counted: assuming that the spheres have radius r and the cells a size of q, and that the left border of my diagram above is 0, then the worst case scenario is having one sphere centered in cell 3 at q + r - delta, and one centered in cell 2' on the right at 2q+delta. Then the first sphere is barely overlapping cell 2 and the balls' centroids are separated by q-r + 2*delta. By setting q = 3r (1.5d), you make it impossible for the spheres to overlap. So I get where 1.5 comes from. But the sqrt(2) doesn't show up anywhere in that math. I can't think of a config that would place the spheres any closer while satisfying the conditions laid out in the article.