Theory To Speed Up Farseer

Topics: Developer Forum, Project Management Forum, User Forum
May 27, 2010 at 10:51 PM
Edited May 27, 2010 at 10:52 PM

Ok, first off I'm just looking for helpful criticism to see if this is a good idea or not. I am building levels for my game that will need around 800 bodies per level. This works fine on my computer but on Xbox, this is a completely different story. Well I got to thinking about how I could simplify this. We have broadphase collision, and narrowphase collision that occur. Well broadphase, to my knowledge, takes all bodies in the WHOLE world and determines whether they need to be checked for narrowphase collision. Well I will have bodies FAR away from other bodies that I know will NEVER react with eachother. I don't know ANYTHING about the activity controller because I don't understand it (be wonderful to see a good post about it!) but I thought of an alternate route. Couldn't you use multiple physics simulators to separate everything? Or at least something that realizes what is even close enough to need physics checked on it? I don't need physics checked with anything off screen but I don't know how to specify what does not need checked. I have TONS of enemies flying and running around that don't need to be if they are off screen. I have set up code to disable them when they are far away but how do I disable their bodies. Is it possible to implement something like this? 

Physics Example

(Sorry for some image problems here. Parallax scrolling and me wanting to finish quick didn't line everything up :)  )

These different colored boxes would be that anything in each of these bounding boxes is made active or inactive depending on where the main character is. So if the main character is in the blue box, all physics are active in there and enemies can attack that are part of the blue bounding box. This would be the same for each bounding box. Thing is, how would you go about doing this? I don't feel it would be the best to have multiple physics simulators for something like this because it would require moving the main character body to whatever simulator is active. 

On top of this I have thought of separating my enemies all into a 2D array. The first dimension is which bounding box it is in and the second dimension is just the enemy itself. Thing is, how do I separate static bodies that don't move? Also how do you TRULY disable a body? I would rather not remove from simulation because of reloading but I want it completely inactive where it doesn't move and no collisions occur. Maybe this is what the inactivitycontroller does lol. I have no clue. I don't understand it really. Anyways sorry if that was a jumbled mess. I thought of some ideas and thought I'd share and also ask some questions.

May 28, 2010 at 9:42 PM

Actually, I had the same issue and modified the SelectiveSweepCollider.cs class.

Check it out here:

May 29, 2010 at 8:49 PM

This is resolved in FPE 3.0 - we have a good sleeping bodies system in 3.0 that should take care of situations like the one you describe. Bodies that stay still for a while simply goes to sleep (it wakes up when touched or moved) and sleeping bodies are ignored in the broadphase.

There are games that have parallax scrolling with physics enabled in both the foreground and background. In the case where the foreground and background bodies can't collide, I would suggest using multiple physics simulator instances and multithread them to speed up such a scenario.