Lookup neighbor chunks more efficiently in async lighting

This commit is contained in:
Byteflux 2015-07-15 02:01:49 -07:00
parent c17ecdd93f
commit 963925b8ea

View file

@ -159,9 +159,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final List<Chunk> neighbors = new ArrayList<Chunk>(); + final List<Chunk> neighbors = new ArrayList<Chunk>();
+ for (int cx = (x >> 4) - 1; cx <= (x >> 4) + 1; ++cx) { + for (int cx = (x >> 4) - 1; cx <= (x >> 4) + 1; ++cx) {
+ for (int cz = (z >> 4) - 1; cz <= (z >> 4) + 1; ++cz) { + for (int cz = (z >> 4) - 1; cz <= (z >> 4) + 1; ++cz) {
+ if (this.chunkProvider.isChunkLoaded(cx, cz)) { + if (cx != x >> 4 && cz != z >> 4) {
+ Chunk neighbor = this.getChunkAt(cx, cz); + Chunk neighbor = this.getChunkIfLoaded(cx, cz);
+ if (neighbor != chunk) { + if (neighbor != null) {
+ neighbor.pendingLightUpdates.incrementAndGet(); + neighbor.pendingLightUpdates.incrementAndGet();
+ neighbor.lightUpdateTime = chunk.world.getTime(); + neighbor.lightUpdateTime = chunk.world.getTime();
+ neighbors.add(neighbor); + neighbors.add(neighbor);