/// <summary>
    /// Overrides the old heights of the temp vertices with the new heights of the temp vertices.
    /// Calls recalculateBuoyPosition() to update buoy position.
    /// </summary>
    private void setTempVertices()
    {
        Vector3[] tempVertices = terrain.tempVertices;
        int       totalSize    = DiamondSquareGenerator.getTotalSize(terrain.size);

        float[,] heights = new float[totalSize, totalSize];
        if (tempVertices.Length > 0)
        {
            for (int index = 0, z = 0; z < totalSize; z++)
            {
                for (int x = 0; x < totalSize; x++)
                {
                    tempVertices[index].y += terrain.tempDiffHeights[x, z];
                    heights[x, z]          = tempVertices[index].y;

                    index++;
                }
            }
        }


        terrain.tempVertices    = tempVertices;
        terrain.tempDiffHeights = new float[totalSize, totalSize];
        terrain.setColliderHeights(heights);
        terrain.recalculateBuoyPosition();
        this.isEditMode = false;
    }