From e2070c8b94a07a8ac7499b9576cc9fbb0eb4f498 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Thu, 11 Sep 2014 00:22:36 +0200 Subject: [PATCH] Do multiple queries in descending y order to make better use of the block rejection. --- tilemapper/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tilemapper/main.go b/tilemapper/main.go index d1d79e1..041f18b 100644 --- a/tilemapper/main.go +++ b/tilemapper/main.go @@ -59,20 +59,28 @@ func main() { q1x, q1y, q1z := int16(x), int16(y), int16(z) q2x, q2y, q2z := q1x+int16(width)-1, q1y+int16(depth)-1, q1z+int16(height)-1 - c1 := common.Coord{X: q1x, Y: q1y, Z: q1z} - c2 := common.Coord{X: q2x, Y: q2y, Z: q2z} - cuboid := common.Cuboid{P1: common.MinCoord(c1, c2), P2: common.MaxCoord(c1, c2)} renderer := NewRenderer(q1x, q1z, width, height) + numBlocks := 0 drawBlock := func(block *common.Block) { if err := renderer.RenderBlock(block, colors.NameIndex); err != nil { log.Printf("WARN: rendering block failed: %s", err) } + numBlocks++ } - if err = client.QueryCuboid(cuboid, drawBlock); err != nil { - log.Fatalf("query failed: %s", err) + c1 := common.Coord{X: q1x, Z: q1z} + c2 := common.Coord{X: q2x, Z: q2z} + for c2.Y = q2y; c2.Y > q1y; c2.Y -= 16 { + c1.Y = c2.Y - 15 + if c1.Y < q1y { + c1.Y = q1y + } + cuboid := common.Cuboid{P1: common.MinCoord(c1, c2), P2: common.MaxCoord(c1, c2)} + if err = client.QueryCuboid(cuboid, drawBlock); err != nil { + log.Fatalf("query failed: %s", err) + } } image := renderer.CreateImage( @@ -83,4 +91,5 @@ func main() { } fmt.Printf("Rejected blocks: %d\n", renderer.RejectedBlocks) + fmt.Printf("num blocks: %d\n", numBlocks) }