Do some early stopping when scanning for min y of a 16x16 region.

This commit is contained in:
Sascha L. Teichmann 2014-09-11 11:03:35 +02:00
parent 6588bef04a
commit 458fc5d1da

View File

@ -44,17 +44,21 @@ func NewRenderer(xOfs, zOfs int16, width, height int) (renderer *Renderer) {
return
}
func (r *Renderer) minY(ofs, w int) (minY int32) {
func (r *Renderer) minY(ofs, w int) (minY int32, filled bool) {
minY = int32(math.MaxInt32)
for yEnd := ofs + w<<4; ofs < yEnd; {
for xEnd := ofs + 16; ofs < xEnd; ofs++ {
y := r.yBuffer[ofs]
if y < minY {
switch {
case y == math.MaxInt32:
return
case y < minY:
minY = y
}
}
ofs += w - 16
}
filled = true
return
}
@ -71,7 +75,7 @@ func (r *Renderer) RenderBlock(block *common.Block, nameIndex map[string]int32)
w := r.width << 4
ofs := int(bz)*w<<4 + int(bx)<<4
blockY := int32(block.Coord.Y) << 4
if blockY < r.minY(ofs, w) {
if minY, filled := r.minY(ofs, w); filled && blockY < minY {
r.Rejected++
return
}