Tooling
This commit is contained in:
@@ -30,9 +30,16 @@ func (g *Grid) ClampToRepose(h []float32, talus float64) float64 {
|
||||
for i := range g.closed {
|
||||
g.closed[i] = false
|
||||
}
|
||||
// Pushed with a jittered bucket, not a plain one. The constraint this pass imposes is isotropic; the
|
||||
// order it imposed it in was not. Every cell went in in flat-index order and the queue pops last-in
|
||||
// first-out within a bucket, so on ground flat to within a centimetre - which is most of a hillside -
|
||||
// cells popped bottom-right to top-left, and whichever popped first decided which of its neighbours got
|
||||
// cut. That is where the grid-aligned pyramid faces came from, and it is one hash away from not being
|
||||
// there. See bucketpq.go.
|
||||
g.pq.reset()
|
||||
for i := 0; i < n; i++ {
|
||||
g.pq.push(h[i], int32(i))
|
||||
x, y := i%g.W, i/g.W
|
||||
g.pq.pushJittered(h[i], int32(i), (hashXY(g.seed, g.worldX(x), g.worldY(y), jitterReposeOrder)-0.5)*2*reposeOrderBuckets)
|
||||
}
|
||||
|
||||
card := talus * g.CellM
|
||||
@@ -62,11 +69,16 @@ func (g *Grid) ClampToRepose(h []float32, talus float64) float64 {
|
||||
if dx8[k] != 0 && dy8[k] != 0 {
|
||||
allow = diag
|
||||
}
|
||||
// The same tie-break ComputeReceivers uses and for the same reason: a fixed allowance resolves
|
||||
// every near-tie the same way and prints its preferred axis. A tenth of a percent, keyed on the
|
||||
// cell being cut, so what a cell is allowed in a direction does not depend on which neighbour
|
||||
// reached it first.
|
||||
allow *= 1 + 1e-3*(float64(hashXY(g.seed, g.worldX(nx), g.worldY(ny), int32(k)+jitterReposeAllow))-0.5)
|
||||
limit := h[c] + float32(allow)
|
||||
if h[ni] > limit {
|
||||
removed += float64(h[ni] - limit)
|
||||
h[ni] = limit
|
||||
g.pq.push(limit, ni)
|
||||
g.pq.pushJittered(limit, ni, (hashXY(g.seed, g.worldX(nx), g.worldY(ny), jitterReposeOrder)-0.5)*2*reposeOrderBuckets)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user