Пример #1
0
        protected StorageTreeRoot CreateStorageGroupAtCoordinate(Vector3Int coord)
        {
            StorageTreeRoot chunkGroup = new StorageTreeRoot(new int[] { coord.x, coord.y, coord.z });

            storageGroups.Add(coord, chunkGroup);
            return(chunkGroup);
        }
Пример #2
0
        //TODO: Dont store when chunk knows he stored before
        public void Store(Vector3Int anchorPos, float[] noise)
        {
            StoredChunkEdits edits;

            if (!TryGetStoredEditsAt(anchorPos, out edits))
            {
                edits = new StoredChunkEdits();
                StorageTreeRoot r = GetOrCreateStorageGroupAtCoordinate(PositionToStorageGroupCoord(anchorPos));
                r.SetLeafAtPosition(anchorPos, edits, true);
            }
            edits.vals = noise;
        }
Пример #3
0
        public void Store(Vector3Int anchorPos, ReducedMarchingCubesChunk chunk, bool overrideNoise = false)
        {
            StoredChunkEdits edits;

            if (!TryGetGroupItemAt(VectorExtension.ToArray(anchorPos), out edits) || overrideNoise)
            {
                edits = new StoredChunkEdits();
                StorageTreeRoot r = GetOrCreateGroupAtCoordinate(PositionToGroupCoord(anchorPos));

                chunk.StoreChunk(edits);

                r.SetLeafAtPosition(anchorPos, edits, true);
                //call all instantiableData from chunk that need to be stored
                //(everything not depending on triangles only, e.g trees )
            }
            //Remove later
            if (edits.noise != chunk.Points)
            {
                throw new Exception();
            }
            chunk.storageLeaf = edits.leaf;
        }