Change Farseer Physics Engine settings to improve performances
Asked Answered
D

1

6

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 bottleneck 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:

Performance

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 happen. I tried to change values as follow:

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

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

Anyone have already changed Settings class values to improve performances?

Derouen answered 28/11, 2011 at 9:17 Comment(3)
You may want to try asking this on gamedev.stackexchange.com. Since its community is specifically focused on game development (with a seemingly high concentration of XNA developers) you may get better answers there.Ayannaaycock
Mono is very slow. There very well may not be any way to alter the setting enough to save yourself.Alyworth
Not true ClassicThunder, Mono and Monotouch are really performant even on iOS. I have solved the issue and I discovered that Farseer it was not the major bottlenek on this.Derouen
D
1

Ok,

I have managed this. The major bottlenek was not related to Farseer. Once I solved all performance issues related to my "bad code", tuning Farseer like described above works very well to gain 5-10% of performances.

My game is written in XNA, ported to iOS an Android with monotouch and mono4android sucessfully.

Derouen answered 20/12, 2011 at 15:36 Comment(3)
You should know about SlimTune (or nProf) -- Very helpful in finding out the bottlenecks in your code.Barbarous
Could you comment how did you improve performance? Is it working ok on a 3GS device?Pozzuoli
Hi Notbad. Are you asking about improving performances of Farseer or MyGame/MonoTouch/Monogame? Yes it runs on the 3GS. You could try my game by yourself. It's called "Smashing Planets" and it's free on the AppStoreDerouen

© 2022 - 2024 — McMap. All rights reserved.