fix optimized poisson sampling (thanks to @TechSparx) https://twitter.com/TechSparx/status/1257943563335200768

This commit is contained in:
Xevion
2020-05-06 03:05:08 -05:00
parent 746db120e6
commit bd273d95da
2 changed files with 7 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ public static class PointGeneration {
// Vector2 dir = new Vector2(Mathf.Sin(angle), Mathf.Cos(angle));
// Vector2 candidate = spawnCenter + dir * Random.Range(radius, radius * 2);
float theta = 2 * Mathf.PI * (seed + i / attempts);
float theta = 2 * Mathf.PI * (seed + i / (float) attempts);
Vector2 candidate = spawnCenter + (radius + epsilon) * new Vector2(Mathf.Sin(theta), Mathf.Cos(theta));
// Check that the point is valid, make the corresponding changes

View File

@@ -150,9 +150,12 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
samplingMethod: 1
numPoints: 428
sphereSize: 0.18
regionSize: {x: 180, y: 100}
numPoints: 23
sphereSize: 4.3
regionSize: {x: 1945, y: 1000}
radius: 266.86
retryAttempts: 1503
drawSphere: 0
--- !u!4 &2048189740
Transform:
m_ObjectHideFlags: 0