# HG changeset patch # User Sascha L. Teichmann # Date 1570463336 -7200 # Node ID 6415368c2c6041e454e2efb959fdb7265f4ce31e # Parent daed8a92024a0a3e0a9072f6dc3c0793e453a1a3 Use simple super-sampling when rasterizing. diff -r daed8a92024a -r 6415368c2c60 pkg/octree/areas.go --- a/pkg/octree/areas.go Mon Oct 07 13:13:14 2019 +0200 +++ b/pkg/octree/areas.go Mon Oct 07 17:48:56 2019 +0200 @@ -61,15 +61,37 @@ rasterRow := func() { defer wg.Done() + quat := 0.25 * cellSize for i := range rows { pos := (i+1)*(xcells+2) + 1 row := raster[pos : pos+xcells] py := min.Y + float64(i)*cellSize + cellSize/2 px := min.X + cellSize/2 + y1 := py - quat + y2 := py + quat for j := range row { - v, ok := tree.Value(px, py) - if ok { - row[j] = v + var n int + var sum float64 + + if v, ok := tree.Value(px-quat, y1); ok { + sum = v + n = 1 + } + if v, ok := tree.Value(px-quat, y2); ok { + sum += v + n++ + } + if v, ok := tree.Value(px+quat, y1); ok { + sum += v + n++ + } + if v, ok := tree.Value(px+quat, y2); ok { + sum += v + n++ + } + + if n > 0 { + row[j] = sum / float64(n) } px += cellSize }