diff --git a/procedural-placement/Assets/PointGeneration.cs b/procedural-placement/Assets/PointGeneration.cs index 8f2c93d..0f3eb5c 100644 --- a/procedural-placement/Assets/PointGeneration.cs +++ b/procedural-placement/Assets/PointGeneration.cs @@ -2,14 +2,30 @@ using UnityEngine; public static class PointGeneration { - public static List random_sampling(int numPoints, Vector2 range, Vector2 offset) { + public static List random_sampling(int numPoints, Vector2 regionSize) { // Create a new empty list of points, and add some randomly var points = new List(); for (var i = 0; i < numPoints; i++) { points.Add( new Vector2( - Random.Range(-range.x, range.x), - Random.Range(-range.y, range.y))); + Random.Range(-regionSize.x, regionSize.x), + Random.Range(-regionSize.y, regionSize.y))); + } + + return points; + } + + public static List poisson_sampling(int numPoints, Vector2 regionSize, int radius) { + float cellSize = radius / Mathf.Sqrt(2); + + int[,] grid = new int[Mathf.CeilToInt(regionSize.x / cellSize), Mathf.CeilToInt(regionSize.y / cellSize)]; + List points = new List(); + List spawnPoints = new List(); + + spawnPoints.Add(regionSize / 2); + while (spawnPoints.Count > 0) { + int spawnIndex = Random.Range(0, spawnPoints.Count); + Vector2 spawnCenter = spawnPoints[spawnIndex]; } return points;