示例#1
0
        public static void SaveMeshGenerationData(string filePath, int[] gridSize, Dictionary <int, Vector3> cells)
        {
            var stride = sizeof(int) + 3 * sizeof(float);
            var size   = 3 * sizeof(int) + stride * cells.Count;

            using (var mmf = MemoryMappedFile.CreateFromFile(filePath, FileMode.Create, null, size))
            {
                using (var accessor = mmf.CreateViewAccessor(0, size))
                {
                    long pos = 0;

                    for (var i = 0; i < 3; ++i)
                    {
                        accessor.Write(pos, gridSize[i]);
                        pos += sizeof(int);
                    }

                    foreach (var cell in cells)
                    {
                        accessor.Write(pos, cell.Key);
                        pos += sizeof(int);
                        TreeUtility.MmvaWriteVector3(cell.Value, accessor, ref pos);
                    }
                }
            }
        }