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

Geometry Instancing Hurtful To Performance?

Topics: Developer Forum, User Forum
Jan 17, 2010 at 6:06 AM
I'm deep into making a 2D platformer using Farseer. I've done some stuff, so that I can get farseer to draw my map using a file containing a list of all the vertices in the map. I get to the line: geometry = GeomFactory.Instance.CreatePolygonGeom(levelPhysicsSimulator, body, verts, collisionGridCellSize); And suddenly it takes an extra 30 seconds to start the program. (As opposed to just drawing the map without the collision geometry). Is there anyway to export Geometries, as I have done with the vertices, and then import them upon startup for performance's sake? My game is currently unplayable in this state. Any help would be greatly appreciated.
Jan 17, 2010 at 1:34 PM

If your levels are static (does not change) then you should serialize the vertices and load them on startup. If you are using a distance grid, it can also take a some time to calculate the grid for a large geometry. You could try tweaking the CollisionGridCellSize property to a value between stable collisions and good performance. There are a lot of articles on content serialization, both related to .net in general and XNA. Try searching the web for them.

Jan 17, 2010 at 9:47 PM

Yes they are static, and I already have a system in place to load the vertices from a file upon startup. The biggest slow down comes from creating the geometry for the level.

If possible, I'd like to export a pre-made geometry object, so that it doesn't need to be generated upon startup.

Jan 18, 2010 at 12:04 AM

You could try to increase the GridCellSize a little. Sometimes that can increase the performance of loading.

Jan 18, 2010 at 3:53 AM
Ah! Problem solved! I had thought it might have been the GridCellSize, but now I've confirmed it. I had my GridCellSize set at 1.0f, thinking that the smaller the value, the less intensive it would be to performance. Thanks for your help.