add AreaMap2D
This commit is contained in:
@@ -52,16 +52,15 @@ void ChunksController::update(int64_t maxDuration) {
|
||||
}
|
||||
|
||||
bool ChunksController::loadVisible() {
|
||||
const int w = chunks->w;
|
||||
const int d = chunks->d;
|
||||
const auto& size = chunks->getSize();
|
||||
|
||||
int nearX = 0;
|
||||
int nearZ = 0;
|
||||
int minDistance = ((w - padding * 2) / 2) * ((w - padding * 2) / 2);
|
||||
for (uint z = padding; z < d - padding; z++) {
|
||||
for (uint x = padding; x < w - padding; x++) {
|
||||
int index = z * w + x;
|
||||
auto& chunk = chunks->chunks[index];
|
||||
int minDistance = ((size.x - padding * 2) / 2) * ((size.y - padding * 2) / 2);
|
||||
for (uint z = padding; z < size.y - padding; z++) {
|
||||
for (uint x = padding; x < size.x - padding; x++) {
|
||||
int index = z * size.x + x;
|
||||
auto& chunk = chunks->getChunks()[index];
|
||||
if (chunk != nullptr) {
|
||||
if (chunk->flags.loaded && !chunk->flags.lighted) {
|
||||
if (buildLights(chunk)) {
|
||||
@@ -70,8 +69,8 @@ bool ChunksController::loadVisible() {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int lx = x - w / 2;
|
||||
int lz = z - d / 2;
|
||||
int lx = x - size.x / 2;
|
||||
int lz = z - size.y / 2;
|
||||
int distance = (lx * lx + lz * lz);
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
@@ -81,14 +80,12 @@ bool ChunksController::loadVisible() {
|
||||
}
|
||||
}
|
||||
|
||||
const auto& chunk = chunks->chunks[nearZ * w + nearX];
|
||||
const auto& chunk = chunks->getChunks()[nearZ * size.x + nearX];
|
||||
if (chunk != nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const int ox = chunks->ox;
|
||||
const int oz = chunks->oz;
|
||||
createChunk(nearX + ox, nearZ + oz);
|
||||
const auto& offset = chunks->getOffset();
|
||||
createChunk(nearX + offset.x, nearZ + offset.y);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user