示例#1
0
 public void AddObject(IUKStaticObject o)
 {
     foreach(var index in RasterObject(o)) {
         if (index >= 0) grid[index] += 1;
     }
 }
示例#2
0
    private IEnumerable<int> RasterObject(IUKStaticObject o)
    {
        Bounds b = o.SpatialBounds();

        var min = AlignToGrid(b.min);
        var max = AlignToGrid(b.max);

        var y = AlignToGrid(b.center).y;

        for(float x = min.x; x <= max.x; x += CELL_SIZE) {
            for(float z = min.z; z <= max.z; z += CELL_SIZE) {
                var p = new Vector3(x, y, z);
                if (o.SpatialIsSolidAt(p + Vector3.one * CELL_SIZE_HALF)) {
                    yield return CalculateIndex(p);
                }
            }
        }
    }