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

How Efficient Is PolygonGeometry?

Topics: User Forum
Jul 19, 2007 at 4:04 AM
I want to try and integrate Farseer's physics into my Puma library ( which uses bezier curves for geometry. I calculate these curves at runtime and then pass the vertices to the PolygonGeometry. It works fine, but seems really slow. Is there any way to speed this up? I know I'm using lots of vertices, so should I just manually break it up, or is there another way? Thanks.
Jul 19, 2007 at 4:16 AM
And as a side question, is there a way to enable object freezing? I find that my performance drops as objects start to settle on the geometry.
Jul 19, 2007 at 11:43 AM

Farseer expects it's geometries to be built during load time. It has to compute a collision grid for each geometry. It can be pretty fast depending on the precision you want, but it's not meant for on-the-fly in-game creation of new geometries. Not sure that is what your doing or if you are creating your geometries at load time.

Anyway, performance depends mostly on collision grid spacing. If you read the .pdf document (link is on the home page of this project) you can get a feel for how the grid cell spacing affects the time it takes to create the grid.

I'm guessing this is where your bottleneck is. I have increased performance a bit in the new version. I know it's a cheap answer, but so much has changed in the new version I'd recomend waiting for that.

Btw, your project looks interesting. I've been keeping my eye on it for a while. Some day I may try to role bezier curves into the engine... probably not in the next version though.
Jul 19, 2007 at 5:02 PM
Oh no, I'm not building the geometry each frame. The bezier curve geometry is built only one. I've gone ahead and split the bezier curve into small sections to create multiple geometry which seemed to help. The problem is somewhere when I get about 40-50 circular bodies coming to rest along the curve.

Good to hear there's some performance increase in the next version. Any estimated release for that?
Jul 19, 2007 at 7:39 PM
Edited Jul 19, 2007 at 7:41 PM
Definelty some good performance increases with the new engine. I had to optimize it because the float math of the compact framework on XBox is slow.

Not sure what the bottle neck is in your situation. Probably the simultaneous collisions.... Not sure though.

There are some things you could try to increase the speed. In the physics simulator set the max # of collisions property to 2 and possibly decrease the interations property. (not sure the actual property names).

The new engine will have a Physics Simulator Viewer that will show the peformance of key process in the engine. This would be helpful right now to see what your bottleneck is.

I don't have a target date. I'm hoping to have things wrapped up in a month or so but I'm not sure how long the documentation is going to take.