fixed an off by 1 threading problem
This commit is contained in:
+5
-2
@@ -187,8 +187,8 @@ func GenerateTrees(img *image.RGBA, lakePixels, roadPixels, buildingPixels []ima
|
|||||||
noise := opensimplex.New(seed)
|
noise := opensimplex.New(seed)
|
||||||
treeNoiseMap := image.NewGray(image.Rect(0, 0, width, height))
|
treeNoiseMap := image.NewGray(image.Rect(0, 0, width, height))
|
||||||
treeNoiseZoom := 0.05
|
treeNoiseZoom := 0.05
|
||||||
for y := range height {
|
for y := 0; y < height; y++ {
|
||||||
for x := range width {
|
for x := 0; x < width; x++ {
|
||||||
val := noise.Eval2(float64(x)*treeNoiseZoom, float64(y)*treeNoiseZoom)
|
val := noise.Eval2(float64(x)*treeNoiseZoom, float64(y)*treeNoiseZoom)
|
||||||
val = (val + 1) / 2 // Normalize to 0-1
|
val = (val + 1) / 2 // Normalize to 0-1
|
||||||
treeNoiseMap.SetGray(x, y, color.Gray{Y: uint8(val * 255)})
|
treeNoiseMap.SetGray(x, y, color.Gray{Y: uint8(val * 255)})
|
||||||
@@ -250,6 +250,9 @@ func GenerateTrees(img *image.RGBA, lakePixels, roadPixels, buildingPixels []ima
|
|||||||
|
|
||||||
for i := 0; i < numGoroutines; i++ {
|
for i := 0; i < numGoroutines; i++ {
|
||||||
start := i * pointsPerGoroutine
|
start := i * pointsPerGoroutine
|
||||||
|
if start >= len(allPoints) {
|
||||||
|
break
|
||||||
|
}
|
||||||
end := start + pointsPerGoroutine
|
end := start + pointsPerGoroutine
|
||||||
if end > len(allPoints) {
|
if end > len(allPoints) {
|
||||||
end = len(allPoints)
|
end = len(allPoints)
|
||||||
|
|||||||
Reference in New Issue
Block a user