mirror of
https://github.com/YouHaveTrouble/BlockEdit.git
synced 2026-06-29 21:46:19 +00:00
the prophesized smarter way to get chunks
This commit is contained in:
@@ -17,12 +17,15 @@ public class WorkSplitter {
|
|||||||
|
|
||||||
protected static HashSet<ChunkWork> getOperatedOnChunks(BoundingBox boundingBox) {
|
protected static HashSet<ChunkWork> getOperatedOnChunks(BoundingBox boundingBox) {
|
||||||
HashSet<ChunkWork> chunks = new HashSet<>();
|
HashSet<ChunkWork> chunks = new HashSet<>();
|
||||||
|
int minChunkX = (int) Math.floor(boundingBox.getMinX()) >> 4;
|
||||||
|
int maxChunkX = (int) Math.floor(boundingBox.getMaxX()) >> 4;
|
||||||
|
int minChunkZ = (int) Math.floor(boundingBox.getMinZ()) >> 4;
|
||||||
|
int maxChunkZ = (int) Math.floor(boundingBox.getMaxZ()) >> 4;
|
||||||
|
|
||||||
ChunkWork chunkWork = new ChunkWork(0,0);
|
ChunkWork chunkWork = new ChunkWork(0,0);
|
||||||
// TODO Find a way to get chunks in the selection more efficiently
|
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||||
for (double x = boundingBox.getMinX(); x <= boundingBox.getMaxX(); x++) {
|
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||||
for (double z = boundingBox.getMinZ(); z <= boundingBox.getMaxZ(); z++) {
|
chunkWork.setCoords(x << 4, z << 4);
|
||||||
chunkWork.setCoords(x,z);
|
|
||||||
if (chunks.contains(chunkWork)) continue;
|
|
||||||
chunks.add(chunkWork.clone());
|
chunks.add(chunkWork.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user