コード例 #1
0
        public void insertFace(Face.Facing facing, ref Voxel voxel)
        {
            List <VertexPositionNormalColor> faces = getVisibleFaces(voxel);

            // If empty, append the face to the end and exit;
            if (faces.Count() == 0)
            {
                VertexPositionNormalColor[] face = Face.getFace(facing, ref voxel);
                vertices.AddRange(face);
                return;
            }

            int index;

            // If faces don't exist in the visible vertices, exit. Something's wrong if so, and this should never occur.
            if ((index = getFaceIndex(ref faces)) == -1)
            {
                return;
            }


            for (int i = 0; i < faces.Count() - 6; i = i + 6)
            {
                if (facing < Face.getFacing(faces.GetRange(i, 6)))
                {
                    vertices.InsertRange(index + i, Face.getFace(facing, ref voxel));
                    return;
                }
            }
            try
            {
                vertices.InsertRange(index + 30, Face.getFace(facing, ref voxel));
            }
            catch (ArgumentOutOfRangeException e)
            {
            }
        }