Mercurial > gemma
comparison pkg/octree/tree.go @ 1788:00f34a00e6d5
Octree: Don't crash in horizontal traversal if the tree is empty.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 13 Jan 2019 13:47:08 +0100 |
parents | f4dcbe8941a1 |
children | fe1aa62195c2 |
comparison
equal
deleted
inserted
replaced
1787:b0bf7533deec | 1788:00f34a00e6d5 |
---|---|
160 pos += 4 // nodes with z-bit set | 160 pos += 4 // nodes with z-bit set |
161 min = mid | 161 min = mid |
162 } else { | 162 } else { |
163 max = mid | 163 max = mid |
164 } | 164 } |
165 stack = append(stack, | 165 if pos+3 < int32(len(ot.index)) { |
166 frame{ot.index[pos+0], min, max}, | 166 stack = append(stack, |
167 frame{ot.index[pos+1], min, max}, | 167 frame{ot.index[pos+0], min, max}, |
168 frame{ot.index[pos+2], min, max}, | 168 frame{ot.index[pos+1], min, max}, |
169 frame{ot.index[pos+3], min, max}) | 169 frame{ot.index[pos+2], min, max}, |
170 frame{ot.index[pos+3], min, max}) | |
171 } | |
170 } else { // leaf | 172 } else { // leaf |
171 pos = -pos - 1 | 173 pos = -pos - 1 |
172 n := ot.index[pos] | 174 n := ot.index[pos] |
173 //log.Printf("%d %d %d\n", pos, n, len(ot.index)) | 175 //log.Printf("%d %d %d\n", pos, n, len(ot.index)) |
174 indices := ot.index[pos+1 : pos+1+n] | 176 indices := ot.index[pos+1 : pos+1+n] |