Farseer tuning Settings for performance

Topics: Developer Forum, User Forum
Nov 27, 2011 at 2:04 PM


I have sucessfully used Farseer to develop one of my game using XNA. The game runs like a charm in Windows and WP7. I'm currently working on porting my game in IOS using Monotouch and Monogame. I've sucessfully compiled and used Farseer also over the first version of my game ported over Monotouch and Monogame. All works fine except for performances. The game runs much more slower on the iPhone device. I did some code investigations and it seems that the major bottlenek is Farseer. It become really slow when it has to manage more then 5-6 bodies with a single fixture attached (circle).

Reading the documentation I noticed that to tune Farseer i could change values from the Setting static class:


In order to get the most out of the engine, you should try and follow the guidelines below:

Enable sleeping 
Sleeping enables you to have large number of bodies in the world. It can also increase the stability of the engine since small movements in a stack of bodies don’t spread in the stack. A sleeping body has little overhead, so enabling it is recommended.

Disable CCD 
Continuous Collision Detection prevents tunneling but at the cost of performance. If you don’t have problems with tunneling, you should disable CCD all together.

Minimize the number of position and velocity iterations 
A high number of iterations makes the engine more stable at the cost of performance. You should tweak the values to fit your game.

The bad news is that if I change any value of that class, nothing seems to happend. I tryed to change values as follow:

  • EnableDiagnostics = false
  • VelocityIterations = 6
  • PositionIterations = 2
  • ContinuousPhysics = false

 I tryed also with lower values like VelocityIterations = 1 but nothing seems to change....

Any hint or suggestions? 

Dec 1, 2011 at 10:01 PM

Hmm I just tried changing th settings for my mini-game and it worked for me. I changed continuousPhysics to false and easily shot a ball through a wall, which has never happened before. So I know the file works and the settings are used. Did you forget to compile your farseer project as well as your game? In otherwords you made the changes but your game didn't recompile the farseer project, so it used the old code it had generated from the last time you did and ran the game? Most IDEs will do it automatically for you unless specified otherwise, but some do not compile all projects in a workspace when you try to run a specific one.