[WP7] Performance issues with kinematic bodies and LinearVelocity

Apr 14, 2012 at 10:27 PM
Edited Apr 14, 2012 at 10:56 PM

The simulation runs smooth at 60 fps both on the emulator and the Windows Phone device and the body update time is ~ 5 - 20 during normal simulation. The problem appears when i attempt to move some kinematic bodies (about 30 of them) by setting their LinearVelocity. When i do that, the body update time skyrockets to 200 - 300. 

Can i assume that it's due to the limited processing power of the device or am i doing something completely wrong?

This is how i move the kinematic bodies:


 const float strength = 0.5f;
 var bodyPosition = ....
 var positionDelta = bodyPosition - destination;
 var velocity = (positionDelta / timestep) * strength;
 Body.LinearVelocity = -velocity;


One solution might be to drop using Farseer bodies and only draw the objects, since i can predict where they're going...

EDIT: I should mention that this is while using debug view, haven't tried by only drawing the textures yet.

Apr 15, 2012 at 10:57 AM

I'd say it's normal - more bodies more time the solver takes to process them. Even though they are kinematic they still participate in collision detection (with dynamic bodies) and normal motion calculations. The questions is does it reduce your fps (my current multibody simulation runs ok with update times around 20 000 on a PC). Of course as you mentioned if you don't need physics from those bodies you can process them yourself too and not add them to the world. I would profile the app first before doing optimizations.

Apr 15, 2012 at 2:38 PM

Thank you for the reply.

The problem is that when the update time increases to those levels, the drawing gets really jerky. I checked some more and on the device it goes up to 500-600 at times. The kinematic bodies don't collide with any dynamic bodies while i'm moving them off the screen.

As far as i can remember the fps doesn't drop, but i'll check tonight.