mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-19 08:30:21 +01:00
Do some early stopping when scanning for min y of a 16x16 region.
This commit is contained in:
parent
6588bef04a
commit
458fc5d1da
@ -44,17 +44,21 @@ func NewRenderer(xOfs, zOfs int16, width, height int) (renderer *Renderer) {
|
|||||||
return
|
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)
|
minY = int32(math.MaxInt32)
|
||||||
for yEnd := ofs + w<<4; ofs < yEnd; {
|
for yEnd := ofs + w<<4; ofs < yEnd; {
|
||||||
for xEnd := ofs + 16; ofs < xEnd; ofs++ {
|
for xEnd := ofs + 16; ofs < xEnd; ofs++ {
|
||||||
y := r.yBuffer[ofs]
|
y := r.yBuffer[ofs]
|
||||||
if y < minY {
|
switch {
|
||||||
|
case y == math.MaxInt32:
|
||||||
|
return
|
||||||
|
case y < minY:
|
||||||
minY = y
|
minY = y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ofs += w - 16
|
ofs += w - 16
|
||||||
}
|
}
|
||||||
|
filled = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ func (r *Renderer) RenderBlock(block *common.Block, nameIndex map[string]int32)
|
|||||||
w := r.width << 4
|
w := r.width << 4
|
||||||
ofs := int(bz)*w<<4 + int(bx)<<4
|
ofs := int(bz)*w<<4 + int(bx)<<4
|
||||||
blockY := int32(block.Coord.Y) << 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++
|
r.Rejected++
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user