I had a question, probably just for Erin - do you happen to know what the running times of the Box2D broadphase operations are? I'm mainly interested in the asymptotics of additions, removals, and queries.
The reason I'm interested is that the last time I manually put together a broadphase (a simple sweep and prune), I was working on an Asteroids-style game where the player could fire at a fairly high rate, the bullets bounced everywhere, and the asteroids exploded into many chunks upon being hit (hard enough), some of which might even be exploded themselves within the same step. Sometimes quite a few objects get created and destroyed each frame. It turned out that while the algorithm worked quite fast to handle normal simulation, the additions and removals happened often enough that the broadphase was more or less useless, causing visible lags whenever things exploded.
There I used the probably too naive method of starting a newly spawned object at infinity and swapping it into place (or reverse for removals), which should be O(N), though with a somewhat high constant since every other swap causes pairs to be added and removed. I've seen people comment on stabbing counts, which I'm pretty sure Box2D uses, to accelerate these actions - if this is the case, do you know a good reference or explanation of what's going on there? I'm curious as to whether replacing my old broadphase with Box2D's might be helpful, but I'd like to better understand the details as well.
The reason I'm interested is that the last time I manually put together a broadphase (a simple sweep and prune), I was working on an Asteroids-style game where the player could fire at a fairly high rate, the bullets bounced everywhere, and the asteroids exploded into many chunks upon being hit (hard enough), some of which might even be exploded themselves within the same step. Sometimes quite a few objects get created and destroyed each frame. It turned out that while the algorithm worked quite fast to handle normal simulation, the additions and removals happened often enough that the broadphase was more or less useless, causing visible lags whenever things exploded.
There I used the probably too naive method of starting a newly spawned object at infinity and swapping it into place (or reverse for removals), which should be O(N), though with a somewhat high constant since every other swap causes pairs to be added and removed. I've seen people comment on stabbing counts, which I'm pretty sure Box2D uses, to accelerate these actions - if this is the case, do you know a good reference or explanation of what's going on there? I'm curious as to whether replacing my old broadphase with Box2D's might be helpful, but I'd like to better understand the details as well.