Reduced jerkiness of CollidesWithTerrain behavior with consecutive
collisions.
Removed superfluous loops and added grid-based query support to
SpacePartitioningGrid.