mirror of
https://github.com/Xevion/procedural-placement.git
synced 2025-12-06 05:16:05 -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 dir = new Vector2(Mathf.Sin(angle), Mathf.Cos(angle));
|
||||||
// Vector2 candidate = spawnCenter + dir * Random.Range(radius, radius * 2);
|
// 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));
|
Vector2 candidate = spawnCenter + (radius + epsilon) * new Vector2(Mathf.Sin(theta), Mathf.Cos(theta));
|
||||||
|
|
||||||
// Check that the point is valid, make the corresponding changes
|
// Check that the point is valid, make the corresponding changes
|
||||||
|
|||||||
@@ -150,9 +150,12 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
samplingMethod: 1
|
samplingMethod: 1
|
||||||
numPoints: 428
|
numPoints: 23
|
||||||
sphereSize: 0.18
|
sphereSize: 4.3
|
||||||
regionSize: {x: 180, y: 100}
|
regionSize: {x: 1945, y: 1000}
|
||||||
|
radius: 266.86
|
||||||
|
retryAttempts: 1503
|
||||||
|
drawSphere: 0
|
||||||
--- !u!4 &2048189740
|
--- !u!4 &2048189740
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user