add octree grid to flatten the terrain
use indexes instead of copy arrays
little modifications