GeomFactory copy speed

Jul 19, 2009 at 8:16 AM

Does calling GeomFactory.Instance.CreateGeom() and passing in an existing Geom save time versus calling CreatePolygonGeom() and passing in a set of vertices?

I'm experimenting with preloading one each of each item, and copying it at runtime, to hopefully save time on creating the Geom (the grid calculation is pretty expensive, I've heard).  Is it worth the hassle?

Coordinator
Jul 19, 2009 at 2:49 PM

Yes, but only when using distance grid as the narrow phase collider. There might be a little increase in speed even if you don't use the distance grid, but it is unnoticeable compared to when you use the distance grid.

Jul 21, 2009 at 1:11 AM

Are you saying that with SAT as the narrow phase, that creating the distance grid (when NEWing a geom) doesn't happen, or is much faster? 

And if distance grid is used, that copying a geom is faster than NEWing?  How much faster?

Coordinator
Jul 21, 2009 at 1:15 AM

The distance grid is a narrow phase collider just like SAT is. You can only use either DG (Distance Grid) or SAT.

If your geometries are identical, copying the geometry (when using DG) is a lot faster than allocating a new one. How much depends on the precision of the distance grid (controlled by the distance grid cell size). If you create 1000 identical geometries and use the distance grid, then it can take several seconds to create all the grids. If you create one and then copy it, it will only take a few miliseconds.