private void CreateMasks(Bounds bounds) { #if RAM_2019 RiverSettings riverSettings = editor.extension.riverSettings; for (int i = 0; i < riverSettings.count; i++) { // just some offset so that we don't start at an edge float offsetX = bounds.size.x / 10f; float offsetZ = bounds.size.z / 10f; float x = Random.Range(bounds.min.x + offsetX, bounds.max.x - offsetX); float y = 0; float z = Random.Range(bounds.min.z + offsetZ, bounds.max.z - offsetZ); // get y position on terrain by raycasting float?terrainHeight = TerrainUtils.GetTerrainHeight(x, z); if (terrainHeight != null) { y = (float)terrainHeight; } Vector3 position = new Vector3(x, y, z); int maskId = editor.GetNextMaskId(); CreateRiver("River " + maskId, position); } #endif }
private List <Vector3> AlignToTerrainHeight(List <Vector3> positions) { List <Vector3> alignedPositions = new List <Vector3>(); foreach (Vector3 position in positions) { float x = position.x; float y = 0; float z = position.z; float?terrainHeight = TerrainUtils.GetTerrainHeight(x, z); if (terrainHeight != null) { y = (float)terrainHeight; } else { Debug.LogError("Terrain height was null at x=" + x + ", z=" + z); } Vector3 positionXYZ = new Vector3(x, y, z); alignedPositions.Add(positionXYZ); } return(alignedPositions); }