浏览代码

fixed poisson disk inital point seeding

/main
sleal-unity 4 年前
当前提交
f5f55a32
共有 1 个文件被更改,包括 5 次插入7 次删除
  1. 12
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Utilities/PoissonDiskSampling.cs

12
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Utilities/PoissonDiskSampling.cs


// Calculate occupancy grid dimensions
var random = new Unity.Mathematics.Random(seed);
var cellSize = minimumRadius / math.sqrt(2);
var rows = Mathf.FloorToInt(height / cellSize);
var cols = Mathf.FloorToInt(width / cellSize);
var cellSize = minimumRadius / math.sqrt(2f);
var rows = Mathf.CeilToInt(height / cellSize);
var cols = Mathf.CeilToInt(width / cellSize);
var gridSize = rows * cols;
if (gridSize == 0)
return samples;

// This list will track all points that may still have space around them for generating new points
var activePoints = new NativeList<float2>(Allocator.Temp);
// Randomly place a seed point in a central location within the generation space to kick off the algorithm
var firstPoint = new float2(
random.NextFloat(0.4f, 0.6f) * width,
random.NextFloat(0.4f, 0.6f) * height);
// Randomly place a seed point to kick off the algorithm
var firstPoint = new float2(random.NextFloat(0f, width), random.NextFloat(0f, height));
samples.Add(firstPoint);
var firstPointCol = Mathf.FloorToInt(firstPoint.x / cellSize);
var firstPointRow = Mathf.FloorToInt(firstPoint.y / cellSize);

正在加载...
取消
保存