public IEnumerable <ushort> GetAllData() { int size = _Extent << 1; for (int index = 0; index < Length; index++) { yield return(GetPoint(WydMath.IndexTo3D(index, size))); } }
private void GenerateIndex(int index) { int3 localPosition = WydMath.IndexTo3D(index, GenerationConstants.CHUNK_SIZE); int heightmapIndex = WydMath.PointToIndex(localPosition.xz, GenerationConstants.CHUNK_SIZE); int noiseHeight = _Heightmap[heightmapIndex]; if (noiseHeight < _OriginPoint.y) { return; } int globalPositionY = _OriginPoint.y + localPosition.y; if ((globalPositionY < 4) && (globalPositionY <= _SeededRandom.Next(0, 4))) { _Blocks.SetPoint(localPosition, GetCachedBlockID("bedrock")); return; } else if (_CaveNoise[index] < 0.000225f) { return; } if (globalPositionY == noiseHeight) { _Blocks.SetPoint(localPosition, GetCachedBlockID("grass")); } else if ((globalPositionY < noiseHeight) && (globalPositionY >= (noiseHeight - 3))) // lay dirt up to 3 blocks below noise height { _Blocks.SetPoint(localPosition, _SeededRandom.Next(0, 8) == 0 ? GetCachedBlockID("dirt_coarse") : GetCachedBlockID("dirt")); } else if (globalPositionY < (noiseHeight - 3)) { if (_SeededRandom.Next(0, 100) == 0) { _Blocks.SetPoint(localPosition, GetCachedBlockID("coal_ore")); } else { _Blocks.SetPoint(localPosition, GetCachedBlockID("stone")); } } }
protected override Task ProcessIndex(int index) { if (_CancellationToken.IsCancellationRequested) { return(Task.CompletedTask); } ushort currentBlockId = _MeshingBlocks[index].ID; int localPosition = CompressVertex(WydMath.IndexTo3D(index, GenerationConstants.CHUNK_SIZE)); if (currentBlockId == BlockController.AirID) { return(Task.CompletedTask); } bool transparentTraversal = BlockController.Current.CheckBlockHasProperty(currentBlockId, BlockDefinition.Property.Transparent); NaiveMeshIndex(index, localPosition, currentBlockId, transparentTraversal); return(Task.CompletedTask); }
public void CopyTo(ushort[] destinationArray) { if (destinationArray == null) { throw new NullReferenceException(nameof(destinationArray)); } else if (destinationArray.Rank != 1) { throw new RankException("Only single dimension arrays are supported here."); } else if (destinationArray.Length < Length) { throw new ArgumentOutOfRangeException(nameof(destinationArray), "Destination array was not long enough."); } int size = _Extent << 1; for (int index = 0; index < destinationArray.Length; index++) { destinationArray[index] = GetPoint(WydMath.IndexTo3D(index, size)); } }