This project has moved. For the latest updates, please go here.

Optimizing Farseer Physics for the Windows Phone 7

Topics: Developer Forum
Nov 13, 2010 at 8:38 PM
Edited Nov 13, 2010 at 8:45 PM


I am trying to port my game, BridgeBasher to the Windows Phone 7 platform. I have gotten the newest version of FPE (v3.1) and ported all of my code over and now I'm running into some serious performance issues.

BridgeBasher is not a very complex game, nor are there that many objects in the scene. However, the entire bridge is glued together with Revolute Joints.

I'm using the System.Diagnostic.Stopwatch class, and I've found that my World.Step( ) is taking around 80 milliseconds for a bridge that has 113 revolute joints, which connect a total of 67 beams. I have implemented BridgeBasher for the iPhone using Box2D (C++), and this same bridge runs great.

I've tried tweaking the Settings.cs file quite a bit, but I have been unable to really improve performance. Does anybody have any idea of how to optimize Farseer this type of scenario when I have tons of Revolute Joints?


EDIT: I should mention, that I am trying this on a real device, the Samsung Focus.

Nov 13, 2010 at 10:10 PM

Does the Stopwatch work on WP7?

I'm currently optimizing the engine to run better on the compact framework. The compiler is not really great at optimizing the code, so I have to do that manually. I've not touched the joints at all and I guess there is a lot of places where I could optimize the for compact framework.

I don't have a WP7 myself (tried several times to get hold of one from Microsoft) - if you are willing, I would take a look at your code and optimize the parts of the engine you use extensively - then you could run it on WP7 and see if it runs better.

Nov 14, 2010 at 2:09 AM

To get Stopwatch on WP7 I think you have to include the Microsoft.Devices.dll  As suggested

Nov 14, 2010 at 2:43 AM

Yes, stopwatch works on WP7.

I sent you a link to the source code so you can download it. I did optimize my code a little, and I was able to get the bridge to around 30 ms per world step. I think I'm also running into some performance problems with Silverlight in general.

Let me know if I can help in any way. I'll be glad to compile and test anything on my device that you come up with!

Nov 14, 2010 at 12:53 PM

If you need a reference that is not included in the default project (when clicking on an XNA project and choosing convert to WP7) then I can't make FPE use stopwatch. At the moment I have WP7 as an exception in World.cs where I use Stopwatch. I'll have to look into that.

I'm looking over your code right now. I can't run the code as I can't even run the WP7 emulator (too old graphics card), so it is a little like shooting in the dark. I'll send the code back to you when I've made a few changes.