Hi guys. I'm part of a team writing a game to Windows Phone as well as Android. We use Box2D on android, and all was going ok(with some problems, but framerate is steady 30FPS).
We tried to port it in couple last days to Windows Phone7, using Farseer instead of Box2D. Obviously some changes had to be made in the game structure, but the overal concept remained the same, plus all the physical concepts were also the same.
So far, we have a background, a level(1600x800 dimensions of the level in pixels) filled with static tiles(with static bodies), 2 players with dynamic bodies, and 10-20 other objects, mostly kinematic bodies. So as you see nothing extreme. Also we don't
use any joints so far, just simple objects.
The problem is, that once we set a PhysicsWorld.Step in update() method in main class, the FPS drop is very grave, to around 1-2FPS, and that's on PC emulator, so on the phone it must look even worse. Once I disable it, everything goes back to normal,
but I don't understand where this sudden drop comes from, especialy since the same stuff is done on android with box2D and nothing like that happens there. I think it's some silly mistake, and I hope I will jog some of you guys memory.
What's weird too, is that I thought(first thing that came to my mind) that the engine has not set an option of fixed time step, and so it is running all the time in real time without any stops/breaks. However it doesn't seem the case. I tried to set
as well as
and both cases don't change anything, so there must be something silly we did, or we're missing. Anybody could direct me to the source of the problem?
Hey guys. We managed to find the sily mistake that was causing it, and indeed it was very silly. When we were creating body for tiles, we were using X, Y coordinates by the tiles, not by the pixels on screen(overlooked mistake due to porting from java).
The result of it, was that there were 43 times 23 static bodies in the very close space, almost all overlapping eachother. I guess farseer can't handle that :P, even though all are static bodies, and in box2d and farseer the static bodies shouldn't colide
with eachother(in theory) and the physics shouldn't do any calculations during those contacts.
However once we corrected that there is no visable framedrop anymore. Hope our mistake will help someone too in the future before they will pull their hair out ;)
Anyways, problem solved. Mods can close the thread and mark as solved.