public TerrainEditor(EditorScreen screen)
        {
            this.screen = screen;
            editor      = screen.WorldEditor;
            renderer    = screen.Window.Renderer;
            terrainPhys = new TerrainPhysicsExtension();
            entRenderer = renderer.GetRenderer3D <EntityRenderer>();
            colorPicker = screen.UI.ColorWindow.ColorPicker;

            blockCursorCube = new DebugCube(Color4.White, Block.CUBE_SIZE);
            SelectionBox    = new EditorSelectionBox();

            undoStack      = new Stack <TerrainOperationBatch>();
            redoStack      = new Stack <TerrainOperationBatch>();
            operationBatch = new TerrainOperationBatch();

            rayIntersection = new TerrainRaycastResult(new Ray(Vector3.Zero, Vector3.UnitZ));
        }
        protected void ApplyActionToSelection(EditorSelectionBox box, Action <Chunk, IndexPosition> action)
        {
            for (int x = box.Min.X; x <= box.Max.X; x++)
            {
                for (int y = box.Min.Y; y <= box.Max.Y; y++)
                {
                    for (int z = box.Min.Z; z <= box.Max.Z; z++)
                    {
                        IndexPosition globalPos = new IndexPosition(x, y, z);
                        IndexPosition cIndex, bIndex;
                        GetLocalBlockCoords(globalPos, out cIndex, out bIndex);

                        Chunk chunk;
                        if (Terrain.Chunks.TryGetValue(cIndex, out chunk))
                        {
                            action(chunk, bIndex);
                        }
                    }
                }
            }
        }