unexport common area type

This commit is contained in:
Sascha L. Teichmann 2024-01-07 03:51:27 +01:00
parent 1df81c3e1d
commit 79d36d6dd8
2 changed files with 9 additions and 9 deletions

View File

@ -8,20 +8,20 @@ import (
"math"
)
type Area struct {
type area struct {
X1, Z1 int16
X2, Z2 int16
}
func (a Area) contains(x, z int16) bool {
func (a area) contains(x, z int16) bool {
return x >= a.X1 && x <= a.X2 && z >= a.Z1 && z <= a.Z2
}
func (a Area) higher() bool {
func (a area) higher() bool {
return a.Z2-a.Z1 > a.X2-a.X1
}
func areasContain(areas []Area, x, z int16) bool {
func areasContain(areas []area, x, z int16) bool {
for _, r := range areas {
if r.contains(x, z) {
return true
@ -37,7 +37,7 @@ func areasContain(areas []Area, x, z int16) bool {
// to newAreas which ist return.
// This is useful to spatial query only blocks from db
// that are not below already rendered blocks.
func (a Area) recalculate(r *Renderer, nareas []Area) []Area {
func (a area) recalculate(r *Renderer, nareas []area) []area {
yM := r.yMin
const ex = 1
@ -52,7 +52,7 @@ func (a Area) recalculate(r *Renderer, nareas []Area) []Area {
if yM[row+x] > math.MinInt32 || areasContain(nareas[nas:], x, z) {
continue
}
ar := Area{X1: x, Z1: z, X2: x, Z2: z}
ar := area{X1: x, Z1: z, X2: x, Z2: z}
// Try to extend the area in x and/or z till no further extension is possible.
ext:
for extend := ex | ez; extend != 0; {

View File

@ -111,10 +111,10 @@ func (btc *BaseTileCreator) RenderArea(x, z int16) error {
var c1, c2 Coord
nareas := make([]Area, 0, tileWidth*tileHeight/2)
areas := make([]Area, 1, tileWidth*tileHeight/2)
nareas := make([]area, 0, tileWidth*tileHeight/2)
areas := make([]area, 1, tileWidth*tileHeight/2)
areas[0] = Area{
areas[0] = area{
X1: 0, Z1: 0,
X2: int16(tileWidth) - 1, Z2: int16(tileHeight) - 1}