mirror of
https://github.com/Xevion/procedural-placement.git
synced 2025-12-06 01:15:56 -06:00
fix optimized poisson sampling (thanks to @TechSparx) https://twitter.com/TechSparx/status/1257943563335200768
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user