Пример #1
0
        //static method for setting voxel values
        //can be used for adding or removing voxels
        //once this method is called the chunk its on will
        //be automatically located and set to re create the mesh using using new voxel data

        /// <summary>
        /// Sets the voxels.
        /// </summary>
        /// <param name="hitpoint">Hitpoint.</param>
        /// <param name="value">Value.</param>
        /// <param name="dist">Dist.</param>
        /// <param name="height">Height.</param>
        public static void SetVoxels(Vector3 hitpoint, float value, float dist)
        {
            for (int i = 0; i < ActiveChunks.Count; i++)
            {
                VoxelChunk chunk = ActiveChunks[i];

                if (chunk.SetVoxels(hitpoint, value, dist))
                {
                    //Create the voxel data
                    //set various flags so the engine knows it needs to create a new mesh for terrain
                    chunk.hascollider = false;
                    EditedActions.Enqueue(chunk.CreateVertices);
                }
            }
        }