This project has moved and is read-only. For the latest updates, please go here.

slow CreatePolygonGeom

Mar 23, 2009 at 3:33 AM
GeomFactory.Instance.CreatePolygonGeom is acting very slow when I use vertices with spaced out points. Here is my code:

Vertices vertices = new Vertices();
vertices.Add(new Vector2(-600,-600));
vertices.Add(new Vector2(-600,600));
vertices.Add(new Vector2(2400,2400));
vertices.Add(new Vector2(600,-600));
vertices.Scale(new Vector2(size, size));

zone.objectList[i]._body = BodyFactory.Instance.CreatePolygonBody(zone.physicsSimulator1, vertices, 2 * size); //these have a mass of 2

zone.objectList[i]._geom = GeomFactory.Instance.CreatePolygonGeom(zone.physicsSimulator1, zone.objectList[i]._body, vertices, 3);

It takes about 3-5 seconds to create a single geom. If I use the same code with values 1/10 the size in the Vector2's it takes about 3-5 seconds to create 60 of geoms.
Do I need to change the scale of my physics engine or is there another way around this?
Mar 23, 2009 at 4:04 AM
Well i don't know why the engine is so slow at that but i'm pretty sure that Farseer Physics (and other engines) are more stable with small objects.
Mar 23, 2009 at 5:35 AM
well one problem may be that the object is SO large(said above)
my computer wont allow me to use images over 2000
Its something graphics cards have a hard time with, so when you create a geometry along with it im sure its gonna stir sum problems.
Mar 23, 2009 at 7:36 AM
I take it that last parameter to CreatePolygonGeom is the gridCellSize? I'd say that is why it takes so long with the larger geometries. If you give it zero, it will use a grid size based on 10% of the shortest polygon edge, which might not be what you want but at least the grid generation time should be constant then.