protected StorageTreeRoot CreateStorageGroupAtCoordinate(Vector3Int coord) { StorageTreeRoot chunkGroup = new StorageTreeRoot(new int[] { coord.x, coord.y, coord.z }); storageGroups.Add(coord, chunkGroup); return(chunkGroup); }
//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; }
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; }