skeleton method for poisson disc sampling seblague

This commit is contained in:
Xevion
2020-05-05 14:32:34 -05:00
parent c12980ee69
commit ff0fb7521a
+19 -3
View File
@@ -2,14 +2,30 @@
using UnityEngine;
public static class PointGeneration {
public static List<Vector2> random_sampling(int numPoints, Vector2 range, Vector2 offset) {
public static List<Vector2> random_sampling(int numPoints, Vector2 regionSize) {
// Create a new empty list of points, and add some randomly
var points = new List<Vector2>();
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<Vector2> 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<Vector2> points = new List<Vector2>();
List<Vector2> spawnPoints = new List<Vector2>();
spawnPoints.Add(regionSize / 2);
while (spawnPoints.Count > 0) {
int spawnIndex = Random.Range(0, spawnPoints.Count);
Vector2 spawnCenter = spawnPoints[spawnIndex];
}
return points;